feat: reth-config crate (#2825)

This commit is contained in:
byyou
2023-05-26 13:56:28 +00:00
committed by GitHub
parent 1176754d6e
commit 0caf051869
15 changed files with 80 additions and 35 deletions

16
Cargo.lock generated
View File

@ -4595,6 +4595,7 @@ dependencies = [
"reth-basic-payload-builder",
"reth-beacon-consensus",
"reth-blockchain-tree",
"reth-config",
"reth-db",
"reth-discv4",
"reth-downloaders",
@ -4723,6 +4724,21 @@ dependencies = [
"test-fuzz",
]
[[package]]
name = "reth-config"
version = "0.1.0"
dependencies = [
"confy",
"reth-discv4",
"reth-downloaders",
"reth-net-nat",
"reth-network",
"secp256k1",
"serde",
"serde_json",
"tempfile",
]
[[package]]
name = "reth-consensus-common"
version = "0.1.0"

View File

@ -1,6 +1,7 @@
[workspace]
members = [
"bin/reth",
"crates/config",
"crates/consensus/auto-seal",
"crates/consensus/beacon",
"crates/consensus/common",

View File

@ -9,6 +9,7 @@ build = "build.rs"
[dependencies]
# reth
reth-config = { path = "../../crates/config" }
reth-primitives = { path = "../../crates/primitives", features = ["arbitrary"] }
reth-db = { path = "../../crates/storage/db", features = ["mdbx", "test-utils"] }
# TODO: Temporary use of the test-utils feature
@ -92,4 +93,4 @@ jemalloc = ["dep:jemallocator"]
only-info-logs = ["tracing/release_max_level_info"]
[build-dependencies]
vergen = { version = "8.0.0", features = ["build", "cargo", "git", "gitcl"] }
vergen = { version = "8.0.0", features = ["build", "cargo", "git", "gitcl"] }

View File

@ -2,10 +2,10 @@
use crate::version::P2P_CLIENT_VERSION;
use clap::Args;
use reth_config::Config;
use reth_net_nat::NatResolver;
use reth_network::{HelloMessage, NetworkConfigBuilder};
use reth_primitives::{mainnet_nodes, ChainSpec, NodeRecord};
use reth_staged_sync::Config;
use secp256k1::SecretKey;
use std::{path::PathBuf, sync::Arc};

View File

@ -8,6 +8,7 @@ use eyre::Context;
use futures::{Stream, StreamExt};
use reth_beacon_consensus::BeaconConsensus;
use reth_config::Config;
use reth_db::database::Database;
use reth_downloaders::{
bodies::bodies::BodiesDownloaderBuilder,
@ -15,12 +16,9 @@ use reth_downloaders::{
};
use reth_interfaces::consensus::Consensus;
use reth_primitives::{ChainSpec, H256};
use reth_staged_sync::{
utils::{
chainspec::genesis_value_parser,
init::{init_db, init_genesis},
},
Config,
use reth_staged_sync::utils::{
chainspec::genesis_value_parser,
init::{init_db, init_genesis},
};
use reth_stages::{
prelude::*,

View File

@ -3,7 +3,7 @@ use std::path::PathBuf;
use clap::Parser;
use eyre::{bail, WrapErr};
use reth_staged_sync::Config;
use reth_config::Config;
/// `reth config` command
#[derive(Debug, Parser)]

View File

@ -9,6 +9,7 @@ use crate::{
use clap::Parser;
use futures::{stream::select as stream_select, StreamExt};
use reth_beacon_consensus::BeaconConsensus;
use reth_config::Config;
use reth_db::{
database::Database,
mdbx::{Env, WriteMap},
@ -26,12 +27,9 @@ use reth_network::NetworkHandle;
use reth_network_api::NetworkInfo;
use reth_primitives::{BlockHashOrNumber, BlockNumber, ChainSpec, H256};
use reth_provider::{ShareableDatabase, Transaction};
use reth_staged_sync::{
utils::{
chainspec::genesis_value_parser,
init::{init_db, init_genesis},
},
Config,
use reth_staged_sync::utils::{
chainspec::genesis_value_parser,
init::{init_db, init_genesis},
};
use reth_stages::{
sets::DefaultStages,

View File

@ -19,6 +19,7 @@ use reth_beacon_consensus::{BeaconConsensus, BeaconConsensusEngine};
use reth_blockchain_tree::{
config::BlockchainTreeConfig, externals::TreeExternals, BlockchainTree, ShareableBlockchainTree,
};
use reth_config::Config;
use reth_db::{
database::Database,
mdbx::{Env, WriteMap},
@ -45,13 +46,10 @@ use reth_provider::{BlockProvider, CanonStateSubscriptions, HeaderProvider, Shar
use reth_revm::Factory;
use reth_revm_inspectors::stack::Hook;
use reth_rpc_engine_api::EngineApi;
use reth_staged_sync::{
utils::{
chainspec::genesis_value_parser,
init::{init_db, init_genesis},
parse_socket_address,
},
Config,
use reth_staged_sync::utils::{
chainspec::genesis_value_parser,
init::{init_db, init_genesis},
parse_socket_address,
};
use reth_stages::{
prelude::*,

View File

@ -6,15 +6,13 @@ use crate::{
};
use backon::{ConstantBuilder, Retryable};
use clap::{Parser, Subcommand};
use reth_config::Config;
use reth_db::mdbx::{Env, EnvKind, WriteMap};
use reth_discv4::NatResolver;
use reth_interfaces::p2p::bodies::client::BodiesClient;
use reth_primitives::{BlockHashOrNumber, ChainSpec, NodeRecord};
use reth_provider::ShareableDatabase;
use reth_staged_sync::{
utils::{chainspec::chain_spec_value_parser, hash_or_num_value_parser},
Config,
};
use reth_staged_sync::utils::{chainspec::chain_spec_value_parser, hash_or_num_value_parser};
use std::{path::PathBuf, sync::Arc};
/// `reth p2p` command

View File

@ -9,13 +9,11 @@ use crate::{
};
use clap::Parser;
use reth_beacon_consensus::BeaconConsensus;
use reth_config::Config;
use reth_downloaders::bodies::bodies::BodiesDownloaderBuilder;
use reth_primitives::{ChainSpec, StageCheckpoint};
use reth_provider::{ShareableDatabase, Transaction};
use reth_staged_sync::{
utils::{chainspec::chain_spec_value_parser, init::init_db},
Config,
};
use reth_staged_sync::utils::{chainspec::chain_spec_value_parser, init::init_db};
use reth_stages::{
stages::{
BodyStage, ExecutionStage, ExecutionStageThresholds, MerkleStage, SenderRecoveryStage,

30
crates/config/Cargo.toml Normal file
View File

@ -0,0 +1,30 @@
[package]
name = "reth-config"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/paradigmxyz/reth"
readme = "README.md"
[dependencies]
# reth
reth-network = { path = "../net/network" }
reth-net-nat = { path = "../../crates/net/nat" }
reth-discv4 = { path = "../../crates/net/discv4" }
reth-downloaders = { path = "../../crates/net/downloaders" }
# io
serde = "1.0"
serde_json = "1.0.91"
#crypto
secp256k1 = { version = "0.27.0", features = [
"global-context",
"rand-std",
"recovery",
] }
confy = "0.5"
tempfile = "3.4"

11
crates/config/src/lib.rs Normal file
View File

@ -0,0 +1,11 @@
#![warn(missing_docs, unreachable_pub)]
#![deny(unused_must_use, rust_2018_idioms)]
#![doc(test(
no_crate_inject,
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
))]
//! Standalone crate for Reth config types
pub mod config;
pub use config::Config;

View File

@ -95,4 +95,4 @@ test-utils = [
"dep:ethers-middleware",
"dep:async-trait"
]
geth-tests = []
geth-tests = []

View File

@ -11,10 +11,6 @@
//!
//! - `test-utils`: Various utilities helpful for writing tests
//! - `geth-tests`: Runs tests that require Geth to be installed locally.
pub mod config;
pub use config::Config;
pub mod utils;
#[cfg(any(test, feature = "test-utils"))]