diff --git a/.github/workflows/pr-main_l2.yaml b/.github/workflows/pr-main_l2.yaml index 589220e5855..f10e23d5ba4 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 }} diff --git a/cmd/ethrex/l2/command.rs b/cmd/ethrex/l2/command.rs index bc9a61d31b3..a8a3859a581 100644 --- a/cmd/ethrex/l2/command.rs +++ b/cmd/ethrex/l2/command.rs @@ -45,7 +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)"; - #[derive(Parser)] #[clap(args_conflicts_with_subcommands = true)] pub struct L2Command { @@ -87,10 +86,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(); + 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 6dd9ffcfa57..0843d03313d 100644 --- a/cmd/ethrex/l2/options.rs +++ b/cmd/ethrex/l2/options.rs @@ -25,6 +25,8 @@ 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"; + #[derive(Parser, Debug)] #[group(id = "L2Options")] pub struct Options { @@ -245,6 +247,38 @@ impl TryFrom for SequencerConfig { } } +impl Options { + pub fn populate_with_defaults(&mut self) { + let defaults = Options::default(); + 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); + } +} + +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( @@ -320,6 +354,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( @@ -369,6 +411,12 @@ impl Default for WatcherOptions { } } +impl WatcherOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + self.bridge_address = self.bridge_address.or(defaults.bridge_address); + } +} + #[derive(Parser, Debug)] pub struct BlockProducerOptions { #[arg( @@ -430,6 +478,12 @@ impl Default for BlockProducerOptions { } } +impl BlockProducerOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + self.coinbase_address = self.coinbase_address.or(defaults.coinbase_address); + } +} + #[derive(Parser, Debug)] pub struct CommitterOptions { #[arg( @@ -526,6 +580,30 @@ impl Default for CommitterOptions { } } +impl CommitterOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + if self.committer_remote_signer_url.is_none() { + self.committer_l1_private_key = self + .committer_l1_private_key + .or(defaults.committer_l1_private_key); + } + 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); + } +} + #[derive(Parser, Debug)] pub struct ProofCoordinatorOptions { #[arg( @@ -622,8 +700,34 @@ 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() { + self.proof_coordinator_l1_private_key = self + .proof_coordinator_l1_private_key + .or(defaults.proof_coordinator_l1_private_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)] @@ -699,6 +803,20 @@ impl Default for AlignedOptions { } } +impl AlignedOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + 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()); + } +} + #[derive(Parser, Default, Debug)] pub struct BasedOptions { #[clap(flatten)] @@ -707,6 +825,14 @@ 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); + // block fetcher contains only non-optional fields. + } +} + #[derive(Parser, Debug)] pub struct StateUpdaterOptions { #[arg( @@ -736,6 +862,12 @@ impl Default for StateUpdaterOptions { } } +impl StateUpdaterOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + self.sequencer_registry = self.sequencer_registry.or(defaults.sequencer_registry); + } +} + #[derive(Parser, Debug)] pub struct BlockFetcherOptions { #[arg( @@ -783,6 +915,12 @@ impl Default for MonitorOptions { } } +impl MonitorOptions { + fn populate_with_defaults(&mut self, defaults: &Self) { + self.batch_widget_height = self.batch_widget_height.or(defaults.batch_widget_height); + } +} + #[derive(Parser, Debug)] pub struct AdminOptions { #[arg( diff --git a/docs/CLI.md b/docs/CLI.md index f3735d60790..0c568222042 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"] ```