mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: extract cli runner from node-core (#7719)
This commit is contained in:
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -6090,6 +6090,7 @@ dependencies = [
|
|||||||
"reth-basic-payload-builder",
|
"reth-basic-payload-builder",
|
||||||
"reth-beacon-consensus",
|
"reth-beacon-consensus",
|
||||||
"reth-blockchain-tree",
|
"reth-blockchain-tree",
|
||||||
|
"reth-cli-runner",
|
||||||
"reth-config",
|
"reth-config",
|
||||||
"reth-consensus-common",
|
"reth-consensus-common",
|
||||||
"reth-db",
|
"reth-db",
|
||||||
@ -6244,6 +6245,16 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "reth-cli-runner"
|
||||||
|
version = "0.2.0-beta.5"
|
||||||
|
dependencies = [
|
||||||
|
"futures",
|
||||||
|
"reth-tasks",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reth-codecs"
|
name = "reth-codecs"
|
||||||
version = "0.2.0-beta.5"
|
version = "0.2.0-beta.5"
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
members = [
|
members = [
|
||||||
"bin/reth/",
|
"bin/reth/",
|
||||||
"crates/blockchain-tree/",
|
"crates/blockchain-tree/",
|
||||||
|
"crates/cli/runner/",
|
||||||
"crates/config/",
|
"crates/config/",
|
||||||
"crates/consensus/auto-seal/",
|
"crates/consensus/auto-seal/",
|
||||||
"crates/consensus/beacon/",
|
"crates/consensus/beacon/",
|
||||||
@ -202,6 +203,7 @@ reth-basic-payload-builder = { path = "crates/payload/basic" }
|
|||||||
reth-beacon-consensus = { path = "crates/consensus/beacon" }
|
reth-beacon-consensus = { path = "crates/consensus/beacon" }
|
||||||
reth-beacon-consensus-core = { path = "crates/consensus/beacon-core" }
|
reth-beacon-consensus-core = { path = "crates/consensus/beacon-core" }
|
||||||
reth-blockchain-tree = { path = "crates/blockchain-tree" }
|
reth-blockchain-tree = { path = "crates/blockchain-tree" }
|
||||||
|
reth-cli-runner = { path = "crates/cli/runner" }
|
||||||
reth-codecs = { path = "crates/storage/codecs" }
|
reth-codecs = { path = "crates/storage/codecs" }
|
||||||
reth-config = { path = "crates/config" }
|
reth-config = { path = "crates/config" }
|
||||||
reth-consensus-common = { path = "crates/consensus/common" }
|
reth-consensus-common = { path = "crates/consensus/common" }
|
||||||
|
|||||||
@ -24,6 +24,7 @@ reth-interfaces = { workspace = true, features = ["clap"] }
|
|||||||
reth-transaction-pool.workspace = true
|
reth-transaction-pool.workspace = true
|
||||||
reth-beacon-consensus.workspace = true
|
reth-beacon-consensus.workspace = true
|
||||||
reth-auto-seal-consensus.workspace = true
|
reth-auto-seal-consensus.workspace = true
|
||||||
|
reth-cli-runner.workspace = true
|
||||||
reth-consensus-common.workspace = true
|
reth-consensus-common.workspace = true
|
||||||
reth-blockchain-tree.workspace = true
|
reth-blockchain-tree.workspace = true
|
||||||
reth-rpc-engine-api.workspace = true
|
reth-rpc-engine-api.workspace = true
|
||||||
|
|||||||
@ -9,10 +9,10 @@ use crate::{
|
|||||||
config_cmd, db, debug_cmd, dump_genesis, import, init_cmd, node, node::NoArgs, p2p,
|
config_cmd, db, debug_cmd, dump_genesis, import, init_cmd, node, node::NoArgs, p2p,
|
||||||
recover, stage, test_vectors,
|
recover, stage, test_vectors,
|
||||||
},
|
},
|
||||||
core::cli::runner::CliRunner,
|
|
||||||
version::{LONG_VERSION, SHORT_VERSION},
|
version::{LONG_VERSION, SHORT_VERSION},
|
||||||
};
|
};
|
||||||
use clap::{value_parser, Parser, Subcommand};
|
use clap::{value_parser, Parser, Subcommand};
|
||||||
|
use reth_cli_runner::CliRunner;
|
||||||
use reth_db::DatabaseEnv;
|
use reth_db::DatabaseEnv;
|
||||||
use reth_node_builder::{InitState, WithLaunchContext};
|
use reth_node_builder::{InitState, WithLaunchContext};
|
||||||
use reth_primitives::ChainSpec;
|
use reth_primitives::ChainSpec;
|
||||||
|
|||||||
@ -5,7 +5,6 @@ use crate::{
|
|||||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||||
DatabaseArgs,
|
DatabaseArgs,
|
||||||
},
|
},
|
||||||
core::cli::runner::CliContext,
|
|
||||||
dirs::{DataDirPath, MaybePlatformPath},
|
dirs::{DataDirPath, MaybePlatformPath},
|
||||||
};
|
};
|
||||||
use alloy_rlp::Decodable;
|
use alloy_rlp::Decodable;
|
||||||
@ -18,6 +17,7 @@ use reth_beacon_consensus::BeaconConsensus;
|
|||||||
use reth_blockchain_tree::{
|
use reth_blockchain_tree::{
|
||||||
BlockchainTree, BlockchainTreeConfig, ShareableBlockchainTree, TreeExternals,
|
BlockchainTree, BlockchainTreeConfig, ShareableBlockchainTree, TreeExternals,
|
||||||
};
|
};
|
||||||
|
use reth_cli_runner::CliContext;
|
||||||
use reth_db::{init_db, DatabaseEnv};
|
use reth_db::{init_db, DatabaseEnv};
|
||||||
use reth_interfaces::{consensus::Consensus, RethResult};
|
use reth_interfaces::{consensus::Consensus, RethResult};
|
||||||
use reth_node_api::PayloadBuilderAttributes;
|
use reth_node_api::PayloadBuilderAttributes;
|
||||||
|
|||||||
@ -6,13 +6,13 @@ use crate::{
|
|||||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||||
DatabaseArgs, NetworkArgs,
|
DatabaseArgs, NetworkArgs,
|
||||||
},
|
},
|
||||||
core::cli::runner::CliContext,
|
|
||||||
dirs::{DataDirPath, MaybePlatformPath},
|
dirs::{DataDirPath, MaybePlatformPath},
|
||||||
utils::get_single_header,
|
utils::get_single_header,
|
||||||
};
|
};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use futures::{stream::select as stream_select, StreamExt};
|
use futures::{stream::select as stream_select, StreamExt};
|
||||||
use reth_beacon_consensus::BeaconConsensus;
|
use reth_beacon_consensus::BeaconConsensus;
|
||||||
|
use reth_cli_runner::CliContext;
|
||||||
use reth_config::{config::EtlConfig, Config};
|
use reth_config::{config::EtlConfig, Config};
|
||||||
use reth_db::{database::Database, init_db, DatabaseEnv};
|
use reth_db::{database::Database, init_db, DatabaseEnv};
|
||||||
use reth_downloaders::{
|
use reth_downloaders::{
|
||||||
|
|||||||
@ -6,12 +6,12 @@ use crate::{
|
|||||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||||
DatabaseArgs, NetworkArgs,
|
DatabaseArgs, NetworkArgs,
|
||||||
},
|
},
|
||||||
core::cli::runner::CliContext,
|
|
||||||
dirs::{DataDirPath, MaybePlatformPath},
|
dirs::{DataDirPath, MaybePlatformPath},
|
||||||
utils::{get_single_body, get_single_header},
|
utils::{get_single_body, get_single_header},
|
||||||
};
|
};
|
||||||
use backon::{ConstantBuilder, Retryable};
|
use backon::{ConstantBuilder, Retryable};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use reth_cli_runner::CliContext;
|
||||||
use reth_config::Config;
|
use reth_config::Config;
|
||||||
use reth_db::{init_db, DatabaseEnv};
|
use reth_db::{init_db, DatabaseEnv};
|
||||||
use reth_interfaces::executor::BlockValidationError;
|
use reth_interfaces::executor::BlockValidationError;
|
||||||
|
|||||||
@ -6,13 +6,13 @@ use crate::{
|
|||||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||||
DatabaseArgs, NetworkArgs,
|
DatabaseArgs, NetworkArgs,
|
||||||
},
|
},
|
||||||
core::cli::runner::CliContext,
|
|
||||||
dirs::{DataDirPath, MaybePlatformPath},
|
dirs::{DataDirPath, MaybePlatformPath},
|
||||||
utils::get_single_header,
|
utils::get_single_header,
|
||||||
};
|
};
|
||||||
use backon::{ConstantBuilder, Retryable};
|
use backon::{ConstantBuilder, Retryable};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use reth_beacon_consensus::BeaconConsensus;
|
use reth_beacon_consensus::BeaconConsensus;
|
||||||
|
use reth_cli_runner::CliContext;
|
||||||
use reth_config::Config;
|
use reth_config::Config;
|
||||||
use reth_db::{cursor::DbCursorRO, init_db, tables, transaction::DbTx, DatabaseEnv};
|
use reth_db::{cursor::DbCursorRO, init_db, tables, transaction::DbTx, DatabaseEnv};
|
||||||
use reth_interfaces::{consensus::Consensus, p2p::full_block::FullBlockClient};
|
use reth_interfaces::{consensus::Consensus, p2p::full_block::FullBlockClient};
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
//! `reth debug` command. Collection of various debugging routines.
|
//! `reth debug` command. Collection of various debugging routines.
|
||||||
|
|
||||||
use crate::core::cli::runner::CliContext;
|
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
use reth_cli_runner::CliContext;
|
||||||
|
|
||||||
mod build_block;
|
mod build_block;
|
||||||
mod execution;
|
mod execution;
|
||||||
mod in_memory_merkle;
|
mod in_memory_merkle;
|
||||||
|
|||||||
@ -4,7 +4,6 @@ use crate::{
|
|||||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||||
DatabaseArgs, NetworkArgs,
|
DatabaseArgs, NetworkArgs,
|
||||||
},
|
},
|
||||||
core::cli::runner::CliContext,
|
|
||||||
dirs::{DataDirPath, MaybePlatformPath},
|
dirs::{DataDirPath, MaybePlatformPath},
|
||||||
};
|
};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
@ -14,6 +13,7 @@ use reth_beacon_consensus::{hooks::EngineHooks, BeaconConsensus, BeaconConsensus
|
|||||||
use reth_blockchain_tree::{
|
use reth_blockchain_tree::{
|
||||||
BlockchainTree, BlockchainTreeConfig, ShareableBlockchainTree, TreeExternals,
|
BlockchainTree, BlockchainTreeConfig, ShareableBlockchainTree, TreeExternals,
|
||||||
};
|
};
|
||||||
|
use reth_cli_runner::CliContext;
|
||||||
use reth_config::Config;
|
use reth_config::Config;
|
||||||
use reth_db::{init_db, DatabaseEnv};
|
use reth_db::{init_db, DatabaseEnv};
|
||||||
use reth_interfaces::consensus::Consensus;
|
use reth_interfaces::consensus::Consensus;
|
||||||
|
|||||||
@ -6,10 +6,10 @@ use crate::{
|
|||||||
DatabaseArgs, DebugArgs, DevArgs, NetworkArgs, PayloadBuilderArgs, PruningArgs,
|
DatabaseArgs, DebugArgs, DevArgs, NetworkArgs, PayloadBuilderArgs, PruningArgs,
|
||||||
RpcServerArgs, TxPoolArgs,
|
RpcServerArgs, TxPoolArgs,
|
||||||
},
|
},
|
||||||
core::cli::runner::CliContext,
|
|
||||||
dirs::{DataDirPath, MaybePlatformPath},
|
dirs::{DataDirPath, MaybePlatformPath},
|
||||||
};
|
};
|
||||||
use clap::{value_parser, Args, Parser};
|
use clap::{value_parser, Args, Parser};
|
||||||
|
use reth_cli_runner::CliContext;
|
||||||
use reth_db::{init_db, DatabaseEnv};
|
use reth_db::{init_db, DatabaseEnv};
|
||||||
use reth_node_builder::{InitState, NodeBuilder, WithLaunchContext};
|
use reth_node_builder::{InitState, NodeBuilder, WithLaunchContext};
|
||||||
use reth_node_core::{node_config::NodeConfig, version};
|
use reth_node_core::{node_config::NodeConfig, version};
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
//! `reth recover` command.
|
//! `reth recover` command.
|
||||||
|
|
||||||
use crate::core::cli::runner::CliContext;
|
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
use reth_cli_runner::CliContext;
|
||||||
|
|
||||||
mod storage_tries;
|
mod storage_tries;
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
args::utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
args::utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||||
core::cli::runner::CliContext,
|
|
||||||
dirs::{DataDirPath, MaybePlatformPath},
|
dirs::{DataDirPath, MaybePlatformPath},
|
||||||
};
|
};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use reth_cli_runner::CliContext;
|
||||||
use reth_db::{
|
use reth_db::{
|
||||||
cursor::{DbCursorRO, DbDupCursorRW},
|
cursor::{DbCursorRO, DbDupCursorRW},
|
||||||
init_db, tables,
|
init_db, tables,
|
||||||
|
|||||||
@ -158,6 +158,10 @@ pub mod rpc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// re-export for convenience
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use reth_cli_runner::{tokio_runtime, CliContext, CliRunner};
|
||||||
|
|
||||||
#[cfg(all(unix, any(target_env = "gnu", target_os = "macos")))]
|
#[cfg(all(unix, any(target_env = "gnu", target_os = "macos")))]
|
||||||
pub mod sigsegv_handler;
|
pub mod sigsegv_handler;
|
||||||
|
|
||||||
|
|||||||
22
crates/cli/runner/Cargo.toml
Normal file
22
crates/cli/runner/Cargo.toml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[package]
|
||||||
|
name = "reth-cli-runner"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
homepage.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
# reth
|
||||||
|
reth-tasks.workspace = true
|
||||||
|
|
||||||
|
# async
|
||||||
|
futures.workspace = true
|
||||||
|
tokio = { workspace = true, features = ["macros", "rt-multi-thread", "signal"] }
|
||||||
|
|
||||||
|
# misc
|
||||||
|
tracing.workspace = true
|
||||||
@ -1,3 +1,13 @@
|
|||||||
|
//! A tokio based CLI runner.
|
||||||
|
|
||||||
|
#![doc(
|
||||||
|
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
|
||||||
|
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
|
||||||
|
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
|
||||||
|
)]
|
||||||
|
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||||
|
|
||||||
//! Entrypoint for running commands.
|
//! Entrypoint for running commands.
|
||||||
|
|
||||||
use futures::pin_mut;
|
use futures::pin_mut;
|
||||||
@ -6,6 +16,8 @@ use std::future::Future;
|
|||||||
use tracing::{debug, error, trace};
|
use tracing::{debug, error, trace};
|
||||||
|
|
||||||
/// Executes CLI commands.
|
/// Executes CLI commands.
|
||||||
|
///
|
||||||
|
/// Provides utilities for running a cli command to completion.
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct CliRunner;
|
pub struct CliRunner;
|
||||||
@ -1,4 +1,3 @@
|
|||||||
//! Additional CLI configuration support.
|
//! Additional CLI configuration support.
|
||||||
|
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod runner;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user