Skip to content

Conversation

@ManuelBilbao
Copy link
Contributor

@ManuelBilbao ManuelBilbao commented Oct 9, 2025

Motivation

Shared bridge feature allows users to communicate between differents L2s seamlessly.

Description

Create a new Router contract 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 L2

Related: #5016

@ManuelBilbao ManuelBilbao self-assigned this Oct 9, 2025
@github-actions github-actions bot added the L2 Rollup client label Oct 9, 2025
@github-actions
Copy link

github-actions bot commented Oct 13, 2025

Lines of code report

Total lines added: 328
Total lines removed: 0
Total lines changed: 328

Detailed view
+----------------------------------------------------+-------+------+
| File                                               | Lines | Diff |
+----------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/build_l2.rs                      | 402   | +5   |
+----------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/l2/command.rs                    | 630   | +1   |
+----------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/l2/deployer.rs                   | 1183  | +105 |
+----------------------------------------------------+-------+------+
| ethrex/crates/common/types/l2.rs                   | 3     | +1   |
+----------------------------------------------------+-------+------+
| ethrex/crates/common/types/l2/batch.rs             | 18    | +4   |
+----------------------------------------------------+-------+------+
| ethrex/crates/common/types/l2/l2_to_l2_message.rs  | 35    | +35  |
+----------------------------------------------------+-------+------+
| ethrex/crates/l2/based/block_fetcher.rs            | 504   | +10  |
+----------------------------------------------------+-------+------+
| ethrex/crates/l2/common/src/l1_messages.rs         | 117   | +54  |
+----------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_committer.rs         | 825   | +30  |
+----------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/api.rs                | 136   | +7   |
+----------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store.rs              | 344   | +18  |
+----------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store_db/in_memory.rs | 361   | +13  |
+----------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store_db/sql.rs       | 931   | +43  |
+----------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/l2/messages.rs   | 167   | +2   |
+----------------------------------------------------+-------+------+

@ManuelBilbao ManuelBilbao marked this pull request as ready for review October 17, 2025 16:09
@ManuelBilbao ManuelBilbao requested review from a team and jrchatruc as code owners October 17, 2025 16:09
@Copilot Copilot AI review requested due to automatic review settings October 17, 2025 16:09
Copy link
Contributor

Copilot AI left a 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.

Comment on lines 581 to 592
if contract_addresses.router.is_some()
&& register_chain(
&eth_client,
contract_addresses,
genesis.config.chain_id,
&signer,
)
.await
.is_err()
{
warn!("Could not register chain in shared bridge router");
}
Copy link
Contributor

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(
            &eth_client,
            contract_addresses,
            genesis.config.chain_id,
            &signer,
        )
        .await
        .inspect_err(|_|  warn!("Could not register chain in shared bridge router");)
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 0b35959

Copy link
Contributor

@avilagaston9 avilagaston9 left a 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);
Copy link
Contributor

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.

Copy link
Contributor Author

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

@ManuelBilbao ManuelBilbao linked an issue Oct 23, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L2 Rollup client

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants