Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: extract db commands #9217

Merged
merged 8 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 7 additions & 20 deletions bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ reth-fs-util.workspace = true
reth-db = { workspace = true, features = ["mdbx"] }
reth-db-api.workspace = true
reth-exex.workspace = true
reth-provider = { workspace = true }
reth-provider.workspace = true
reth-evm.workspace = true
reth-revm.workspace = true
reth-stages.workspace = true
Expand All @@ -30,6 +30,7 @@ reth-errors.workspace = true
reth-transaction-pool.workspace = true
reth-beacon-consensus.workspace = true
reth-cli-runner.workspace = true
reth-cli-commands.workspace = true
reth-consensus-common.workspace = true
reth-blockchain-tree.workspace = true
reth-rpc-builder.workspace = true
Expand All @@ -39,34 +40,29 @@ reth-rpc-types-compat.workspace = true
reth-rpc-api = { workspace = true, features = ["client"] }
reth-network = { workspace = true, features = ["serde"] }
reth-network-p2p.workspace = true
reth-net-banlist.workspace = true
reth-network-api.workspace = true
reth-downloaders.workspace = true
reth-tracing.workspace = true
reth-tasks.workspace = true
reth-ethereum-payload-builder.workspace = true
reth-payload-builder.workspace = true
reth-payload-primitives.workspace = true
reth-payload-validator.workspace = true
reth-basic-payload-builder.workspace = true
reth-discv4.workspace = true
reth-discv5.workspace = true
reth-static-file.workspace = true
reth-static-file-types = { workspace = true, features = ["clap"] }
reth-trie = { workspace = true, features = ["metrics"] }
reth-nippy-jar.workspace = true
reth-node-api.workspace = true
reth-node-ethereum.workspace = true
reth-node-optimism = { workspace = true, optional = true, features = [
"optimism",
] }
reth-node-core.workspace = true
reth-ethereum-payload-builder.workspace = true
reth-db-common.workspace = true
reth-node-ethereum.workspace = true
reth-node-builder.workspace = true
reth-node-events.workspace = true
reth-consensus.workspace = true
reth-optimism-primitives.workspace = true
reth-prune-types.workspace = true
reth-engine-util.workspace = true
reth-prune.workspace = true

Expand All @@ -90,15 +86,7 @@ metrics-process.workspace = true
proptest.workspace = true
arbitrary.workspace = true
proptest-arbitrary-interop.workspace = true
rand.workspace = true

# tui
comfy-table = "7.1"
crossterm = "0.27.0"
ratatui = { version = "0.27", default-features = false, features = [
"crossterm",
] }
human_bytes = "0.4.1"

