diff --git a/Cargo.lock b/Cargo.lock index 3f85f1b76..2518f6ae7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6479,7 +6479,6 @@ dependencies = [ "reth-primitives-traits", "reth-rpc-types", "reth-trie-common", - "serde", "serde_json", ] diff --git a/bin/reth/src/cli/mod.rs b/bin/reth/src/cli/mod.rs index 8750b84f5..ff5c4add5 100644 --- a/bin/reth/src/cli/mod.rs +++ b/bin/reth/src/cli/mod.rs @@ -2,7 +2,7 @@ use crate::{ args::{ - utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS}, + utils::{chain_help, chain_value_parser, SUPPORTED_CHAINS}, LogArgs, }, commands::{ @@ -46,7 +46,7 @@ pub struct Cli { value_name = "CHAIN_OR_PATH", long_help = chain_help(), default_value = SUPPORTED_CHAINS[0], - value_parser = genesis_value_parser, + value_parser = chain_value_parser, global = true, )] chain: Arc, diff --git a/bin/reth/src/commands/common.rs b/bin/reth/src/commands/common.rs index 329047cdd..31c0329a5 100644 --- a/bin/reth/src/commands/common.rs +++ b/bin/reth/src/commands/common.rs @@ -10,7 +10,7 @@ use reth_downloaders::{bodies::noop::NoopBodiesDownloader, headers::noop::NoopHe use reth_evm::noop::NoopBlockExecutorProvider; use reth_node_core::{ args::{ - utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS}, + utils::{chain_help, chain_value_parser, SUPPORTED_CHAINS}, DatabaseArgs, DatadirArgs, }, dirs::{ChainPath, DataDirPath}, @@ -42,7 +42,7 @@ pub struct EnvironmentArgs { value_name = "CHAIN_OR_PATH", long_help = chain_help(), default_value = SUPPORTED_CHAINS[0], - value_parser = genesis_value_parser + value_parser = chain_value_parser )] pub chain: Arc, diff --git a/bin/reth/src/commands/dump_genesis.rs b/bin/reth/src/commands/dump_genesis.rs index f4208584f..70b95e736 100644 --- a/bin/reth/src/commands/dump_genesis.rs +++ b/bin/reth/src/commands/dump_genesis.rs @@ -1,5 +1,5 @@ //! Command that dumps genesis block JSON configuration to stdout -use crate::args::utils::{chain_help, genesis_value_parser, SUPPORTED_CHAINS}; +use crate::args::utils::{chain_help, chain_value_parser, SUPPORTED_CHAINS}; use clap::Parser; use reth_chainspec::ChainSpec; use std::sync::Arc; @@ -15,7 +15,7 @@ pub struct DumpGenesisCommand { value_name = "CHAIN_OR_PATH", long_help = chain_help(), default_value = SUPPORTED_CHAINS[0], - value_parser = genesis_value_parser + value_parser = chain_value_parser )] chain: Arc, } diff --git a/bin/reth/src/commands/node/mod.rs b/bin/reth/src/commands/node/mod.rs index 606e0de42..f4c355b17 100644 --- a/bin/reth/src/commands/node/mod.rs +++ b/bin/reth/src/commands/node/mod.rs @@ -1,7 +1,7 @@ //! Main node command for launching a node use crate::args::{ - utils::{chain_help, genesis_value_parser, parse_socket_address, SUPPORTED_CHAINS}, + utils::{chain_help, chain_value_parser, parse_socket_address, SUPPORTED_CHAINS}, DatabaseArgs, DatadirArgs, DebugArgs, DevArgs, NetworkArgs, PayloadBuilderArgs, PruningArgs, RpcServerArgs, TxPoolArgs, }; @@ -29,7 +29,7 @@ pub struct NodeCommand { long_help = chain_help(), default_value = SUPPORTED_CHAINS[0], default_value_if("dev", "true", "dev"), - value_parser = genesis_value_parser, + value_parser = chain_value_parser, required = false, )] pub chain: Arc, diff --git a/bin/reth/src/commands/p2p/mod.rs b/bin/reth/src/commands/p2p/mod.rs index b40207c80..290a0a0b0 100644 --- a/bin/reth/src/commands/p2p/mod.rs +++ b/bin/reth/src/commands/p2p/mod.rs @@ -3,7 +3,7 @@ use crate::{ args::{ get_secret_key, - utils::{chain_help, genesis_value_parser, hash_or_num_value_parser, SUPPORTED_CHAINS}, + utils::{chain_help, chain_value_parser, hash_or_num_value_parser, SUPPORTED_CHAINS}, DatabaseArgs, DiscoveryArgs, NetworkArgs, }, utils::get_single_header, @@ -40,7 +40,7 @@ pub struct Command { value_name = "CHAIN_OR_PATH", long_help = chain_help(), default_value = SUPPORTED_CHAINS[0], - value_parser = genesis_value_parser + value_parser = chain_value_parser )] chain: Arc, diff --git a/crates/chainspec/Cargo.toml b/crates/chainspec/Cargo.toml index 8c1d4d4da..682289145 100644 --- a/crates/chainspec/Cargo.toml +++ b/crates/chainspec/Cargo.toml @@ -26,7 +26,6 @@ alloy-trie.workspace = true # misc once_cell.workspace = true -serde.workspace = true serde_json.workspace = true derive_more.workspace = true diff --git a/crates/chainspec/src/spec.rs b/crates/chainspec/src/spec.rs index 2d88f4508..bf16a88f0 100644 --- a/crates/chainspec/src/spec.rs +++ b/crates/chainspec/src/spec.rs @@ -26,7 +26,6 @@ use reth_primitives_traits::{ Header, SealedHeader, }; use reth_trie_common::root::state_root_ref_unhashed; -use serde::{Deserialize, Serialize}; #[cfg(feature = "std")] use std::{collections::BTreeMap, sync::Arc}; @@ -290,8 +289,7 @@ pub static BASE_MAINNET: Lazy> = Lazy::new(|| { /// A wrapper around [`BaseFeeParams`] that allows for specifying constant or dynamic EIP-1559 /// parameters based on the active [Hardfork]. -#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] -#[serde(untagged)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum BaseFeeParamsKind { /// Constant [`BaseFeeParams`]; used for chains that don't have dynamic EIP-1559 parameters Constant(BaseFeeParams), @@ -314,7 +312,7 @@ impl From for BaseFeeParamsKind { /// A type alias to a vector of tuples of [Hardfork] and [`BaseFeeParams`], sorted by [Hardfork] /// activation order. This is used to specify dynamic EIP-1559 parameters for chains like Optimism. -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, From)] +#[derive(Clone, Debug, PartialEq, Eq, From)] pub struct ForkBaseFeeParams(Vec<(Hardfork, BaseFeeParams)>); /// An Ethereum chain specification. @@ -324,7 +322,7 @@ pub struct ForkBaseFeeParams(Vec<(Hardfork, BaseFeeParams)>); /// - Meta-information about the chain (the chain ID) /// - The genesis block of the chain ([`Genesis`]) /// - What hardforks are activated, and under which conditions -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct ChainSpec { /// The chain ID pub chain: Chain, @@ -333,7 +331,6 @@ pub struct ChainSpec { /// /// This acts as a small cache for known chains. If the chain is known, then the genesis hash /// is also known ahead of time, and this will be `Some`. - #[serde(skip, default)] pub genesis_hash: Option, /// The genesis block @@ -341,14 +338,12 @@ pub struct ChainSpec { /// The block at which [`Hardfork::Paris`] was activated and the final difficulty at this /// block. - #[serde(skip, default)] pub paris_block_and_final_difficulty: Option<(u64, U256)>, /// The active hard forks and their activation conditions pub hardforks: BTreeMap, /// The deposit contract deployed for `PoS` - #[serde(skip, default)] pub deposit_contract: Option, /// The parameters that configure how a block's base fee is computed @@ -357,7 +352,6 @@ pub struct ChainSpec { /// The delete limit for pruner, per block. In the actual pruner run it will be multiplied by /// the amount of blocks between pruner runs to account for the difference in amount of new /// data coming in. - #[serde(default)] pub prune_delete_limit: usize, } diff --git a/crates/net/network/src/config.rs b/crates/net/network/src/config.rs index ad865c55c..993132f6c 100644 --- a/crates/net/network/src/config.rs +++ b/crates/net/network/src/config.rs @@ -159,6 +159,7 @@ pub struct NetworkConfigBuilder { /// How to configure the sessions manager sessions_config: Option, /// The network's chain spec + #[serde(skip)] chain_spec: Arc, /// The default mode of the network. network_mode: NetworkMode, diff --git a/crates/node-core/src/args/utils.rs b/crates/node-core/src/args/utils.rs index fce8f6890..8a54a8942 100644 --- a/crates/node-core/src/args/utils.rs +++ b/crates/node-core/src/args/utils.rs @@ -41,9 +41,8 @@ pub fn chain_help() -> String { /// Clap value parser for [`ChainSpec`]s. /// /// The value parser matches either a known chain, the path -/// to a json file, or a json formatted string in-memory. The json can be either -/// a serialized [`ChainSpec`] or Genesis struct. -pub fn genesis_value_parser(s: &str) -> eyre::Result, eyre::Error> { +/// to a json file, or a json formatted string in-memory. The json needs to be a Genesis struct. +pub fn chain_value_parser(s: &str) -> eyre::Result, eyre::Error> { Ok(match s { #[cfg(not(feature = "optimism"))] "mainnet" => MAINNET.clone(), @@ -146,7 +145,7 @@ mod tests { #[test] fn parse_known_chain_spec() { for chain in SUPPORTED_CHAINS { - genesis_value_parser(chain).unwrap(); + chain_value_parser(chain).unwrap(); } }