From 6e24951950a0cbb281fb264922894a5203738489 Mon Sep 17 00:00:00 2001 From: refcell Date: Fri, 5 Dec 2025 14:22:28 -0500 Subject: [PATCH 1/2] feat(bin/node): support proofs exex cli flags --- bin/node/src/cli.rs | 57 ++++++++++++++++++++++++++++--------- crates/runner/src/config.rs | 12 ++++++++ crates/runner/src/lib.rs | 2 +- 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/bin/node/src/cli.rs b/bin/node/src/cli.rs index 8feed7aa..b38b93d9 100644 --- a/bin/node/src/cli.rs +++ b/bin/node/src/cli.rs @@ -1,8 +1,8 @@ //! Contains the CLI arguments -use std::sync::Arc; +use std::{path::PathBuf, sync::Arc}; -use base_reth_runner::{BaseNodeConfig, FlashblocksCell, FlashblocksConfig, TracingConfig}; +use base_reth_runner::{BaseNodeConfig, FlashblocksConfig, ProofsConfig, TracingConfig}; use once_cell::sync::OnceCell; use reth_optimism_node::args::RollupArgs; @@ -40,6 +40,19 @@ pub struct Args { /// Enable metering RPC for transaction bundle simulation #[arg(long = "enable-metering", value_name = "ENABLE_METERING")] pub enable_metering: bool, + + /// If true, initialize external-proofs exex to save and serve trie nodes to provide proofs + /// faster. + #[arg(long = "proofs-history", value_name = "PROOFS_HISTORY", default_value = "false")] + pub proofs_history: bool, + + /// The path to the storage DB for proofs history. + #[arg( + long = "proofs-history.storage-path", + value_name = "PROOFS_HISTORY_STORAGE_PATH", + required_if_eq("proofs_history", "true") + )] + pub proofs_history_storage_path: Option, } impl Args { @@ -48,25 +61,41 @@ impl Args { pub const fn flashblocks_enabled(&self) -> bool { self.websocket_url.is_some() } + + /// Returns the [`FlashblocksConfig`] if flashblocks is enabled. + pub fn flashblocks_config(&self) -> Option { + self.websocket_url.as_ref().map(|websocket_url| FlashblocksConfig { + websocket_url: websocket_url.clone(), + max_pending_blocks_depth: self.max_pending_blocks_depth, + }) + } + + /// Returns the [`ProofsConfig`]. + pub fn proofs_config(&self) -> ProofsConfig { + ProofsConfig { + enabled: self.proofs_history, + storage_path: self.proofs_history_storage_path.clone(), + } + } + + /// Returns the [`TracingConfig`]. + pub const fn tracing_config(&self) -> TracingConfig { + TracingConfig { + enabled: self.enable_transaction_tracing, + logs_enabled: self.enable_transaction_tracing_logs, + } + } } impl From for BaseNodeConfig { fn from(args: Args) -> Self { - let flashblocks_cell: FlashblocksCell = Arc::new(OnceCell::new()); - let flashblocks = args.websocket_url.map(|websocket_url| FlashblocksConfig { - websocket_url, - max_pending_blocks_depth: args.max_pending_blocks_depth, - }); - Self { + flashblocks: args.flashblocks_config(), + proofs: args.proofs_config(), + tracing: args.tracing_config(), rollup_args: args.rollup_args, - flashblocks, - tracing: TracingConfig { - enabled: args.enable_transaction_tracing, - logs_enabled: args.enable_transaction_tracing_logs, - }, metering_enabled: args.enable_metering, - flashblocks_cell, + flashblocks_cell: Arc::new(OnceCell::new()), } } } diff --git a/crates/runner/src/config.rs b/crates/runner/src/config.rs index 58c60a56..4c78acfd 100644 --- a/crates/runner/src/config.rs +++ b/crates/runner/src/config.rs @@ -13,6 +13,8 @@ pub struct BaseNodeConfig { pub flashblocks: Option, /// Execution extension tracing toggles. pub tracing: TracingConfig, + /// Proofs extension configuration. + pub proofs: ProofsConfig, /// Indicates whether the metering RPC surface should be installed. pub metering_enabled: bool, /// Shared Flashblocks state cache. @@ -35,6 +37,16 @@ pub struct FlashblocksConfig { pub max_pending_blocks_depth: u64, } +/// Proofs Extension Configuration. +#[derive(Debug, Clone)] +pub struct ProofsConfig { + /// If true, initializes external-proofs ExEx to save and serve trie nodes to provide proofs + /// faster. + pub enabled: bool, + /// The path to the storage DB for proofs history. + pub storage_path: Option, +} + /// Transaction tracing toggles. #[derive(Debug, Clone, Copy)] pub struct TracingConfig { diff --git a/crates/runner/src/lib.rs b/crates/runner/src/lib.rs index c96fadf1..6ce6b5c9 100644 --- a/crates/runner/src/lib.rs +++ b/crates/runner/src/lib.rs @@ -13,7 +13,7 @@ mod runner; pub use runner::BaseNodeRunner; mod config; -pub use config::{BaseNodeConfig, FlashblocksConfig, TracingConfig}; +pub use config::{BaseNodeConfig, FlashblocksConfig, ProofsConfig, TracingConfig}; mod extensions; pub use extensions::{ From b9b7fdb8d90a1dc9a7c3d389030bec73b2d14b05 Mon Sep 17 00:00:00 2001 From: Andreas Bigger Date: Fri, 12 Dec 2025 12:28:30 -0500 Subject: [PATCH 2/2] feat(bin): add missing proofs flags --- Cargo.lock | 1 + Cargo.toml | 1 + bin/node/Cargo.toml | 1 + bin/node/src/cli.rs | 33 ++++++++++++++++++++++++++++++++- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 485c65f6..52da57d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1635,6 +1635,7 @@ dependencies = [ "base-reth-cli", "base-reth-runner", "clap", + "humantime", "once_cell", "reth-cli-util", "reth-optimism-cli", diff --git a/Cargo.toml b/Cargo.toml index 3ecc1505..aa56be6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -153,6 +153,7 @@ httpmock = "0.8.2" tracing = "0.1.43" metrics = "0.24.3" arc-swap = "1.7.1" +humantime = "2.3.0" once_cell = "1.21.3" itertools = "0.14.0" derive_more = "2.1.0" diff --git a/bin/node/Cargo.toml b/bin/node/Cargo.toml index 2782995f..3abd382a 100644 --- a/bin/node/Cargo.toml +++ b/bin/node/Cargo.toml @@ -25,6 +25,7 @@ reth-cli-util.workspace = true # misc clap.workspace = true once_cell.workspace = true +humantime.workspace = true [features] default = [] diff --git a/bin/node/src/cli.rs b/bin/node/src/cli.rs index b38b93d9..22c2b3f9 100644 --- a/bin/node/src/cli.rs +++ b/bin/node/src/cli.rs @@ -1,6 +1,6 @@ //! Contains the CLI arguments -use std::{path::PathBuf, sync::Arc}; +use std::{path::PathBuf, sync::Arc, time::Duration}; use base_reth_runner::{BaseNodeConfig, FlashblocksConfig, ProofsConfig, TracingConfig}; use once_cell::sync::OnceCell; @@ -53,6 +53,37 @@ pub struct Args { required_if_eq("proofs_history", "true") )] pub proofs_history_storage_path: Option, + + /// The window to span blocks for proofs history. Value is the number of blocks. + /// Default is 1 month of blocks based on 2 seconds block time. + /// 30 * 24 * 60 * 60 / 2 = `1_296_000` + // TODO: Pass this arg to the ExEx or remove it if not needed. + #[arg( + long = "proofs-history.window", + default_value_t = 1_296_000, + value_name = "PROOFS_HISTORY_WINDOW" + )] + pub proofs_history_window: u64, + + /// Interval between proof-storage prune runs. Accepts human-friendly durations + /// like "100s", "5m", "1h". Defaults to 1h. + /// + /// - Shorter intervals prune smaller batches more often, so each prune run tends to be faster + /// and the blocking pause for writes is shorter, at the cost of more frequent pauses. + /// - Longer intervals prune larger batches less often, which reduces how often pruning runs, + /// but each run can take longer and block writes for longer. + /// + /// A shorter interval is preferred so that prune + /// runs stay small and don’t stall writes for too long. + /// + /// CLI: `--proofs-history.prune-interval 10m` + #[arg( + long = "proofs-history.prune-interval", + value_name = "PROOFS_HISTORY_PRUNE_INTERVAL", + default_value = "1h", + value_parser = humantime::parse_duration + )] + pub proofs_history_prune_interval: Duration, } impl Args {