Skip to content

refactor(l2): replace sequencer config toml with CLI flags #2606

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 75 commits into from
May 10, 2025
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
4acf92b
Add sequencer options & refactor `cmd/ethrex/l2.rs`
ilitteri Apr 25, 2025
93e0cbe
Update Makefile
ilitteri Apr 25, 2025
6ffd633
Cut needless configs
ilitteri Apr 25, 2025
e81d119
Refactor L2 configs
ilitteri Apr 25, 2025
0da65cc
Pass `SequencerConfig` to all components that need it & add `Sequence…
ilitteri Apr 25, 2025
cf43fec
Update utils config leftovers
ilitteri Apr 25, 2025
c9ac518
Fix metrics
ilitteri Apr 25, 2025
7fa0991
More fixes
ilitteri Apr 25, 2025
5f71c74
Fix pr-main_l2 workflow
ilitteri Apr 25, 2025
ffbe069
Fix compilation under based feature
ilitteri Apr 25, 2025
fa0c2e8
Fix `main_prover` workflow
ilitteri Apr 25, 2025
b3856e3
Fix l2 workflows
ilitteri Apr 25, 2025
0e3b9e9
CI fix intent
ilitteri Apr 25, 2025
9544774
CI fix intent
ilitteri Apr 25, 2025
dc766c0
Update Makefile
ilitteri Apr 25, 2025
441412c
Merge branch 'main' of github.com:lambdaclass/ethrex into replace_seq…
ilitteri Apr 28, 2025
de164c8
Merge leftover
ilitteri Apr 28, 2025
d5baae4
Fix merge errors
ilitteri Apr 28, 2025
12ad897
CI fix intent
ilitteri Apr 28, 2025
2d2d27d
Delete server_makefile
ilitteri Apr 28, 2025
0bcd421
Delete deploy_blockscout.sh
ilitteri Apr 28, 2025
60e8456
CI fix intent
ilitteri Apr 28, 2025
b3c6c4d
Merge branch 'replace_sequencer_config' of github.com:lambdaclass/eth…
ilitteri Apr 28, 2025
ae775ac
Fix flags long
ilitteri Apr 28, 2025
eba610b
Fix defaults and pass new flag
ilitteri Apr 28, 2025
4310e15
Merge branch 'main' of github.com:lambdaclass/ethrex into replace_seq…
ilitteri Apr 28, 2025
1618702
CI fix intent
ilitteri Apr 28, 2025
c323f8a
CI fix intent
ilitteri Apr 28, 2025
222792b
CI fix intent
ilitteri Apr 28, 2025
249e43f
CI fix intent
ilitteri Apr 28, 2025
ad5c054
Cleanup workflows
ilitteri Apr 28, 2025
9b9fddd
CI fix intent
ilitteri Apr 28, 2025
cc02921
CI fix intent
ilitteri Apr 28, 2025
43261e2
CI fix intent
ilitteri Apr 28, 2025
4183fb0
Merge branch 'main' into replace_sequencer_config
ilitteri Apr 28, 2025
9b881c7
CI fix intent
ilitteri Apr 28, 2025
635aaf8
CI fix intent
ilitteri Apr 28, 2025
befed7d
Update pr-main_l2.yaml
ilitteri Apr 28, 2025
22c71d8
Update pr-main_l2.yaml
ilitteri Apr 28, 2025
8745c7b
Merge branch 'main' into replace_sequencer_config
jrchatruc Apr 28, 2025
03b779f
Clean up
ilitteri Apr 29, 2025
257e5f7
Merge branch 'main' of github.com:lambdaclass/ethrex into replace_seq…
ilitteri Apr 29, 2025
0e04890
Merge branch 'main' of github.com:lambdaclass/ethrex into replace_seq…
ilitteri Apr 30, 2025
41a0664
Fix merge
ilitteri Apr 30, 2025
0da9048
Fix merge
ilitteri Apr 30, 2025
08c39a3
Make bridge and on chain prop addresses required flags
ilitteri Apr 30, 2025
c6a7ec6
Use default values for contract addresses
ilitteri Apr 30, 2025
6bb4634
Fix overrides
ilitteri Apr 30, 2025
49af901
CI fix intent: deploy L1 contracts on state-diff-test job
ilitteri May 5, 2025
67de823
Merge branch 'main' of github.com:lambdaclass/ethrex into replace_seq…
ilitteri May 5, 2025
03b966b
refactor(l2): rewrite deployer and system contracts updater bins (#2643)
ilitteri May 7, 2025
a956a6f
Merge branch 'main' of github.com:lambdaclass/ethrex into replace_seq…
ilitteri May 7, 2025
43fd4a8
Remove comment
ilitteri May 7, 2025
a5196d4
Use copies of the config instead of `Arc`s
ilitteri May 7, 2025
52ad825
Merge branch 'main' into replace_sequencer_config
ilitteri May 8, 2025
22ba592
Merge branch 'main' into replace_sequencer_config
jrchatruc May 8, 2025
8cd7ead
Fix `integration-test-gpu` target
ilitteri May 8, 2025
18a59ba
Fix main_prover workflow
ilitteri May 8, 2025
336d8b0
Fix pr-main_l2 workflow
ilitteri May 8, 2025
34968ab
Merge branch 'main' of github.com:lambdaclass/ethrex into replace_seq…
ilitteri May 8, 2025
510da14
Remove `DeployerOptions` from Sequencer CLI
ilitteri May 8, 2025
cc99fd7
Fix deployer's prover-related args
ilitteri May 8, 2025
7a8c205
Fix deployer's prover-related args
ilitteri May 8, 2025
80374f8
Fix deployer's prover-related args
ilitteri May 9, 2025
40657ad
Deployer docker fix intent
ilitteri May 9, 2025
8da8005
Update Deploy L1 step in workflows
ilitteri May 9, 2025
fe2b678
Fix `make deploy-l1`
ilitteri May 9, 2025
636b789
Merge branch 'main' into replace_sequencer_config
ilitteri May 9, 2025
c8e77a9
Fix `make deploy-l1`
ilitteri May 9, 2025
3d0e11a
Update default addresses
ilitteri May 9, 2025
ecf0fe6
Merge branch 'replace_sequencer_config' of github.com:lambdaclass/eth…
ilitteri May 9, 2025
039c84f
Add logs for L1 Proof Sender
ilitteri May 9, 2025
9ef29f7
Add `ETHREX_PROOF_COORDINATOR_DEV_MODE` to the ethrex_l2 docker conta…
ilitteri May 9, 2025
77dfbfc
Fix `main_prover` workflow
ilitteri May 9, 2025
ae833d6
FIx `main_prover` workflow
ilitteri May 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/main_prover.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ jobs:
cp configs/prover_client_config_example.toml configs/prover_client_config.toml
cp configs/sequencer_config_example.toml configs/sequencer_config.toml

sed -i 's/sp1_deploy_verifier = false/sp1_deploy_verifier = true/' configs/sequencer_config.toml
sed -i 's/block_time_ms = 5000/block_time_ms = 12000/' configs/sequencer_config.toml
sed -i 's/listen_ip = "127.0.0.1"/listen_ip = "0.0.0.0"/' configs/sequencer_config.toml
sed -i 's/dev_mode = true/dev_mode = false/' configs/sequencer_config.toml

ETHREX_PROOF_COORDINATOR_DEV_MODE=false \
ETHREX_PROPOSER_BLOCK_TIME_MS=12000 \
ETHREX_DEPLOYER_PICO_DEPLOY_VERIFIER=true \
make integration-test-gpu

- name: Ensure admin permissions in _work
Expand Down
33 changes: 25 additions & 8 deletions .github/workflows/pr-main_l2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,28 @@ jobs:
run: |
cargo test l2 --no-run --release

- name: Run test
- name: Deploy L1 Contracts
run: |
cd crates/l2
cp configs/prover_client_config_example.toml configs/prover_client_config.toml
cp configs/sequencer_config_example.toml configs/sequencer_config.toml
sed -i 's/listen_ip = "127.0.0.1"/listen_ip = "0.0.0.0"/' configs/sequencer_config.toml
if [ "${{ matrix.validium }}" = "true" ]; then
sed -i.bak 's/^validium = false$/validium = true/' configs/sequencer_config.toml && rm configs/sequencer_config.toml.bak
fi
make integration-test
touch .env
CI_ETHREX_WORKDIR=/usr/local/bin docker compose -f docker-compose-l2.yaml up --detach contract_deployer

- name: Start Sequencer
run: |
sleep 30
cd crates/l2
CI_ETHREX_WORKDIR=/usr/local/bin \
ETHREX_COMMITTER_VALIDIUM=${{ matrix.validium }} \
docker compose -f docker-compose-l2.yaml up --detach ethrex_l2

- name: Run test
run: |
cd crates/l2
RUST_LOG=info,ethrex_prover_lib=debug make init-prover &
PROPOSER_COINBASE_ADDRESS=0x0007a881CD95B1484fca47615B64803dad620C8d cargo test l2 --release -- --nocapture --test-threads=1
killall ethrex_prover

state-diff-test:
name: State Reconstruction Tests
Expand Down Expand Up @@ -173,13 +185,18 @@ jobs:
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update && sudo apt-get -y install solc

- name: Deploy L1 Contracts
run: |
cd crates/l2
cp configs/prover_client_config_example.toml configs/prover_client_config.toml
touch .env
CI_ETHREX_WORKDIR=/usr/local/bin docker compose -f docker-compose-l2.yaml up --detach contract_deployer

- name: Run tests
run: |
cd crates/l2
cp configs/prover_client_config_example.toml configs/prover_client_config.toml
cp configs/sequencer_config_example.toml configs/sequencer_config.toml
sed -i 's/listen_ip = "127.0.0.1"/listen_ip = "0.0.0.0"/' configs/sequencer_config.toml

make state-diff-test

# The purpose of this job is to add it as a required check in GitHub so that we don't have to add every individual job as a required check
Expand Down
13 changes: 1 addition & 12 deletions cmd/ethrex/initializers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ use crate::l2::L2Options;
#[cfg(feature = "l2")]
use ::{
ethrex_common::Address,
ethrex_l2::utils::config::{read_env_file_by_config, ConfigMode},
ethrex_storage_rollup::{EngineTypeRollup, StoreRollup},
secp256k1::SecretKey,
};
Expand Down Expand Up @@ -424,15 +423,5 @@ pub fn get_sponsor_pk(opts: &L2Options) -> SecretKey {
if let Some(pk) = opts.sponsor_private_key {
return pk;
}

warn!("Sponsor private key not provided. Trying to read from the .env file.");

if let Err(e) = read_env_file_by_config(ConfigMode::Sequencer) {
panic!("Failed to read .env file: {e}");
}
let pk = std::env::var("L1_WATCHER_L2_PROPOSER_PRIVATE_KEY").unwrap_or_default();
pk.strip_prefix("0x")
.unwrap_or(&pk)
.parse::<SecretKey>()
.expect("Failed to parse a secret key to sponsor transactions")
opts.sequencer_opts.watcher_opts.l2_proposer_private_key
}
80 changes: 11 additions & 69 deletions cmd/ethrex/l2.rs → cmd/ethrex/l2/command.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use crate::{
cli::{self as ethrex_cli, Options},
cli::{self as ethrex_cli, Options as NodeOptions},
initializers::{
get_local_p2p_node, get_network, get_signer, init_blockchain, init_metrics, init_network,
init_rollup_store, init_rpc_api, init_store,
},
utils::{self, set_datadir, store_known_peers},
l2::options::Options,
utils::{set_datadir, store_known_peers},
DEFAULT_L2_DATADIR,
};
use clap::{Parser, Subcommand};
use clap::Subcommand;
use ethrex_common::{Address, U256};
use ethrex_l2::SequencerConfig;
use ethrex_p2p::network::peer_table;
use ethrex_rpc::{
clients::{beacon::BeaconClient, eth::BlockByNumber},
Expand All @@ -17,7 +19,6 @@ use ethrex_rpc::{
use eyre::OptionExt;
use keccak_hash::keccak;
use reqwest::Url;
use secp256k1::SecretKey;
use std::{fs::create_dir_all, future::IntoFuture, path::PathBuf, time::Duration};
use tokio_util::task::TaskTracker;
use tracing::info;
Expand All @@ -28,7 +29,7 @@ pub enum Command {
#[clap(about = "Initialize an ethrex L2 node", visible_alias = "i")]
Init {
#[command(flatten)]
opts: L2Options,
opts: Options,
},
#[clap(name = "removedb", about = "Remove the database", visible_aliases = ["rm", "clean"])]
RemoveDB {
Expand All @@ -54,68 +55,6 @@ pub enum Command {
},
}

#[derive(Parser, Default)]
pub struct L2Options {
#[command(flatten)]
pub node_opts: Options,
#[arg(
long = "sponsorable-addresses",
value_name = "SPONSORABLE_ADDRESSES_PATH",
help = "Path to a file containing addresses of contracts to which ethrex_SendTransaction should sponsor txs",
help_heading = "L2 options"
)]
pub sponsorable_addresses_file_path: Option<String>,
#[arg(long, value_parser = utils::parse_private_key, env = "SPONSOR_PRIVATE_KEY", help = "The private key of ethrex L2 transactions sponsor.", help_heading = "L2 options")]
pub sponsor_private_key: Option<SecretKey>,
#[cfg(feature = "based")]
#[command(flatten)]
pub based_opts: BasedOptions,
}

#[cfg(feature = "based")]
#[derive(Parser, Default)]
pub struct BasedOptions {
#[arg(
long = "gateway.addr",
default_value = "0.0.0.0",
value_name = "GATEWAY_ADDRESS",
env = "GATEWAY_ADDRESS",
help_heading = "Based options"
)]
pub gateway_addr: String,
#[arg(
long = "gateway.eth_port",
default_value = "8546",
value_name = "GATEWAY_ETH_PORT",
env = "GATEWAY_ETH_PORT",
help_heading = "Based options"
)]
pub gateway_eth_port: String,
#[arg(
long = "gateway.auth_port",
default_value = "8553",
value_name = "GATEWAY_AUTH_PORT",
env = "GATEWAY_AUTH_PORT",
help_heading = "Based options"
)]
pub gateway_auth_port: String,
#[arg(
long = "gateway.jwtsecret",
default_value = "jwt.hex",
value_name = "GATEWAY_JWTSECRET_PATH",
env = "GATEWAY_JWTSECRET_PATH",
help_heading = "Based options"
)]
pub gateway_jwtsecret: String,
#[arg(
long = "gateway.pubkey",
value_name = "GATEWAY_PUBKEY",
env = "GATEWAY_PUBKEY",
help_heading = "Based options"
)]
pub gateway_pubkey: String,
}

impl Command {
pub async fn run(self) -> eyre::Result<()> {
match self {
Expand Down Expand Up @@ -177,8 +116,11 @@ impl Command {
info!("P2P is disabled");
}

let l2_sequencer_cfg = SequencerConfig::from(opts.sequencer_opts);

let l2_sequencer =
ethrex_l2::start_l2(store, rollup_store, blockchain).into_future();
ethrex_l2::start_l2(store, rollup_store, blockchain, l2_sequencer_cfg)
.into_future();

tracker.spawn(l2_sequencer);

Expand All @@ -197,7 +139,7 @@ impl Command {
Self::RemoveDB { datadir, force } => {
Box::pin(async {
ethrex_cli::Subcommand::RemoveDB { datadir, force }
.run(&Options::default()) // This is not used by the RemoveDB command.
.run(&NodeOptions::default()) // This is not used by the RemoveDB command.
.await
})
.await?
Expand Down
10 changes: 10 additions & 0 deletions cmd/ethrex/l2/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pub mod command;
pub mod options;

pub use command::Command;
#[cfg(feature = "based")]
pub use options::BasedOptions;
pub use options::{
CommitterOptions, DeployerOptions, EthOptions, Options as L2Options, ProofCoordinatorOptions,
ProposerOptions, SequencerOptions, WatcherOptions,
};
Loading
Loading