Skip to content
Draft
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
54 changes: 43 additions & 11 deletions bin/node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! Contains the CLI arguments

use base_reth_runner::{BaseNodeConfig, FlashblocksConfig, TracingConfig};
use std::path::PathBuf;

use base_reth_runner::{BaseNodeConfig, FlashblocksConfig, ProofsConfig, TracingConfig};
use reth_optimism_node::args::RollupArgs;

/// CLI Arguments
Expand Down Expand Up @@ -37,6 +39,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<PathBuf>,
}

impl Args {
Expand All @@ -45,22 +60,39 @@ 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 = 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,
}
}
Expand Down
12 changes: 12 additions & 0 deletions crates/runner/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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,
}
Expand All @@ -31,6 +33,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
5 changes: 4 additions & 1 deletion crates/runner/src/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
//! Builder extensions for the node nicely modularizes parts
//! of the node building process.

mod proofs;
pub use proofs::ProofsExtension;

mod canon;
pub use canon::FlashblocksCanonExtension;

Expand All @@ -13,4 +16,4 @@ mod tracing;
pub use tracing::TransactionTracingExtension;

mod types;
pub use types::{FlashblocksCell, OpBuilder, OpProvider};
pub use types::{FlashblocksCell, OpBuilder, OpProvider, ProofsCell};
24 changes: 24 additions & 0 deletions crates/runner/src/extensions/proofs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//! Contains a [`ProofsExtensions`] which stores intermediate storage updates.

use crate::{ProofsCell, ProofsConfig, extensions::OpBuilder};

/// Proofs Extension.
#[derive(Debug, Clone)]
pub struct ProofsExtension<S> {
/// Shared state.
pub cell: ProofsCell<S>,
/// Proofs config.
pub config: ProofsConfig,
}

impl<S> ProofsExtension<S> {
/// Create a new Proofs extension helper.
pub const fn new(cell: ProofsCell<S>, config: ProofsConfig) -> Self {
Self { cell, config }
}

/// Applies the extension to the supplied builder.
pub fn apply(&self, _builder: OpBuilder) -> OpBuilder {
unimplemented!("ProofsExtension::apply is not yet implemented")
}
}
3 changes: 3 additions & 0 deletions crates/runner/src/extensions/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ pub type OpBuilder =

/// The flashblocks cell holds the [`FlashblocksState`].
pub type FlashblocksCell = Arc<OnceCell<Arc<FlashblocksState<OpProvider>>>>;

/// A cell holding the proofs state.
pub type ProofsCell<S> = Arc<OnceCell<Arc<S>>>;
4 changes: 2 additions & 2 deletions crates/runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ 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::{
BaseRpcExtension, FlashblocksCanonExtension, FlashblocksCell, OpBuilder, OpProvider,
TransactionTracingExtension,
ProofsCell, ProofsExtension, TransactionTracingExtension,
};
11 changes: 9 additions & 2 deletions crates/runner/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use reth_optimism_node::OpNode;
use tracing::info;

use crate::{
BaseNodeBuilder, BaseNodeConfig, BaseRpcExtension, FlashblocksCanonExtension,
TransactionTracingExtension,
BaseNodeBuilder, BaseNodeConfig, BaseRpcExtension, FlashblocksCanonExtension, ProofsCell,
ProofsExtension, TransactionTracingExtension,
};

/// Wraps the Base node configuration and orchestrates builder wiring.
Expand Down Expand Up @@ -54,10 +54,17 @@ impl BaseNodeRunner {
FlashblocksCanonExtension::new(flashblocks_cell.clone(), flashblocks_config.clone());
let builder = flashblocks_extension.apply(builder);

// Apply the Proofs extension
let proofs_cell: ProofsCell<()> = Arc::new(OnceCell::new());
let proofs_extension =
ProofsExtension::new(proofs_cell.clone(), self.config.proofs.clone());
let builder = ProofsExtension::apply(&proofs_extension, builder);

// Apply the Transaction Tracing extension
let tracing_extension = TransactionTracingExtension::new(self.config.tracing);
let builder = tracing_extension.apply(builder);

// Apply the Base RPC extension
let rpc_extension = BaseRpcExtension::new(
flashblocks_cell.clone(),
flashblocks_config.clone(),
Expand Down