From a7bb1d1fa33836533d8e3f1c07d64f4872cb1d5f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 14 Nov 2024 18:36:31 +0100 Subject: [PATCH] chore: remove constants reexport (#12549) --- Cargo.lock | 5 +++++ bin/reth-bench/Cargo.toml | 1 + bin/reth-bench/src/bench/output.rs | 2 +- crates/consensus/consensus/Cargo.toml | 16 +++++++++++----- crates/consensus/consensus/src/lib.rs | 5 +++-- crates/ethereum/consensus/Cargo.toml | 1 + crates/ethereum/consensus/src/lib.rs | 5 ++--- crates/net/eth-wire/Cargo.toml | 4 +++- crates/net/eth-wire/src/hello.rs | 2 +- crates/payload/basic/Cargo.toml | 1 + crates/payload/basic/src/lib.rs | 3 ++- crates/primitives/src/constants/mod.rs | 3 --- crates/primitives/src/lib.rs | 2 -- crates/storage/db-common/src/init.rs | 5 +++-- 14 files changed, 34 insertions(+), 21 deletions(-) delete mode 100644 crates/primitives/src/constants/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 216088877..dbc1230f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6438,6 +6438,7 @@ dependencies = [ "reth-payload-builder", "reth-payload-primitives", "reth-primitives", + "reth-primitives-traits", "reth-provider", "reth-revm", "reth-tasks", @@ -6526,6 +6527,7 @@ dependencies = [ "reth-node-api", "reth-node-core", "reth-primitives", + "reth-primitives-traits", "reth-rpc-types-compat", "reth-tracing", "serde", @@ -6802,6 +6804,7 @@ dependencies = [ "auto_impl", "derive_more 1.0.0", "reth-primitives", + "reth-primitives-traits", ] [[package]] @@ -7330,6 +7333,7 @@ dependencies = [ "reth-metrics", "reth-network-peers", "reth-primitives", + "reth-primitives-traits", "reth-tracing", "secp256k1", "serde", @@ -7388,6 +7392,7 @@ dependencies = [ "reth-consensus", "reth-consensus-common", "reth-primitives", + "reth-primitives-traits", "tracing", ] diff --git a/bin/reth-bench/Cargo.toml b/bin/reth-bench/Cargo.toml index 03844633a..018207613 100644 --- a/bin/reth-bench/Cargo.toml +++ b/bin/reth-bench/Cargo.toml @@ -20,6 +20,7 @@ reth-node-core.workspace = true reth-node-api.workspace = true reth-rpc-types-compat.workspace = true reth-primitives = { workspace = true, features = ["alloy-compat"] } +reth-primitives-traits.workspace = true reth-tracing.workspace = true # alloy diff --git a/bin/reth-bench/src/bench/output.rs b/bin/reth-bench/src/bench/output.rs index 8f68dac45..56343c6af 100644 --- a/bin/reth-bench/src/bench/output.rs +++ b/bin/reth-bench/src/bench/output.rs @@ -1,7 +1,7 @@ //! Contains various benchmark output formats, either for logging or for //! serialization to / from files. -use reth_primitives::constants::gas_units::GIGAGAS; +use reth_primitives_traits::constants::GIGAGAS; use serde::{ser::SerializeStruct, Serialize}; use std::time::Duration; diff --git a/crates/consensus/consensus/Cargo.toml b/crates/consensus/consensus/Cargo.toml index d120d268b..55188dd84 100644 --- a/crates/consensus/consensus/Cargo.toml +++ b/crates/consensus/consensus/Cargo.toml @@ -13,6 +13,7 @@ workspace = true [dependencies] # reth reth-primitives.workspace = true +reth-primitives-traits.workspace = true # ethereum alloy-eips.workspace = true @@ -26,9 +27,14 @@ derive_more.workspace = true [features] default = ["std"] std = [ - "reth-primitives/std", - "alloy-primitives/std", - "alloy-eips/std", - "alloy-consensus/std", + "reth-primitives/std", + "reth-primitives-traits/std", + "alloy-primitives/std", + "alloy-eips/std", + "alloy-consensus/std", + "reth-primitives-traits/std" +] +test-utils = [ + "reth-primitives/test-utils", + "reth-primitives-traits/test-utils" ] -test-utils = ["reth-primitives/test-utils"] diff --git a/crates/consensus/consensus/src/lib.rs b/crates/consensus/consensus/src/lib.rs index a8f0a01f2..ec296f3ed 100644 --- a/crates/consensus/consensus/src/lib.rs +++ b/crates/consensus/consensus/src/lib.rs @@ -16,9 +16,10 @@ use alloy_consensus::Header; use alloy_eips::eip7685::Requests; use alloy_primitives::{BlockHash, BlockNumber, Bloom, B256, U256}; use reth_primitives::{ - constants::MINIMUM_GAS_LIMIT, BlockBody, BlockWithSenders, GotExpected, GotExpectedBoxed, - InvalidTransactionError, Receipt, SealedBlock, SealedHeader, + BlockBody, BlockWithSenders, GotExpected, GotExpectedBoxed, InvalidTransactionError, Receipt, + SealedBlock, SealedHeader, }; +use reth_primitives_traits::constants::MINIMUM_GAS_LIMIT; /// A consensus implementation that does nothing. pub mod noop; diff --git a/crates/ethereum/consensus/Cargo.toml b/crates/ethereum/consensus/Cargo.toml index bace4195c..8e6158ff4 100644 --- a/crates/ethereum/consensus/Cargo.toml +++ b/crates/ethereum/consensus/Cargo.toml @@ -15,6 +15,7 @@ workspace = true reth-chainspec.workspace = true reth-consensus-common.workspace = true reth-primitives.workspace = true +reth-primitives-traits.workspace = true reth-consensus.workspace = true # alloy diff --git a/crates/ethereum/consensus/src/lib.rs b/crates/ethereum/consensus/src/lib.rs index 3dc7a02af..7198a7036 100644 --- a/crates/ethereum/consensus/src/lib.rs +++ b/crates/ethereum/consensus/src/lib.rs @@ -18,9 +18,8 @@ use reth_consensus_common::validation::{ validate_against_parent_timestamp, validate_block_pre_execution, validate_body_against_header, validate_header_base_fee, validate_header_extradata, validate_header_gas, }; -use reth_primitives::{ - constants::MINIMUM_GAS_LIMIT, BlockBody, BlockWithSenders, SealedBlock, SealedHeader, -}; +use reth_primitives::{BlockBody, BlockWithSenders, SealedBlock, SealedHeader}; +use reth_primitives_traits::constants::MINIMUM_GAS_LIMIT; use std::{fmt::Debug, sync::Arc, time::SystemTime}; /// The bound divisor of the gas limit, used in update calculations. diff --git a/crates/net/eth-wire/Cargo.toml b/crates/net/eth-wire/Cargo.toml index 791f05cc9..d4989ca3b 100644 --- a/crates/net/eth-wire/Cargo.toml +++ b/crates/net/eth-wire/Cargo.toml @@ -15,6 +15,7 @@ workspace = true # reth reth-codecs.workspace = true reth-primitives.workspace = true +reth-primitives-traits.workspace = true reth-ecies.workspace = true alloy-rlp = { workspace = true, features = ["derive"] } reth-eth-wire-types.workspace = true @@ -72,7 +73,8 @@ arbitrary = [ "alloy-eips/arbitrary", "alloy-primitives/arbitrary", "reth-codecs/arbitrary", - "alloy-chains/arbitrary" + "alloy-chains/arbitrary", + "reth-primitives-traits/arbitrary" ] serde = [ "dep:serde", diff --git a/crates/net/eth-wire/src/hello.rs b/crates/net/eth-wire/src/hello.rs index 2eb42eaeb..5d7650b4b 100644 --- a/crates/net/eth-wire/src/hello.rs +++ b/crates/net/eth-wire/src/hello.rs @@ -2,7 +2,7 @@ use crate::{Capability, EthVersion, ProtocolVersion}; use alloy_rlp::{RlpDecodable, RlpEncodable}; use reth_codecs::add_arbitrary_tests; use reth_network_peers::PeerId; -use reth_primitives::constants::RETH_CLIENT_VERSION; +use reth_primitives_traits::constants::RETH_CLIENT_VERSION; /// The default tcp port for p2p. /// diff --git a/crates/payload/basic/Cargo.toml b/crates/payload/basic/Cargo.toml index 74dea45d1..5e9e524f7 100644 --- a/crates/payload/basic/Cargo.toml +++ b/crates/payload/basic/Cargo.toml @@ -15,6 +15,7 @@ workspace = true # reth reth-chainspec.workspace = true reth-primitives.workspace = true +reth-primitives-traits.workspace = true reth-transaction-pool.workspace = true reth-provider.workspace = true reth-payload-builder.workspace = true diff --git a/crates/payload/basic/src/lib.rs b/crates/payload/basic/src/lib.rs index 9b36e44b1..a905f8544 100644 --- a/crates/payload/basic/src/lib.rs +++ b/crates/payload/basic/src/lib.rs @@ -20,7 +20,8 @@ use reth_payload_builder::{KeepPayloadJobAlive, PayloadId, PayloadJob, PayloadJo use reth_payload_primitives::{ BuiltPayload, PayloadBuilderAttributes, PayloadBuilderError, PayloadKind, }; -use reth_primitives::{constants::RETH_CLIENT_VERSION, proofs, SealedHeader}; +use reth_primitives::{proofs, SealedHeader}; +use reth_primitives_traits::constants::RETH_CLIENT_VERSION; use reth_provider::{BlockReaderIdExt, CanonStateNotification, StateProviderFactory}; use reth_revm::cached::CachedReads; use reth_tasks::TaskSpawner; diff --git a/crates/primitives/src/constants/mod.rs b/crates/primitives/src/constants/mod.rs deleted file mode 100644 index 09c488cc2..000000000 --- a/crates/primitives/src/constants/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -//! Ethereum protocol-related constants - -pub use reth_primitives_traits::constants::*; diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 534b525f0..2318b3c24 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -26,7 +26,6 @@ mod alloy_compat; mod block; #[cfg(feature = "reth-codec")] mod compression; -pub mod constants; pub mod proofs; mod receipt; pub use reth_static_file_types as static_file; @@ -36,7 +35,6 @@ pub use block::{generate_valid_header, valid_header_strategy}; pub use block::{Block, BlockBody, BlockWithSenders, SealedBlock, SealedBlockWithSenders}; #[cfg(feature = "reth-codec")] pub use compression::*; -pub use constants::HOLESKY_GENESIS_HASH; pub use receipt::{ gas_spent_by_transactions, Receipt, ReceiptWithBloom, ReceiptWithBloomRef, Receipts, }; diff --git a/crates/storage/db-common/src/init.rs b/crates/storage/db-common/src/init.rs index 8c930b22e..45fb4b76b 100644 --- a/crates/storage/db-common/src/init.rs +++ b/crates/storage/db-common/src/init.rs @@ -584,7 +584,9 @@ struct GenesisAccountWithAddress { #[cfg(test)] mod tests { use super::*; - use alloy_consensus::constants::{MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH}; + use alloy_consensus::constants::{ + HOLESKY_GENESIS_HASH, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH, + }; use alloy_genesis::Genesis; use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET, SEPOLIA}; use reth_db::DatabaseEnv; @@ -595,7 +597,6 @@ mod tests { transaction::DbTx, Database, }; - use reth_primitives::HOLESKY_GENESIS_HASH; use reth_primitives_traits::IntegerList; use reth_provider::{ test_utils::{create_test_provider_factory_with_chain_spec, MockNodeTypesWithDB},