# async
tokio = { workspace = true, features = [
Expand All @@ -117,8 +105,6 @@ tempfile.workspace = true
backon.workspace = true
similar-asserts.workspace = true
itertools.workspace = true
rayon.workspace = true
ahash = "0.8"

# p2p
discv5.workspace = true
Expand All @@ -128,8 +114,9 @@ tikv-jemallocator = { version = "0.5.0", optional = true }
libc = "0.2"

[dev-dependencies]
jsonrpsee.workspace = true
assert_matches = "1.5.0"
reth-discv4.workspace = true



[features]
default = ["jemalloc"]
Expand Down
3 changes: 2 additions & 1 deletion bin/reth/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ use crate::{
LogArgs,
},
commands::{
config_cmd, db, debug_cmd, dump_genesis, import, init_cmd, init_state,
config_cmd, debug_cmd, dump_genesis, import, init_cmd, init_state,
node::{self, NoArgs},
p2p, prune, recover, stage, test_vectors,
},
version::{LONG_VERSION, SHORT_VERSION},
};
use clap::{value_parser, Parser, Subcommand};
use reth_chainspec::ChainSpec;
use reth_cli_commands::db;
use reth_cli_runner::CliRunner;
use reth_db::DatabaseEnv;
use reth_node_builder::{NodeBuilder, WithLaunchContext};
Expand Down
7 changes: 2 additions & 5 deletions bin/reth/src/commands/debug_cmd/build_block.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
//! Command for debugging block building.

use crate::{
commands::common::{AccessRights, Environment, EnvironmentArgs},
macros::block_executor,
};
use crate::macros::block_executor;
use alloy_rlp::Decodable;
use clap::Parser;
use eyre::Context;
Expand All @@ -14,6 +10,7 @@ use reth_beacon_consensus::EthBeaconConsensus;
use reth_blockchain_tree::{
BlockchainTree, BlockchainTreeConfig, ShareableBlockchainTree, TreeExternals,
};
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
use reth_cli_runner::CliContext;
use reth_consensus::Consensus;
use reth_db::DatabaseEnv;
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/commands/debug_cmd/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

use crate::{
args::{get_secret_key, NetworkArgs},
commands::common::{AccessRights, Environment, EnvironmentArgs},
macros::block_executor,
utils::get_single_header,
};
use clap::Parser;
use futures::{stream::select as stream_select, StreamExt};
use reth_beacon_consensus::EthBeaconConsensus;
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
use reth_cli_runner::CliContext;
use reth_config::Config;
use reth_consensus::Consensus;
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/commands/debug_cmd/in_memory_merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

use crate::{
args::{get_secret_key, NetworkArgs},
commands::common::{AccessRights, Environment, EnvironmentArgs},
macros::block_executor,
utils::{get_single_body, get_single_header},
};
use backon::{ConstantBuilder, Retryable};
use clap::Parser;
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
use reth_cli_runner::CliContext;
use reth_config::Config;
use reth_db::DatabaseEnv;
Expand Down
3 changes: 1 addition & 2 deletions bin/reth/src/commands/debug_cmd/merkle.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
//! Command for debugging merkle trie calculation.

use crate::{
args::{get_secret_key, NetworkArgs},
commands::common::{AccessRights, Environment, EnvironmentArgs},
macros::block_executor,
utils::get_single_header,
};
use backon::{ConstantBuilder, Retryable};
use clap::Parser;
use reth_beacon_consensus::EthBeaconConsensus;
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
use reth_cli_runner::CliContext;
use reth_config::Config;
use reth_consensus::Consensus;
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/commands/debug_cmd/replay_engine.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{
args::{get_secret_key, NetworkArgs},
commands::common::{AccessRights, Environment, EnvironmentArgs},
macros::block_executor,
};
use clap::Parser;
Expand All @@ -10,6 +9,7 @@ use reth_beacon_consensus::{hooks::EngineHooks, BeaconConsensusEngine, EthBeacon
use reth_blockchain_tree::{
BlockchainTree, BlockchainTreeConfig, ShareableBlockchainTree, TreeExternals,
};
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
use reth_cli_runner::CliContext;
use reth_config::Config;
use reth_consensus::Consensus;
Expand Down
8 changes: 2 additions & 6 deletions bin/reth/src/commands/import.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
//! Command that initializes the node by importing a chain from a file.

use crate::{
commands::common::{AccessRights, Environment, EnvironmentArgs},
macros::block_executor,
version::SHORT_VERSION,
};
use crate::{macros::block_executor, version::SHORT_VERSION};
use clap::Parser;
use futures::{Stream, StreamExt};
use reth_beacon_consensus::EthBeaconConsensus;
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
use reth_config::Config;
use reth_consensus::Consensus;
use reth_db::tables;
Expand Down
10 changes: 2 additions & 8 deletions bin/reth/src/commands/import_op.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
//! Command that initializes the node by importing OP Mainnet chain segment below Bedrock, from a
//! file.

use crate::{
commands::{
common::{AccessRights, Environment, EnvironmentArgs},
import::build_import_pipeline,
},
version::SHORT_VERSION,
};
use crate::{commands::import::build_import_pipeline, version::SHORT_VERSION};
use clap::Parser;
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
use reth_consensus::noop::NoopConsensus;
use reth_db::tables;
use reth_db_api::transaction::DbTx;
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/commands/import_receipts_op.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Command that imports OP mainnet receipts from Bedrock datadir, exported via
//! <https://github.com/testinprod-io/op-geth/pull/1>.

use crate::commands::common::{AccessRights, Environment, EnvironmentArgs};
use clap::Parser;
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
use reth_db::tables;
use reth_db_api::{database::Database, transaction::DbTx};
use reth_downloaders::{
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/commands/init_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Command that initializes the node from a genesis file.

use crate::commands::common::{AccessRights, Environment, EnvironmentArgs};
use clap::Parser;
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
use reth_provider::BlockHashReader;
use tracing::info;

Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/commands/init_state.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Command that initializes the node from a genesis file.

use crate::commands::common::{AccessRights, Environment, EnvironmentArgs};
use clap::Parser;
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
use reth_config::config::EtlConfig;
use reth_db_api::database::Database;
use reth_db_common::init::init_from_state_dump;
Expand Down
3 changes: 0 additions & 3 deletions bin/reth/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! This contains all of the `reth` commands

pub mod config_cmd;
pub mod db;
pub mod debug_cmd;
pub mod dump_genesis;
pub mod import;
Expand All @@ -15,5 +14,3 @@ pub mod prune;
pub mod recover;
pub mod stage;
pub mod test_vectors;

pub mod common;
3 changes: 1 addition & 2 deletions bin/reth/src/commands/prune.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Command that runs pruning without any limits.

use crate::commands::common::{AccessRights, Environment, EnvironmentArgs};
use clap::Parser;
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
use reth_prune::PrunerBuilder;
use reth_static_file::StaticFileProducer;
use tracing::info;
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/commands/recover/storage_tries.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::commands::common::{AccessRights, Environment, EnvironmentArgs};
use clap::Parser;
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
use reth_cli_runner::CliContext;
use reth_db::tables;
use reth_db_api::{
Expand Down
7 changes: 2 additions & 5 deletions bin/reth/src/commands/stage/drop.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
//! Database debugging tool

use crate::{
args::StageEnum,
commands::common::{AccessRights, Environment, EnvironmentArgs},
};
use crate::args::StageEnum;
use clap::Parser;
use itertools::Itertools;
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
use reth_db::{static_file::iter_static_files, tables, DatabaseEnv};
use reth_db_api::transaction::DbTxMut;
use reth_db_common::{
Expand Down
Loading
Loading