Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion crates/optimism/bin/op-reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ tracing.workspace = true
eyre.workspace = true
futures-util.workspace = true
tokio.workspace = true
humantime.workspace = true

[lints]
workspace = true
Expand Down
88 changes: 11 additions & 77 deletions crates/optimism/bin/op-reth/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(missing_docs, rustdoc::missing_crate_level_docs)]

use clap::{builder::ArgPredicate, Parser};
use clap::Parser;
use eyre::ErrReport;
use futures_util::FutureExt;
use reth_db::DatabaseEnv;
Expand All @@ -16,7 +16,7 @@ use reth_optimism_rpc::{
};
use reth_optimism_trie::{db::MdbxProofsStorage, OpProofsStorage};
use reth_tasks::TaskExecutor;
use std::{path::PathBuf, sync::Arc, time::Duration};
use std::{sync::Arc, time::Duration};
use tokio::time::sleep;
use tracing::info;

Expand All @@ -27,89 +27,21 @@ static ALLOC: reth_cli_util::allocator::Allocator = reth_cli_util::allocator::ne
#[unsafe(export_name = "_rjem_malloc_conf")]
static MALLOC_CONF: &[u8] = b"prof:true,prof_active:true,lg_prof_sample:19\0";

#[derive(Debug, Clone, PartialEq, Eq, clap::Args)]
#[command(next_help_heading = "Proofs History")]
struct Args {
#[command(flatten)]
pub rollup_args: RollupArgs,

/// 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_ifs([
("proofs-history.storage-path", ArgPredicate::IsPresent, "true")
])
)]
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")]
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`
#[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 15s.
///
/// - 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 = "15s",
value_parser = humantime::parse_duration
)]
pub proofs_history_prune_interval: Duration,
/// Verification interval: perform full block execution every N blocks for data integrity.
/// - 0: Disabled (Default) (always use fast path with pre-computed data from notifications)
/// - 1: Always verify (always execute blocks, slowest)
/// - N: Verify every Nth block (e.g., 100 = every 100 blocks)
///
/// Periodic verification helps catch data corruption or consensus bugs while maintaining
/// good performance.
///
/// CLI: `--proofs-history.verification-interval 100`
#[arg(
long = "proofs-history.verification-interval",
value_name = "PROOFS_HISTORY_VERIFICATION_INTERVAL",
default_value_t = 0
)]
pub proofs_history_verification_interval: u64,
}

/// Single entry that handles:
/// - no proofs history (plain node),
/// - in-mem proofs storage,
/// - MDBX proofs storage.
async fn launch_node(
builder: WithLaunchContext<NodeBuilder<Arc<DatabaseEnv>, OpChainSpec>>,
args: Args,
args: RollupArgs,
) -> eyre::Result<(), ErrReport> {
let proofs_history_enabled = args.proofs_history;
let rollup_args = args.rollup_args.clone();
let proofs_history_window = args.proofs_history_window;
let proofs_history_prune_interval = args.proofs_history_prune_interval;
let proofs_history_verification_interval = args.proofs_history_verification_interval;

// Start from a plain OpNode builder
let mut node_builder = builder.node(OpNode::new(rollup_args));
let mut node_builder = builder.node(OpNode::new(args.clone()));

if proofs_history_enabled {
let path = args
Expand Down Expand Up @@ -196,11 +128,13 @@ fn main() {
}
}

if let Err(err) = Cli::<OpChainSpecParser, Args>::parse().run(async move |builder, args| {
info!(target: "reth::cli", "Launching node");
launch_node(builder, args.clone()).await?;
Ok(())
}) {
if let Err(err) =
Cli::<OpChainSpecParser, RollupArgs>::parse().run(async move |builder, args| {
info!(target: "reth::cli", "Launching node");
launch_node(builder, args.clone()).await?;
Ok(())
})
{
eprintln!("Error: {err:?}");
std::process::exit(1);
}
Expand Down
1 change: 1 addition & 0 deletions crates/optimism/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ clap.workspace = true
serde.workspace = true
eyre.workspace = true
url.workspace = true
humantime.workspace = true

# test-utils dependencies
reth-e2e-test-utils = { workspace = true, optional = true }
Expand Down
67 changes: 67 additions & 0 deletions crates/optimism/node/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
//! clap [Args](clap::Args) for optimism rollup configuration
use clap::builder::ArgPredicate;
use op_alloy_consensus::interop::SafetyLevel;
use reth_optimism_txpool::supervisor::DEFAULT_SUPERVISOR_URL;
use std::{path::PathBuf, time::Duration};
use url::Url;

/// Parameters for rollup configuration
Expand Down Expand Up @@ -82,6 +84,66 @@ pub struct RollupArgs {
/// Requires `flashblocks_url` to be set.
#[arg(long, default_value_t = false, requires = "flashblocks_url")]
pub flashblock_consensus: 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_ifs([
("proofs-history.storage-path", ArgPredicate::IsPresent, "true")
])
)]
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")]
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`
#[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 15s.
///
/// - 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 = "15s",
value_parser = humantime::parse_duration
)]
pub proofs_history_prune_interval: Duration,
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing blank line before doc comment. Add a blank line before this doc comment to separate it from the previous field's documentation, consistent with the rest of the struct.

Suggested change
pub proofs_history_prune_interval: Duration,
pub proofs_history_prune_interval: Duration,

Copilot uses AI. Check for mistakes.
/// Verification interval: perform full block execution every N blocks for data integrity.
/// - 0: Disabled (Default) (always use fast path with pre-computed data from notifications)
/// - 1: Always verify (always execute blocks, slowest)
/// - N: Verify every Nth block (e.g., 100 = every 100 blocks)
///
/// Periodic verification helps catch data corruption or consensus bugs while maintaining
/// good performance.
///
/// CLI: `--proofs-history.verification-interval 100`
#[arg(
long = "proofs-history.verification-interval",
value_name = "PROOFS_HISTORY_VERIFICATION_INTERVAL",
default_value_t = 0
)]
pub proofs_history_verification_interval: u64,
}

impl Default for RollupArgs {
Expand All @@ -99,6 +161,11 @@ impl Default for RollupArgs {
min_suggested_priority_fee: 1_000_000,
flashblocks_url: None,
flashblock_consensus: false,
proofs_history: false,
proofs_history_storage_path: None,
proofs_history_window: 1_296_000,
proofs_history_prune_interval: Duration::from_secs(15),
proofs_history_verification_interval: 0,
}
}
}
Expand Down
Loading