diff --git a/Cargo.lock b/Cargo.lock index 53064f34d9b4..ce08ce4a7620 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6184,6 +6184,7 @@ dependencies = [ name = "reth-auto-seal-consensus" version = "1.0.6" dependencies = [ + "alloy-primitives", "futures-util", "reth-beacon-consensus", "reth-chainspec", @@ -6234,6 +6235,7 @@ name = "reth-beacon-consensus" version = "1.0.6" dependencies = [ "alloy-genesis", + "alloy-primitives", "assert_matches", "futures", "itertools 0.13.0", @@ -6556,6 +6558,7 @@ dependencies = [ name = "reth-consensus" version = "1.0.6" dependencies = [ + "alloy-primitives", "auto_impl", "derive_more 1.0.0", "reth-primitives", @@ -6565,6 +6568,7 @@ dependencies = [ name = "reth-consensus-common" version = "1.0.6" dependencies = [ + "alloy-primitives", "mockall", "rand 0.8.5", "reth-chainspec", diff --git a/crates/consensus/auto-seal/Cargo.toml b/crates/consensus/auto-seal/Cargo.toml index 9c4c26c91fda..4e3e2db86809 100644 --- a/crates/consensus/auto-seal/Cargo.toml +++ b/crates/consensus/auto-seal/Cargo.toml @@ -31,6 +31,9 @@ reth-network-peers.workspace = true reth-tokio-util.workspace = true reth-trie.workspace = true +# ethereum +alloy-primitives.workspace = true + # async futures-util.workspace = true tokio = { workspace = true, features = ["sync", "time"] } diff --git a/crates/consensus/auto-seal/src/client.rs b/crates/consensus/auto-seal/src/client.rs index d55cf6443139..f9b80f10bb5c 100644 --- a/crates/consensus/auto-seal/src/client.rs +++ b/crates/consensus/auto-seal/src/client.rs @@ -1,6 +1,7 @@ //! This includes download client implementations for auto sealing miners. use crate::Storage; +use alloy_primitives::B256; use reth_network_p2p::{ bodies::client::{BodiesClient, BodiesFut}, download::DownloadClient, @@ -8,7 +9,7 @@ use reth_network_p2p::{ priority::Priority, }; use reth_network_peers::{PeerId, WithPeerId}; -use reth_primitives::{BlockBody, BlockHashOrNumber, Header, B256}; +use reth_primitives::{BlockBody, BlockHashOrNumber, Header}; use std::fmt::Debug; use tracing::{trace, warn}; diff --git a/crates/consensus/auto-seal/src/lib.rs b/crates/consensus/auto-seal/src/lib.rs index 8bf9616a0790..e11d5e2e9b1b 100644 --- a/crates/consensus/auto-seal/src/lib.rs +++ b/crates/consensus/auto-seal/src/lib.rs @@ -15,6 +15,7 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +use alloy_primitives::{BlockHash, BlockNumber, Bloom, B256, U256}; use reth_beacon_consensus::BeaconEngineMessage; use reth_chainspec::{ChainSpec, EthereumHardforks}; use reth_consensus::{Consensus, ConsensusError, PostExecutionInput}; @@ -24,9 +25,8 @@ use reth_execution_errors::{ }; use reth_execution_types::ExecutionOutcome; use reth_primitives::{ - eip4844::calculate_excess_blob_gas, proofs, Block, BlockBody, BlockHash, BlockHashOrNumber, - BlockNumber, BlockWithSenders, Bloom, Header, Requests, SealedBlock, SealedHeader, - TransactionSigned, Withdrawals, B256, U256, + eip4844::calculate_excess_blob_gas, proofs, Block, BlockBody, BlockHashOrNumber, + BlockWithSenders, Header, Requests, SealedBlock, SealedHeader, TransactionSigned, Withdrawals, }; use reth_provider::{BlockReaderIdExt, StateProviderFactory, StateRootProvider}; use reth_revm::database::StateProviderDatabase; diff --git a/crates/consensus/auto-seal/src/mode.rs b/crates/consensus/auto-seal/src/mode.rs index 2ff918af63dc..82750c8e47b6 100644 --- a/crates/consensus/auto-seal/src/mode.rs +++ b/crates/consensus/auto-seal/src/mode.rs @@ -1,7 +1,7 @@ //! The mode the auto seal miner is operating in. +use alloy_primitives::TxHash; use futures_util::{stream::Fuse, StreamExt}; -use reth_primitives::TxHash; use reth_transaction_pool::{TransactionPool, ValidPoolTransaction}; use std::{ fmt, diff --git a/crates/consensus/beacon/Cargo.toml b/crates/consensus/beacon/Cargo.toml index 1a56c5990734..db9ed5a29157 100644 --- a/crates/consensus/beacon/Cargo.toml +++ b/crates/consensus/beacon/Cargo.toml @@ -30,6 +30,9 @@ reth-engine-primitives.workspace = true reth-network-p2p.workspace = true reth-node-types.workspace = true +# ethereum +alloy-primitives.workspace = true + # async tokio = { workspace = true, features = ["sync"] } tokio-stream.workspace = true diff --git a/crates/consensus/beacon/src/engine/event.rs b/crates/consensus/beacon/src/engine/event.rs index 9f00ef561670..994cda060c61 100644 --- a/crates/consensus/beacon/src/engine/event.rs +++ b/crates/consensus/beacon/src/engine/event.rs @@ -1,5 +1,6 @@ use crate::engine::forkchoice::ForkchoiceStatus; -use reth_primitives::{SealedBlock, SealedHeader, B256}; +use alloy_primitives::B256; +use reth_primitives::{SealedBlock, SealedHeader}; use reth_rpc_types::engine::ForkchoiceState; use std::{sync::Arc, time::Duration}; diff --git a/crates/consensus/beacon/src/engine/forkchoice.rs b/crates/consensus/beacon/src/engine/forkchoice.rs index 7ce42ce7ecfd..f02b1200338b 100644 --- a/crates/consensus/beacon/src/engine/forkchoice.rs +++ b/crates/consensus/beacon/src/engine/forkchoice.rs @@ -1,4 +1,4 @@ -use reth_primitives::B256; +use alloy_primitives::B256; use reth_rpc_types::engine::{ForkchoiceState, PayloadStatusEnum}; /// The struct that keeps track of the received forkchoice state and their status. diff --git a/crates/consensus/beacon/src/engine/hooks/mod.rs b/crates/consensus/beacon/src/engine/hooks/mod.rs index 5d699921a650..b5e6ea61e38a 100644 --- a/crates/consensus/beacon/src/engine/hooks/mod.rs +++ b/crates/consensus/beacon/src/engine/hooks/mod.rs @@ -1,5 +1,5 @@ +use alloy_primitives::BlockNumber; use reth_errors::{RethError, RethResult}; -use reth_primitives::BlockNumber; use std::{ fmt, task::{Context, Poll}, diff --git a/crates/consensus/beacon/src/engine/hooks/prune.rs b/crates/consensus/beacon/src/engine/hooks/prune.rs index 3aa787e4a4ea..eb5ca7cf5ce0 100644 --- a/crates/consensus/beacon/src/engine/hooks/prune.rs +++ b/crates/consensus/beacon/src/engine/hooks/prune.rs @@ -4,11 +4,11 @@ use crate::{ engine::hooks::{EngineHook, EngineHookContext, EngineHookError, EngineHookEvent}, hooks::EngineHookDBAccessLevel, }; +use alloy_primitives::BlockNumber; use futures::FutureExt; use metrics::Counter; use reth_errors::{RethError, RethResult}; use reth_node_types::NodeTypesWithDB; -use reth_primitives::BlockNumber; use reth_provider::{providers::ProviderNodeTypes, ProviderFactory}; use reth_prune::{Pruner, PrunerError, PrunerWithResult}; use reth_tasks::TaskSpawner; diff --git a/crates/consensus/beacon/src/engine/hooks/static_file.rs b/crates/consensus/beacon/src/engine/hooks/static_file.rs index 356726d1d902..fbadb5e5cfd3 100644 --- a/crates/consensus/beacon/src/engine/hooks/static_file.rs +++ b/crates/consensus/beacon/src/engine/hooks/static_file.rs @@ -4,10 +4,11 @@ use crate::{ engine::hooks::{EngineHook, EngineHookContext, EngineHookError, EngineHookEvent}, hooks::EngineHookDBAccessLevel, }; +use alloy_primitives::BlockNumber; use futures::FutureExt; use reth_errors::RethResult; use reth_node_types::NodeTypesWithDB; -use reth_primitives::{static_file::HighestStaticFiles, BlockNumber}; +use reth_primitives::static_file::HighestStaticFiles; use reth_provider::providers::ProviderNodeTypes; use reth_static_file::{StaticFileProducer, StaticFileProducerWithResult}; use reth_tasks::TaskSpawner; diff --git a/crates/consensus/beacon/src/engine/invalid_headers.rs b/crates/consensus/beacon/src/engine/invalid_headers.rs index b93138901d03..ff5ede5a7a69 100644 --- a/crates/consensus/beacon/src/engine/invalid_headers.rs +++ b/crates/consensus/beacon/src/engine/invalid_headers.rs @@ -1,8 +1,9 @@ +use alloy_primitives::B256; use reth_metrics::{ metrics::{Counter, Gauge}, Metrics, }; -use reth_primitives::{Header, SealedHeader, B256}; +use reth_primitives::{Header, SealedHeader}; use schnellru::{ByLength, LruMap}; use std::sync::Arc; use tracing::warn; diff --git a/crates/consensus/beacon/src/engine/mod.rs b/crates/consensus/beacon/src/engine/mod.rs index f9c3e09ae876..bd35307271e9 100644 --- a/crates/consensus/beacon/src/engine/mod.rs +++ b/crates/consensus/beacon/src/engine/mod.rs @@ -1,3 +1,4 @@ +use alloy_primitives::{BlockNumber, B256}; use futures::{stream::BoxStream, Future, StreamExt}; use itertools::Either; use reth_blockchain_tree_api::{ @@ -15,8 +16,7 @@ use reth_payload_builder::PayloadBuilderHandle; use reth_payload_primitives::{PayloadAttributes, PayloadBuilderAttributes}; use reth_payload_validator::ExecutionPayloadValidator; use reth_primitives::{ - constants::EPOCH_SLOTS, BlockNumHash, BlockNumber, Head, Header, SealedBlock, SealedHeader, - B256, + constants::EPOCH_SLOTS, BlockNumHash, Head, Header, SealedBlock, SealedHeader, }; use reth_provider::{ providers::ProviderNodeTypes, BlockIdReader, BlockReader, BlockSource, CanonChainTracker, @@ -2177,10 +2177,10 @@ mod tests { mod fork_choice_updated { use super::*; + use alloy_primitives::U256; use generators::BlockParams; use reth_db::{tables, test_utils::create_test_static_files_dir, Database}; use reth_db_api::transaction::DbTxMut; - use reth_primitives::U256; use reth_provider::{providers::StaticFileProvider, test_utils::MockNodeTypesWithDB}; use reth_rpc_types::engine::ForkchoiceUpdateError; use reth_testing_utils::generators::random_block; @@ -2578,9 +2578,10 @@ mod tests { mod new_payload { use super::*; use alloy_genesis::Genesis; + use alloy_primitives::U256; use generators::BlockParams; use reth_db::test_utils::create_test_static_files_dir; - use reth_primitives::{EthereumHardfork, U256}; + use reth_primitives::EthereumHardfork; use reth_provider::{ providers::StaticFileProvider, test_utils::{blocks::BlockchainTestData, MockNodeTypesWithDB}, diff --git a/crates/consensus/beacon/src/engine/sync.rs b/crates/consensus/beacon/src/engine/sync.rs index 007fb702741e..1a5bca49de33 100644 --- a/crates/consensus/beacon/src/engine/sync.rs +++ b/crates/consensus/beacon/src/engine/sync.rs @@ -4,13 +4,14 @@ use crate::{ engine::metrics::EngineSyncMetrics, BeaconConsensusEngineEvent, ConsensusEngineLiveSyncProgress, EthBeaconConsensus, }; +use alloy_primitives::{BlockNumber, B256}; use futures::FutureExt; use reth_network_p2p::{ full_block::{FetchFullBlockFuture, FetchFullBlockRangeFuture, FullBlockClient}, BlockClient, }; use reth_node_types::NodeTypesWithDB; -use reth_primitives::{BlockNumber, SealedBlock, B256}; +use reth_primitives::SealedBlock; use reth_provider::providers::ProviderNodeTypes; use reth_stages_api::{ControlFlow, Pipeline, PipelineError, PipelineTarget, PipelineWithResult}; use reth_tasks::TaskSpawner; diff --git a/crates/consensus/beacon/src/engine/test_utils.rs b/crates/consensus/beacon/src/engine/test_utils.rs index 33025bb9aa11..5627e3618bc8 100644 --- a/crates/consensus/beacon/src/engine/test_utils.rs +++ b/crates/consensus/beacon/src/engine/test_utils.rs @@ -3,6 +3,7 @@ use crate::{ BeaconConsensusEngineError, BeaconConsensusEngineHandle, BeaconForkChoiceUpdateError, BeaconOnNewPayloadError, EthBeaconConsensus, MIN_BLOCKS_FOR_PIPELINE_RUN, }; +use alloy_primitives::{BlockNumber, B256}; use reth_blockchain_tree::{ config::BlockchainTreeConfig, externals::TreeExternals, BlockchainTree, ShareableBlockchainTree, }; @@ -20,7 +21,6 @@ use reth_evm_ethereum::execute::EthExecutorProvider; use reth_exex_types::FinishedExExHeight; use reth_network_p2p::{sync::NoopSyncStateUpdater, test_utils::NoopFullBlockClient, BlockClient}; use reth_payload_builder::test_utils::spawn_test_payload_service; -use reth_primitives::{BlockNumber, B256}; use reth_provider::{ providers::BlockchainProvider, test_utils::{create_test_provider_factory_with_chain_spec, MockNodeTypesWithDB}, diff --git a/crates/consensus/common/Cargo.toml b/crates/consensus/common/Cargo.toml index dca553deb4c9..0c622245f345 100644 --- a/crates/consensus/common/Cargo.toml +++ b/crates/consensus/common/Cargo.toml @@ -16,6 +16,9 @@ reth-chainspec.workspace = true reth-primitives.workspace = true reth-consensus.workspace = true +# ethereum +alloy-primitives.workspace = true + [dev-dependencies] reth-storage-api.workspace = true rand.workspace = true diff --git a/crates/consensus/common/src/calc.rs b/crates/consensus/common/src/calc.rs index e4b2abc13ba6..88fd10f177fa 100644 --- a/crates/consensus/common/src/calc.rs +++ b/crates/consensus/common/src/calc.rs @@ -1,5 +1,6 @@ +use alloy_primitives::{BlockNumber, U256}; use reth_chainspec::{ChainSpec, EthereumHardfork}; -use reth_primitives::{constants::ETH_TO_WEI, BlockNumber, U256}; +use reth_primitives::constants::ETH_TO_WEI; /// Calculates the base block reward. /// @@ -57,7 +58,7 @@ pub fn base_block_reward_pre_merge(chain_spec: &ChainSpec, block_number: BlockNu /// # use reth_chainspec::MAINNET; /// # use reth_consensus_common::calc::{base_block_reward, block_reward}; /// # use reth_primitives::constants::ETH_TO_WEI; -/// # use reth_primitives::U256; +/// # use alloy_primitives::U256; /// # /// // This is block 126 on mainnet. /// let block_number = 126; diff --git a/crates/consensus/common/src/validation.rs b/crates/consensus/common/src/validation.rs index 9646ddf73115..848ab59cad4b 100644 --- a/crates/consensus/common/src/validation.rs +++ b/crates/consensus/common/src/validation.rs @@ -300,13 +300,13 @@ pub fn validate_against_parent_4844( #[cfg(test)] mod tests { use super::*; + use alloy_primitives::{hex_literal::hex, Address, BlockHash, BlockNumber, Bytes, U256}; use mockall::mock; use rand::Rng; use reth_chainspec::ChainSpecBuilder; use reth_primitives::{ - hex_literal::hex, proofs, Account, Address, BlockBody, BlockHash, BlockHashOrNumber, - BlockNumber, Bytes, Signature, Transaction, TransactionSigned, TxEip4844, Withdrawal, - Withdrawals, U256, + proofs, Account, BlockBody, BlockHashOrNumber, Signature, Transaction, TransactionSigned, + TxEip4844, Withdrawal, Withdrawals, }; use reth_storage_api::{ errors::provider::ProviderResult, AccountReader, HeaderProvider, WithdrawalsProvider, diff --git a/crates/consensus/consensus/Cargo.toml b/crates/consensus/consensus/Cargo.toml index 8e7ecbb68812..660b43865ea7 100644 --- a/crates/consensus/consensus/Cargo.toml +++ b/crates/consensus/consensus/Cargo.toml @@ -14,6 +14,9 @@ workspace = true # reth reth-primitives.workspace = true +# ethereum +alloy-primitives.workspace = true + # misc auto_impl.workspace = true derive_more.workspace = true diff --git a/crates/consensus/consensus/src/lib.rs b/crates/consensus/consensus/src/lib.rs index a0c23810184d..40e4d1ce5871 100644 --- a/crates/consensus/consensus/src/lib.rs +++ b/crates/consensus/consensus/src/lib.rs @@ -9,10 +9,10 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] +use alloy_primitives::{BlockHash, BlockNumber, Bloom, B256, U256}; use reth_primitives::{ - constants::MINIMUM_GAS_LIMIT, BlockHash, BlockNumber, BlockWithSenders, Bloom, GotExpected, - GotExpectedBoxed, Header, InvalidTransactionError, Receipt, Request, SealedBlock, SealedHeader, - B256, U256, + constants::MINIMUM_GAS_LIMIT, BlockWithSenders, GotExpected, GotExpectedBoxed, Header, + InvalidTransactionError, Receipt, Request, SealedBlock, SealedHeader, }; #[cfg(feature = "std")] diff --git a/crates/consensus/consensus/src/noop.rs b/crates/consensus/consensus/src/noop.rs index 31c168eb0c83..53bdb72afb2d 100644 --- a/crates/consensus/consensus/src/noop.rs +++ b/crates/consensus/consensus/src/noop.rs @@ -1,5 +1,6 @@ use crate::{Consensus, ConsensusError, PostExecutionInput}; -use reth_primitives::{BlockWithSenders, Header, SealedBlock, SealedHeader, U256}; +use alloy_primitives::U256; +use reth_primitives::{BlockWithSenders, Header, SealedBlock, SealedHeader}; /// A Consensus implementation that does nothing. #[derive(Debug, Copy, Clone, Default)] diff --git a/crates/consensus/consensus/src/test_utils.rs b/crates/consensus/consensus/src/test_utils.rs index 14f565a69da8..436947209178 100644 --- a/crates/consensus/consensus/src/test_utils.rs +++ b/crates/consensus/consensus/src/test_utils.rs @@ -1,6 +1,7 @@ use crate::{Consensus, ConsensusError, PostExecutionInput}; +use alloy_primitives::U256; use core::sync::atomic::{AtomicBool, Ordering}; -use reth_primitives::{BlockWithSenders, Header, SealedBlock, SealedHeader, U256}; +use reth_primitives::{BlockWithSenders, Header, SealedBlock, SealedHeader}; /// Consensus engine implementation for testing #[derive(Debug)]