-
Notifications
You must be signed in to change notification settings - Fork 0
Add Linea pusher and buffer #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…caster into linea-pusher
…caster into linea-pusher
📝 WalkthroughWalkthroughAdds Linea network support to the block hash pusher system by introducing a new submodule, creating LineaPusher and LineaBuffer contracts for L1-to-L2 cross-chain communication, updating import mappings, and providing comprehensive tests and documentation. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant L1 as LineaPusher<br/>(L1)
participant MessageService as Linea<br/>MessageService
participant L2 as LineaBuffer<br/>(L2)
User->>L1: pushHashes(firstBlock, batchSize, l2TxData)
L1->>L1: Build block hash array
L1->>L1: Encode receiveHashes calldata
L1->>MessageService: sendMessage(buffer, fee, calldata)
MessageService->>MessageService: Store & emit MessageSent
Note over MessageService: L2 message relay
MessageService->>L2: claimMessage(...)
L2->>L2: Verify sender == MessageService
L2->>L2: Extract pusher from MessageService
L2->>L2: Validate pusher address matches
L2->>L2: Store block hashes
L2->>MessageService: Emit MessageClaimed
MessageService->>L1: Message execution confirmed
L1->>L1: Emit BlockHashesPushed
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| pragma solidity 0.8.30; | ||
|
|
||
| import {IBuffer} from "./interfaces/IBuffer.sol"; | ||
| import {AddressAliasHelper} from "@arbitrum/nitro-contracts/src/libraries/AddressAliasHelper.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not used
| } | ||
|
|
||
| /// @inheritdoc IBuffer | ||
| function receiveHashes(uint256 firstBlockNumber, bytes32[] calldata blockHashes) external { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on the interface blockHashes is memory, here is calldata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, changed it to calldata
…caster into linea-pusher
…caster into linea-pusher
| address private _pusherAddress; | ||
|
|
||
| /// @notice Thrown when attempting to receive hashes before the pusher address has been set. | ||
| error PusherAddressNotSet(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seem to be a few errors and events that show up in every Buffer. Perhaps those should be moved to IBuffer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/contracts/block-hash-pusher/linea/LineaPusher.sol`:
- Around line 27-30: Add explicit zero-address checks in the constructor to fail
fast if rollup_ or bufferAddress_ is address(0). In the constructor of
LineaPusher.sol, validate rollup_ and bufferAddress_ with require(rollup_ !=
address(0), "...") and require(bufferAddress_ != address(0), "...") before
assigning to _lineaRollup and _bufferAddress, using clear revert messages that
identify the bad parameter (e.g., "LineaPusher: rollup is zero address" and
"LineaPusher: buffer is zero address").
🧹 Nitpick comments (2)
src/contracts/block-hash-pusher/linea/LineaBuffer.sol (1)
20-51: Consider making_l2MessageServiceimmutable.
It’s constructor-only state, soimmutablesaves storage reads and locks the invariant.♻️ Proposed refactor
- address private _l2MessageService; + address private immutable _l2MessageService; - constructor(address l2MessageService_, address initialOwner_) Ownable(initialOwner_) { - _l2MessageService = l2MessageService_; - - if (l2MessageService_ == address(0)) { - revert InvalidL2MessageServiceAddress(); - } - } + constructor(address l2MessageService_, address initialOwner_) Ownable(initialOwner_) { + if (l2MessageService_ == address(0)) { + revert InvalidL2MessageServiceAddress(); + } + _l2MessageService = l2MessageService_; + }test/block-hash-pusher/linea/LineaBuffer.t.sol (1)
45-56: Unusedl2Calldatavariable.Line 51 creates
l2Calldatabut it's not used since the test callsreceiveHashesdirectly. This is a minor cleanup opportunity.♻️ Suggested cleanup
function testFuzz_receiveHashes_reverts_if_sender_is_not_linea_message_service(address notLineaMessageService) public { vm.assume(notLineaMessageService != address(mockLineaMessageService)); LineaBuffer buffer = new LineaBuffer(address(mockLineaMessageService), owner); - bytes memory l2Calldata = abi.encodeCall(buffer.receiveHashes, (1, new bytes32[](1))); - vm.expectRevert(abi.encodeWithSelector(LineaBuffer.InvalidSender.selector)); vm.prank(notLineaMessageService); buffer.receiveHashes(1, new bytes32[](1)); }
| constructor(address rollup_, address bufferAddress_) { | ||
| _lineaRollup = rollup_; | ||
| _bufferAddress = bufferAddress_; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add zero-address checks for rollup and buffer.
Fail fast on misconfiguration to avoid sending messages to address(0).
🐛 Proposed fix
constructor(address rollup_, address bufferAddress_) {
+ require(rollup_ != address(0) && bufferAddress_ != address(0), "LineaPusher: zero address");
_lineaRollup = rollup_;
_bufferAddress = bufferAddress_;
}🤖 Prompt for AI Agents
In `@src/contracts/block-hash-pusher/linea/LineaPusher.sol` around lines 27 - 30,
Add explicit zero-address checks in the constructor to fail fast if rollup_ or
bufferAddress_ is address(0). In the constructor of LineaPusher.sol, validate
rollup_ and bufferAddress_ with require(rollup_ != address(0), "...") and
require(bufferAddress_ != address(0), "...") before assigning to _lineaRollup
and _bufferAddress, using clear revert messages that identify the bad parameter
(e.g., "LineaPusher: rollup is zero address" and "LineaPusher: buffer is zero
address").
Add Linea Chain Support to Block Hash Pusher
This PR adds support for Linea L2 to the block hash pusher system, enabling Ethereum L1 block hashes to be pushed to Linea L2.
Contracts:
LineaPusher- L1 contract that pushes block hashes to Linea L2 viaLinea Rollup.sendMessage()LineaBuffer- L2 contract that receives and stores block hashes with access control viaL2MessageServicePS: this PR must be merged after #56 and #57
Summary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.