From ad64de896230c46b25046e71cfc90b8a7b95a3af Mon Sep 17 00:00:00 2001 From: Thomas Coratger <60488569+tcoratger@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:18:56 +0200 Subject: [PATCH] primitives: rm more `alloy_primitives` reexports (#11250) Co-authored-by: Matthias Seitz --- crates/node/builder/src/launch/mod.rs | 2 +- crates/primitives/benches/recover_ecdsa_crit.rs | 3 ++- crates/primitives/src/block.rs | 2 +- crates/primitives/src/lib.rs | 4 +--- crates/primitives/src/proofs.rs | 4 ++-- crates/primitives/src/receipt.rs | 3 +-- crates/primitives/src/transaction/mod.rs | 2 +- crates/primitives/src/transaction/tx_type.rs | 3 +-- crates/revm/src/test_utils.rs | 2 +- crates/stages/stages/src/stages/bodies.rs | 7 ++++--- crates/stages/stages/src/stages/execution.rs | 6 ++---- crates/stages/stages/src/stages/mod.rs | 6 ++---- crates/stages/stages/src/stages/sender_recovery.rs | 4 ++-- crates/stages/stages/src/stages/tx_lookup.rs | 8 ++++---- crates/stages/stages/src/test_utils/test_db.rs | 6 +++--- .../storage/provider/src/providers/static_file/mod.rs | 4 ++-- crates/storage/provider/src/test_utils/blocks.rs | 10 ++++++---- crates/trie/db/src/trie_cursor.rs | 2 +- crates/trie/db/tests/trie.rs | 4 ++-- 19 files changed, 39 insertions(+), 43 deletions(-) diff --git a/crates/node/builder/src/launch/mod.rs b/crates/node/builder/src/launch/mod.rs index 9c7d562d19d2..db98ffacedeb 100644 --- a/crates/node/builder/src/launch/mod.rs +++ b/crates/node/builder/src/launch/mod.rs @@ -11,6 +11,7 @@ pub use exex::ExExLauncher; use std::{future::Future, sync::Arc}; +use alloy_primitives::utils::format_ether; use alloy_rpc_types::engine::ClientVersionV1; use futures::{future::Either, stream, stream_select, StreamExt}; use reth_beacon_consensus::{ @@ -33,7 +34,6 @@ use reth_node_core::{ version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA}, }; use reth_node_events::{cl::ConsensusLayerHealthEvents, node}; -use reth_primitives::format_ether; use reth_provider::providers::BlockchainProvider; use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi}; use reth_tasks::TaskExecutor; diff --git a/crates/primitives/benches/recover_ecdsa_crit.rs b/crates/primitives/benches/recover_ecdsa_crit.rs index e1e896dbbf8f..8e8e279b2a4a 100644 --- a/crates/primitives/benches/recover_ecdsa_crit.rs +++ b/crates/primitives/benches/recover_ecdsa_crit.rs @@ -1,8 +1,9 @@ #![allow(missing_docs)] +use alloy_primitives::hex_literal::hex; use alloy_rlp::Decodable; use criterion::{criterion_group, criterion_main, Criterion}; use pprof::criterion::{Output, PProfProfiler}; -use reth_primitives::{hex_literal::hex, TransactionSigned}; +use reth_primitives::TransactionSigned; /// Benchmarks the recovery of the public key from the ECDSA message using criterion. pub fn criterion_benchmark(c: &mut Criterion) { diff --git a/crates/primitives/src/block.rs b/crates/primitives/src/block.rs index a5357fcec993..78a98f78ab2a 100644 --- a/crates/primitives/src/block.rs +++ b/crates/primitives/src/block.rs @@ -709,8 +709,8 @@ impl<'a> arbitrary::Arbitrary<'a> for BlockBody { #[cfg(test)] mod tests { use super::{BlockNumberOrTag::*, *}; - use crate::hex_literal::hex; use alloy_eips::eip1898::HexStringMissingPrefixError; + use alloy_primitives::hex_literal::hex; use alloy_rlp::{Decodable, Encodable}; use std::str::FromStr; diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index b0564ed07d5a..778230f5f870 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -72,9 +72,7 @@ pub use transaction::{ pub use alloy_primitives::{ self, address, b256, bloom, bytes, bytes::{Buf, BufMut, BytesMut}, - hex, hex_literal, ruint, - utils::format_ether, - Bytes, StorageValue, TxHash, TxIndex, TxNumber, B128, B256, B512, B64, U128, U256, U64, + hex, Bytes, TxHash, B256, U256, U64, }; pub use reth_ethereum_forks::*; pub use revm_primitives::{self, JumpTable}; diff --git a/crates/primitives/src/proofs.rs b/crates/primitives/src/proofs.rs index 040ec365503e..454524081f0b 100644 --- a/crates/primitives/src/proofs.rs +++ b/crates/primitives/src/proofs.rs @@ -65,9 +65,9 @@ pub fn calculate_ommers_root(ommers: &[Header]) -> B256 { #[cfg(test)] mod tests { use super::*; - use crate::{constants::EMPTY_ROOT_HASH, hex_literal::hex, Block, U256}; + use crate::{constants::EMPTY_ROOT_HASH, Block, U256}; use alloy_genesis::GenesisAccount; - use alloy_primitives::{b256, Address}; + use alloy_primitives::{b256, hex_literal::hex, Address}; use alloy_rlp::Decodable; use reth_chainspec::{HOLESKY, MAINNET, SEPOLIA}; use reth_trie_common::root::{state_root_ref_unhashed, state_root_unhashed}; diff --git a/crates/primitives/src/receipt.rs b/crates/primitives/src/receipt.rs index 6b43e77e913a..0b32e0899a12 100644 --- a/crates/primitives/src/receipt.rs +++ b/crates/primitives/src/receipt.rs @@ -501,8 +501,7 @@ impl<'a> Encodable for ReceiptWithBloomEncoder<'a> { #[cfg(test)] mod tests { use super::*; - use crate::hex_literal::hex; - use alloy_primitives::{address, b256, bytes}; + use alloy_primitives::{address, b256, bytes, hex_literal::hex}; // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 #[test] diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 8e2f2977dedc..d7ab9a22bc2b 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -1921,7 +1921,7 @@ mod tests { #[test] fn decode_raw_tx_and_recover_signer() { - use crate::hex_literal::hex; + use alloy_primitives::hex_literal::hex; // transaction is from ropsten let hash: B256 = diff --git a/crates/primitives/src/transaction/tx_type.rs b/crates/primitives/src/transaction/tx_type.rs index 4017d8d4b9c4..14ac420e0a90 100644 --- a/crates/primitives/src/transaction/tx_type.rs +++ b/crates/primitives/src/transaction/tx_type.rs @@ -1,5 +1,4 @@ -use crate::U64; -use alloy_primitives::U8; +use alloy_primitives::{U64, U8}; use alloy_rlp::{Decodable, Encodable}; use serde::{Deserialize, Serialize}; diff --git a/crates/revm/src/test_utils.rs b/crates/revm/src/test_utils.rs index bbb45687353b..3f89d99125be 100644 --- a/crates/revm/src/test_utils.rs +++ b/crates/revm/src/test_utils.rs @@ -136,7 +136,7 @@ impl StateProvider for StateProviderTest { &self, account: Address, storage_key: StorageKey, - ) -> ProviderResult> { + ) -> ProviderResult> { Ok(self.accounts.get(&account).and_then(|(storage, _)| storage.get(&storage_key).copied())) } diff --git a/crates/stages/stages/src/stages/bodies.rs b/crates/stages/stages/src/stages/bodies.rs index cc30fc90a11d..248e2ff52748 100644 --- a/crates/stages/stages/src/stages/bodies.rs +++ b/crates/stages/stages/src/stages/bodies.rs @@ -6,6 +6,7 @@ use std::{ use futures_util::TryStreamExt; use tracing::*; +use alloy_primitives::TxNumber; use reth_db::tables; use reth_db_api::{ cursor::{DbCursorRO, DbCursorRW}, @@ -13,7 +14,7 @@ use reth_db_api::{ transaction::DbTxMut, }; use reth_network_p2p::bodies::{downloader::BodyDownloader, response::BlockResponse}; -use reth_primitives::{StaticFileSegment, TxNumber}; +use reth_primitives::StaticFileSegment; use reth_provider::{ providers::{StaticFileProvider, StaticFileWriter}, BlockReader, DBProvider, ProviderError, StaticFileProviderFactory, StatsReader, @@ -621,7 +622,7 @@ mod tests { UnwindStageTestRunner, }, }; - use alloy_primitives::{BlockHash, BlockNumber}; + use alloy_primitives::{BlockHash, BlockNumber, TxNumber}; use futures_util::Stream; use reth_db::{static_file::HeaderMask, tables}; use reth_db_api::{ @@ -637,7 +638,7 @@ mod tests { error::DownloadResult, }; use reth_primitives::{ - BlockBody, Header, SealedBlock, SealedHeader, StaticFileSegment, TxNumber, B256, + BlockBody, Header, SealedBlock, SealedHeader, StaticFileSegment, B256, }; use reth_provider::{ providers::StaticFileWriter, test_utils::MockNodeTypesWithDB, HeaderProvider, diff --git a/crates/stages/stages/src/stages/execution.rs b/crates/stages/stages/src/stages/execution.rs index 04cc1dd65923..1305e6825451 100644 --- a/crates/stages/stages/src/stages/execution.rs +++ b/crates/stages/stages/src/stages/execution.rs @@ -658,16 +658,14 @@ where mod tests { use super::*; use crate::test_utils::TestStageDB; - use alloy_primitives::{keccak256, Address}; + use alloy_primitives::{hex_literal::hex, keccak256, Address}; use alloy_rlp::Decodable; use assert_matches::assert_matches; use reth_chainspec::ChainSpecBuilder; use reth_db_api::{models::AccountBeforeTx, transaction::DbTxMut}; use reth_evm_ethereum::execute::EthExecutorProvider; use reth_execution_errors::BlockValidationError; - use reth_primitives::{ - address, hex_literal::hex, Account, Bytecode, SealedBlock, StorageEntry, B256, U256, - }; + use reth_primitives::{address, Account, Bytecode, SealedBlock, StorageEntry, B256, U256}; use reth_provider::{ test_utils::create_test_provider_factory, AccountReader, DatabaseProviderFactory, ReceiptProvider, StaticFileProviderFactory, diff --git a/crates/stages/stages/src/stages/mod.rs b/crates/stages/stages/src/stages/mod.rs index d3c5b7099d21..6ae1b30e7e24 100644 --- a/crates/stages/stages/src/stages/mod.rs +++ b/crates/stages/stages/src/stages/mod.rs @@ -42,7 +42,7 @@ use utils::*; mod tests { use super::*; use crate::test_utils::{StorageKind, TestStageDB}; - use alloy_primitives::{keccak256, BlockNumber}; + use alloy_primitives::{hex_literal::hex, keccak256, BlockNumber}; use alloy_rlp::Decodable; use reth_chainspec::ChainSpecBuilder; use reth_db::{ @@ -56,9 +56,7 @@ mod tests { }; use reth_evm_ethereum::execute::EthExecutorProvider; use reth_exex::ExExManagerHandle; - use reth_primitives::{ - address, hex_literal::hex, Account, Bytecode, SealedBlock, StaticFileSegment, B256, U256, - }; + use reth_primitives::{address, Account, Bytecode, SealedBlock, StaticFileSegment, B256, U256}; use reth_provider::{ providers::{StaticFileProvider, StaticFileWriter}, test_utils::MockNodeTypesWithDB, diff --git a/crates/stages/stages/src/stages/sender_recovery.rs b/crates/stages/stages/src/stages/sender_recovery.rs index 344a8ea848ee..8ffbb2070aa1 100644 --- a/crates/stages/stages/src/stages/sender_recovery.rs +++ b/crates/stages/stages/src/stages/sender_recovery.rs @@ -1,4 +1,4 @@ -use alloy_primitives::Address; +use alloy_primitives::{Address, TxNumber}; use reth_config::config::SenderRecoveryConfig; use reth_consensus::ConsensusError; use reth_db::{static_file::TransactionMask, tables, RawValue}; @@ -7,7 +7,7 @@ use reth_db_api::{ transaction::{DbTx, DbTxMut}, DbTxUnwindExt, }; -use reth_primitives::{GotExpected, StaticFileSegment, TransactionSignedNoHash, TxNumber}; +use reth_primitives::{GotExpected, StaticFileSegment, TransactionSignedNoHash}; use reth_provider::{ BlockReader, DBProvider, HeaderProvider, ProviderError, PruneCheckpointReader, StaticFileProviderFactory, StatsReader, diff --git a/crates/stages/stages/src/stages/tx_lookup.rs b/crates/stages/stages/src/stages/tx_lookup.rs index 4e68cfe90b76..1744b933c2d3 100644 --- a/crates/stages/stages/src/stages/tx_lookup.rs +++ b/crates/stages/stages/src/stages/tx_lookup.rs @@ -1,3 +1,4 @@ +use alloy_primitives::{TxHash, TxNumber}; use num_traits::Zero; use reth_config::config::{EtlConfig, TransactionLookupConfig}; use reth_db::{tables, RawKey, RawValue}; @@ -6,7 +7,6 @@ use reth_db_api::{ transaction::{DbTx, DbTxMut}, }; use reth_etl::Collector; -use reth_primitives::{TxHash, TxNumber}; use reth_provider::{ BlockReader, DBProvider, PruneCheckpointReader, PruneCheckpointWriter, StaticFileProviderFactory, StatsReader, TransactionsProvider, TransactionsProviderExt, @@ -109,7 +109,7 @@ where } } if input.target_reached() { - return Ok(ExecOutput::done(input.checkpoint())) + return Ok(ExecOutput::done(input.checkpoint())); } // 500MB temporary files @@ -172,7 +172,7 @@ where "Transaction hashes inserted" ); - break + break; } } @@ -199,7 +199,7 @@ where let mut rev_walker = body_cursor.walk_back(Some(*range.end()))?; while let Some((number, body)) = rev_walker.next().transpose()? { if number <= unwind_to { - break + break; } // Delete all transactions that belong to this block diff --git a/crates/stages/stages/src/test_utils/test_db.rs b/crates/stages/stages/src/test_utils/test_db.rs index 89d74d9d4092..7607b1d3142c 100644 --- a/crates/stages/stages/src/test_utils/test_db.rs +++ b/crates/stages/stages/src/test_utils/test_db.rs @@ -1,4 +1,4 @@ -use alloy_primitives::{keccak256, Address, BlockNumber}; +use alloy_primitives::{keccak256, Address, BlockNumber, TxNumber}; use reth_chainspec::MAINNET; use reth_db::{ tables, @@ -15,8 +15,8 @@ use reth_db_api::{ DatabaseError as DbError, }; use reth_primitives::{ - Account, Receipt, SealedBlock, SealedHeader, StaticFileSegment, StorageEntry, TxHash, TxNumber, - B256, U256, + Account, Receipt, SealedBlock, SealedHeader, StaticFileSegment, StorageEntry, TxHash, B256, + U256, }; use reth_provider::{ providers::{StaticFileProvider, StaticFileProviderRWRefMut, StaticFileWriter}, diff --git a/crates/storage/provider/src/providers/static_file/mod.rs b/crates/storage/provider/src/providers/static_file/mod.rs index 04f032b0fef4..45b7816af02a 100644 --- a/crates/storage/provider/src/providers/static_file/mod.rs +++ b/crates/storage/provider/src/providers/static_file/mod.rs @@ -56,7 +56,7 @@ impl Deref for LoadedJar { mod tests { use super::*; use crate::{test_utils::create_test_provider_factory, HeaderProvider}; - use alloy_primitives::{BlockHash, B256, U256}; + use alloy_primitives::{BlockHash, TxNumber, B256, U256}; use rand::seq::SliceRandom; use reth_db::{ test_utils::create_test_static_files_dir, CanonicalHeaders, HeaderNumbers, @@ -65,7 +65,7 @@ mod tests { use reth_db_api::transaction::DbTxMut; use reth_primitives::{ static_file::{find_fixed_range, SegmentRangeInclusive, DEFAULT_BLOCKS_PER_STATIC_FILE}, - Header, Receipt, TransactionSignedNoHash, TxNumber, + Header, Receipt, TransactionSignedNoHash, }; use reth_storage_api::{ReceiptProvider, TransactionsProvider}; use reth_testing_utils::generators::{self, random_header_range}; diff --git a/crates/storage/provider/src/test_utils/blocks.rs b/crates/storage/provider/src/test_utils/blocks.rs index 09daf998731a..32033bcb2803 100644 --- a/crates/storage/provider/src/test_utils/blocks.rs +++ b/crates/storage/provider/src/test_utils/blocks.rs @@ -1,14 +1,16 @@ //! Dummy blocks and data for tests use crate::{DatabaseProviderRW, ExecutionOutcome}; use alloy_consensus::TxLegacy; -use alloy_primitives::{map::HashMap, Address, BlockNumber, Log, Parity, Sealable, TxKind}; +use alloy_primitives::{ + hex_literal::hex, map::HashMap, Address, BlockNumber, Log, Parity, Sealable, TxKind, +}; use once_cell::sync::Lazy; use reth_db::tables; use reth_db_api::{database::Database, models::StoredBlockBodyIndices}; use reth_primitives::{ - alloy_primitives, b256, hex_literal::hex, Account, BlockBody, Bytes, Header, Receipt, - SealedBlock, SealedBlockWithSenders, SealedHeader, Signature, Transaction, TransactionSigned, - TxType, Withdrawal, Withdrawals, B256, U256, + alloy_primitives, b256, Account, BlockBody, Bytes, Header, Receipt, SealedBlock, + SealedBlockWithSenders, SealedHeader, Signature, Transaction, TransactionSigned, TxType, + Withdrawal, Withdrawals, B256, U256, }; use reth_trie::root::{state_root_unhashed, storage_root_unhashed}; use revm::{db::BundleState, primitives::AccountInfo}; diff --git a/crates/trie/db/src/trie_cursor.rs b/crates/trie/db/src/trie_cursor.rs index 124b8ccb20ca..601100b3faee 100644 --- a/crates/trie/db/src/trie_cursor.rs +++ b/crates/trie/db/src/trie_cursor.rs @@ -209,8 +209,8 @@ where #[cfg(test)] mod tests { use super::*; + use alloy_primitives::hex_literal::hex; use reth_db_api::{cursor::DbCursorRW, transaction::DbTxMut}; - use reth_primitives::hex_literal::hex; use reth_provider::test_utils::create_test_provider_factory; #[test] diff --git a/crates/trie/db/tests/trie.rs b/crates/trie/db/tests/trie.rs index f7413c64509f..59fffec58d06 100644 --- a/crates/trie/db/tests/trie.rs +++ b/crates/trie/db/tests/trie.rs @@ -1,6 +1,6 @@ #![allow(missing_docs)] -use alloy_primitives::{keccak256, Address, B256, U256}; +use alloy_primitives::{hex_literal::hex, keccak256, Address, B256, U256}; use proptest::{prelude::ProptestConfig, proptest}; use proptest_arbitrary_interop::arb; use reth_db::{tables, test_utils::TempDatabase, DatabaseEnv}; @@ -8,7 +8,7 @@ use reth_db_api::{ cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO}, transaction::DbTxMut, }; -use reth_primitives::{constants::EMPTY_ROOT_HASH, hex_literal::hex, Account, StorageEntry}; +use reth_primitives::{constants::EMPTY_ROOT_HASH, Account, StorageEntry}; use reth_provider::{ test_utils::create_test_provider_factory, DatabaseProviderRW, StorageTrieWriter, TrieWriter, };