consensus: replace reth-primitive imports (#10768)

This commit is contained in:
Håvard Anda Estensen
2024-09-09 14:54:49 +02:00
committed by GitHub
parent 9a541c9853
commit cb0625c391
22 changed files with 52 additions and 27 deletions

4
Cargo.lock generated
View File

@ -6184,6 +6184,7 @@ dependencies = [
name = "reth-auto-seal-consensus" name = "reth-auto-seal-consensus"
version = "1.0.6" version = "1.0.6"
dependencies = [ dependencies = [
"alloy-primitives",
"futures-util", "futures-util",
"reth-beacon-consensus", "reth-beacon-consensus",
"reth-chainspec", "reth-chainspec",
@ -6234,6 +6235,7 @@ name = "reth-beacon-consensus"
version = "1.0.6" version = "1.0.6"
dependencies = [ dependencies = [
"alloy-genesis", "alloy-genesis",
"alloy-primitives",
"assert_matches", "assert_matches",
"futures", "futures",
"itertools 0.13.0", "itertools 0.13.0",
@ -6556,6 +6558,7 @@ dependencies = [
name = "reth-consensus" name = "reth-consensus"
version = "1.0.6" version = "1.0.6"
dependencies = [ dependencies = [
"alloy-primitives",
"auto_impl", "auto_impl",
"derive_more 1.0.0", "derive_more 1.0.0",
"reth-primitives", "reth-primitives",
@ -6565,6 +6568,7 @@ dependencies = [
name = "reth-consensus-common" name = "reth-consensus-common"
version = "1.0.6" version = "1.0.6"
dependencies = [ dependencies = [
"alloy-primitives",
"mockall", "mockall",
"rand 0.8.5", "rand 0.8.5",
"reth-chainspec", "reth-chainspec",

View File

@ -31,6 +31,9 @@ reth-network-peers.workspace = true
reth-tokio-util.workspace = true reth-tokio-util.workspace = true
reth-trie.workspace = true reth-trie.workspace = true
# ethereum
alloy-primitives.workspace = true
# async # async
futures-util.workspace = true futures-util.workspace = true
tokio = { workspace = true, features = ["sync", "time"] } tokio = { workspace = true, features = ["sync", "time"] }

View File

@ -1,6 +1,7 @@
//! This includes download client implementations for auto sealing miners. //! This includes download client implementations for auto sealing miners.
use crate::Storage; use crate::Storage;
use alloy_primitives::B256;
use reth_network_p2p::{ use reth_network_p2p::{
bodies::client::{BodiesClient, BodiesFut}, bodies::client::{BodiesClient, BodiesFut},
download::DownloadClient, download::DownloadClient,
@ -8,7 +9,7 @@ use reth_network_p2p::{
priority::Priority, priority::Priority,
}; };
use reth_network_peers::{PeerId, WithPeerId}; use reth_network_peers::{PeerId, WithPeerId};
use reth_primitives::{BlockBody, BlockHashOrNumber, Header, B256}; use reth_primitives::{BlockBody, BlockHashOrNumber, Header};
use std::fmt::Debug; use std::fmt::Debug;
use tracing::{trace, warn}; use tracing::{trace, warn};

View File

@ -15,6 +15,7 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
use alloy_primitives::{BlockHash, BlockNumber, Bloom, B256, U256};
use reth_beacon_consensus::BeaconEngineMessage; use reth_beacon_consensus::BeaconEngineMessage;
use reth_chainspec::{ChainSpec, EthereumHardforks}; use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_consensus::{Consensus, ConsensusError, PostExecutionInput}; use reth_consensus::{Consensus, ConsensusError, PostExecutionInput};
@ -24,9 +25,8 @@ use reth_execution_errors::{
}; };
use reth_execution_types::ExecutionOutcome; use reth_execution_types::ExecutionOutcome;
use reth_primitives::{ use reth_primitives::{
eip4844::calculate_excess_blob_gas, proofs, Block, BlockBody, BlockHash, BlockHashOrNumber, eip4844::calculate_excess_blob_gas, proofs, Block, BlockBody, BlockHashOrNumber,
BlockNumber, BlockWithSenders, Bloom, Header, Requests, SealedBlock, SealedHeader, BlockWithSenders, Header, Requests, SealedBlock, SealedHeader, TransactionSigned, Withdrawals,
TransactionSigned, Withdrawals, B256, U256,
}; };
use reth_provider::{BlockReaderIdExt, StateProviderFactory, StateRootProvider}; use reth_provider::{BlockReaderIdExt, StateProviderFactory, StateRootProvider};
use reth_revm::database::StateProviderDatabase; use reth_revm::database::StateProviderDatabase;

View File

@ -1,7 +1,7 @@
//! The mode the auto seal miner is operating in. //! The mode the auto seal miner is operating in.
use alloy_primitives::TxHash;
use futures_util::{stream::Fuse, StreamExt}; use futures_util::{stream::Fuse, StreamExt};
use reth_primitives::TxHash;
use reth_transaction_pool::{TransactionPool, ValidPoolTransaction}; use reth_transaction_pool::{TransactionPool, ValidPoolTransaction};
use std::{ use std::{
fmt, fmt,

View File

@ -30,6 +30,9 @@ reth-engine-primitives.workspace = true
reth-network-p2p.workspace = true reth-network-p2p.workspace = true
reth-node-types.workspace = true reth-node-types.workspace = true
# ethereum
alloy-primitives.workspace = true
# async # async
tokio = { workspace = true, features = ["sync"] } tokio = { workspace = true, features = ["sync"] }
tokio-stream.workspace = true tokio-stream.workspace = true

View File

@ -1,5 +1,6 @@
use crate::engine::forkchoice::ForkchoiceStatus; 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 reth_rpc_types::engine::ForkchoiceState;
use std::{sync::Arc, time::Duration}; use std::{sync::Arc, time::Duration};

View File

@ -1,4 +1,4 @@
use reth_primitives::B256; use alloy_primitives::B256;
use reth_rpc_types::engine::{ForkchoiceState, PayloadStatusEnum}; use reth_rpc_types::engine::{ForkchoiceState, PayloadStatusEnum};
/// The struct that keeps track of the received forkchoice state and their status. /// The struct that keeps track of the received forkchoice state and their status.

View File

@ -1,5 +1,5 @@
use alloy_primitives::BlockNumber;
use reth_errors::{RethError, RethResult}; use reth_errors::{RethError, RethResult};
use reth_primitives::BlockNumber;
use std::{ use std::{
fmt, fmt,
task::{Context, Poll}, task::{Context, Poll},

View File

@ -4,11 +4,11 @@ use crate::{
engine::hooks::{EngineHook, EngineHookContext, EngineHookError, EngineHookEvent}, engine::hooks::{EngineHook, EngineHookContext, EngineHookError, EngineHookEvent},
hooks::EngineHookDBAccessLevel, hooks::EngineHookDBAccessLevel,
}; };
use alloy_primitives::BlockNumber;
use futures::FutureExt; use futures::FutureExt;
use metrics::Counter; use metrics::Counter;
use reth_errors::{RethError, RethResult}; use reth_errors::{RethError, RethResult};
use reth_node_types::NodeTypesWithDB; use reth_node_types::NodeTypesWithDB;
use reth_primitives::BlockNumber;
use reth_provider::{providers::ProviderNodeTypes, ProviderFactory}; use reth_provider::{providers::ProviderNodeTypes, ProviderFactory};
use reth_prune::{Pruner, PrunerError, PrunerWithResult}; use reth_prune::{Pruner, PrunerError, PrunerWithResult};
use reth_tasks::TaskSpawner; use reth_tasks::TaskSpawner;

View File

@ -4,10 +4,11 @@ use crate::{
engine::hooks::{EngineHook, EngineHookContext, EngineHookError, EngineHookEvent}, engine::hooks::{EngineHook, EngineHookContext, EngineHookError, EngineHookEvent},
hooks::EngineHookDBAccessLevel, hooks::EngineHookDBAccessLevel,
}; };
use alloy_primitives::BlockNumber;
use futures::FutureExt; use futures::FutureExt;
use reth_errors::RethResult; use reth_errors::RethResult;
use reth_node_types::NodeTypesWithDB; 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_provider::providers::ProviderNodeTypes;
use reth_static_file::{StaticFileProducer, StaticFileProducerWithResult}; use reth_static_file::{StaticFileProducer, StaticFileProducerWithResult};
use reth_tasks::TaskSpawner; use reth_tasks::TaskSpawner;

View File

@ -1,8 +1,9 @@
use alloy_primitives::B256;
use reth_metrics::{ use reth_metrics::{
metrics::{Counter, Gauge}, metrics::{Counter, Gauge},
Metrics, Metrics,
}; };
use reth_primitives::{Header, SealedHeader, B256}; use reth_primitives::{Header, SealedHeader};
use schnellru::{ByLength, LruMap}; use schnellru::{ByLength, LruMap};
use std::sync::Arc; use std::sync::Arc;
use tracing::warn; use tracing::warn;

View File

@ -1,3 +1,4 @@
use alloy_primitives::{BlockNumber, B256};
use futures::{stream::BoxStream, Future, StreamExt}; use futures::{stream::BoxStream, Future, StreamExt};
use itertools::Either; use itertools::Either;
use reth_blockchain_tree_api::{ use reth_blockchain_tree_api::{
@ -15,8 +16,7 @@ use reth_payload_builder::PayloadBuilderHandle;
use reth_payload_primitives::{PayloadAttributes, PayloadBuilderAttributes}; use reth_payload_primitives::{PayloadAttributes, PayloadBuilderAttributes};
use reth_payload_validator::ExecutionPayloadValidator; use reth_payload_validator::ExecutionPayloadValidator;
use reth_primitives::{ use reth_primitives::{
constants::EPOCH_SLOTS, BlockNumHash, BlockNumber, Head, Header, SealedBlock, SealedHeader, constants::EPOCH_SLOTS, BlockNumHash, Head, Header, SealedBlock, SealedHeader,
B256,
}; };
use reth_provider::{ use reth_provider::{
providers::ProviderNodeTypes, BlockIdReader, BlockReader, BlockSource, CanonChainTracker, providers::ProviderNodeTypes, BlockIdReader, BlockReader, BlockSource, CanonChainTracker,
@ -2177,10 +2177,10 @@ mod tests {
mod fork_choice_updated { mod fork_choice_updated {
use super::*; use super::*;
use alloy_primitives::U256;
use generators::BlockParams; use generators::BlockParams;
use reth_db::{tables, test_utils::create_test_static_files_dir, Database}; use reth_db::{tables, test_utils::create_test_static_files_dir, Database};
use reth_db_api::transaction::DbTxMut; use reth_db_api::transaction::DbTxMut;
use reth_primitives::U256;
use reth_provider::{providers::StaticFileProvider, test_utils::MockNodeTypesWithDB}; use reth_provider::{providers::StaticFileProvider, test_utils::MockNodeTypesWithDB};
use reth_rpc_types::engine::ForkchoiceUpdateError; use reth_rpc_types::engine::ForkchoiceUpdateError;
use reth_testing_utils::generators::random_block; use reth_testing_utils::generators::random_block;
@ -2578,9 +2578,10 @@ mod tests {
mod new_payload { mod new_payload {
use super::*; use super::*;
use alloy_genesis::Genesis; use alloy_genesis::Genesis;
use alloy_primitives::U256;
use generators::BlockParams; use generators::BlockParams;
use reth_db::test_utils::create_test_static_files_dir; use reth_db::test_utils::create_test_static_files_dir;
use reth_primitives::{EthereumHardfork, U256}; use reth_primitives::EthereumHardfork;
use reth_provider::{ use reth_provider::{
providers::StaticFileProvider, providers::StaticFileProvider,
test_utils::{blocks::BlockchainTestData, MockNodeTypesWithDB}, test_utils::{blocks::BlockchainTestData, MockNodeTypesWithDB},

View File

@ -4,13 +4,14 @@ use crate::{
engine::metrics::EngineSyncMetrics, BeaconConsensusEngineEvent, engine::metrics::EngineSyncMetrics, BeaconConsensusEngineEvent,
ConsensusEngineLiveSyncProgress, EthBeaconConsensus, ConsensusEngineLiveSyncProgress, EthBeaconConsensus,
}; };
use alloy_primitives::{BlockNumber, B256};
use futures::FutureExt; use futures::FutureExt;
use reth_network_p2p::{ use reth_network_p2p::{
full_block::{FetchFullBlockFuture, FetchFullBlockRangeFuture, FullBlockClient}, full_block::{FetchFullBlockFuture, FetchFullBlockRangeFuture, FullBlockClient},
BlockClient, BlockClient,
}; };
use reth_node_types::NodeTypesWithDB; use reth_node_types::NodeTypesWithDB;
use reth_primitives::{BlockNumber, SealedBlock, B256}; use reth_primitives::SealedBlock;
use reth_provider::providers::ProviderNodeTypes; use reth_provider::providers::ProviderNodeTypes;
use reth_stages_api::{ControlFlow, Pipeline, PipelineError, PipelineTarget, PipelineWithResult}; use reth_stages_api::{ControlFlow, Pipeline, PipelineError, PipelineTarget, PipelineWithResult};
use reth_tasks::TaskSpawner; use reth_tasks::TaskSpawner;

View File

@ -3,6 +3,7 @@ use crate::{
BeaconConsensusEngineError, BeaconConsensusEngineHandle, BeaconForkChoiceUpdateError, BeaconConsensusEngineError, BeaconConsensusEngineHandle, BeaconForkChoiceUpdateError,
BeaconOnNewPayloadError, EthBeaconConsensus, MIN_BLOCKS_FOR_PIPELINE_RUN, BeaconOnNewPayloadError, EthBeaconConsensus, MIN_BLOCKS_FOR_PIPELINE_RUN,
}; };
use alloy_primitives::{BlockNumber, B256};
use reth_blockchain_tree::{ use reth_blockchain_tree::{
config::BlockchainTreeConfig, externals::TreeExternals, BlockchainTree, ShareableBlockchainTree, config::BlockchainTreeConfig, externals::TreeExternals, BlockchainTree, ShareableBlockchainTree,
}; };
@ -20,7 +21,6 @@ use reth_evm_ethereum::execute::EthExecutorProvider;
use reth_exex_types::FinishedExExHeight; use reth_exex_types::FinishedExExHeight;
use reth_network_p2p::{sync::NoopSyncStateUpdater, test_utils::NoopFullBlockClient, BlockClient}; use reth_network_p2p::{sync::NoopSyncStateUpdater, test_utils::NoopFullBlockClient, BlockClient};
use reth_payload_builder::test_utils::spawn_test_payload_service; use reth_payload_builder::test_utils::spawn_test_payload_service;
use reth_primitives::{BlockNumber, B256};
use reth_provider::{ use reth_provider::{
providers::BlockchainProvider, providers::BlockchainProvider,
test_utils::{create_test_provider_factory_with_chain_spec, MockNodeTypesWithDB}, test_utils::{create_test_provider_factory_with_chain_spec, MockNodeTypesWithDB},

View File

@ -16,6 +16,9 @@ reth-chainspec.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-consensus.workspace = true reth-consensus.workspace = true
# ethereum
alloy-primitives.workspace = true
[dev-dependencies] [dev-dependencies]
reth-storage-api.workspace = true reth-storage-api.workspace = true
rand.workspace = true rand.workspace = true

View File

@ -1,5 +1,6 @@
use alloy_primitives::{BlockNumber, U256};
use reth_chainspec::{ChainSpec, EthereumHardfork}; 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. /// 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_chainspec::MAINNET;
/// # use reth_consensus_common::calc::{base_block_reward, block_reward}; /// # use reth_consensus_common::calc::{base_block_reward, block_reward};
/// # use reth_primitives::constants::ETH_TO_WEI; /// # use reth_primitives::constants::ETH_TO_WEI;
/// # use reth_primitives::U256; /// # use alloy_primitives::U256;
/// # /// #
/// // This is block 126 on mainnet. /// // This is block 126 on mainnet.
/// let block_number = 126; /// let block_number = 126;

View File

@ -300,13 +300,13 @@ pub fn validate_against_parent_4844(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use alloy_primitives::{hex_literal::hex, Address, BlockHash, BlockNumber, Bytes, U256};
use mockall::mock; use mockall::mock;
use rand::Rng; use rand::Rng;
use reth_chainspec::ChainSpecBuilder; use reth_chainspec::ChainSpecBuilder;
use reth_primitives::{ use reth_primitives::{
hex_literal::hex, proofs, Account, Address, BlockBody, BlockHash, BlockHashOrNumber, proofs, Account, BlockBody, BlockHashOrNumber, Signature, Transaction, TransactionSigned,
BlockNumber, Bytes, Signature, Transaction, TransactionSigned, TxEip4844, Withdrawal, TxEip4844, Withdrawal, Withdrawals,
Withdrawals, U256,
}; };
use reth_storage_api::{ use reth_storage_api::{
errors::provider::ProviderResult, AccountReader, HeaderProvider, WithdrawalsProvider, errors::provider::ProviderResult, AccountReader, HeaderProvider, WithdrawalsProvider,

View File

@ -14,6 +14,9 @@ workspace = true
# reth # reth
reth-primitives.workspace = true reth-primitives.workspace = true
# ethereum
alloy-primitives.workspace = true
# misc # misc
auto_impl.workspace = true auto_impl.workspace = true
derive_more.workspace = true derive_more.workspace = true

View File

@ -9,10 +9,10 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use alloy_primitives::{BlockHash, BlockNumber, Bloom, B256, U256};
use reth_primitives::{ use reth_primitives::{
constants::MINIMUM_GAS_LIMIT, BlockHash, BlockNumber, BlockWithSenders, Bloom, GotExpected, constants::MINIMUM_GAS_LIMIT, BlockWithSenders, GotExpected, GotExpectedBoxed, Header,
GotExpectedBoxed, Header, InvalidTransactionError, Receipt, Request, SealedBlock, SealedHeader, InvalidTransactionError, Receipt, Request, SealedBlock, SealedHeader,
B256, U256,
}; };
#[cfg(feature = "std")] #[cfg(feature = "std")]

View File

@ -1,5 +1,6 @@
use crate::{Consensus, ConsensusError, PostExecutionInput}; 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. /// A Consensus implementation that does nothing.
#[derive(Debug, Copy, Clone, Default)] #[derive(Debug, Copy, Clone, Default)]

View File

@ -1,6 +1,7 @@
use crate::{Consensus, ConsensusError, PostExecutionInput}; use crate::{Consensus, ConsensusError, PostExecutionInput};
use alloy_primitives::U256;
use core::sync::atomic::{AtomicBool, Ordering}; 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 /// Consensus engine implementation for testing
#[derive(Debug)] #[derive(Debug)]