diff --git a/snapshots/verifyBroadcastMessage.json b/snapshots/verifyBroadcastMessage.json index 65cab6e..568f4a9 100644 --- a/snapshots/verifyBroadcastMessage.json +++ b/snapshots/verifyBroadcastMessage.json @@ -1,9 +1,9 @@ { - "EthereumToOptimism": "1639195", + "EthereumToOptimism": "1639239", "EthereumToTaikoL2": "1052214", "LineaL2ToEthereum": "2551776", "ScrollL2ToEthereum": "1361940", - "ScrollToOptimism": "1348688", + "ScrollToOptimism": "1348710", "TaikoL2ToEthereum": "1022277", "ZkSyncL2ToEthereum": "125663" } \ No newline at end of file diff --git a/src/contracts/provers/arbitrum/ChildToParentProver.sol b/src/contracts/provers/arbitrum/ChildToParentProver.sol index 6434549..b092ce9 100644 --- a/src/contracts/provers/arbitrum/ChildToParentProver.sol +++ b/src/contracts/provers/arbitrum/ChildToParentProver.sol @@ -13,10 +13,10 @@ import {SlotDerivation} from "@openzeppelin/contracts/utils/SlotDerivation.sol"; contract ChildToParentProver is IStateProver { /// @dev Address of the block hash buffer contract /// See https://github.com/OffchainLabs/block-hash-pusher/blob/a1e26f2e42e6306d1e7f03c5d20fa6aa64ff7a12/.env.example#L12 - address public constant blockHashBuffer = 0x0000000048C4Ed10cF14A02B9E0AbDDA5227b071; + address public constant BLOCK_HASH_BUFFER = 0x0000000048C4Ed10cF14A02B9E0AbDDA5227b071; /// @dev Storage slot the buffer contract uses to store block hashes. /// See https://github.com/OffchainLabs/block-hash-pusher/blob/a1e26f2e42e6306d1e7f03c5d20fa6aa64ff7a12/contracts/Buffer.sol#L32 - uint256 public constant blockHashMappingSlot = 51; + uint256 public constant BLOCK_HASH_MAPPING_SLOT = 51; /// @dev The chain Id of the home chain, i.e., the child chain. uint256 public immutable homeChainId; @@ -28,7 +28,7 @@ contract ChildToParentProver is IStateProver { homeChainId = _homeChainId; } - /// @notice Get a parent chain block hash from the buffer at `blockHashBuffer` using a storage proof + /// @notice Get a parent chain block hash from the buffer at `BLOCK_HASH_BUFFER` using a storage proof /// @param homeBlockHash The block hash of the home chain. /// @param input ABI encoded (bytes blockHeader, uint256 targetBlockNumber, bytes accountProof, bytes storageProof) function verifyTargetStateCommitment(bytes32 homeBlockHash, bytes calldata input) @@ -45,15 +45,15 @@ contract ChildToParentProver is IStateProver { // calculate the slot based on the provided block number // see: https://github.com/OffchainLabs/block-hash-pusher/blob/a1e26f2e42e6306d1e7f03c5d20fa6aa64ff7a12/contracts/Buffer.sol#L32 - uint256 slot = uint256(SlotDerivation.deriveMapping(bytes32(blockHashMappingSlot), targetBlockNumber)); + uint256 slot = uint256(SlotDerivation.deriveMapping(bytes32(BLOCK_HASH_MAPPING_SLOT), targetBlockNumber)); // verify proofs and get the block hash targetStateCommitment = ProverUtils.getSlotFromBlockHeader( - homeBlockHash, rlpBlockHeader, blockHashBuffer, slot, accountProof, storageProof + homeBlockHash, rlpBlockHeader, BLOCK_HASH_BUFFER, slot, accountProof, storageProof ); } - /// @notice Get a parent chain block hash from the buffer at `blockHashBuffer`. + /// @notice Get a parent chain block hash from the buffer at `BLOCK_HASH_BUFFER`. /// @param input ABI encoded (uint256 targetBlockNumber) function getTargetStateCommitment(bytes calldata input) external view returns (bytes32 targetStateCommitment) { if (block.chainid != homeChainId) { @@ -63,7 +63,7 @@ contract ChildToParentProver is IStateProver { uint256 targetBlockNumber = abi.decode(input, (uint256)); // get the block hash from the buffer - targetStateCommitment = IBuffer(blockHashBuffer).parentChainBlockHash(targetBlockNumber); + targetStateCommitment = IBuffer(BLOCK_HASH_BUFFER).parentChainBlockHash(targetBlockNumber); } /// @notice Verify a storage slot given a target chain block hash and a proof. diff --git a/src/contracts/provers/linea/ChildToParentProver.sol b/src/contracts/provers/linea/ChildToParentProver.sol index fd32bf3..f3f1817 100644 --- a/src/contracts/provers/linea/ChildToParentProver.sol +++ b/src/contracts/provers/linea/ChildToParentProver.sol @@ -14,7 +14,7 @@ contract ChildToParentProver is IStateProver { address public immutable blockHashBuffer; /// @dev Storage slot the buffer contract uses to store block hashes. /// See https://github.com/openintentsframework/broadcaster/blob/main/src/contracts/block-hash-pusher/BaseBuffer.sol - uint256 public constant blockHashMappingSlot = 1; + uint256 public constant BLOCK_HASH_MAPPING_SLOT = 1; /// @dev The chain ID of the home chain (child chain). uint256 public immutable homeChainId; @@ -44,7 +44,7 @@ contract ChildToParentProver is IStateProver { // calculate the slot based on the provided block number // see: https://github.com/OffchainLabs/block-hash-pusher/blob/a1e26f2e42e6306d1e7f03c5d20fa6aa64ff7a12/contracts/Buffer.sol#L32 - uint256 slot = uint256(SlotDerivation.deriveMapping(bytes32(blockHashMappingSlot), targetBlockNumber)); + uint256 slot = uint256(SlotDerivation.deriveMapping(bytes32(BLOCK_HASH_MAPPING_SLOT), targetBlockNumber)); // verify proofs and get the block hash targetStateCommitment = ProverUtils.getSlotFromBlockHeader( diff --git a/src/contracts/provers/optimism/ChildToParentProver.sol b/src/contracts/provers/optimism/ChildToParentProver.sol index acef4fc..4896e33 100644 --- a/src/contracts/provers/optimism/ChildToParentProver.sol +++ b/src/contracts/provers/optimism/ChildToParentProver.sol @@ -17,8 +17,8 @@ interface IL1Block { /// Pre-generated proofs become stale when L1Block updates (~5 minutes). /// Operational difference from Arbitrum: proofs must be generated just-in-time rather than pre-cached. contract ChildToParentProver is IStateProver { - address public constant l1BlockPredeploy = 0x4200000000000000000000000000000000000015; - uint256 public constant l1BlockHashSlot = 2; // hash is at slot 2 + address public constant L1_BLOCK_PREDEPLOY = 0x4200000000000000000000000000000000000015; + uint256 public constant L1_BLOCK_HASH_SLOT = 2; // hash is at slot 2 /// @dev The chain ID of the home chain (Optimism L2) uint256 public immutable homeChainId; @@ -50,7 +50,7 @@ contract ChildToParentProver is IStateProver { // verify proofs and get the value targetStateCommitment = ProverUtils.getSlotFromBlockHeader( - homeBlockHash, rlpBlockHeader, l1BlockPredeploy, l1BlockHashSlot, accountProof, storageProof + homeBlockHash, rlpBlockHeader, L1_BLOCK_PREDEPLOY, L1_BLOCK_HASH_SLOT, accountProof, storageProof ); } @@ -67,7 +67,7 @@ contract ChildToParentProver is IStateProver { if (block.chainid != homeChainId) { revert CallNotOnHomeChain(); } - return IL1Block(l1BlockPredeploy).hash(); + return IL1Block(L1_BLOCK_PREDEPLOY).hash(); } /// @notice Verify a storage slot given a target chain block hash and a proof. diff --git a/src/contracts/provers/scroll/ChildToParentProver.sol b/src/contracts/provers/scroll/ChildToParentProver.sol index c24c401..3cc36f1 100644 --- a/src/contracts/provers/scroll/ChildToParentProver.sol +++ b/src/contracts/provers/scroll/ChildToParentProver.sol @@ -15,7 +15,7 @@ contract ChildToParentProver is IStateProver { address public immutable blockHashBuffer; /// @dev Storage slot the buffer contract uses to store block hashes. /// https://github.com/openintentsframework/broadcaster/blob/main/src/contracts/block-hash-pusher/BaseBuffer.sol - uint256 public constant blockHashMappingSlot = 1; + uint256 public constant BLOCK_HASH_MAPPING_SLOT = 1; /// @dev The chain ID of the home chain (child chain). uint256 public immutable homeChainId; @@ -45,7 +45,7 @@ contract ChildToParentProver is IStateProver { // calculate the slot based on the provided block number // see: https://github.com/OffchainLabs/block-hash-pusher/blob/a1e26f2e42e6306d1e7f03c5d20fa6aa64ff7a12/contracts/Buffer.sol#L32 - uint256 slot = uint256(SlotDerivation.deriveMapping(bytes32(blockHashMappingSlot), targetBlockNumber)); + uint256 slot = uint256(SlotDerivation.deriveMapping(bytes32(BLOCK_HASH_MAPPING_SLOT), targetBlockNumber)); // verify proofs and get the block hash targetStateCommitment = ProverUtils.getSlotFromBlockHeader( diff --git a/src/contracts/provers/zksync/ChildToParentProver.sol b/src/contracts/provers/zksync/ChildToParentProver.sol index 20a950c..76990b8 100644 --- a/src/contracts/provers/zksync/ChildToParentProver.sol +++ b/src/contracts/provers/zksync/ChildToParentProver.sol @@ -15,7 +15,7 @@ contract ChildToParentProver is IStateProver { address public immutable blockHashBuffer; /// @dev Storage slot the buffer contract uses to store block hashes. /// See https://github.com/openintentsframework/broadcaster/blob/main/src/contracts/block-hash-pusher/BaseBuffer.sol - uint256 public constant blockHashMappingSlot = 1; + uint256 public constant BLOCK_HASH_MAPPING_SLOT = 1; /// @dev The chain ID of the home chain (child chain). uint256 public immutable homeChainId; @@ -45,7 +45,7 @@ contract ChildToParentProver is IStateProver { // calculate the slot based on the provided block number // see: https://github.com/OffchainLabs/block-hash-pusher/blob/a1e26f2e42e6306d1e7f03c5d20fa6aa64ff7a12/contracts/Buffer.sol#L32 - uint256 slot = uint256(SlotDerivation.deriveMapping(bytes32(blockHashMappingSlot), targetBlockNumber)); + uint256 slot = uint256(SlotDerivation.deriveMapping(bytes32(BLOCK_HASH_MAPPING_SLOT), targetBlockNumber)); // verify proofs and get the block hash targetStateCommitment = ProverUtils.getSlotFromBlockHeader( diff --git a/test/Receiver.t.sol b/test/Receiver.t.sol index 64806bd..bee5b5c 100644 --- a/test/Receiver.t.sol +++ b/test/Receiver.t.sol @@ -294,7 +294,7 @@ contract ReceiverTest is Test { assertEq(blockHash, expectedBlockHash); bytes memory input = abi.encode(rlpBlockHeader, account, slot, rlpAccountProof, rlpStorageProof); - IL1Block l1Block = IL1Block(childToParentProver.l1BlockPredeploy()); + IL1Block l1Block = IL1Block(childToParentProver.L1_BLOCK_PREDEPLOY()); vm.prank(l1Block.DEPOSITOR_ACCOUNT()); l1Block.setL1BlockValues( @@ -369,7 +369,7 @@ contract ReceiverTest is Test { assertEq(blockHash, expectedBlockHash); bytes memory input = abi.encode(rlpBlockHeader, account, slot, rlpAccountProof, rlpStorageProof); - IL1Block l1Block = IL1Block(childToParentProver.l1BlockPredeploy()); + IL1Block l1Block = IL1Block(childToParentProver.L1_BLOCK_PREDEPLOY()); vm.prank(l1Block.DEPOSITOR_ACCOUNT()); l1Block.setL1BlockValues( @@ -446,7 +446,7 @@ contract ReceiverTest is Test { assertEq(blockHash, expectedBlockHash); bytes memory input = abi.encode(rlpBlockHeader, account, slot, rlpAccountProof, rlpStorageProof); - IL1Block l1Block = IL1Block(childToParentProver.l1BlockPredeploy()); + IL1Block l1Block = IL1Block(childToParentProver.L1_BLOCK_PREDEPLOY()); vm.prank(l1Block.DEPOSITOR_ACCOUNT()); l1Block.setL1BlockValues( @@ -515,7 +515,7 @@ contract ReceiverTest is Test { bytes memory inputForOPChildToParentProver = abi.encode(rlpBlockHeader, account, slot, rlpAccountProof, rlpStorageProof); - IL1Block l1Block = IL1Block(childToParentProver.l1BlockPredeploy()); + IL1Block l1Block = IL1Block(childToParentProver.L1_BLOCK_PREDEPLOY()); vm.prank(l1Block.DEPOSITOR_ACCOUNT()); l1Block.setL1BlockValues( @@ -579,7 +579,7 @@ contract ReceiverTest is Test { bytes memory rlpAccountProofArbitrum = jsonArbitrum.readBytes(".rlpAccountProof"); bytes memory rlpStorageProofArbitrum = jsonArbitrum.readBytes(".rlpStorageProof"); - IL1Block l1Block = IL1Block(childToParentProver.l1BlockPredeploy()); + IL1Block l1Block = IL1Block(childToParentProver.L1_BLOCK_PREDEPLOY()); vm.prank(l1Block.DEPOSITOR_ACCOUNT()); l1Block.setL1BlockValues( diff --git a/test/VerifyBroadcastMessageBenchmark.t.sol b/test/VerifyBroadcastMessageBenchmark.t.sol index 01ad5a1..2f7c0c0 100644 --- a/test/VerifyBroadcastMessageBenchmark.t.sol +++ b/test/VerifyBroadcastMessageBenchmark.t.sol @@ -369,7 +369,7 @@ contract VerifyBroadcastMessageBenchmark is Test { address publisher = 0x9a56fFd72F4B526c523C733F1F74197A51c495E1; // Mock L1Block predeploy - address l1Block = prover.l1BlockPredeploy(); + address l1Block = prover.L1_BLOCK_PREDEPLOY(); vm.mockCall(l1Block, abi.encodeWithSignature("hash()"), abi.encode(blockHash)); vm.mockCall(l1Block, abi.encodeWithSignature("number()"), abi.encode(blockNumber)); @@ -435,7 +435,7 @@ contract VerifyBroadcastMessageBenchmark is Test { bytes32 ethBlockHash = ethJson.readBytes32(".blockHash"); // Mock L1Block predeploy for first hop - address l1Block = opC2PProver.l1BlockPredeploy(); + address l1Block = opC2PProver.L1_BLOCK_PREDEPLOY(); vm.mockCall(l1Block, abi.encodeWithSignature("hash()"), abi.encode(ethBlockHash)); vm.mockCall(l1Block, abi.encodeWithSignature("number()"), abi.encode(ethBlockNumber));