diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index 3623f31db..b9c65365a 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -152,10 +152,6 @@ ethereum = [] name = "reth" path = "src/main.rs" -[[bin]] -name = "engine2" -path = "src/engine2.rs" - [[bin]] name = "op-reth" path = "src/optimism.rs" diff --git a/bin/reth/src/engine2.rs b/bin/reth/src/engine2.rs deleted file mode 100644 index 94777307c..000000000 --- a/bin/reth/src/engine2.rs +++ /dev/null @@ -1,40 +0,0 @@ -#![allow(missing_docs)] -#![allow(rustdoc::missing_crate_level_docs)] - -// We use jemalloc for performance reasons. -#[cfg(all(feature = "jemalloc", unix))] -#[global_allocator] -static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; - -#[cfg(not(feature = "optimism"))] -fn main() { - use reth::cli::Cli; - use reth_node_ethereum::{launch::EthNodeLauncher, node::EthereumAddOns, EthereumNode}; - use reth_provider::providers::BlockchainProvider2; - - reth_cli_util::sigsegv_handler::install(); - - // Enable backtraces unless a RUST_BACKTRACE value has already been explicitly provided. - if std::env::var_os("RUST_BACKTRACE").is_none() { - std::env::set_var("RUST_BACKTRACE", "1"); - } - - if let Err(err) = Cli::parse_args().run(|builder, _| async { - let handle = builder - .with_types_and_provider::>() - .with_components(EthereumNode::components()) - .with_add_ons::() - .launch_with_fn(|builder| { - let launcher = EthNodeLauncher::new( - builder.task_executor().clone(), - builder.config().datadir(), - ); - builder.launch_with(launcher) - }) - .await?; - handle.node_exit_future.await - }) { - eprintln!("Error: {err:?}"); - std::process::exit(1); - } -} diff --git a/bin/reth/src/main.rs b/bin/reth/src/main.rs index 4eacb9df3..a2558985e 100644 --- a/bin/reth/src/main.rs +++ b/bin/reth/src/main.rs @@ -8,10 +8,24 @@ static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; #[cfg(all(feature = "optimism", not(test)))] compile_error!("Cannot build the `reth` binary with the `optimism` feature flag enabled. Did you mean to build `op-reth`?"); +/// clap [Args] for Engine related arguments. +use clap::Args; + +/// Parameters for configuring the engine +#[derive(Debug, Clone, Args, PartialEq, Eq, Default)] +#[command(next_help_heading = "Engine")] +pub struct EngineArgs { + /// Enable the engine2 experimental features on reth binary + #[arg(long = "engine.experimental", default_value = "false")] + pub experimental: bool, +} + #[cfg(not(feature = "optimism"))] fn main() { + use clap::Parser; use reth::cli::Cli; - use reth_node_ethereum::EthereumNode; + use reth_node_ethereum::{launch::EthNodeLauncher, node::EthereumAddOns, EthereumNode}; + use reth_provider::providers::BlockchainProvider2; reth_cli_util::sigsegv_handler::install(); @@ -20,11 +34,51 @@ fn main() { std::env::set_var("RUST_BACKTRACE", "1"); } - if let Err(err) = Cli::parse_args().run(|builder, _| async { - let handle = builder.launch_node(EthereumNode::default()).await?; - handle.node_exit_future.await + if let Err(err) = Cli::::parse().run(|builder, engine_args| async move { + let enable_engine2 = engine_args.experimental; + match enable_engine2 { + true => { + let handle = builder + .with_types_and_provider::>() + .with_components(EthereumNode::components()) + .with_add_ons::() + .launch_with_fn(|builder| { + let launcher = EthNodeLauncher::new( + builder.task_executor().clone(), + builder.config().datadir(), + ); + builder.launch_with(launcher) + }) + .await?; + handle.node_exit_future.await + } + false => { + let handle = builder.launch_node(EthereumNode::default()).await?; + handle.node_exit_future.await + } + } }) { eprintln!("Error: {err:?}"); std::process::exit(1); } } + +#[cfg(test)] +mod tests { + use super::*; + use clap::Parser; + + /// A helper type to parse Args more easily + #[derive(Parser)] + struct CommandParser { + #[command(flatten)] + args: T, + } + + #[test] + fn test_parse_engine_args() { + let default_args = EngineArgs::default(); + let args = CommandParser::::parse_from(["reth"]).args; + assert_eq!(args, default_args); + } +} diff --git a/book/cli/reth/node.md b/book/cli/reth/node.md index ca8d3742c..7e9c0bdf7 100644 --- a/book/cli/reth/node.md +++ b/book/cli/reth/node.md @@ -525,6 +525,10 @@ Pruning: --full Run full node. Only the most recent [`MINIMUM_PRUNING_DISTANCE`] block states are stored. This flag takes priority over pruning configuration in reth.toml +Engine: + --engine.experimental + Enable the engine2 experimental features on reth binary + Logging: --log.stdout.format The format to use for logs written to stdout