Skip to content

Conversation

@ManuelBilbao
Copy link
Contributor

@ManuelBilbao ManuelBilbao commented Oct 9, 2025

Motivation

We aim to reintroduce the L2 feature flag making so that ethrex has 3 available binaries, the L1 execution client, the L2 client and the L2+GPU client. This is done for the following advantages:

  • Less crates needed for the L1 as the UI, L2, zkVMs crates are excluded.
  • L1, L2, y zkVMs are compiled with the optimum crates for performance and their needs.
  • The L1 user only downloads a client without unneeded functionality.

Description

  • Added feature flag l2 to ethrex to compile l2 dependencies separately
  • Added feature flag l2-sql to ethrex to launch l2 with the SQL database for the rollup
  • Modified CI to create 2 tar images of ethrex for testing, ethrex:main and ethrex:main-l2
  • Modified lint commands in makefile to lint l1 and l2 separately. L1 can't handle the workspace flag, due to some l2 crates in the workspace.

@github-actions
Copy link

github-actions bot commented Oct 9, 2025

Lines of code report

Total lines added: 421
Total lines removed: 364
Total lines changed: 785

Detailed view
+-----------------------------------------------------------+-------+------+
| File                                                      | Lines | Diff |
+-----------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/build.rs                                | 31    | -364 |
+-----------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/build_l2.rs                             | 374   | +374 |
+-----------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/cli.rs                                  | 570   | +3   |
+-----------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/initializers.rs                         | 458   | +3   |
+-----------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/lib.rs                                  | 6     | +1   |
+-----------------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/src/backend/sp1.rs                | 136   | +1   |
+-----------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/block_producer.rs              | 235   | +3   |
+-----------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_committer.rs                | 722   | +1   |
+-----------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/metrics.rs                   | 589   | +1   |
+-----------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/network.rs                   | 363   | +3   |
+-----------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/connection/handshake.rs | 528   | +2   |
+-----------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/connection/server.rs    | 985   | +6   |
+-----------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/error.rs                | 119   | +2   |
+-----------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/l2/l2_connection.rs     | 457   | +10  |
+-----------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/message.rs              | 336   | +10  |
+-----------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/mod.rs                  | 11    | +1   |
+-----------------------------------------------------------+-------+------+

@fedacking fedacking marked this pull request as ready for review October 14, 2025 15:41
@fedacking fedacking requested a review from a team as a code owner October 14, 2025 15:41
@ethrex-project-sync ethrex-project-sync bot moved this to In Review in ethrex_l1 Oct 14, 2025
Copilot AI review requested due to automatic review settings October 14, 2025 21:32
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 refactors ethrex to separate L1 and L2 functionality into distinct binaries through feature flags. The main goal is to create optimized builds where the L1 client excludes unnecessary L2 dependencies, while L2 builds include additional database options.

Key changes include:

  • Introduction of l2 and l2-sql feature flags to conditionally compile L2 functionality
  • Separation of build processes to create ethrex:main (L1) and ethrex:main-l2 (L2) Docker images
  • Updated CI/CD workflows to handle both L1 and L2 builds independently

Reviewed Changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cmd/ethrex/Cargo.toml Restructured dependencies to be conditional on l2 feature flags
crates/networking/p2p/rlpx/message.rs Added feature guards around L2 message handling
crates/networking/p2p/rlpx/connection/server.rs Moved imports and added conditional compilation for L2 features
cmd/ethrex/build.rs Extracted L2-specific build logic into separate module
.github/workflows/ Updated CI workflows to build separate L1 and L2 artifacts
Makefile Split linting commands to handle L1 and L2 separately
Comments suppressed due to low confidence (1)

crates/l2/prover/src/backend/sp1.rs:1

  • Missing space in error message. Should be 'Failed to read bytecode file'.
use std::{fmt::Debug, sync::OnceLock};

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

datatest_stable::harness!(blockchain_runner, TEST_FOLDER, r".*");

#[cfg(any(all(feature = "sp1", feature = "stateless"),))]
#[cfg(all(feature = "sp1", feature = "stateless"))]
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

The cfg attribute syntax is incorrect. The trailing comma inside the any() macro was removed but the outer structure should use any() for mutually exclusive features, not all().

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +49
endpoint
.join("/twirp/")
.expect("Failed to parse moongate server url")
.to_string(),
.as_ref(),
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

The method call chain is incorrect. join() returns a Result<Url, url::ParseError>, but as_ref() is being called on the Url result. The original code passed &endpoint to preserve the reference, but now endpoint is moved and as_ref() is called on the wrong type.

Copilot uses AI. Check for mistakes.
let mut batch_gas_used = 0_u64;

info!("Preparing state diff from block {first_block_of_batch}");
info!("Preparing state diff from block {first_block_of_batch}, {batch_number}");
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

[nitpick] The log message format is unclear. Consider using named parameters or a clearer format like 'Preparing state diff from block {} for batch {}'.

Suggested change
info!("Preparing state diff from block {first_block_of_batch}, {batch_number}");
info!("Preparing state diff from block {} for batch {}", first_block_of_batch, batch_number);

Copilot uses AI. Check for mistakes.
where
S: Unpin + Stream<Item = Result<Message, PeerConnectionError>>,
{
// This allow is because in l2 we mut the capabilities
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

Grammar error in comment. Should be 'we mutate the capabilities' instead of 'we mut the capabilities'.

Suggested change
// This allow is because in l2 we mut the capabilities
// This allow is because in l2 we mutate the capabilities

Copilot uses AI. Check for mistakes.
tracker: TaskTracker,
blockchain: Arc<Blockchain>,
based_context: Option<P2PBasedContext>,
#[cfg(feature = "l2")] based_context: Option<P2PBasedContext>,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not optimal and we should fix this in another PR.

{
// This allow is because in l2 we mut the capabilities
// to include the l2 cap
#[allow(unused_mut)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#[allow(unused_mut)]
#[expect(unused_mut)]

Copy link
Contributor

@ilitteri ilitteri left a comment

Choose a reason for hiding this comment

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

Block it until next version release

@github-project-automation github-project-automation bot moved this from In Review to In Progress in ethrex_l1 Oct 14, 2025
@github-project-automation github-project-automation bot moved this to Requires Changes in ethrex_l2 Oct 14, 2025
@github-project-automation github-project-automation bot moved this from In Progress to In Review in ethrex_l1 Oct 16, 2025
@ManuelBilbao ManuelBilbao added this pull request to the merge queue Oct 16, 2025
Merged via the queue into main with commit cdb952e Oct 16, 2025
37 of 45 checks passed
@ManuelBilbao ManuelBilbao deleted the separate_binaries branch October 16, 2025 20:18
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Oct 16, 2025
@github-project-automation github-project-automation bot moved this from Requires Changes to Done in ethrex_l2 Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client L2 Rollup client

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants