-
Notifications
You must be signed in to change notification settings - Fork 111
feat(l2): shared bridge router contract #4834
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
base: main
Are you sure you want to change the base?
Conversation
Lines of code reportTotal lines added: Detailed view |
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.
Pull Request Overview
This PR implements a shared bridge router contract that enables seamless communication between different L2 chains. Users can send transactions to one L2 bridge that will be processed on another L2, with the Router contract on L1 managing the cross-chain routing.
Key changes:
- Adds L2-to-L2 message infrastructure and routing capabilities
- Implements Router contract for managing chain registrations and message forwarding
- Updates batch commit process to include L2-to-L2 messages in the commit signature
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| fixtures/genesis/l2.json | Updates blob schedule configuration and contract bytecode for L2 genesis |
| crates/networking/p2p/rlpx/l2/messages.rs | Adds l2_to_l2_messages field to BatchSealed message structure |
| crates/l2/storage/src/store_db/sql.rs | Implements SQL storage for L2-to-L2 messages with new table and operations |
| crates/l2/storage/src/store_db/in_memory.rs | Adds in-memory storage support for L2-to-L2 messages |
| crates/l2/storage/src/store.rs | Updates Store interface to handle L2-to-L2 message storage and retrieval |
| crates/l2/storage/src/api.rs | Adds StoreEngineRollup trait methods for L2-to-L2 message operations |
| crates/l2/sequencer/l1_committer.rs | Updates commit function signature and batch processing to include L2-to-L2 messages |
| crates/l2/contracts/src/l2/interfaces/IL2ToL1Messenger.sol | Adds L2ToL2Message event and sendMessageToL2 function interface |
| crates/l2/contracts/src/l2/interfaces/ICommonBridgeL2.sol | Adds sendToL2 function for cross-chain messaging |
| crates/l2/contracts/src/l2/L2ToL1Messenger.sol | Implements L2-to-L2 message sending functionality |
| crates/l2/contracts/src/l2/CommonBridgeL2.sol | Adds sendToL2 function with gas burning mechanism |
| crates/l2/contracts/src/l1/interfaces/IRouter.sol | Defines Router contract interface for chain management and message routing |
| crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol | Adds L2toL2Message struct and updates commitBatch signature |
| crates/l2/contracts/src/l1/interfaces/ICommonBridge.sol | Updates bridge interface for shared bridge router integration |
| crates/l2/contracts/src/l1/Router.sol | Implements Router contract for managing chain registrations and message forwarding |
| crates/l2/contracts/src/l1/OnChainProposer.sol | Updates batch commit to process L2-to-L2 messages via router |
| crates/l2/contracts/src/l1/CommonBridge.sol | Adds shared bridge router integration and message handling |
| crates/l2/common/src/l1_messages.rs | Implements L2-to-L2 message extraction from transaction logs |
| crates/l2/based/block_fetcher.rs | Updates block fetching to extract and store L2-to-L2 messages |
| crates/common/types/l2/l2_to_l2_message.rs | Defines L2toL2Message struct and RLP decoding |
| crates/common/types/l2/batch.rs | Adds l2_to_l2_messages field to Batch struct |
| crates/common/types/l2.rs | Exports l2_to_l2_message module |
| cmd/ethrex/l2/deployer.rs | Adds Router contract deployment and chain registration |
| cmd/ethrex/l2/command.rs | Updates batch creation to include empty L2-to-L2 messages |
| cmd/ethrex/build_l2.rs | Adds Router contract to build process |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
cmd/ethrex/l2/deployer.rs
Outdated
| if contract_addresses.router.is_some() | ||
| && register_chain( | ||
| ð_client, | ||
| contract_addresses, | ||
| genesis.config.chain_id, | ||
| &signer, | ||
| ) | ||
| .await | ||
| .is_err() | ||
| { | ||
| warn!("Could not register chain in shared bridge router"); | ||
| } |
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 would put the register_chain inside the if to make it more readable
if contract_addresses.router.is_some() {
register_chain(
ð_client,
contract_addresses,
genesis.config.chain_id,
&signer,
)
.await
.inspect_err(|_| warn!("Could not register chain in shared bridge router");)
}
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.
Done 0b35959
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.
Left some comments. A how-to-run guide would be nice to have once the docs are completed.
| /// @inheritdoc ICommonBridgeL2 | ||
| function sendToL2(uint256 chainId, address to, uint256 destGasLimit, bytes calldata data) external override payable { | ||
| _burnGas(destGasLimit); | ||
| IL2ToL1Messenger(L1_MESSENGER).sendMessageToL2{value: msg.value}(chainId, msg.sender, to, destGasLimit, data); |
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.
We should consider renaming this to CROSS_CHAIN_MESSENGER or something similar.
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.
Yes, we should debate the naming of this
Motivation
Shared bridge feature allows users to communicate between differents L2s seamlessly.
Description
Create a new
Routercontract that know each chain's contracts. A user can send a tx to the L2 bridge, with value and calldata to interact in another L2. When the batch is sent to L1, those transactions are processed in the L1 along with the batch commitment/verifying. Then, the transaction is processed in the destination L2Related: #5016