From b3e5e496d6bba161795ff140f8dfdf2f09fef549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Tue, 14 Oct 2025 17:09:58 -0300 Subject: [PATCH 1/9] first approach --- cmd/ethrex/l2/command.rs | 140 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 136 insertions(+), 4 deletions(-) diff --git a/cmd/ethrex/l2/command.rs b/cmd/ethrex/l2/command.rs index bc9a61d31b3..3e5ab7ac23e 100644 --- a/cmd/ethrex/l2/command.rs +++ b/cmd/ethrex/l2/command.rs @@ -46,6 +46,140 @@ const PAUSE_CONTRACT_SELECTOR: &str = "pause()"; const UNPAUSE_CONTRACT_SELECTOR: &str = "unpause()"; const REVERT_BATCH_SELECTOR: &str = "revertBatch(uint256)"; +fn set_if_none(target: &mut Option, default: &Option) { + if let (None, Some(value)) = (target.as_ref(), default) { + *target = Some(value.clone()); + } +} + +fn populate_missing_l2_defaults(options: &mut Options) { + let defaults = Options::default(); + set_if_none( + &mut options.sponsorable_addresses_file_path, + &defaults.sponsorable_addresses_file_path, + ); + + let sequencer_defaults = &defaults.sequencer_opts; + let sequencer_options = &mut options.sequencer_opts; + + // Eth options + if sequencer_options.eth_opts.rpc_url.is_empty() { + sequencer_options.eth_opts.rpc_url = sequencer_defaults.eth_opts.rpc_url.clone(); + } + + // Watcher options + set_if_none( + &mut sequencer_options.watcher_opts.bridge_address, + &sequencer_defaults.watcher_opts.bridge_address, + ); + + // Block producer + set_if_none( + &mut sequencer_options.block_producer_opts.coinbase_address, + &sequencer_defaults.block_producer_opts.coinbase_address, + ); + + // Committer options - Here is a problem if we want to differ from remote and local signing - always set local + set_if_none( + &mut sequencer_options.committer_opts.committer_l1_private_key, + &sequencer_defaults.committer_opts.committer_l1_private_key, + ); + set_if_none( + &mut sequencer_options.committer_opts.committer_remote_signer_url, + &sequencer_defaults + .committer_opts + .committer_remote_signer_url, + ); + set_if_none( + &mut sequencer_options + .committer_opts + .committer_remote_signer_public_key, + &sequencer_defaults + .committer_opts + .committer_remote_signer_public_key, + ); + set_if_none( + &mut sequencer_options.committer_opts.on_chain_proposer_address, + &sequencer_defaults.committer_opts.on_chain_proposer_address, + ); + set_if_none( + &mut sequencer_options.committer_opts.batch_gas_limit, + &sequencer_defaults.committer_opts.batch_gas_limit, + ); + set_if_none( + &mut sequencer_options.committer_opts.first_wake_up_time_ms, + &sequencer_defaults.committer_opts.first_wake_up_time_ms, + ); + + // Proof coordinator options + set_if_none( + &mut sequencer_options + .proof_coordinator_opts + .proof_coordinator_l1_private_key, + &sequencer_defaults + .proof_coordinator_opts + .proof_coordinator_l1_private_key, + ); + set_if_none( + &mut sequencer_options + .proof_coordinator_opts + .proof_coordinator_tdx_private_key, + &sequencer_defaults + .proof_coordinator_opts + .proof_coordinator_tdx_private_key, + ); + if let (None, Some(default_path)) = ( + &sequencer_options + .proof_coordinator_opts + .proof_coordinator_qpl_tool_path, + &sequencer_defaults + .proof_coordinator_opts + .proof_coordinator_qpl_tool_path, + ) { + sequencer_options + .proof_coordinator_opts + .proof_coordinator_qpl_tool_path = Some(default_path.clone()); + } + set_if_none( + &mut sequencer_options.proof_coordinator_opts.remote_signer_url, + &sequencer_defaults.proof_coordinator_opts.remote_signer_url, + ); + set_if_none( + &mut sequencer_options + .proof_coordinator_opts + .remote_signer_public_key, + &sequencer_defaults + .proof_coordinator_opts + .remote_signer_public_key, + ); + + // Based options + set_if_none( + &mut sequencer_options + .based_opts + .state_updater_opts + .sequencer_registry, + &sequencer_defaults + .based_opts + .state_updater_opts + .sequencer_registry, + ); + + // Aligned options + set_if_none( + &mut sequencer_options.aligned_opts.beacon_url, + &sequencer_defaults.aligned_opts.beacon_url, + ); + set_if_none( + &mut sequencer_options.aligned_opts.aligned_network, + &sequencer_defaults.aligned_opts.aligned_network, + ); + set_if_none( + &mut sequencer_options.aligned_opts.aligned_sp1_elf_path, + &sequencer_defaults.aligned_opts.aligned_sp1_elf_path, + ); +} + #[derive(Parser)] #[clap(args_conflicts_with_subcommands = true)] pub struct L2Command { @@ -87,10 +221,8 @@ impl L2Command { let contract_addresses = l2::deployer::deploy_l1_contracts(l2::deployer::DeployerOptions::default()).await?; - l2_options = l2::options::Options { - node_opts: crate::cli::Options::default_l2(), - ..Default::default() - }; + l2_options.node_opts = crate::cli::Options::default_l2(); + populate_missing_l2_defaults(&mut l2_options); l2_options .sequencer_opts .committer_opts From b464bb873612a9b4dda5600562adec1ed1cfcbb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 15 Oct 2025 09:36:47 -0300 Subject: [PATCH 2/9] more clean setup --- cmd/ethrex/l2/command.rs | 137 +--------------------------------- cmd/ethrex/l2/options.rs | 154 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 154 insertions(+), 137 deletions(-) diff --git a/cmd/ethrex/l2/command.rs b/cmd/ethrex/l2/command.rs index 3e5ab7ac23e..a8a3859a581 100644 --- a/cmd/ethrex/l2/command.rs +++ b/cmd/ethrex/l2/command.rs @@ -45,141 +45,6 @@ pub const DB_ETHREX_DEV_L2: &str = "dev_ethrex_l2"; const PAUSE_CONTRACT_SELECTOR: &str = "pause()"; const UNPAUSE_CONTRACT_SELECTOR: &str = "unpause()"; const REVERT_BATCH_SELECTOR: &str = "revertBatch(uint256)"; - -fn set_if_none(target: &mut Option, default: &Option) { - if let (None, Some(value)) = (target.as_ref(), default) { - *target = Some(value.clone()); - } -} - -fn populate_missing_l2_defaults(options: &mut Options) { - let defaults = Options::default(); - set_if_none( - &mut options.sponsorable_addresses_file_path, - &defaults.sponsorable_addresses_file_path, - ); - - let sequencer_defaults = &defaults.sequencer_opts; - let sequencer_options = &mut options.sequencer_opts; - - // Eth options - if sequencer_options.eth_opts.rpc_url.is_empty() { - sequencer_options.eth_opts.rpc_url = sequencer_defaults.eth_opts.rpc_url.clone(); - } - - // Watcher options - set_if_none( - &mut sequencer_options.watcher_opts.bridge_address, - &sequencer_defaults.watcher_opts.bridge_address, - ); - - // Block producer - set_if_none( - &mut sequencer_options.block_producer_opts.coinbase_address, - &sequencer_defaults.block_producer_opts.coinbase_address, - ); - - // Committer options - Here is a problem if we want to differ from remote and local signing - always set local - set_if_none( - &mut sequencer_options.committer_opts.committer_l1_private_key, - &sequencer_defaults.committer_opts.committer_l1_private_key, - ); - set_if_none( - &mut sequencer_options.committer_opts.committer_remote_signer_url, - &sequencer_defaults - .committer_opts - .committer_remote_signer_url, - ); - set_if_none( - &mut sequencer_options - .committer_opts - .committer_remote_signer_public_key, - &sequencer_defaults - .committer_opts - .committer_remote_signer_public_key, - ); - set_if_none( - &mut sequencer_options.committer_opts.on_chain_proposer_address, - &sequencer_defaults.committer_opts.on_chain_proposer_address, - ); - set_if_none( - &mut sequencer_options.committer_opts.batch_gas_limit, - &sequencer_defaults.committer_opts.batch_gas_limit, - ); - set_if_none( - &mut sequencer_options.committer_opts.first_wake_up_time_ms, - &sequencer_defaults.committer_opts.first_wake_up_time_ms, - ); - - // Proof coordinator options - set_if_none( - &mut sequencer_options - .proof_coordinator_opts - .proof_coordinator_l1_private_key, - &sequencer_defaults - .proof_coordinator_opts - .proof_coordinator_l1_private_key, - ); - set_if_none( - &mut sequencer_options - .proof_coordinator_opts - .proof_coordinator_tdx_private_key, - &sequencer_defaults - .proof_coordinator_opts - .proof_coordinator_tdx_private_key, - ); - if let (None, Some(default_path)) = ( - &sequencer_options - .proof_coordinator_opts - .proof_coordinator_qpl_tool_path, - &sequencer_defaults - .proof_coordinator_opts - .proof_coordinator_qpl_tool_path, - ) { - sequencer_options - .proof_coordinator_opts - .proof_coordinator_qpl_tool_path = Some(default_path.clone()); - } - set_if_none( - &mut sequencer_options.proof_coordinator_opts.remote_signer_url, - &sequencer_defaults.proof_coordinator_opts.remote_signer_url, - ); - set_if_none( - &mut sequencer_options - .proof_coordinator_opts - .remote_signer_public_key, - &sequencer_defaults - .proof_coordinator_opts - .remote_signer_public_key, - ); - - // Based options - set_if_none( - &mut sequencer_options - .based_opts - .state_updater_opts - .sequencer_registry, - &sequencer_defaults - .based_opts - .state_updater_opts - .sequencer_registry, - ); - - // Aligned options - set_if_none( - &mut sequencer_options.aligned_opts.beacon_url, - &sequencer_defaults.aligned_opts.beacon_url, - ); - set_if_none( - &mut sequencer_options.aligned_opts.aligned_network, - &sequencer_defaults.aligned_opts.aligned_network, - ); - set_if_none( - &mut sequencer_options.aligned_opts.aligned_sp1_elf_path, - &sequencer_defaults.aligned_opts.aligned_sp1_elf_path, - ); -} - #[derive(Parser)] #[clap(args_conflicts_with_subcommands = true)] pub struct L2Command { @@ -222,7 +87,7 @@ impl L2Command { l2::deployer::deploy_l1_contracts(l2::deployer::DeployerOptions::default()).await?; l2_options.node_opts = crate::cli::Options::default_l2(); - populate_missing_l2_defaults(&mut l2_options); + l2_options.populate_with_defaults(); l2_options .sequencer_opts .committer_opts diff --git a/cmd/ethrex/l2/options.rs b/cmd/ethrex/l2/options.rs index 518fb42268c..4bd2ecf416b 100644 --- a/cmd/ethrex/l2/options.rs +++ b/cmd/ethrex/l2/options.rs @@ -25,6 +25,14 @@ use std::{ }; use tracing::Level; +pub const DEFAULT_PROOF_COORDINATOR_QPL_TOOL_PATH: &str = "./tee/contracts/automata-dcap-qpl/automata-dcap-qpl-tool/target/release/automata-dcap-qpl-tool"; + +fn fill_option(target: &mut Option, default: &Option) { + if let (None, Some(value)) = (target.as_ref(), default) { + *target = Some(value.clone()); + } +} + #[derive(Parser, Debug)] #[group(id = "L2Options")] pub struct Options { @@ -244,6 +252,38 @@ impl TryFrom for SequencerConfig { } } +impl Options { + pub fn populate_with_defaults(&mut self) { + let defaults = Options::default(); + fill_option( + &mut self.sponsorable_addresses_file_path, + &defaults.sponsorable_addresses_file_path, + ); + self.sequencer_opts + .populate_with_defaults(&defaults.sequencer_opts); + } +} + +impl SequencerOptions { + pub fn populate_with_defaults(&mut self, defaults: &SequencerOptions) { + self.eth_opts.populate_with_defaults(&defaults.eth_opts); + self.watcher_opts + .populate_with_defaults(&defaults.watcher_opts); + self.block_producer_opts + .populate_with_defaults(&defaults.block_producer_opts); + self.committer_opts + .populate_with_defaults(&defaults.committer_opts); + self.proof_coordinator_opts + .populate_with_defaults(&defaults.proof_coordinator_opts); + self.based_opts.populate_with_defaults(&defaults.based_opts); + self.aligned_opts + .populate_with_defaults(&defaults.aligned_opts); + self.monitor_opts + .populate_with_defaults(&defaults.monitor_opts); + // admin_opts contains only non-optional fields. + } +} + #[derive(Parser, Debug)] pub struct EthOptions { #[arg( @@ -319,6 +359,14 @@ impl Default for EthOptions { } } +impl EthOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + if self.rpc_url.is_empty() { + self.rpc_url = defaults.rpc_url.clone(); + } + } +} + #[derive(Parser, Debug)] pub struct WatcherOptions { #[arg( @@ -368,6 +416,12 @@ impl Default for WatcherOptions { } } +impl WatcherOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + fill_option(&mut self.bridge_address, &defaults.bridge_address); + } +} + #[derive(Parser, Debug)] pub struct BlockProducerOptions { #[arg( @@ -421,6 +475,12 @@ impl Default for BlockProducerOptions { } } +impl BlockProducerOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + fill_option(&mut self.coinbase_address, &defaults.coinbase_address); + } +} + #[derive(Parser, Debug)] pub struct CommitterOptions { #[arg( @@ -517,6 +577,34 @@ impl Default for CommitterOptions { } } +impl CommitterOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + if self.committer_remote_signer_url.is_none() { + fill_option( + &mut self.committer_l1_private_key, + &defaults.committer_l1_private_key, + ); + } + fill_option( + &mut self.committer_remote_signer_url, + &defaults.committer_remote_signer_url, + ); + fill_option( + &mut self.committer_remote_signer_public_key, + &defaults.committer_remote_signer_public_key, + ); + fill_option( + &mut self.on_chain_proposer_address, + &defaults.on_chain_proposer_address, + ); + fill_option(&mut self.batch_gas_limit, &defaults.batch_gas_limit); + fill_option( + &mut self.first_wake_up_time_ms, + &defaults.first_wake_up_time_ms, + ); + } +} + #[derive(Parser, Debug)] pub struct ProofCoordinatorOptions { #[arg( @@ -613,10 +701,36 @@ impl Default for ProofCoordinatorOptions { listen_port: 3900, proof_send_interval_ms: 5000, proof_coordinator_tdx_private_key: None, - proof_coordinator_qpl_tool_path: None, + proof_coordinator_qpl_tool_path: Some( + DEFAULT_PROOF_COORDINATOR_QPL_TOOL_PATH.to_string(), + ), } } } + +impl ProofCoordinatorOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + if self.remote_signer_url.is_none() { + fill_option( + &mut self.proof_coordinator_l1_private_key, + &defaults.proof_coordinator_l1_private_key, + ); + } + fill_option( + &mut self.proof_coordinator_tdx_private_key, + &defaults.proof_coordinator_tdx_private_key, + ); + fill_option( + &mut self.proof_coordinator_qpl_tool_path, + &defaults.proof_coordinator_qpl_tool_path, + ); + fill_option(&mut self.remote_signer_url, &defaults.remote_signer_url); + fill_option( + &mut self.remote_signer_public_key, + &defaults.remote_signer_public_key, + ); + } +} #[derive(Parser, Debug, Clone)] pub struct AlignedOptions { #[arg( @@ -690,6 +804,17 @@ impl Default for AlignedOptions { } } +impl AlignedOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + fill_option(&mut self.beacon_url, &defaults.beacon_url); + fill_option(&mut self.aligned_network, &defaults.aligned_network); + fill_option( + &mut self.aligned_sp1_elf_path, + &defaults.aligned_sp1_elf_path, + ); + } +} + #[derive(Parser, Default, Debug)] pub struct BasedOptions { #[clap(flatten)] @@ -698,6 +823,15 @@ pub struct BasedOptions { pub block_fetcher: BlockFetcherOptions, } +impl BasedOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + self.state_updater_opts + .populate_with_defaults(&defaults.state_updater_opts); + self.block_fetcher + .populate_with_defaults(&defaults.block_fetcher); + } +} + #[derive(Parser, Debug)] pub struct StateUpdaterOptions { #[arg( @@ -727,6 +861,12 @@ impl Default for StateUpdaterOptions { } } +impl StateUpdaterOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + fill_option(&mut self.sequencer_registry, &defaults.sequencer_registry); + } +} + #[derive(Parser, Debug)] pub struct BlockFetcherOptions { #[arg( @@ -756,6 +896,12 @@ impl Default for BlockFetcherOptions { } } +impl BlockFetcherOptions { + fn populate_with_defaults(&mut self, _defaults: &Self) { + // No optional fields to hydrate. + } +} + #[derive(Parser, Debug)] pub struct MonitorOptions { /// time in ms between two ticks. @@ -774,6 +920,12 @@ impl Default for MonitorOptions { } } +impl MonitorOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + fill_option(&mut self.batch_widget_height, &defaults.batch_widget_height); + } +} + #[derive(Parser, Debug)] pub struct AdminOptions { #[arg( From 1278021239e293dc2c085bfd859972ac47c04945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 15 Oct 2025 10:16:40 -0300 Subject: [PATCH 3/9] l2 change --- crates/l2/sequencer/errors.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/l2/sequencer/errors.rs b/crates/l2/sequencer/errors.rs index 67afeafd84d..d55b99d15a5 100644 --- a/crates/l2/sequencer/errors.rs +++ b/crates/l2/sequencer/errors.rs @@ -339,6 +339,7 @@ pub enum MonitorError { GetLastFetchedL1, #[error("Failed to get pending privileged transactions")] GetPendingPrivilegedTx, + #[error("Failed to get transaction pool")] TxPoolError, #[error("Failed to encode calldata: {0}")] From 314ed1dbcd8c8afa2febbf1e3479674a36fb7d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 15 Oct 2025 10:17:12 -0300 Subject: [PATCH 4/9] Revert "l2 change" This reverts commit 1278021239e293dc2c085bfd859972ac47c04945. --- crates/l2/sequencer/errors.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/l2/sequencer/errors.rs b/crates/l2/sequencer/errors.rs index d55b99d15a5..67afeafd84d 100644 --- a/crates/l2/sequencer/errors.rs +++ b/crates/l2/sequencer/errors.rs @@ -339,7 +339,6 @@ pub enum MonitorError { GetLastFetchedL1, #[error("Failed to get pending privileged transactions")] GetPendingPrivilegedTx, - #[error("Failed to get transaction pool")] TxPoolError, #[error("Failed to encode calldata: {0}")] From 1036677728217d6ac7ffc586c6bcfe4ed89b4141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 15 Oct 2025 10:46:00 -0300 Subject: [PATCH 5/9] document fill_options --- cmd/ethrex/l2/options.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/ethrex/l2/options.rs b/cmd/ethrex/l2/options.rs index 4bd2ecf416b..b575d63d62b 100644 --- a/cmd/ethrex/l2/options.rs +++ b/cmd/ethrex/l2/options.rs @@ -27,6 +27,9 @@ use tracing::Level; pub const DEFAULT_PROOF_COORDINATOR_QPL_TOOL_PATH: &str = "./tee/contracts/automata-dcap-qpl/automata-dcap-qpl-tool/target/release/automata-dcap-qpl-tool"; +/// Sets the value of an Option to a default if it is currently None. +/// If the target already contains a value, it is left unchanged. +/// Useful for populating option fields with defaults when not specified by the user. fn fill_option(target: &mut Option, default: &Option) { if let (None, Some(value)) = (target.as_ref(), default) { *target = Some(value.clone()); From 12df495eb2fb7ac102e2722a34ef30b05298c38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 15 Oct 2025 10:57:11 -0300 Subject: [PATCH 6/9] feat: enable l2 flow when modifying l2 init --- .github/workflows/pr-main_l2.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-main_l2.yaml b/.github/workflows/pr-main_l2.yaml index 07e961aba3e..dc74db9e55e 100644 --- a/.github/workflows/pr-main_l2.yaml +++ b/.github/workflows/pr-main_l2.yaml @@ -10,6 +10,7 @@ on: - "crates/blockchain/dev/**" - "crates/vm/levm/**" - ".github/workflows/pr-main_l2.yaml" + - "cmd/ethrex/l2/**" concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} From 7c1b09cd53b035028353afdbf693806f3df5b25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 15 Oct 2025 12:01:57 -0300 Subject: [PATCH 7/9] use Option::or instead of fill_option --- cmd/ethrex/l2/options.rs | 112 ++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 61 deletions(-) diff --git a/cmd/ethrex/l2/options.rs b/cmd/ethrex/l2/options.rs index b575d63d62b..011d949ddc6 100644 --- a/cmd/ethrex/l2/options.rs +++ b/cmd/ethrex/l2/options.rs @@ -27,15 +27,6 @@ use tracing::Level; pub const DEFAULT_PROOF_COORDINATOR_QPL_TOOL_PATH: &str = "./tee/contracts/automata-dcap-qpl/automata-dcap-qpl-tool/target/release/automata-dcap-qpl-tool"; -/// Sets the value of an Option to a default if it is currently None. -/// If the target already contains a value, it is left unchanged. -/// Useful for populating option fields with defaults when not specified by the user. -fn fill_option(target: &mut Option, default: &Option) { - if let (None, Some(value)) = (target.as_ref(), default) { - *target = Some(value.clone()); - } -} - #[derive(Parser, Debug)] #[group(id = "L2Options")] pub struct Options { @@ -258,10 +249,10 @@ impl TryFrom for SequencerConfig { impl Options { pub fn populate_with_defaults(&mut self) { let defaults = Options::default(); - fill_option( - &mut self.sponsorable_addresses_file_path, - &defaults.sponsorable_addresses_file_path, - ); + self.sponsorable_addresses_file_path = self + .sponsorable_addresses_file_path + .clone() + .or(defaults.sponsorable_addresses_file_path.clone()); self.sequencer_opts .populate_with_defaults(&defaults.sequencer_opts); } @@ -421,7 +412,7 @@ impl Default for WatcherOptions { impl WatcherOptions { fn populate_with_defaults(&mut self, defaults: &Self) { - fill_option(&mut self.bridge_address, &defaults.bridge_address); + self.bridge_address = self.bridge_address.or(defaults.bridge_address); } } @@ -480,7 +471,7 @@ impl Default for BlockProducerOptions { impl BlockProducerOptions { fn populate_with_defaults(&mut self, defaults: &Self) { - fill_option(&mut self.coinbase_address, &defaults.coinbase_address); + self.coinbase_address = self.coinbase_address.or(defaults.coinbase_address); } } @@ -583,28 +574,24 @@ impl Default for CommitterOptions { impl CommitterOptions { fn populate_with_defaults(&mut self, defaults: &Self) { if self.committer_remote_signer_url.is_none() { - fill_option( - &mut self.committer_l1_private_key, - &defaults.committer_l1_private_key, - ); + self.committer_l1_private_key = self + .committer_l1_private_key + .or(defaults.committer_l1_private_key); } - fill_option( - &mut self.committer_remote_signer_url, - &defaults.committer_remote_signer_url, - ); - fill_option( - &mut self.committer_remote_signer_public_key, - &defaults.committer_remote_signer_public_key, - ); - fill_option( - &mut self.on_chain_proposer_address, - &defaults.on_chain_proposer_address, - ); - fill_option(&mut self.batch_gas_limit, &defaults.batch_gas_limit); - fill_option( - &mut self.first_wake_up_time_ms, - &defaults.first_wake_up_time_ms, - ); + self.committer_remote_signer_url = self + .committer_remote_signer_url + .clone() + .or(defaults.committer_remote_signer_url.clone()); + self.committer_remote_signer_public_key = self + .committer_remote_signer_public_key + .or(defaults.committer_remote_signer_public_key); + self.on_chain_proposer_address = self + .on_chain_proposer_address + .or(defaults.on_chain_proposer_address); + self.batch_gas_limit = self.batch_gas_limit.or(defaults.batch_gas_limit); + self.first_wake_up_time_ms = self + .first_wake_up_time_ms + .or(defaults.first_wake_up_time_ms); } } @@ -714,24 +701,24 @@ impl Default for ProofCoordinatorOptions { impl ProofCoordinatorOptions { fn populate_with_defaults(&mut self, defaults: &Self) { if self.remote_signer_url.is_none() { - fill_option( - &mut self.proof_coordinator_l1_private_key, - &defaults.proof_coordinator_l1_private_key, - ); + self.proof_coordinator_l1_private_key = self + .proof_coordinator_l1_private_key + .or(defaults.proof_coordinator_l1_private_key); } - fill_option( - &mut self.proof_coordinator_tdx_private_key, - &defaults.proof_coordinator_tdx_private_key, - ); - fill_option( - &mut self.proof_coordinator_qpl_tool_path, - &defaults.proof_coordinator_qpl_tool_path, - ); - fill_option(&mut self.remote_signer_url, &defaults.remote_signer_url); - fill_option( - &mut self.remote_signer_public_key, - &defaults.remote_signer_public_key, - ); + self.proof_coordinator_tdx_private_key = self + .proof_coordinator_tdx_private_key + .or(defaults.proof_coordinator_tdx_private_key); + self.proof_coordinator_qpl_tool_path = self + .proof_coordinator_qpl_tool_path + .clone() + .or(defaults.proof_coordinator_qpl_tool_path.clone()); + self.remote_signer_url = self + .remote_signer_url + .clone() + .or(defaults.remote_signer_url.clone()); + self.remote_signer_public_key = self + .remote_signer_public_key + .or(defaults.remote_signer_public_key); } } #[derive(Parser, Debug, Clone)] @@ -809,12 +796,15 @@ impl Default for AlignedOptions { impl AlignedOptions { fn populate_with_defaults(&mut self, defaults: &Self) { - fill_option(&mut self.beacon_url, &defaults.beacon_url); - fill_option(&mut self.aligned_network, &defaults.aligned_network); - fill_option( - &mut self.aligned_sp1_elf_path, - &defaults.aligned_sp1_elf_path, - ); + self.beacon_url = self.beacon_url.clone().or(defaults.beacon_url.clone()); + self.aligned_network = self + .aligned_network + .clone() + .or(defaults.aligned_network.clone()); + self.aligned_sp1_elf_path = self + .aligned_sp1_elf_path + .clone() + .or(defaults.aligned_sp1_elf_path.clone()); } } @@ -866,7 +856,7 @@ impl Default for StateUpdaterOptions { impl StateUpdaterOptions { fn populate_with_defaults(&mut self, defaults: &Self) { - fill_option(&mut self.sequencer_registry, &defaults.sequencer_registry); + self.sequencer_registry = self.sequencer_registry.or(defaults.sequencer_registry); } } @@ -925,7 +915,7 @@ impl Default for MonitorOptions { impl MonitorOptions { fn populate_with_defaults(&mut self, defaults: &Self) { - fill_option(&mut self.batch_widget_height, &defaults.batch_widget_height); + self.batch_widget_height = self.batch_widget_height.or(defaults.batch_widget_height); } } From fa203a90ddcbb938670345628d183d234fbdbcb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 15 Oct 2025 12:05:38 -0300 Subject: [PATCH 8/9] remove unnecessary function --- cmd/ethrex/l2/options.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cmd/ethrex/l2/options.rs b/cmd/ethrex/l2/options.rs index 011d949ddc6..fb3cc9c00f4 100644 --- a/cmd/ethrex/l2/options.rs +++ b/cmd/ethrex/l2/options.rs @@ -820,8 +820,7 @@ impl BasedOptions { fn populate_with_defaults(&mut self, defaults: &Self) { self.state_updater_opts .populate_with_defaults(&defaults.state_updater_opts); - self.block_fetcher - .populate_with_defaults(&defaults.block_fetcher); + // block fetcher contains only non-optional fields. } } @@ -889,12 +888,6 @@ impl Default for BlockFetcherOptions { } } -impl BlockFetcherOptions { - fn populate_with_defaults(&mut self, _defaults: &Self) { - // No optional fields to hydrate. - } -} - #[derive(Parser, Debug)] pub struct MonitorOptions { /// time in ms between two ticks. From 91a4f19d000fade8847779410097759eddb86751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 15 Oct 2025 12:55:50 -0300 Subject: [PATCH 9/9] fix docs cli --- docs/CLI.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CLI.md b/docs/CLI.md index 4c091d4f4d5..80157c536b5 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -121,7 +121,7 @@ Block producer options: --block-producer.extra-data Block extra data message. - [default: "ethrex 0.1.0"] + [default: "ethrex 3.0.0"] ```