mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: rename default chainspec parser (#11398)
This commit is contained in:
@ -16,7 +16,7 @@ use reth_cli_commands::{
|
|||||||
use reth_cli_runner::CliRunner;
|
use reth_cli_runner::CliRunner;
|
||||||
use reth_db::DatabaseEnv;
|
use reth_db::DatabaseEnv;
|
||||||
use reth_node_builder::{NodeBuilder, WithLaunchContext};
|
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_node_ethereum::{EthExecutorProvider, EthereumNode};
|
||||||
use reth_tracing::FileWorkerGuard;
|
use reth_tracing::FileWorkerGuard;
|
||||||
use std::{ffi::OsString, fmt, future::Future, sync::Arc};
|
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.
|
/// This is the entrypoint to the executable.
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
#[command(author, version = SHORT_VERSION, long_version = LONG_VERSION, about = "Reth", long_about = None)]
|
#[command(author, version = SHORT_VERSION, long_version = LONG_VERSION, about = "Reth", long_about = None)]
|
||||||
pub struct Cli<C: ChainSpecParser = DefaultChainSpecParser, Ext: clap::Args + fmt::Debug = NoArgs> {
|
pub struct Cli<C: ChainSpecParser = EthereumChainSpecParser, Ext: clap::Args + fmt::Debug = NoArgs>
|
||||||
|
{
|
||||||
/// The command to run
|
/// The command to run
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Commands<C, Ext>,
|
command: Commands<C, Ext>,
|
||||||
@ -116,14 +117,14 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>, Ext: clap::Args + fmt::Debug> Cl
|
|||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// use clap::Parser;
|
/// use clap::Parser;
|
||||||
/// use reth::{args::utils::DefaultChainSpecParser, cli::Cli};
|
/// use reth::{args::utils::EthereumChainSpecParser, cli::Cli};
|
||||||
///
|
///
|
||||||
/// #[derive(Debug, Parser)]
|
/// #[derive(Debug, Parser)]
|
||||||
/// pub struct MyArgs {
|
/// pub struct MyArgs {
|
||||||
/// pub enable: bool,
|
/// pub enable: bool,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// Cli::<DefaultChainSpecParser, MyArgs>::parse()
|
/// Cli::<EthereumChainSpecParser, MyArgs>::parse()
|
||||||
/// .run(|builder, my_args: MyArgs| async move {
|
/// .run(|builder, my_args: MyArgs| async move {
|
||||||
/// // launch the node
|
/// // launch the node
|
||||||
///
|
///
|
||||||
@ -250,7 +251,7 @@ mod tests {
|
|||||||
/// runtime
|
/// runtime
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_help_all_subcommands() {
|
fn test_parse_help_all_subcommands() {
|
||||||
let reth = Cli::<DefaultChainSpecParser, NoArgs>::command();
|
let reth = Cli::<EthereumChainSpecParser, NoArgs>::command();
|
||||||
for sub_command in reth.get_subcommands() {
|
for sub_command in reth.get_subcommands() {
|
||||||
let err = Cli::try_parse_args_from(["reth", sub_command.get_name(), "--help"])
|
let err = Cli::try_parse_args_from(["reth", sub_command.get_name(), "--help"])
|
||||||
.err()
|
.err()
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
static ALLOC: reth_cli_util::allocator::Allocator = reth_cli_util::allocator::new_allocator();
|
static ALLOC: reth_cli_util::allocator::Allocator = reth_cli_util::allocator::new_allocator();
|
||||||
|
|
||||||
use clap::{Args, Parser};
|
use clap::{Args, Parser};
|
||||||
use reth::{args::utils::DefaultChainSpecParser, cli::Cli};
|
use reth::{args::utils::EthereumChainSpecParser, cli::Cli};
|
||||||
use reth_node_builder::{
|
use reth_node_builder::{
|
||||||
engine_tree_config::{
|
engine_tree_config::{
|
||||||
TreeConfig, DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, DEFAULT_PERSISTENCE_THRESHOLD,
|
TreeConfig, DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, DEFAULT_PERSISTENCE_THRESHOLD,
|
||||||
@ -50,7 +50,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) =
|
if let Err(err) =
|
||||||
Cli::<DefaultChainSpecParser, EngineArgs>::parse().run(|builder, engine_args| async move {
|
Cli::<EthereumChainSpecParser, EngineArgs>::parse().run(|builder, engine_args| async move {
|
||||||
let enable_engine2 = engine_args.experimental;
|
let enable_engine2 = engine_args.experimental;
|
||||||
match enable_engine2 {
|
match enable_engine2 {
|
||||||
true => {
|
true => {
|
||||||
|
|||||||
@ -160,13 +160,13 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C>
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use reth_node_core::args::utils::{DefaultChainSpecParser, SUPPORTED_CHAINS};
|
use reth_node_core::args::utils::{EthereumChainSpecParser, SUPPORTED_CHAINS};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_stats_globals() {
|
fn parse_stats_globals() {
|
||||||
let path = format!("../{}", SUPPORTED_CHAINS[0]);
|
let path = format!("../{}", SUPPORTED_CHAINS[0]);
|
||||||
let cmd = Command::<DefaultChainSpecParser>::try_parse_from([
|
let cmd = Command::<EthereumChainSpecParser>::try_parse_from([
|
||||||
"reth",
|
"reth",
|
||||||
"--datadir",
|
"--datadir",
|
||||||
&path,
|
&path,
|
||||||
|
|||||||
@ -32,12 +32,12 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec>> DumpGenesisCommand<C> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use reth_node_core::args::utils::{DefaultChainSpecParser, SUPPORTED_CHAINS};
|
use reth_node_core::args::utils::{EthereumChainSpecParser, SUPPORTED_CHAINS};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_dump_genesis_command_chain_args() {
|
fn parse_dump_genesis_command_chain_args() {
|
||||||
for chain in SUPPORTED_CHAINS {
|
for chain in SUPPORTED_CHAINS {
|
||||||
let args: DumpGenesisCommand<DefaultChainSpecParser> =
|
let args: DumpGenesisCommand<EthereumChainSpecParser> =
|
||||||
DumpGenesisCommand::parse_from(["reth", "--chain", chain]);
|
DumpGenesisCommand::parse_from(["reth", "--chain", chain]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Ok(args.chain.chain),
|
Ok(args.chain.chain),
|
||||||
|
|||||||
@ -231,12 +231,12 @@ where
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use reth_node_core::args::utils::{DefaultChainSpecParser, SUPPORTED_CHAINS};
|
use reth_node_core::args::utils::{EthereumChainSpecParser, SUPPORTED_CHAINS};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_common_import_command_chain_args() {
|
fn parse_common_import_command_chain_args() {
|
||||||
for chain in SUPPORTED_CHAINS {
|
for chain in SUPPORTED_CHAINS {
|
||||||
let args: ImportCommand<DefaultChainSpecParser> =
|
let args: ImportCommand<EthereumChainSpecParser> =
|
||||||
ImportCommand::parse_from(["reth", "--chain", chain, "."]);
|
ImportCommand::parse_from(["reth", "--chain", chain, "."]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Ok(args.env.chain.chain),
|
Ok(args.env.chain.chain),
|
||||||
|
|||||||
@ -9,7 +9,7 @@ use reth_db::{init_db, DatabaseEnv};
|
|||||||
use reth_node_builder::{NodeBuilder, WithLaunchContext};
|
use reth_node_builder::{NodeBuilder, WithLaunchContext};
|
||||||
use reth_node_core::{
|
use reth_node_core::{
|
||||||
args::{
|
args::{
|
||||||
utils::DefaultChainSpecParser, DatabaseArgs, DatadirArgs, DebugArgs, DevArgs, NetworkArgs,
|
utils::EthereumChainSpecParser, DatabaseArgs, DatadirArgs, DebugArgs, DevArgs, NetworkArgs,
|
||||||
PayloadBuilderArgs, PruningArgs, RpcServerArgs, TxPoolArgs,
|
PayloadBuilderArgs, PruningArgs, RpcServerArgs, TxPoolArgs,
|
||||||
},
|
},
|
||||||
node_config::NodeConfig,
|
node_config::NodeConfig,
|
||||||
@ -21,7 +21,7 @@ use std::{ffi::OsString, fmt, future::Future, net::SocketAddr, path::PathBuf, sy
|
|||||||
/// Start the node
|
/// Start the node
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct NodeCommand<
|
pub struct NodeCommand<
|
||||||
C: ChainSpecParser = DefaultChainSpecParser,
|
C: ChainSpecParser = EthereumChainSpecParser,
|
||||||
Ext: clap::Args + fmt::Debug = NoArgs,
|
Ext: clap::Args + fmt::Debug = NoArgs,
|
||||||
> {
|
> {
|
||||||
/// The path to the configuration file to use.
|
/// The path to the configuration file to use.
|
||||||
@ -218,7 +218,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_help_node_command() {
|
fn parse_help_node_command() {
|
||||||
let err = NodeCommand::<DefaultChainSpecParser>::try_parse_args_from(["reth", "--help"])
|
let err = NodeCommand::<EthereumChainSpecParser>::try_parse_args_from(["reth", "--help"])
|
||||||
.unwrap_err();
|
.unwrap_err();
|
||||||
assert_eq!(err.kind(), clap::error::ErrorKind::DisplayHelp);
|
assert_eq!(err.kind(), clap::error::ErrorKind::DisplayHelp);
|
||||||
}
|
}
|
||||||
@ -359,7 +359,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn with_unused_ports_conflicts_with_instance() {
|
fn with_unused_ports_conflicts_with_instance() {
|
||||||
let err = NodeCommand::<DefaultChainSpecParser>::try_parse_args_from([
|
let err = NodeCommand::<EthereumChainSpecParser>::try_parse_args_from([
|
||||||
"reth",
|
"reth",
|
||||||
"--with-unused-ports",
|
"--with-unused-ports",
|
||||||
"--instance",
|
"--instance",
|
||||||
|
|||||||
@ -213,13 +213,13 @@ impl Subcommands {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use reth_node_core::args::utils::DefaultChainSpecParser;
|
use reth_node_core::args::utils::EthereumChainSpecParser;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_unwind() {
|
fn parse_unwind() {
|
||||||
let cmd = Command::<DefaultChainSpecParser>::parse_from([
|
let cmd = Command::<EthereumChainSpecParser>::parse_from([
|
||||||
"reth",
|
"reth",
|
||||||
"--datadir",
|
"--datadir",
|
||||||
"dir",
|
"dir",
|
||||||
@ -228,7 +228,7 @@ mod tests {
|
|||||||
]);
|
]);
|
||||||
assert_eq!(cmd.command, Subcommands::ToBlock { target: BlockHashOrNumber::Number(100) });
|
assert_eq!(cmd.command, Subcommands::ToBlock { target: BlockHashOrNumber::Number(100) });
|
||||||
|
|
||||||
let cmd = Command::<DefaultChainSpecParser>::parse_from([
|
let cmd = Command::<EthereumChainSpecParser>::parse_from([
|
||||||
"reth",
|
"reth",
|
||||||
"--datadir",
|
"--datadir",
|
||||||
"dir",
|
"dir",
|
||||||
|
|||||||
@ -71,11 +71,12 @@ pub fn parse_custom_chain_spec(s: &str) -> eyre::Result<ChainSpec, eyre::Error>
|
|||||||
Ok(genesis.into())
|
Ok(genesis.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Default chain specification parser.
|
/// A chain specification parser for ethereum chains.
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Copy, Clone, Default)]
|
||||||
pub struct DefaultChainSpecParser;
|
#[non_exhaustive]
|
||||||
|
pub struct EthereumChainSpecParser;
|
||||||
|
|
||||||
impl ChainSpecParser for DefaultChainSpecParser {
|
impl ChainSpecParser for EthereumChainSpecParser {
|
||||||
type ChainSpec = ChainSpec;
|
type ChainSpec = ChainSpec;
|
||||||
|
|
||||||
const SUPPORTED_CHAINS: &'static [&'static str] = SUPPORTED_CHAINS;
|
const SUPPORTED_CHAINS: &'static [&'static str] = SUPPORTED_CHAINS;
|
||||||
|
|||||||
@ -23,7 +23,7 @@ use clap::Parser;
|
|||||||
use futures_util::{stream::FuturesUnordered, StreamExt};
|
use futures_util::{stream::FuturesUnordered, StreamExt};
|
||||||
use mined_sidecar::MinedSidecarStream;
|
use mined_sidecar::MinedSidecarStream;
|
||||||
use reth::{
|
use reth::{
|
||||||
args::utils::DefaultChainSpecParser, builder::NodeHandle, cli::Cli,
|
args::utils::EthereumChainSpecParser, builder::NodeHandle, cli::Cli,
|
||||||
providers::CanonStateSubscriptions,
|
providers::CanonStateSubscriptions,
|
||||||
};
|
};
|
||||||
use reth_node_ethereum::EthereumNode;
|
use reth_node_ethereum::EthereumNode;
|
||||||
@ -31,7 +31,7 @@ use reth_node_ethereum::EthereumNode;
|
|||||||
pub mod mined_sidecar;
|
pub mod mined_sidecar;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
Cli::<DefaultChainSpecParser, BeaconSidecarConfig>::parse()
|
Cli::<EthereumChainSpecParser, BeaconSidecarConfig>::parse()
|
||||||
.run(|builder, beacon_config| async move {
|
.run(|builder, beacon_config| async move {
|
||||||
// launch the node
|
// launch the node
|
||||||
let NodeHandle { node, node_exit_future } =
|
let NodeHandle { node, node_exit_future } =
|
||||||
|
|||||||
@ -21,13 +21,13 @@ use alloy_rpc_types_beacon::events::PayloadAttributesEvent;
|
|||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use futures_util::stream::StreamExt;
|
use futures_util::stream::StreamExt;
|
||||||
use mev_share_sse::{client::EventStream, EventClient};
|
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 reth_node_ethereum::EthereumNode;
|
||||||
use std::net::{IpAddr, Ipv4Addr};
|
use std::net::{IpAddr, Ipv4Addr};
|
||||||
use tracing::{info, warn};
|
use tracing::{info, warn};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
Cli::<DefaultChainSpecParser, BeaconEventsConfig>::parse()
|
Cli::<EthereumChainSpecParser, BeaconEventsConfig>::parse()
|
||||||
.run(|builder, args| async move {
|
.run(|builder, args| async move {
|
||||||
let handle = builder.node(EthereumNode::default()).launch().await?;
|
let handle = builder.node(EthereumNode::default()).launch().await?;
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ use alloy_rpc_types::state::EvmOverrides;
|
|||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
use reth::{
|
use reth::{
|
||||||
args::utils::DefaultChainSpecParser,
|
args::utils::EthereumChainSpecParser,
|
||||||
builder::NodeHandle,
|
builder::NodeHandle,
|
||||||
cli::Cli,
|
cli::Cli,
|
||||||
primitives::BlockNumberOrTag,
|
primitives::BlockNumberOrTag,
|
||||||
@ -30,7 +30,7 @@ use reth::{
|
|||||||
use reth_node_ethereum::node::EthereumNode;
|
use reth_node_ethereum::node::EthereumNode;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
Cli::<DefaultChainSpecParser, RethCliTxpoolExt>::parse()
|
Cli::<EthereumChainSpecParser, RethCliTxpoolExt>::parse()
|
||||||
.run(|builder, args| async move {
|
.run(|builder, args| async move {
|
||||||
// launch the node
|
// launch the node
|
||||||
let NodeHandle { node, node_exit_future } =
|
let NodeHandle { node, node_exit_future } =
|
||||||
|
|||||||
@ -14,12 +14,12 @@
|
|||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
|
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_node_ethereum::EthereumNode;
|
||||||
use reth_transaction_pool::TransactionPool;
|
use reth_transaction_pool::TransactionPool;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
Cli::<DefaultChainSpecParser, RethCliTxpoolExt>::parse()
|
Cli::<EthereumChainSpecParser, RethCliTxpoolExt>::parse()
|
||||||
.run(|builder, args| async move {
|
.run(|builder, args| async move {
|
||||||
let handle = builder
|
let handle = builder
|
||||||
.node(EthereumNode::default())
|
.node(EthereumNode::default())
|
||||||
|
|||||||
@ -15,13 +15,13 @@ use alloy_rpc_types_trace::{parity::TraceType, tracerequest::TraceCallRequest};
|
|||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
use reth::{
|
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,
|
rpc::compat::transaction::transaction_to_call_request, transaction_pool::TransactionPool,
|
||||||
};
|
};
|
||||||
use reth_node_ethereum::node::EthereumNode;
|
use reth_node_ethereum::node::EthereumNode;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
Cli::<DefaultChainSpecParser, RethCliTxpoolExt>::parse()
|
Cli::<EthereumChainSpecParser, RethCliTxpoolExt>::parse()
|
||||||
.run(|builder, args| async move {
|
.run(|builder, args| async move {
|
||||||
// launch the node
|
// launch the node
|
||||||
let NodeHandle { node, node_exit_future } =
|
let NodeHandle { node, node_exit_future } =
|
||||||
|
|||||||
Reference in New Issue
Block a user