Verified contractPartialMIT
L1BlockHashSender
Address0xd03edf090a28003d43bf9b8baa888932dd9b5e5a
- Balance
0 ETH
- Transactions
14
- Compiler
solc 0.8.26
- Same code
Only this contract
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,344,656
- Creation transaction
- 0x913ee1b0b2…8664bd7945
src/cells/L1BlockHashes.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
/// @notice Arbitrum (Orbit) inbox on the parent chain: creates an L1 → L2 message that the rollup itself delivers.
interface IArbInbox {
function createRetryableTicket(
address to,
uint256 l2CallValue,
uint256 maxSubmissionCost,
address excessFeeRefundAddress,
address callValueRefundAddress,
uint256 gasLimit,
uint256 maxFeePerGas,
bytes calldata data
) external payable returns (uint256);
}
/// @title L1BlockHashSender (lives on Ethereum / Sepolia)
/// @notice Anyone may push the hash of a recent L1 block to Robinhood Chain through the rollup's own inbox.
/// No relayer is trusted: the hash comes from the EVM's `blockhash` / the EIP-2935 history contract,
/// and the message travels inside the rollup protocol.
contract L1BlockHashSender {
/// @dev EIP-2935 (Prague): the last 8191 block hashes are kept by this system contract
address public constant HISTORY = 0x0000F90827F1C53a10cb7A02335B175320002935;
/// @dev only blocks at least this old (~4 epochs ≈ 26 min; normally finalized — the operator tool also uses the
/// `finalized` tag) — a hash of a block that is later
/// reorged away must never reach Robinhood Chain
uint256 public constant MIN_AGE = 128;
IArbInbox public immutable inbox;
address public immutable receiver; // L1BlockHashes on Robinhood Chain
error UnknownBlock(uint256 number);
event Sent(uint256 indexed number, bytes32 hash, uint256 ticket);
constructor(IArbInbox inbox_, address receiver_) {
inbox = inbox_;
receiver = receiver_;
}
/// @notice Hash of an L1 block: the last 256 from `blockhash`, older ones (up to 8191) from EIP-2935.
function hashOf(uint256 number) public view returns (bytes32 h) {
if (number + MIN_AGE > block.number) revert UnknownBlock(number);
h = blockhash(number);
if (h == bytes32(0) && HISTORY.code.length != 0) {
(bool ok, bytes memory out) = HISTORY.staticcall(abi.encode(number));
if (ok && out.length == 32) h = abi.decode(out, (bytes32));
}
if (h == bytes32(0)) revert UnknownBlock(number);
}
/// @notice Send block `number`'s hash. msg.value pays the L2 submission and execution (any excess is
/// refunded to the caller on L2).
function send(uint256 number, uint256 maxSubmissionCost, uint256 gasLimit, uint256 maxFeePerGas)
external
payable
returns (uint256 ticket)
{
bytes32 h = hashOf(number);
ticket = inbox.createRetryableTicket{value: msg.value}(
receiver,
0,
maxSubmissionCost,
msg.sender,
msg.sender,
gasLimit,
maxFeePerGas,
abi.encodeCall(L1BlockHashes.record, (number, h))
);
emit Sent(number, h, ticket);
}
}
/// @title L1BlockHashes (lives on Robinhood Chain)
/// @notice Stores L1 block hashes that arrived from L1BlockHashSender through the rollup inbox.
/// Accepts only the aliased address of that one L1 contract, so nobody on L2 can write a hash.
/// The sender's L1 address is COMPUTED here (standard CREATE2 deployer, the sender's code, the inbox and
/// this contract), so no one can point this contract at another sender.
contract L1BlockHashes {
/// @dev Arbitrum shifts an L1 contract's address by this offset when its message executes on L2
uint160 internal constant ALIAS_OFFSET = uint160(0x1111000000000000000000000000000000001111);
address public constant L1_CREATE2_DEPLOYER = 0x4e59b44847b379578588920cA78FbF26c0B4956C;
address public immutable l1Sender;
mapping(uint256 number => bytes32) public hashOf;
error NotFromL1Sender();
error Conflict(uint256 number);
event Recorded(uint256 indexed number, bytes32 hash);
/// @param inbox the rollup's (delayed) Inbox on Ethereum
constructor(IArbInbox inbox, bytes32 salt) {
l1Sender = address(
uint160(
uint256(
keccak256(
abi.encodePacked(bytes1(0xff), L1_CREATE2_DEPLOYER, salt, keccak256(senderInitCode(inbox, address(this))))
)
)
)
);
}
function senderInitCode(IArbInbox inbox, address receiver) public pure returns (bytes memory) {
return abi.encodePacked(type(L1BlockHashSender).creationCode, abi.encode(inbox, receiver));
}
function aliased() public view returns (address) {
unchecked {
return address(uint160(l1Sender) + ALIAS_OFFSET);
}
}
function record(uint256 number, bytes32 h) external {
if (msg.sender != aliased()) revert NotFromL1Sender();
bytes32 old = hashOf[number];
if (old != bytes32(0) && old != h) revert Conflict(number); // cannot happen for a real chain
hashOf[number] = h;
emit Recorded(number, h);
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": false,
"bytecodeHash": "none",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.