Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions bin/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ reth-cli-util.workspace = true
# misc
clap.workspace = true
once_cell.workspace = true
humantime.workspace = true

[features]
default = []
Expand Down
88 changes: 74 additions & 14 deletions bin/node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Contains the CLI arguments

use std::sync::Arc;
use std::{path::PathBuf, sync::Arc, time::Duration};

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;

Expand Down Expand Up @@ -40,6 +40,50 @@ 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<PathBuf>,

/// 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 {
Expand All @@ -48,25 +92,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<FlashblocksConfig> {
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<Args> 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()),
}
}
}
12 changes: 12 additions & 0 deletions crates/runner/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub struct BaseNodeConfig {
pub flashblocks: Option<FlashblocksConfig>,
/// 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.
Expand All @@ -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<std::path::PathBuf>,
}

/// Transaction tracing toggles.
#[derive(Debug, Clone, Copy)]
pub struct TracingConfig {
Expand Down
2 changes: 1 addition & 1 deletion crates/runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down