mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat(cli): override static files datadir (#7212)
Co-authored-by: Oliver Nordbjerg <onbjerg@users.noreply.github.com> Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com> Co-authored-by: Oliver Nordbjerg <hi@notbjerg.me>
This commit is contained in:
@ -5,7 +5,6 @@ use crate::{
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
utils::DbTool,
|
||||
};
|
||||
use clap::{Parser, Subcommand};
|
||||
@ -13,6 +12,7 @@ use reth_db::{
|
||||
open_db, open_db_read_only,
|
||||
version::{get_db_version, DatabaseVersionError, DB_VERSION},
|
||||
};
|
||||
use reth_node_core::args::DatadirArgs;
|
||||
use reth_primitives::ChainSpec;
|
||||
use reth_provider::{providers::StaticFileProvider, ProviderFactory};
|
||||
use std::{
|
||||
@ -32,16 +32,6 @@ mod tui;
|
||||
/// `reth db` command
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Command {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t, global = true)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -55,6 +45,9 @@ pub struct Command {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
|
||||
@ -105,7 +98,7 @@ impl Command {
|
||||
/// Execute `db` command
|
||||
pub async fn execute(self) -> eyre::Result<()> {
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.resolve_datadir(self.chain.chain);
|
||||
let db_path = data_dir.db();
|
||||
let db_args = self.db.database_args();
|
||||
let static_files_path = data_dir.static_files();
|
||||
@ -205,7 +198,7 @@ mod tests {
|
||||
#[test]
|
||||
fn parse_stats_globals() {
|
||||
let path = format!("../{}", SUPPORTED_CHAINS[0]);
|
||||
let cmd = Command::try_parse_from(["reth", "stats", "--datadir", &path]).unwrap();
|
||||
assert_eq!(cmd.datadir.as_ref(), Some(Path::new(&path)));
|
||||
let cmd = Command::try_parse_from(["reth", "--datadir", &path, "stats"]).unwrap();
|
||||
assert_eq!(cmd.datadir.resolve_datadir(cmd.chain.chain).as_ref(), Path::new(&path));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,9 +3,8 @@
|
||||
use crate::{
|
||||
args::{
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs,
|
||||
DatabaseArgs, DatadirArgs,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
macros::block_executor,
|
||||
};
|
||||
use alloy_rlp::Decodable;
|
||||
@ -53,16 +52,6 @@ use tracing::*;
|
||||
/// The script will then parse the block and attempt to build a similar one.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Command {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -75,6 +64,9 @@ pub struct Command {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
/// Database arguments.
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
@ -145,7 +137,7 @@ impl Command {
|
||||
/// Execute `debug in-memory-merkle` command
|
||||
pub async fn execute(self, ctx: CliContext) -> eyre::Result<()> {
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain);
|
||||
let db_path = data_dir.db();
|
||||
fs::create_dir_all(&db_path)?;
|
||||
|
||||
|
||||
@ -4,9 +4,8 @@ use crate::{
|
||||
args::{
|
||||
get_secret_key,
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs, NetworkArgs,
|
||||
DatabaseArgs, DatadirArgs, NetworkArgs,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
macros::block_executor,
|
||||
utils::get_single_header,
|
||||
};
|
||||
@ -48,16 +47,6 @@ use tracing::*;
|
||||
/// `reth debug execution` command
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Command {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -70,6 +59,9 @@ pub struct Command {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
network: NetworkArgs,
|
||||
|
||||
@ -165,7 +157,7 @@ impl Command {
|
||||
self.network.discovery.addr,
|
||||
self.network.discovery.port,
|
||||
))
|
||||
.build(provider_factory.clone())
|
||||
.build(provider_factory)
|
||||
.start_network()
|
||||
.await?;
|
||||
info!(target: "reth::cli", peer_id = %network.peer_id(), local_addr = %network.local_addr(), "Connected to P2P network");
|
||||
@ -196,7 +188,7 @@ impl Command {
|
||||
pub async fn execute(self, ctx: CliContext) -> eyre::Result<()> {
|
||||
let mut config = Config::default();
|
||||
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain);
|
||||
let db_path = data_dir.db();
|
||||
|
||||
// Make sure ETL doesn't default to /tmp/, but to whatever datadir is set to
|
||||
|
||||
@ -4,9 +4,8 @@ use crate::{
|
||||
args::{
|
||||
get_secret_key,
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs, NetworkArgs,
|
||||
DatabaseArgs, DatadirArgs, NetworkArgs,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
macros::block_executor,
|
||||
utils::{get_single_body, get_single_header},
|
||||
};
|
||||
@ -38,16 +37,6 @@ use tracing::*;
|
||||
/// merkle root for it.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Command {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -60,6 +49,9 @@ pub struct Command {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
|
||||
@ -107,7 +99,7 @@ impl Command {
|
||||
let config = Config::default();
|
||||
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain);
|
||||
let db_path = data_dir.db();
|
||||
fs::create_dir_all(&db_path)?;
|
||||
|
||||
|
||||
@ -4,9 +4,8 @@ use crate::{
|
||||
args::{
|
||||
get_secret_key,
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs, NetworkArgs,
|
||||
DatabaseArgs, DatadirArgs, NetworkArgs,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
macros::block_executor,
|
||||
utils::get_single_header,
|
||||
};
|
||||
@ -40,16 +39,6 @@ use tracing::*;
|
||||
/// `reth debug merkle` command
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Command {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -62,6 +51,9 @@ pub struct Command {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
|
||||
@ -100,7 +92,7 @@ impl Command {
|
||||
self.network.discovery.addr,
|
||||
self.network.discovery.port,
|
||||
))
|
||||
.build(provider_factory.clone())
|
||||
.build(provider_factory)
|
||||
.start_network()
|
||||
.await?;
|
||||
info!(target: "reth::cli", peer_id = %network.peer_id(), local_addr = %network.local_addr(), "Connected to P2P network");
|
||||
@ -113,7 +105,7 @@ impl Command {
|
||||
let config = Config::default();
|
||||
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain);
|
||||
let db_path = data_dir.db();
|
||||
fs::create_dir_all(&db_path)?;
|
||||
|
||||
|
||||
@ -2,9 +2,8 @@ use crate::{
|
||||
args::{
|
||||
get_secret_key,
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs, NetworkArgs,
|
||||
DatabaseArgs, DatadirArgs, NetworkArgs,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
macros::block_executor,
|
||||
};
|
||||
use clap::Parser;
|
||||
@ -41,16 +40,6 @@ use tracing::*;
|
||||
/// It does not require
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Command {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -63,6 +52,9 @@ pub struct Command {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
|
||||
@ -97,7 +89,7 @@ impl Command {
|
||||
self.network.discovery.addr,
|
||||
self.network.discovery.port,
|
||||
))
|
||||
.build(provider_factory.clone())
|
||||
.build(provider_factory)
|
||||
.start_network()
|
||||
.await?;
|
||||
info!(target: "reth::cli", peer_id = %network.peer_id(), local_addr = %network.local_addr(), "Connected to P2P network");
|
||||
@ -110,7 +102,7 @@ impl Command {
|
||||
let config = Config::default();
|
||||
|
||||
// Add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain);
|
||||
let db_path = data_dir.db();
|
||||
fs::create_dir_all(&db_path)?;
|
||||
|
||||
|
||||
@ -3,9 +3,8 @@
|
||||
use crate::{
|
||||
args::{
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs,
|
||||
DatabaseArgs, DatadirArgs,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
macros::block_executor,
|
||||
version::SHORT_VERSION,
|
||||
};
|
||||
@ -46,16 +45,6 @@ pub struct ImportCommand {
|
||||
#[arg(long, value_name = "FILE", verbatim_doc_comment)]
|
||||
config: Option<PathBuf>,
|
||||
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -76,6 +65,9 @@ pub struct ImportCommand {
|
||||
#[arg(long, value_name = "CHUNK_LEN", verbatim_doc_comment)]
|
||||
chunk_len: Option<u64>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
|
||||
@ -102,7 +94,7 @@ impl ImportCommand {
|
||||
);
|
||||
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.resolve_datadir(self.chain.chain);
|
||||
let config_path = self.config.clone().unwrap_or_else(|| data_dir.config());
|
||||
|
||||
let mut config: Config = load_config(config_path.clone())?;
|
||||
|
||||
@ -7,7 +7,6 @@ use crate::{
|
||||
DatabaseArgs,
|
||||
},
|
||||
commands::import::{build_import_pipeline, load_config},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
version::SHORT_VERSION,
|
||||
};
|
||||
use clap::Parser;
|
||||
@ -18,6 +17,7 @@ use reth_db_common::init::init_genesis;
|
||||
use reth_downloaders::file_client::{
|
||||
ChunkedFileReader, FileClient, DEFAULT_BYTE_LEN_CHUNK_CHAIN_FILE,
|
||||
};
|
||||
use reth_node_core::args::DatadirArgs;
|
||||
use reth_optimism_primitives::bedrock_import::is_dup_tx;
|
||||
use reth_primitives::{stage::StageId, PruneModes};
|
||||
use reth_provider::{
|
||||
@ -35,20 +35,13 @@ pub struct ImportOpCommand {
|
||||
#[arg(long, value_name = "FILE", verbatim_doc_comment)]
|
||||
config: Option<PathBuf>,
|
||||
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// Chunk byte length to read from file.
|
||||
#[arg(long, value_name = "CHUNK_LEN", verbatim_doc_comment)]
|
||||
chunk_len: Option<u64>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
|
||||
@ -77,7 +70,7 @@ impl ImportOpCommand {
|
||||
let chain_spec = genesis_value_parser(SUPPORTED_CHAINS[0])?;
|
||||
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(chain_spec.chain);
|
||||
let data_dir = self.datadir.resolve_datadir(chain_spec.chain);
|
||||
let config_path = self.config.clone().unwrap_or_else(|| data_dir.config());
|
||||
|
||||
let mut config: Config = load_config(config_path.clone())?;
|
||||
|
||||
@ -12,7 +12,7 @@ use reth_downloaders::{
|
||||
file_client::{ChunkedFileReader, DEFAULT_BYTE_LEN_CHUNK_CHAIN_FILE},
|
||||
receipt_file_client::ReceiptFileClient,
|
||||
};
|
||||
use reth_node_core::version::SHORT_VERSION;
|
||||
use reth_node_core::{args::DatadirArgs, version::SHORT_VERSION};
|
||||
use reth_optimism_primitives::bedrock_import::is_dup_tx;
|
||||
use reth_primitives::{stage::StageId, Receipts, StaticFileSegment};
|
||||
use reth_provider::{
|
||||
@ -21,26 +21,16 @@ use reth_provider::{
|
||||
};
|
||||
use tracing::{debug, error, info, trace};
|
||||
|
||||
use crate::{
|
||||
args::{
|
||||
utils::{genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
use crate::args::{
|
||||
utils::{genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs,
|
||||
};
|
||||
|
||||
/// Initializes the database with the genesis block.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct ImportReceiptsOpCommand {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
/// Chunk byte length to read from file.
|
||||
#[arg(long, value_name = "CHUNK_LEN", verbatim_doc_comment)]
|
||||
@ -70,7 +60,7 @@ impl ImportReceiptsOpCommand {
|
||||
let chain_spec = genesis_value_parser(SUPPORTED_CHAINS[0])?;
|
||||
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(chain_spec.chain);
|
||||
let data_dir = self.datadir.resolve_datadir(chain_spec.chain);
|
||||
|
||||
let db_path = data_dir.db();
|
||||
info!(target: "reth::cli", path = ?db_path, "Opening database");
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
//! Command that initializes the node from a genesis file.
|
||||
|
||||
use crate::{
|
||||
args::{
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
use crate::args::{
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs, DatadirArgs,
|
||||
};
|
||||
use clap::Parser;
|
||||
use reth_db::init_db;
|
||||
@ -18,16 +15,6 @@ use tracing::info;
|
||||
/// Initializes the database with the genesis block.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct InitCommand {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -40,6 +27,9 @@ pub struct InitCommand {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
}
|
||||
@ -50,9 +40,9 @@ impl InitCommand {
|
||||
info!(target: "reth::cli", "reth init starting");
|
||||
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.resolve_datadir(self.chain.chain);
|
||||
let db_path = data_dir.db();
|
||||
info!(target: "reth::cli", path = ?db_path, "Opening database");
|
||||
info!(target: "reth::cl", path = ?db_path, "Opening database");
|
||||
let db = Arc::new(init_db(&db_path, self.db.database_args())?);
|
||||
info!(target: "reth::cli", "Database opened");
|
||||
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
//! Command that initializes the node from a genesis file.
|
||||
|
||||
use crate::{
|
||||
args::{
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
use crate::args::{
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs,
|
||||
};
|
||||
use clap::Parser;
|
||||
use reth_config::config::EtlConfig;
|
||||
use reth_db::{database::Database, init_db};
|
||||
use reth_db_common::init::init_from_state_dump;
|
||||
use reth_node_core::args::DatadirArgs;
|
||||
use reth_primitives::{ChainSpec, B256};
|
||||
use reth_provider::{providers::StaticFileProvider, ProviderFactory};
|
||||
|
||||
@ -20,16 +18,6 @@ use tracing::info;
|
||||
/// Initializes the database with the genesis block.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct InitStateCommand {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -42,6 +30,9 @@ pub struct InitStateCommand {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
/// JSONL file with state dump.
|
||||
///
|
||||
/// Must contain accounts in following format, additional account fields are ignored. Must
|
||||
@ -72,7 +63,7 @@ impl InitStateCommand {
|
||||
info!(target: "reth::cli", "Reth init-state starting");
|
||||
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.resolve_datadir(self.chain.chain);
|
||||
let db_path = data_dir.db();
|
||||
info!(target: "reth::cli", path = ?db_path, "Opening database");
|
||||
let db = Arc::new(init_db(&db_path, self.db.database_args())?);
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
//! Main node command for launching a node
|
||||
|
||||
use crate::{
|
||||
args::{
|
||||
utils::{chain_help, genesis_value_parser, parse_socket_address, SUPPORTED_CHAINS},
|
||||
DatabaseArgs, DebugArgs, DevArgs, NetworkArgs, PayloadBuilderArgs, PruningArgs,
|
||||
RpcServerArgs, TxPoolArgs,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
use crate::args::{
|
||||
utils::{chain_help, genesis_value_parser, parse_socket_address, SUPPORTED_CHAINS},
|
||||
DatabaseArgs, DatadirArgs, DebugArgs, DevArgs, NetworkArgs, PayloadBuilderArgs, PruningArgs,
|
||||
RpcServerArgs, TxPoolArgs,
|
||||
};
|
||||
use clap::{value_parser, Args, Parser};
|
||||
use reth_cli_runner::CliContext;
|
||||
@ -19,16 +16,6 @@ use std::{ffi::OsString, fmt, future::Future, net::SocketAddr, path::PathBuf, sy
|
||||
/// Start the node
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct NodeCommand<Ext: clap::Args + fmt::Debug = NoArgs> {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
pub datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The path to the configuration file to use.
|
||||
#[arg(long, value_name = "FILE", verbatim_doc_comment)]
|
||||
pub config: Option<PathBuf>,
|
||||
@ -76,6 +63,10 @@ pub struct NodeCommand<Ext: clap::Args + fmt::Debug = NoArgs> {
|
||||
#[arg(long, conflicts_with = "instance", global = true)]
|
||||
pub with_unused_ports: bool,
|
||||
|
||||
/// All datadir related arguments
|
||||
#[command(flatten)]
|
||||
pub datadir: DatadirArgs,
|
||||
|
||||
/// All networking related arguments
|
||||
#[command(flatten)]
|
||||
pub network: NetworkArgs,
|
||||
@ -161,6 +152,7 @@ impl<Ext: clap::Args + fmt::Debug> NodeCommand<Ext> {
|
||||
|
||||
// set up node config
|
||||
let mut node_config = NodeConfig {
|
||||
datadir,
|
||||
config,
|
||||
chain,
|
||||
metrics,
|
||||
@ -179,7 +171,7 @@ impl<Ext: clap::Args + fmt::Debug> NodeCommand<Ext> {
|
||||
// because database init needs it to register metrics.
|
||||
let _ = node_config.install_prometheus_recorder()?;
|
||||
|
||||
let data_dir = datadir.unwrap_or_chain_default(node_config.chain.chain);
|
||||
let data_dir = node_config.datadir();
|
||||
let db_path = data_dir.db();
|
||||
|
||||
tracing::info!(target: "reth::cli", path = ?db_path, "Opening database");
|
||||
@ -279,30 +271,32 @@ mod tests {
|
||||
let cmd =
|
||||
NodeCommand::try_parse_args_from(["reth", "--config", "my/path/to/reth.toml"]).unwrap();
|
||||
// always store reth.toml in the data dir, not the chain specific data dir
|
||||
let data_dir = cmd.datadir.unwrap_or_chain_default(cmd.chain.chain);
|
||||
let data_dir = cmd.datadir.resolve_datadir(cmd.chain.chain);
|
||||
let config_path = cmd.config.unwrap_or_else(|| data_dir.config());
|
||||
assert_eq!(config_path, Path::new("my/path/to/reth.toml"));
|
||||
|
||||
let cmd = NodeCommand::try_parse_args_from(["reth"]).unwrap();
|
||||
|
||||
// always store reth.toml in the data dir, not the chain specific data dir
|
||||
let data_dir = cmd.datadir.unwrap_or_chain_default(cmd.chain.chain);
|
||||
let data_dir = cmd.datadir.resolve_datadir(cmd.chain.chain);
|
||||
let config_path = cmd.config.clone().unwrap_or_else(|| data_dir.config());
|
||||
let end = format!("reth/{}/reth.toml", SUPPORTED_CHAINS[0]);
|
||||
let end = format!("{}/reth.toml", SUPPORTED_CHAINS[0]);
|
||||
assert!(config_path.ends_with(end), "{:?}", cmd.config);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_db_path() {
|
||||
let cmd = NodeCommand::try_parse_args_from(["reth"]).unwrap();
|
||||
let data_dir = cmd.datadir.unwrap_or_chain_default(cmd.chain.chain);
|
||||
let data_dir = cmd.datadir.resolve_datadir(cmd.chain.chain);
|
||||
|
||||
let db_path = data_dir.db();
|
||||
let end = format!("reth/{}/db", SUPPORTED_CHAINS[0]);
|
||||
assert!(db_path.ends_with(end), "{:?}", cmd.config);
|
||||
|
||||
let cmd =
|
||||
NodeCommand::try_parse_args_from(["reth", "--datadir", "my/custom/path"]).unwrap();
|
||||
let data_dir = cmd.datadir.unwrap_or_chain_default(cmd.chain.chain);
|
||||
let data_dir = cmd.datadir.resolve_datadir(cmd.chain.chain);
|
||||
|
||||
let db_path = data_dir.db();
|
||||
assert_eq!(db_path, Path::new("my/custom/path/db"));
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ use crate::{
|
||||
utils::{chain_help, chain_spec_value_parser, hash_or_num_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs, DiscoveryArgs, NetworkArgs,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
utils::get_single_header,
|
||||
};
|
||||
use backon::{ConstantBuilder, Retryable};
|
||||
@ -16,6 +15,7 @@ use reth_config::Config;
|
||||
use reth_db::create_db;
|
||||
use reth_network::NetworkConfigBuilder;
|
||||
use reth_network_p2p::bodies::client::BodiesClient;
|
||||
use reth_node_core::args::DatadirArgs;
|
||||
use reth_primitives::{BlockHashOrNumber, ChainSpec};
|
||||
use reth_provider::{providers::StaticFileProvider, ProviderFactory};
|
||||
use std::{
|
||||
@ -43,24 +43,16 @@ pub struct Command {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// Disable the discovery service.
|
||||
#[command(flatten)]
|
||||
pub network: NetworkArgs,
|
||||
|
||||
/// The number of retries per request
|
||||
#[arg(long, default_value = "5")]
|
||||
retries: usize,
|
||||
|
||||
#[command(flatten)]
|
||||
network: NetworkArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
|
||||
@ -91,7 +83,7 @@ impl Command {
|
||||
let noop_db = Arc::new(create_db(tempdir.into_path(), self.db.database_args())?);
|
||||
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain);
|
||||
let config_path = self.config.clone().unwrap_or_else(|| data_dir.config());
|
||||
|
||||
let mut config: Config = confy::load_path(&config_path).unwrap_or_default();
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
use crate::{
|
||||
args::utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
};
|
||||
use crate::args::utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS};
|
||||
use clap::Parser;
|
||||
use reth_cli_runner::CliContext;
|
||||
use reth_db::{
|
||||
@ -10,7 +7,7 @@ use reth_db::{
|
||||
transaction::DbTx,
|
||||
};
|
||||
use reth_db_common::init::init_genesis;
|
||||
use reth_node_core::args::DatabaseArgs;
|
||||
use reth_node_core::args::{DatabaseArgs, DatadirArgs};
|
||||
use reth_primitives::ChainSpec;
|
||||
use reth_provider::{
|
||||
providers::StaticFileProvider, BlockNumReader, HeaderProvider, ProviderError, ProviderFactory,
|
||||
@ -22,16 +19,6 @@ use tracing::*;
|
||||
/// `reth recover storage-tries` command
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Command {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -44,6 +31,9 @@ pub struct Command {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
/// All database related arguments
|
||||
#[command(flatten)]
|
||||
pub db: DatabaseArgs,
|
||||
@ -52,7 +42,7 @@ pub struct Command {
|
||||
impl Command {
|
||||
/// Execute `storage-tries` recovery command
|
||||
pub async fn execute(self, _ctx: CliContext) -> eyre::Result<()> {
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.resolve_datadir(self.chain.chain);
|
||||
let db_path = data_dir.db();
|
||||
fs::create_dir_all(&db_path)?;
|
||||
let db = Arc::new(init_db(db_path, self.db.database_args())?);
|
||||
|
||||
@ -3,9 +3,8 @@
|
||||
use crate::{
|
||||
args::{
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs, StageEnum,
|
||||
DatabaseArgs, DatadirArgs, StageEnum,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
utils::DbTool,
|
||||
};
|
||||
use clap::Parser;
|
||||
@ -25,16 +24,6 @@ use std::sync::Arc;
|
||||
/// `reth drop-stage` command
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Command {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -47,6 +36,9 @@ pub struct Command {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
|
||||
@ -57,7 +49,7 @@ impl Command {
|
||||
/// Execute `db` command
|
||||
pub async fn execute(self) -> eyre::Result<()> {
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.resolve_datadir(self.chain.chain);
|
||||
let db_path = data_dir.db();
|
||||
fs::create_dir_all(&db_path)?;
|
||||
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
//! Database debugging tool
|
||||
|
||||
use crate::{
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
utils::DbTool,
|
||||
};
|
||||
use crate::{dirs::DataDirPath, utils::DbTool};
|
||||
|
||||
use crate::args::{
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs,
|
||||
DatabaseArgs, DatadirArgs,
|
||||
};
|
||||
use clap::Parser;
|
||||
use reth_db::{
|
||||
@ -36,16 +33,6 @@ use merkle::dump_merkle_stage;
|
||||
/// `reth dump-stage` command
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Command {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -58,6 +45,9 @@ pub struct Command {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
|
||||
@ -101,7 +91,7 @@ impl Command {
|
||||
/// Execute `dump-stage` command
|
||||
pub async fn execute(self) -> eyre::Result<()> {
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain);
|
||||
let db_path = data_dir.db();
|
||||
info!(target: "reth::cli", path = ?db_path, "Opening database");
|
||||
let db = Arc::new(open_db_read_only(&db_path, self.db.database_args())?);
|
||||
@ -121,7 +111,7 @@ impl Command {
|
||||
&tool,
|
||||
*from,
|
||||
*to,
|
||||
output_datadir.with_chain(self.chain.chain),
|
||||
output_datadir.with_chain(self.chain.chain, self.datadir.clone()),
|
||||
*dry_run,
|
||||
)
|
||||
.await?
|
||||
@ -131,7 +121,7 @@ impl Command {
|
||||
&tool,
|
||||
*from,
|
||||
*to,
|
||||
output_datadir.with_chain(self.chain.chain),
|
||||
output_datadir.with_chain(self.chain.chain, self.datadir.clone()),
|
||||
*dry_run,
|
||||
)
|
||||
.await?
|
||||
@ -141,7 +131,7 @@ impl Command {
|
||||
&tool,
|
||||
*from,
|
||||
*to,
|
||||
output_datadir.with_chain(self.chain.chain),
|
||||
output_datadir.with_chain(self.chain.chain, self.datadir.clone()),
|
||||
*dry_run,
|
||||
)
|
||||
.await?
|
||||
@ -151,7 +141,7 @@ impl Command {
|
||||
&tool,
|
||||
*from,
|
||||
*to,
|
||||
output_datadir.with_chain(self.chain.chain),
|
||||
output_datadir.with_chain(self.chain.chain, self.datadir.clone()),
|
||||
*dry_run,
|
||||
)
|
||||
.await?
|
||||
|
||||
@ -6,9 +6,8 @@ use crate::{
|
||||
args::{
|
||||
get_secret_key,
|
||||
utils::{chain_help, chain_spec_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs, NetworkArgs, StageEnum,
|
||||
DatabaseArgs, DatadirArgs, NetworkArgs, StageEnum,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
macros::block_executor,
|
||||
prometheus_exporter,
|
||||
version::SHORT_VERSION,
|
||||
@ -46,16 +45,6 @@ pub struct Command {
|
||||
#[arg(long, value_name = "FILE", verbatim_doc_comment)]
|
||||
config: Option<PathBuf>,
|
||||
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -106,12 +95,6 @@ pub struct Command {
|
||||
#[arg(long, short)]
|
||||
skip_unwind: bool,
|
||||
|
||||
#[command(flatten)]
|
||||
network: NetworkArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
|
||||
/// Commits the changes in the database. WARNING: potentially destructive.
|
||||
///
|
||||
/// Useful when you want to run diagnostics on the database.
|
||||
@ -123,6 +106,15 @@ pub struct Command {
|
||||
/// Save stage checkpoints
|
||||
#[arg(long)]
|
||||
checkpoints: bool,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
network: NetworkArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
}
|
||||
|
||||
impl Command {
|
||||
@ -133,7 +125,7 @@ impl Command {
|
||||
let _ = fdlimit::raise_fd_limit();
|
||||
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.resolve_datadir(self.chain.chain);
|
||||
let config_path = self.config.clone().unwrap_or_else(|| data_dir.config());
|
||||
|
||||
let config: Config = confy::load_path(config_path).unwrap_or_default();
|
||||
|
||||
@ -26,25 +26,14 @@ use tracing::info;
|
||||
use crate::{
|
||||
args::{
|
||||
utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs,
|
||||
DatabaseArgs, DatadirArgs,
|
||||
},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
macros::block_executor,
|
||||
};
|
||||
|
||||
/// `reth stage unwind` command
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Command {
|
||||
/// The path to the data dir for all reth files and subdirectories.
|
||||
///
|
||||
/// Defaults to the OS-specific data directory:
|
||||
///
|
||||
/// - Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
|
||||
/// - Windows: `{FOLDERID_RoamingAppData}/reth/`
|
||||
/// - macOS: `$HOME/Library/Application Support/reth/`
|
||||
#[arg(long, value_name = "DATA_DIR", verbatim_doc_comment, default_value_t, global = true)]
|
||||
datadir: MaybePlatformPath<DataDirPath>,
|
||||
|
||||
/// The chain this node is running.
|
||||
///
|
||||
/// Possible values are either a built-in chain or the path to a chain specification file.
|
||||
@ -58,6 +47,9 @@ pub struct Command {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
#[command(flatten)]
|
||||
datadir: DatadirArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
db: DatabaseArgs,
|
||||
|
||||
@ -72,7 +64,7 @@ impl Command {
|
||||
/// Execute `db stage unwind` command
|
||||
pub async fn execute(self) -> eyre::Result<()> {
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain);
|
||||
let db_path = data_dir.db();
|
||||
if !db_path.exists() {
|
||||
eyre::bail!("Database {db_path:?} does not exist.")
|
||||
|
||||
Reference in New Issue
Block a user