mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Optimism Cli struct (#9416)
This commit is contained in:
@ -25,6 +25,8 @@ reth-static-file.workspace = true
|
|||||||
reth-execution-types.workspace = true
|
reth-execution-types.workspace = true
|
||||||
reth-node-core.workspace = true
|
reth-node-core.workspace = true
|
||||||
reth-primitives.workspace = true
|
reth-primitives.workspace = true
|
||||||
|
|
||||||
|
reth-chainspec.workspace = true
|
||||||
reth-stages-types.workspace = true
|
reth-stages-types.workspace = true
|
||||||
reth-node-events.workspace = true
|
reth-node-events.workspace = true
|
||||||
reth-network-p2p.workspace = true
|
reth-network-p2p.workspace = true
|
||||||
@ -32,7 +34,6 @@ reth-errors.workspace = true
|
|||||||
reth-config.workspace = true
|
reth-config.workspace = true
|
||||||
reth-evm-optimism.workspace = true
|
reth-evm-optimism.workspace = true
|
||||||
reth-cli.workspace = true
|
reth-cli.workspace = true
|
||||||
reth-chainspec.workspace = true
|
|
||||||
|
|
||||||
# eth
|
# eth
|
||||||
alloy-genesis.workspace = true
|
alloy-genesis.workspace = true
|
||||||
|
|||||||
@ -26,7 +26,7 @@ use tokio::sync::watch;
|
|||||||
///
|
///
|
||||||
/// If configured to execute, all stages will run. Otherwise, only stages that don't require state
|
/// If configured to execute, all stages will run. Otherwise, only stages that don't require state
|
||||||
/// will run.
|
/// will run.
|
||||||
pub async fn build_import_pipeline<DB, C>(
|
pub(crate) async fn build_import_pipeline<DB, C>(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
provider_factory: ProviderFactory<DB>,
|
provider_factory: ProviderFactory<DB>,
|
||||||
consensus: &Arc<C>,
|
consensus: &Arc<C>,
|
||||||
|
|||||||
@ -1,4 +1,54 @@
|
|||||||
|
use clap::Subcommand;
|
||||||
|
use import::ImportOpCommand;
|
||||||
|
use import_receipts::ImportReceiptsOpCommand;
|
||||||
|
use reth_cli_commands::{
|
||||||
|
config_cmd, db, dump_genesis, init_cmd, init_state,
|
||||||
|
node::{self, NoArgs},
|
||||||
|
p2p, prune, recover, stage,
|
||||||
|
};
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
/// Helper function to build an import pipeline.
|
/// Helper function to build an import pipeline.
|
||||||
pub mod build_pipeline;
|
mod build_pipeline;
|
||||||
pub mod import;
|
pub mod import;
|
||||||
pub mod import_receipts;
|
pub mod import_receipts;
|
||||||
|
|
||||||
|
/// Commands to be executed
|
||||||
|
#[derive(Debug, Subcommand)]
|
||||||
|
pub enum Commands<Ext: clap::Args + fmt::Debug = NoArgs> {
|
||||||
|
/// Start the node
|
||||||
|
#[command(name = "node")]
|
||||||
|
Node(node::NodeCommand<Ext>),
|
||||||
|
/// Initialize the database from a genesis file.
|
||||||
|
#[command(name = "init")]
|
||||||
|
Init(init_cmd::InitCommand),
|
||||||
|
/// Initialize the database from a state dump file.
|
||||||
|
#[command(name = "init-state")]
|
||||||
|
InitState(init_state::InitStateCommand),
|
||||||
|
/// This syncs RLP encoded OP blocks below Bedrock from a file, without executing.
|
||||||
|
#[command(name = "import-op")]
|
||||||
|
ImportOp(ImportOpCommand),
|
||||||
|
/// This imports RLP encoded receipts from a file.
|
||||||
|
#[command(name = "import-receipts-op")]
|
||||||
|
ImportReceiptsOp(ImportReceiptsOpCommand),
|
||||||
|
/// Dumps genesis block JSON configuration to stdout.
|
||||||
|
DumpGenesis(dump_genesis::DumpGenesisCommand),
|
||||||
|
/// Database debugging utilities
|
||||||
|
#[command(name = "db")]
|
||||||
|
Db(db::Command),
|
||||||
|
/// Manipulate individual stages.
|
||||||
|
#[command(name = "stage")]
|
||||||
|
Stage(stage::Command),
|
||||||
|
/// P2P Debugging utilities
|
||||||
|
#[command(name = "p2p")]
|
||||||
|
P2P(p2p::Command),
|
||||||
|
/// Write config to stdout
|
||||||
|
#[command(name = "config")]
|
||||||
|
Config(config_cmd::Command),
|
||||||
|
/// Scripts for node recovery
|
||||||
|
#[command(name = "recover")]
|
||||||
|
Recover(recover::Command),
|
||||||
|
/// Prune according to the configuration without any limits
|
||||||
|
#[command(name = "prune")]
|
||||||
|
Prune(prune::PruneCommand),
|
||||||
|
}
|
||||||
|
|||||||
@ -10,8 +10,79 @@
|
|||||||
// The `optimism` feature must be enabled to use this crate.
|
// The `optimism` feature must be enabled to use this crate.
|
||||||
#![cfg(feature = "optimism")]
|
#![cfg(feature = "optimism")]
|
||||||
|
|
||||||
|
use chainspec::OpChainSpecParser;
|
||||||
|
use clap::{command, value_parser, Parser};
|
||||||
|
use commands::Commands;
|
||||||
|
use reth_chainspec::ChainSpec;
|
||||||
|
use reth_cli::chainspec::ChainSpecParser;
|
||||||
|
use reth_cli_commands::node::NoArgs;
|
||||||
|
use reth_node_core::{
|
||||||
|
args::{utils::chain_help, LogArgs},
|
||||||
|
version::{LONG_VERSION, SHORT_VERSION},
|
||||||
|
};
|
||||||
|
use std::{ffi::OsString, fmt, sync::Arc};
|
||||||
|
|
||||||
/// Optimism chain specification parser.
|
/// Optimism chain specification parser.
|
||||||
pub mod chainspec;
|
pub mod chainspec;
|
||||||
/// Optimism CLI commands.
|
/// Optimism CLI commands.
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
pub use commands::{import::ImportOpCommand, import_receipts::ImportReceiptsOpCommand};
|
pub use commands::{import::ImportOpCommand, import_receipts::ImportReceiptsOpCommand};
|
||||||
|
|
||||||
|
/// The main reth cli interface.
|
||||||
|
///
|
||||||
|
/// 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<Ext: clap::Args + fmt::Debug = NoArgs> {
|
||||||
|
/// The command to run
|
||||||
|
#[command(subcommand)]
|
||||||
|
command: Commands<Ext>,
|
||||||
|
|
||||||
|
/// The chain this node is running.
|
||||||
|
///
|
||||||
|
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
value_name = "CHAIN_OR_PATH",
|
||||||
|
long_help = chain_help(),
|
||||||
|
default_value = OpChainSpecParser::SUPPORTED_CHAINS[0],
|
||||||
|
value_parser = OpChainSpecParser::default(),
|
||||||
|
global = true,
|
||||||
|
)]
|
||||||
|
chain: Arc<ChainSpec>,
|
||||||
|
|
||||||
|
/// Add a new instance of a node.
|
||||||
|
///
|
||||||
|
/// Configures the ports of the node to avoid conflicts with the defaults.
|
||||||
|
/// This is useful for running multiple nodes on the same machine.
|
||||||
|
///
|
||||||
|
/// Max number of instances is 200. It is chosen in a way so that it's not possible to have
|
||||||
|
/// port numbers that conflict with each other.
|
||||||
|
///
|
||||||
|
/// Changes to the following port numbers:
|
||||||
|
/// - `DISCOVERY_PORT`: default + `instance` - 1
|
||||||
|
/// - `AUTH_PORT`: default + `instance` * 100 - 100
|
||||||
|
/// - `HTTP_RPC_PORT`: default - `instance` + 1
|
||||||
|
/// - `WS_RPC_PORT`: default + `instance` * 2 - 2
|
||||||
|
#[arg(long, value_name = "INSTANCE", global = true, default_value_t = 1, value_parser = value_parser!(u16).range(..=200))]
|
||||||
|
instance: u16,
|
||||||
|
|
||||||
|
#[command(flatten)]
|
||||||
|
logs: LogArgs,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Cli {
|
||||||
|
/// Parsers only the default CLI arguments
|
||||||
|
pub fn parse_args() -> Self {
|
||||||
|
Self::parse()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parsers only the default CLI arguments from the given iterator
|
||||||
|
pub fn try_parse_args_from<I, T>(itr: I) -> Result<Self, clap::error::Error>
|
||||||
|
where
|
||||||
|
I: IntoIterator<Item = T>,
|
||||||
|
T: Into<OsString> + Clone,
|
||||||
|
{
|
||||||
|
Self::try_parse_from(itr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user