diff --git a/bin/reth/src/cli/mod.rs b/bin/reth/src/cli/mod.rs index f06cb7169..8bb0971ec 100644 --- a/bin/reth/src/cli/mod.rs +++ b/bin/reth/src/cli/mod.rs @@ -16,7 +16,7 @@ use reth_cli_commands::{ use reth_cli_runner::CliRunner; use reth_db::DatabaseEnv; use reth_node_builder::{NodeBuilder, WithLaunchContext}; -use reth_node_core::args::utils::DefaultChainSpecParser; +use reth_node_core::args::utils::EthereumChainSpecParser; use reth_node_ethereum::{EthExecutorProvider, EthereumNode}; use reth_tracing::FileWorkerGuard; use std::{ffi::OsString, fmt, future::Future, sync::Arc}; @@ -34,7 +34,8 @@ pub use crate::core::cli::*; /// This is the entrypoint to the executable. #[derive(Debug, Parser)] #[command(author, version = SHORT_VERSION, long_version = LONG_VERSION, about = "Reth", long_about = None)] -pub struct Cli { +pub struct Cli +{ /// The command to run #[command(subcommand)] command: Commands, @@ -116,14 +117,14 @@ impl, Ext: clap::Args + fmt::Debug> Cl /// /// ```no_run /// use clap::Parser; - /// use reth::{args::utils::DefaultChainSpecParser, cli::Cli}; + /// use reth::{args::utils::EthereumChainSpecParser, cli::Cli}; /// /// #[derive(Debug, Parser)] /// pub struct MyArgs { /// pub enable: bool, /// } /// - /// Cli::::parse() + /// Cli::::parse() /// .run(|builder, my_args: MyArgs| async move { /// // launch the node /// @@ -250,7 +251,7 @@ mod tests { /// runtime #[test] fn test_parse_help_all_subcommands() { - let reth = Cli::::command(); + let reth = Cli::::command(); for sub_command in reth.get_subcommands() { let err = Cli::try_parse_args_from(["reth", sub_command.get_name(), "--help"]) .err() diff --git a/bin/reth/src/main.rs b/bin/reth/src/main.rs index 67a8919e2..578f2987d 100644 --- a/bin/reth/src/main.rs +++ b/bin/reth/src/main.rs @@ -4,7 +4,7 @@ static ALLOC: reth_cli_util::allocator::Allocator = reth_cli_util::allocator::new_allocator(); use clap::{Args, Parser}; -use reth::{args::utils::DefaultChainSpecParser, cli::Cli}; +use reth::{args::utils::EthereumChainSpecParser, cli::Cli}; use reth_node_builder::{ engine_tree_config::{ TreeConfig, DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, DEFAULT_PERSISTENCE_THRESHOLD, @@ -50,7 +50,7 @@ fn main() { } if let Err(err) = - Cli::::parse().run(|builder, engine_args| async move { + Cli::::parse().run(|builder, engine_args| async move { let enable_engine2 = engine_args.experimental; match enable_engine2 { true => { diff --git a/crates/cli/commands/src/db/mod.rs b/crates/cli/commands/src/db/mod.rs index be1b117d9..1c000f56b 100644 --- a/crates/cli/commands/src/db/mod.rs +++ b/crates/cli/commands/src/db/mod.rs @@ -160,13 +160,13 @@ impl> Command #[cfg(test)] mod tests { use super::*; - use reth_node_core::args::utils::{DefaultChainSpecParser, SUPPORTED_CHAINS}; + use reth_node_core::args::utils::{EthereumChainSpecParser, SUPPORTED_CHAINS}; use std::path::Path; #[test] fn parse_stats_globals() { let path = format!("../{}", SUPPORTED_CHAINS[0]); - let cmd = Command::::try_parse_from([ + let cmd = Command::::try_parse_from([ "reth", "--datadir", &path, diff --git a/crates/cli/commands/src/dump_genesis.rs b/crates/cli/commands/src/dump_genesis.rs index 44c0b660f..a5c0675cc 100644 --- a/crates/cli/commands/src/dump_genesis.rs +++ b/crates/cli/commands/src/dump_genesis.rs @@ -32,12 +32,12 @@ impl> DumpGenesisCommand { #[cfg(test)] mod tests { use super::*; - use reth_node_core::args::utils::{DefaultChainSpecParser, SUPPORTED_CHAINS}; + use reth_node_core::args::utils::{EthereumChainSpecParser, SUPPORTED_CHAINS}; #[test] fn parse_dump_genesis_command_chain_args() { for chain in SUPPORTED_CHAINS { - let args: DumpGenesisCommand = + let args: DumpGenesisCommand = DumpGenesisCommand::parse_from(["reth", "--chain", chain]); assert_eq!( Ok(args.chain.chain), diff --git a/crates/cli/commands/src/import.rs b/crates/cli/commands/src/import.rs index 15407f29d..4d78d977c 100644 --- a/crates/cli/commands/src/import.rs +++ b/crates/cli/commands/src/import.rs @@ -231,12 +231,12 @@ where #[cfg(test)] mod tests { use super::*; - use reth_node_core::args::utils::{DefaultChainSpecParser, SUPPORTED_CHAINS}; + use reth_node_core::args::utils::{EthereumChainSpecParser, SUPPORTED_CHAINS}; #[test] fn parse_common_import_command_chain_args() { for chain in SUPPORTED_CHAINS { - let args: ImportCommand = + let args: ImportCommand = ImportCommand::parse_from(["reth", "--chain", chain, "."]); assert_eq!( Ok(args.env.chain.chain), diff --git a/crates/cli/commands/src/node.rs b/crates/cli/commands/src/node.rs index abdb00dff..fe49b769a 100644 --- a/crates/cli/commands/src/node.rs +++ b/crates/cli/commands/src/node.rs @@ -9,7 +9,7 @@ use reth_db::{init_db, DatabaseEnv}; use reth_node_builder::{NodeBuilder, WithLaunchContext}; use reth_node_core::{ args::{ - utils::DefaultChainSpecParser, DatabaseArgs, DatadirArgs, DebugArgs, DevArgs, NetworkArgs, + utils::EthereumChainSpecParser, DatabaseArgs, DatadirArgs, DebugArgs, DevArgs, NetworkArgs, PayloadBuilderArgs, PruningArgs, RpcServerArgs, TxPoolArgs, }, node_config::NodeConfig, @@ -21,7 +21,7 @@ use std::{ffi::OsString, fmt, future::Future, net::SocketAddr, path::PathBuf, sy /// Start the node #[derive(Debug, Parser)] pub struct NodeCommand< - C: ChainSpecParser = DefaultChainSpecParser, + C: ChainSpecParser = EthereumChainSpecParser, Ext: clap::Args + fmt::Debug = NoArgs, > { /// The path to the configuration file to use. @@ -218,7 +218,7 @@ mod tests { #[test] fn parse_help_node_command() { - let err = NodeCommand::::try_parse_args_from(["reth", "--help"]) + let err = NodeCommand::::try_parse_args_from(["reth", "--help"]) .unwrap_err(); assert_eq!(err.kind(), clap::error::ErrorKind::DisplayHelp); } @@ -359,7 +359,7 @@ mod tests { #[test] fn with_unused_ports_conflicts_with_instance() { - let err = NodeCommand::::try_parse_args_from([ + let err = NodeCommand::::try_parse_args_from([ "reth", "--with-unused-ports", "--instance", diff --git a/crates/cli/commands/src/stage/unwind.rs b/crates/cli/commands/src/stage/unwind.rs index c1029f33b..ae3ae2500 100644 --- a/crates/cli/commands/src/stage/unwind.rs +++ b/crates/cli/commands/src/stage/unwind.rs @@ -213,13 +213,13 @@ impl Subcommands { #[cfg(test)] mod tests { - use reth_node_core::args::utils::DefaultChainSpecParser; + use reth_node_core::args::utils::EthereumChainSpecParser; use super::*; #[test] fn parse_unwind() { - let cmd = Command::::parse_from([ + let cmd = Command::::parse_from([ "reth", "--datadir", "dir", @@ -228,7 +228,7 @@ mod tests { ]); assert_eq!(cmd.command, Subcommands::ToBlock { target: BlockHashOrNumber::Number(100) }); - let cmd = Command::::parse_from([ + let cmd = Command::::parse_from([ "reth", "--datadir", "dir", diff --git a/crates/node/core/src/args/utils.rs b/crates/node/core/src/args/utils.rs index 68cfc3219..e6ebda45b 100644 --- a/crates/node/core/src/args/utils.rs +++ b/crates/node/core/src/args/utils.rs @@ -71,11 +71,12 @@ pub fn parse_custom_chain_spec(s: &str) -> eyre::Result Ok(genesis.into()) } -/// Default chain specification parser. -#[derive(Debug, Clone, Default)] -pub struct DefaultChainSpecParser; +/// A chain specification parser for ethereum chains. +#[derive(Debug, Copy, Clone, Default)] +#[non_exhaustive] +pub struct EthereumChainSpecParser; -impl ChainSpecParser for DefaultChainSpecParser { +impl ChainSpecParser for EthereumChainSpecParser { type ChainSpec = ChainSpec; const SUPPORTED_CHAINS: &'static [&'static str] = SUPPORTED_CHAINS; diff --git a/examples/beacon-api-sidecar-fetcher/src/main.rs b/examples/beacon-api-sidecar-fetcher/src/main.rs index 631a17a09..7d8880ca1 100644 --- a/examples/beacon-api-sidecar-fetcher/src/main.rs +++ b/examples/beacon-api-sidecar-fetcher/src/main.rs @@ -23,7 +23,7 @@ use clap::Parser; use futures_util::{stream::FuturesUnordered, StreamExt}; use mined_sidecar::MinedSidecarStream; use reth::{ - args::utils::DefaultChainSpecParser, builder::NodeHandle, cli::Cli, + args::utils::EthereumChainSpecParser, builder::NodeHandle, cli::Cli, providers::CanonStateSubscriptions, }; use reth_node_ethereum::EthereumNode; @@ -31,7 +31,7 @@ use reth_node_ethereum::EthereumNode; pub mod mined_sidecar; fn main() { - Cli::::parse() + Cli::::parse() .run(|builder, beacon_config| async move { // launch the node let NodeHandle { node, node_exit_future } = diff --git a/examples/beacon-api-sse/src/main.rs b/examples/beacon-api-sse/src/main.rs index 53078e5bc..81535ef61 100644 --- a/examples/beacon-api-sse/src/main.rs +++ b/examples/beacon-api-sse/src/main.rs @@ -21,13 +21,13 @@ use alloy_rpc_types_beacon::events::PayloadAttributesEvent; use clap::Parser; use futures_util::stream::StreamExt; use mev_share_sse::{client::EventStream, EventClient}; -use reth::{args::utils::DefaultChainSpecParser, cli::Cli}; +use reth::{args::utils::EthereumChainSpecParser, cli::Cli}; use reth_node_ethereum::EthereumNode; use std::net::{IpAddr, Ipv4Addr}; use tracing::{info, warn}; fn main() { - Cli::::parse() + Cli::::parse() .run(|builder, args| async move { let handle = builder.node(EthereumNode::default()).launch().await?; diff --git a/examples/custom-inspector/src/main.rs b/examples/custom-inspector/src/main.rs index 42271dcab..700de274e 100644 --- a/examples/custom-inspector/src/main.rs +++ b/examples/custom-inspector/src/main.rs @@ -15,7 +15,7 @@ use alloy_rpc_types::state::EvmOverrides; use clap::Parser; use futures_util::StreamExt; use reth::{ - args::utils::DefaultChainSpecParser, + args::utils::EthereumChainSpecParser, builder::NodeHandle, cli::Cli, primitives::BlockNumberOrTag, @@ -30,7 +30,7 @@ use reth::{ use reth_node_ethereum::node::EthereumNode; fn main() { - Cli::::parse() + Cli::::parse() .run(|builder, args| async move { // launch the node let NodeHandle { node, node_exit_future } = diff --git a/examples/node-custom-rpc/src/main.rs b/examples/node-custom-rpc/src/main.rs index 40a7beb7c..5aeecfd29 100644 --- a/examples/node-custom-rpc/src/main.rs +++ b/examples/node-custom-rpc/src/main.rs @@ -14,12 +14,12 @@ use clap::Parser; use jsonrpsee::{core::RpcResult, proc_macros::rpc}; -use reth::{args::utils::DefaultChainSpecParser, cli::Cli}; +use reth::{args::utils::EthereumChainSpecParser, cli::Cli}; use reth_node_ethereum::EthereumNode; use reth_transaction_pool::TransactionPool; fn main() { - Cli::::parse() + Cli::::parse() .run(|builder, args| async move { let handle = builder .node(EthereumNode::default()) diff --git a/examples/txpool-tracing/src/main.rs b/examples/txpool-tracing/src/main.rs index 6b916dcb5..f8c2e19d2 100644 --- a/examples/txpool-tracing/src/main.rs +++ b/examples/txpool-tracing/src/main.rs @@ -15,13 +15,13 @@ use alloy_rpc_types_trace::{parity::TraceType, tracerequest::TraceCallRequest}; use clap::Parser; use futures_util::StreamExt; use reth::{ - args::utils::DefaultChainSpecParser, builder::NodeHandle, cli::Cli, + args::utils::EthereumChainSpecParser, builder::NodeHandle, cli::Cli, rpc::compat::transaction::transaction_to_call_request, transaction_pool::TransactionPool, }; use reth_node_ethereum::node::EthereumNode; fn main() { - Cli::::parse() + Cli::::parse() .run(|builder, args| async move { // launch the node let NodeHandle { node, node_exit_future } =