Skip to content

Commit

Permalink
consensus: replace reth-primitive imports (#10768)
Browse files Browse the repository at this point in the history
  • Loading branch information
estensen committed Sep 9, 2024
1 parent 9a541c9 commit cb0625c
Show file tree
Hide file tree
Showing 22 changed files with 52 additions and 27 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/consensus/auto-seal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
3 changes: 2 additions & 1 deletion crates/consensus/auto-seal/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
//! 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,
headers::client::{HeadersClient, HeadersDirection, HeadersFut, HeadersRequest},
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};

Expand Down
6 changes: 3 additions & 3 deletions crates/consensus/auto-seal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/auto-seal/src/mode.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/consensus/beacon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion crates/consensus/beacon/src/engine/event.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/beacon/src/engine/forkchoice.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/beacon/src/engine/hooks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloy_primitives::BlockNumber;
use reth_errors::{RethError, RethResult};
use reth_primitives::BlockNumber;
use std::{
fmt,
task::{Context, Poll},
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/beacon/src/engine/hooks/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion crates/consensus/beacon/src/engine/hooks/static_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion crates/consensus/beacon/src/engine/invalid_headers.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
9 changes: 5 additions & 4 deletions crates/consensus/beacon/src/engine/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloy_primitives::{BlockNumber, B256};
use futures::{stream::BoxStream, Future, StreamExt};
use itertools::Either;
use reth_blockchain_tree_api::{
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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},
Expand Down
3 changes: 2 additions & 1 deletion crates/consensus/beacon/src/engine/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/beacon/src/engine/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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},
Expand Down
3 changes: 3 additions & 0 deletions crates/consensus/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions crates/consensus/common/src/calc.rs
Original file line number Diff line number Diff line change
@@ -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.
///
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions crates/consensus/common/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/consensus/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions crates/consensus/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
3 changes: 2 additions & 1 deletion crates/consensus/consensus/src/noop.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
3 changes: 2 additions & 1 deletion crates/consensus/consensus/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down

0 comments on commit cb0625c

Please sign in to comment.