Skip to content

Commit

Permalink
primitives: rm more alloy_primitives reexports (#11250)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
tcoratger and mattsse authored Sep 26, 2024
1 parent 2e05ec0 commit ad64de8
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 43 deletions.
2 changes: 1 addition & 1 deletion crates/node/builder/src/launch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion crates/primitives/benches/recover_ecdsa_crit.rs
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/src/proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 1 addition & 2 deletions crates/primitives/src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
3 changes: 1 addition & 2 deletions crates/primitives/src/transaction/tx_type.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl StateProvider for StateProviderTest {
&self,
account: Address,
storage_key: StorageKey,
) -> ProviderResult<Option<reth_primitives::StorageValue>> {
) -> ProviderResult<Option<alloy_primitives::StorageValue>> {
Ok(self.accounts.get(&account).and_then(|(storage, _)| storage.get(&storage_key).copied()))
}

Expand Down
7 changes: 4 additions & 3 deletions crates/stages/stages/src/stages/bodies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ use std::{
use futures_util::TryStreamExt;
use tracing::*;

use alloy_primitives::TxNumber;
use reth_db::tables;
use reth_db_api::{
cursor::{DbCursorRO, DbCursorRW},
models::{StoredBlockBodyIndices, StoredBlockOmmers, StoredBlockWithdrawals},
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,
Expand Down Expand Up @@ -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::{
Expand All @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions crates/stages/stages/src/stages/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions crates/stages/stages/src/stages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions crates/stages/stages/src/stages/sender_recovery.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions crates/stages/stages/src/stages/tx_lookup.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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,
Expand Down Expand Up @@ -109,7 +109,7 @@ where
}
}
if input.target_reached() {
return Ok(ExecOutput::done(input.checkpoint()))
return Ok(ExecOutput::done(input.checkpoint()));
}

// 500MB temporary files
Expand Down Expand Up @@ -172,7 +172,7 @@ where
"Transaction hashes inserted"
);

break
break;
}
}

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions crates/stages/stages/src/test_utils/test_db.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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},
Expand Down
4 changes: 2 additions & 2 deletions crates/storage/provider/src/providers/static_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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};
Expand Down
10 changes: 6 additions & 4 deletions crates/storage/provider/src/test_utils/blocks.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
2 changes: 1 addition & 1 deletion crates/trie/db/src/trie_cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions crates/trie/db/tests/trie.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#![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};
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,
};
Expand Down

0 comments on commit ad64de8

Please sign in to comment.