diff --git a/src/contracts/block-hash-pusher/BaseBuffer.sol b/src/contracts/block-hash-pusher/BaseBuffer.sol index 462c688..b236dda 100644 --- a/src/contracts/block-hash-pusher/BaseBuffer.sol +++ b/src/contracts/block-hash-pusher/BaseBuffer.sol @@ -16,8 +16,8 @@ abstract contract BaseBuffer is IBuffer { /// @dev For a parent chain with a block time of 12s (Ethereum), this is equivalent to roughly 54 days of history. uint256 private constant _BUFFER_SIZE = 393168; // 48 * 8191, where 8191 is the EIP-2935 history storage window - /// @dev The block number of the newest block in the buffer. - uint256 private _newestBlockNumber; + /// @notice The block number of the newest block in the buffer. + uint256 public newestBlockNumber; /// @dev Mapping of block numbers to block hashes. mapping(uint256 blockNumber => bytes32 blockHash) private _blockHashes; @@ -66,16 +66,11 @@ abstract contract BaseBuffer is IBuffer { uint256 lastBlockNumber = firstBlockNumber + blockHashesLength - 1; - if (lastBlockNumber > _newestBlockNumber) { + if (lastBlockNumber > newestBlockNumber) { // update the newest block number - _newestBlockNumber = lastBlockNumber; + newestBlockNumber = lastBlockNumber; } emit BlockHashesPushed(firstBlockNumber, lastBlockNumber); } - - /// @inheritdoc IBuffer - function newestBlockNumber() public view returns (uint256) { - return _newestBlockNumber; - } } diff --git a/src/contracts/block-hash-pusher/linea/LineaBuffer.sol b/src/contracts/block-hash-pusher/linea/LineaBuffer.sol index b56c0a9..836a7d3 100644 --- a/src/contracts/block-hash-pusher/linea/LineaBuffer.sol +++ b/src/contracts/block-hash-pusher/linea/LineaBuffer.sol @@ -17,8 +17,8 @@ contract LineaBuffer is BaseBuffer { /// @dev The address of the L2MessageService contract on L2. address private immutable _l2MessageService; - /// @dev The address of the pusher contract on L1. - address private immutable _pusher; + /// @notice The address of the pusher contract on L1. + address public immutable pusher; /// @notice Thrown when attempting to set an invalid L2MessageService address. error InvalidL2MessageServiceAddress(); @@ -34,7 +34,7 @@ contract LineaBuffer is BaseBuffer { constructor(address l2MessageService_, address pusher_) { _l2MessageService = l2MessageService_; - _pusher = pusher_; + pusher = pusher_; if (l2MessageService_ == address(0)) { revert InvalidL2MessageServiceAddress(); @@ -48,21 +48,16 @@ contract LineaBuffer is BaseBuffer { if (msg.sender != address(l2MessageServiceCached)) { revert InvalidSender(); } - if (_pusher == address(0)) { + if (pusher == address(0)) { revert InvalidPusherAddress(); } - if (l2MessageServiceCached.sender() != _pusher) { + if (l2MessageServiceCached.sender() != pusher) { revert SenderMismatch(); } _receiveHashes(firstBlockNumber, blockHashes); } - /// @inheritdoc IBuffer - function pusher() public view returns (address) { - return _pusher; - } - /// @notice The address of the Linea L2MessageService contract on L2. /// @return The address of the Linea L2MessageService contract on L2. function l2MessageService() public view returns (address) { diff --git a/src/contracts/block-hash-pusher/linea/LineaPusher.sol b/src/contracts/block-hash-pusher/linea/LineaPusher.sol index 2d03435..fda05ef 100644 --- a/src/contracts/block-hash-pusher/linea/LineaPusher.sol +++ b/src/contracts/block-hash-pusher/linea/LineaPusher.sol @@ -12,8 +12,8 @@ import {IMessageService} from "@linea-contracts/messaging/interfaces/IMessageSer /// via the Linea MessageService's `sendMessage` function. The pusher must be configured /// with the correct rollup address. contract LineaPusher is BlockHashArrayBuilder, IPusher { - /// @dev The address of the Linea Rollup contract on L1. - address private immutable _lineaRollup; + /// @notice The address of the Linea Rollup contract on L1. + address public immutable lineaRollup; /// @notice Parameters for the L2 transaction that will be executed on Linea. /// @param _fee The fee paid for the postman to claim the message on L2 @@ -22,7 +22,7 @@ contract LineaPusher is BlockHashArrayBuilder, IPusher { } constructor(address rollup_) { - _lineaRollup = rollup_; + lineaRollup = rollup_; } /// @inheritdoc IPusher @@ -39,14 +39,8 @@ contract LineaPusher is BlockHashArrayBuilder, IPusher { LineaL2Transaction memory l2Transaction = abi.decode(l2TransactionData, (LineaL2Transaction)); - IMessageService(lineaRollup()).sendMessage{value: msg.value}(buffer, l2Transaction._fee, l2Calldata); + IMessageService(lineaRollup).sendMessage{value: msg.value}(buffer, l2Transaction._fee, l2Calldata); emit BlockHashesPushed(firstBlockNumber, firstBlockNumber + batchSize - 1); } - - /// @notice The address of the Linea Rollup contract on L1. - /// @return The address of the Linea Rollup contract on L1. - function lineaRollup() public view returns (address) { - return _lineaRollup; - } } diff --git a/src/contracts/block-hash-pusher/scroll/ScrollBuffer.sol b/src/contracts/block-hash-pusher/scroll/ScrollBuffer.sol index 9266952..b91ae2f 100644 --- a/src/contracts/block-hash-pusher/scroll/ScrollBuffer.sol +++ b/src/contracts/block-hash-pusher/scroll/ScrollBuffer.sol @@ -14,8 +14,8 @@ contract ScrollBuffer is BaseBuffer { /// @dev The address of the L2ScrollMessenger contract on L2. address private immutable _l2ScrollMessenger; - /// @dev The address of the pusher contract on L1. - address private immutable _pusher; + /// @notice The address of the pusher contract on L1. + address public immutable pusher; /// @notice Thrown when attempting to set an invalid L2ScrollMessenger address. error InvalidL2ScrollMessengerAddress(); @@ -31,7 +31,7 @@ contract ScrollBuffer is BaseBuffer { constructor(address l2ScrollMessenger_, address pusher_) { _l2ScrollMessenger = l2ScrollMessenger_; - _pusher = pusher_; + pusher = pusher_; if (l2ScrollMessenger_ == address(0)) { revert InvalidL2ScrollMessengerAddress(); @@ -45,21 +45,16 @@ contract ScrollBuffer is BaseBuffer { if (msg.sender != address(l2ScrollMessengerCached)) { revert InvalidSender(); } - if (_pusher == address(0)) { + if (pusher == address(0)) { revert InvalidPusherAddress(); } - if (l2ScrollMessengerCached.xDomainMessageSender() != _pusher) { + if (l2ScrollMessengerCached.xDomainMessageSender() != pusher) { revert DomainMessageSenderMismatch(); } _receiveHashes(firstBlockNumber, blockHashes); } - /// @inheritdoc IBuffer - function pusher() public view returns (address) { - return _pusher; - } - /// @notice The address of the L2ScrollMessenger contract on L2. /// @return The address of the L2ScrollMessenger contract on L2. function l2ScrollMessenger() public view returns (address) { diff --git a/src/contracts/block-hash-pusher/scroll/ScrollPusher.sol b/src/contracts/block-hash-pusher/scroll/ScrollPusher.sol index 2d5a8c7..cebb082 100644 --- a/src/contracts/block-hash-pusher/scroll/ScrollPusher.sol +++ b/src/contracts/block-hash-pusher/scroll/ScrollPusher.sol @@ -12,8 +12,8 @@ import {IL1ScrollMessenger} from "@scroll-tech/scroll-contracts/L1/IL1ScrollMess /// via the Scroll L1ScrollMessenger's `sendMessage` function. The pusher must be configured /// with the correct L1ScrollMessenger address. contract ScrollPusher is BlockHashArrayBuilder, IPusher { - /// @dev The address of the Scroll L1ScrollMessenger contract on L1. - address private immutable _l1ScrollMessenger; + /// @notice The address of the Scroll L1ScrollMessenger contract on L1. + address public immutable l1ScrollMessenger; /// @notice Parameters for the L2 transaction that will be executed on Scroll. /// @param gasLimit The gas limit for the L2 transaction. @@ -24,7 +24,7 @@ contract ScrollPusher is BlockHashArrayBuilder, IPusher { } constructor(address l1ScrollMessenger_) { - _l1ScrollMessenger = l1ScrollMessenger_; + l1ScrollMessenger = l1ScrollMessenger_; } /// @inheritdoc IPusher @@ -41,7 +41,7 @@ contract ScrollPusher is BlockHashArrayBuilder, IPusher { ScrollL2Transaction memory l2Transaction = abi.decode(l2TransactionData, (ScrollL2Transaction)); - IL1ScrollMessenger(l1ScrollMessenger()).sendMessage{value: msg.value}( + IL1ScrollMessenger(l1ScrollMessenger).sendMessage{value: msg.value}( buffer, 0, l2Calldata, @@ -51,10 +51,4 @@ contract ScrollPusher is BlockHashArrayBuilder, IPusher { emit BlockHashesPushed(firstBlockNumber, firstBlockNumber + batchSize - 1); } - - /// @notice The address of the Scroll L1ScrollMessenger contract on L1. - /// @return The address of the Scroll L1ScrollMessenger contract on L1. - function l1ScrollMessenger() public view returns (address) { - return _l1ScrollMessenger; - } } diff --git a/src/contracts/block-hash-pusher/zksync/ZkSyncBuffer.sol b/src/contracts/block-hash-pusher/zksync/ZkSyncBuffer.sol index 0208fcd..8053372 100644 --- a/src/contracts/block-hash-pusher/zksync/ZkSyncBuffer.sol +++ b/src/contracts/block-hash-pusher/zksync/ZkSyncBuffer.sol @@ -11,14 +11,14 @@ import {IBuffer} from "../interfaces/IBuffer.sol"; /// When a message is sent from L1 to L2 via ZkSync's Mailbox, the sender address is aliased. /// The buffer only accepts hash pushes from the aliased pusher address. contract ZkSyncBuffer is BaseBuffer { - /// @dev The address of the pusher contract on L1. - address private immutable _pusher; + /// @notice The address of the pusher contract on L1. + address public immutable pusher; /// @notice Thrown when attempting to set an invalid pusher address. error InvalidPusherAddress(); constructor(address pusher_) { - _pusher = pusher_; + pusher = pusher_; if (pusher_ == address(0)) { revert InvalidPusherAddress(); @@ -34,16 +34,11 @@ contract ZkSyncBuffer is BaseBuffer { _receiveHashes(firstBlockNumber, blockHashes); } - /// @inheritdoc IBuffer - function pusher() public view returns (address) { - return _pusher; - } - /// @notice The aliased address of the pusher contract on L2. function aliasedPusher() public view returns (address) { - if (_pusher == address(0)) { + if (pusher == address(0)) { revert InvalidPusherAddress(); } - return AddressAliasHelper.applyL1ToL2Alias(_pusher); + return AddressAliasHelper.applyL1ToL2Alias(pusher); } } diff --git a/src/contracts/block-hash-pusher/zksync/ZkSyncPusher.sol b/src/contracts/block-hash-pusher/zksync/ZkSyncPusher.sol index 9648afa..83616d6 100644 --- a/src/contracts/block-hash-pusher/zksync/ZkSyncPusher.sol +++ b/src/contracts/block-hash-pusher/zksync/ZkSyncPusher.sol @@ -24,8 +24,8 @@ interface IMailbox { /// via the ZkSync Mailbox's `requestL2Transaction` function. The pusher must be configured /// with the correct ZkSync Diamond proxy address. contract ZkSyncPusher is BlockHashArrayBuilder, IPusher { - /// @dev The address of the ZkSync Diamond proxy contract on L1. - address private immutable _zkSyncDiamond; + /// @notice The address of the ZkSync Diamond proxy contract on L1. + address public immutable zkSyncDiamond; /// @notice Thrown when the L2 transaction request fails. error FailedToPushHashes(); @@ -41,7 +41,7 @@ contract ZkSyncPusher is BlockHashArrayBuilder, IPusher { } constructor(address zkSyncDiamond_) { - _zkSyncDiamond = zkSyncDiamond_; + zkSyncDiamond = zkSyncDiamond_; } /// @inheritdoc IPusher @@ -60,7 +60,7 @@ contract ZkSyncPusher is BlockHashArrayBuilder, IPusher { /// In the current behavior of the ZkSync Mailbox, the `l2GasPerPubdataByteLimit` value must be equal to the `REQUIRED_L2_GAS_PRICE_PER_PUBDATA` value, /// which is a constant defined by ZkSync. The current value is 800. However, since this might change in the future, the value must be passed in as a parameter. - bytes32 canonicalTxHash = IMailbox(zkSyncDiamond()).requestL2Transaction{value: msg.value}( + bytes32 canonicalTxHash = IMailbox(zkSyncDiamond).requestL2Transaction{value: msg.value}( buffer, 0, l2Calldata, @@ -76,10 +76,4 @@ contract ZkSyncPusher is BlockHashArrayBuilder, IPusher { emit BlockHashesPushed(firstBlockNumber, firstBlockNumber + batchSize - 1); } - - /// @notice The address of the ZkSync Diamond proxy contract on L1. - /// @return The address of the ZkSync Diamond proxy contract on L1. - function zkSyncDiamond() public view returns (address) { - return _zkSyncDiamond; - } }