-
Notifications
You must be signed in to change notification settings - Fork 0
[Provers M01] Proof Stale Time in Optimism #87
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c101c06
add OP Pusher and Buffer
luiz-lvj e61cc92
up
luiz-lvj b9ca49b
up
luiz-lvj 9aa1c09
update prover to use buffer
luiz-lvj bc60297
Merge branch 'main' of github.com:openintentsframework/broadcaster in…
luiz-lvj 173b9b1
add security contact
luiz-lvj f322565
up
luiz-lvj e6abc5a
up
luiz-lvj be6bd35
merge main
luiz-lvj 66bab41
up
luiz-lvj 6e254fe
up
luiz-lvj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| { | ||
| "EthereumToOptimism": "1639239", | ||
| "EthereumToOptimism": "1642677", | ||
| "EthereumToTaikoL2": "1052244", | ||
| "LineaL2ToEthereum": "2551806", | ||
| "ScrollL2ToEthereum": "1361970", | ||
| "ScrollToOptimism": "1348710", | ||
| "ScrollToOptimism": "1352078", | ||
| "TaikoL2ToEthereum": "1022307", | ||
| "ZkSyncL2ToEthereum": "125693" | ||
| } |
61 changes: 61 additions & 0 deletions
61
src/contracts/block-hash-pusher/optimism/OptimismBuffer.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.8.30; | ||
|
|
||
| import {BaseBuffer} from "../BaseBuffer.sol"; | ||
| import {IBuffer} from "../interfaces/IBuffer.sol"; | ||
| import {ICrossDomainMessenger} from "@eth-optimism/contracts/libraries/bridge/ICrossDomainMessenger.sol"; | ||
|
|
||
| /// @title OptimismBuffer | ||
| /// @notice Implementation of BaseBuffer for storing Ethereum L1 block hashes on Optimism L2. | ||
| /// @dev This contract extends BaseBuffer with access control specific to Optimism's L1->L2 messaging. | ||
| /// The pusher address on L1 must send the message via L1CrossDomainMessengerProxy to the buffer address on L2. | ||
| /// The L2CrossDomainMessenger contract on L2 is responsible for relaying the message to the buffer contract on L2. | ||
| /// @custom:security-contact security@openzeppelin.com | ||
| contract OptimismBuffer is BaseBuffer { | ||
| /// @dev The address of the L2CrossDomainMessenger contract on L2. | ||
| address private immutable _l2CrossDomainMessenger; | ||
|
|
||
| /// @dev The address of the pusher contract on L1. | ||
| address private immutable _pusher; | ||
|
|
||
| /// @notice Thrown when attempting to set an invalid L2CrossDomainMessenger address. | ||
| error InvalidL2CrossDomainMessengerAddress(); | ||
|
|
||
| /// @notice Thrown when attempting to set an invalid pusher address. | ||
| error InvalidPusherAddress(); | ||
|
|
||
| /// @notice Thrown when the domain message sender does not match the pusher address. | ||
| error DomainMessageSenderMismatch(); | ||
|
|
||
| /// @notice Thrown when the sender is not the L2CrossDomainMessenger contract. | ||
| error InvalidSender(); | ||
|
|
||
| constructor(address l2CrossDomainMessenger_, address pusher_) { | ||
| require(l2CrossDomainMessenger_ != address(0), InvalidL2CrossDomainMessengerAddress()); | ||
| require(pusher_ != address(0), InvalidPusherAddress()); | ||
|
|
||
| _l2CrossDomainMessenger = l2CrossDomainMessenger_; | ||
| _pusher = pusher_; | ||
| } | ||
|
|
||
| /// @inheritdoc IBuffer | ||
| function receiveHashes(uint256 firstBlockNumber, bytes32[] calldata blockHashes) external { | ||
| ICrossDomainMessenger l2CrossDomainMessengerCached = ICrossDomainMessenger(l2CrossDomainMessenger()); | ||
|
|
||
| require(msg.sender == address(l2CrossDomainMessengerCached), InvalidSender()); | ||
| require(l2CrossDomainMessengerCached.xDomainMessageSender() == _pusher, DomainMessageSenderMismatch()); | ||
|
|
||
| _receiveHashes(firstBlockNumber, blockHashes); | ||
| } | ||
|
|
||
| /// @inheritdoc IBuffer | ||
| function pusher() public view returns (address) { | ||
| return _pusher; | ||
| } | ||
|
|
||
| /// @notice The address of the L2CrossDomainMessenger contract on L2. | ||
| /// @return The address of the L2CrossDomainMessenger contract on L2. | ||
| function l2CrossDomainMessenger() public view returns (address) { | ||
| return _l2CrossDomainMessenger; | ||
| } | ||
| } |
57 changes: 57 additions & 0 deletions
57
src/contracts/block-hash-pusher/optimism/OptimismPusher.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.8.30; | ||
|
|
||
| import {BlockHashArrayBuilder} from "../BlockHashArrayBuilder.sol"; | ||
| import {IBuffer} from "../interfaces/IBuffer.sol"; | ||
| import {IPusher} from "../interfaces/IPusher.sol"; | ||
| import {ICrossDomainMessenger} from "@eth-optimism/contracts/libraries/bridge/ICrossDomainMessenger.sol"; | ||
|
|
||
| /// @title OPtimismPusher | ||
| /// @notice Implementation of IPusher for pushing block hashes to Optimism L2. | ||
| /// @dev This contract sends block hashes from Ethereum L1 to a OptimismBuffer contract on Optimism L2 | ||
| /// via the Optimism L1CrossDomainMessenger's `sendMessage` function. The pusher must be configured | ||
| /// with the correct L1CrossDomainMessengerProxy address. | ||
| /// @custom:security-contact security@openzeppelin.com | ||
| contract OptimismPusher is BlockHashArrayBuilder, IPusher { | ||
| /// @dev The address of the Optimism L1CrossDomainMessengerProxy contract on L1. | ||
| address private immutable _l1CrossDomainMessengerProxy; | ||
|
|
||
| /// @notice Parameters for the L2 transaction that will be executed on Optimism. | ||
| /// @param gasLimit The gas limit for the L2 transaction. | ||
| struct OptimismL2Transaction { | ||
| uint32 gasLimit; | ||
| } | ||
|
|
||
| /// @notice Thrown when attempting to set an invalid L1CrossDomainMessengerProxy address. | ||
| error InvalidL1CrossDomainMessengerProxyAddress(); | ||
|
|
||
| constructor(address l1CrossDomainMessengerProxy_) { | ||
| require(l1CrossDomainMessengerProxy_ != address(0), InvalidL1CrossDomainMessengerProxyAddress()); | ||
|
|
||
| _l1CrossDomainMessengerProxy = l1CrossDomainMessengerProxy_; | ||
| } | ||
|
|
||
| /// @inheritdoc IPusher | ||
| function pushHashes(address buffer, uint256 firstBlockNumber, uint256 batchSize, bytes calldata l2TransactionData) | ||
| external | ||
| payable | ||
| { | ||
| require(buffer != address(0), InvalidBuffer(buffer)); | ||
| require(msg.value == 0, IncorrectMsgValue(0, msg.value)); | ||
|
|
||
| bytes32[] memory blockHashes = _buildBlockHashArray(firstBlockNumber, batchSize); | ||
| bytes memory l2Calldata = abi.encodeCall(IBuffer.receiveHashes, (firstBlockNumber, blockHashes)); | ||
|
|
||
| OptimismL2Transaction memory l2Transaction = abi.decode(l2TransactionData, (OptimismL2Transaction)); | ||
|
|
||
| ICrossDomainMessenger(l1CrossDomainMessengerProxy()).sendMessage(buffer, l2Calldata, l2Transaction.gasLimit); | ||
|
|
||
| emit BlockHashesPushed(firstBlockNumber, firstBlockNumber + batchSize - 1); | ||
| } | ||
|
|
||
| /// @notice The address of the Optimism L1CrossDomainMessengerProxy contract on L1. | ||
| /// @return The address of the Optimism L1CrossDomainMessengerProxy contract on L1. | ||
| function l1CrossDomainMessengerProxy() public view returns (address) { | ||
| return _l1CrossDomainMessengerProxy; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Typo in NatSpec title: "OPtimismPusher" → "OptimismPusher".
📝 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents