chore: Replace remaining uses of reth_primitives with reth_primitives_traits (#15704)

This commit is contained in:
kevaundray
2025-04-14 10:40:34 +01:00
committed by GitHub
parent fe1af71310
commit a3b749676c
8 changed files with 33 additions and 25 deletions

View File

@@ -14,18 +14,19 @@ workspace = true
[features]
ef-tests = []
asm-keccak = [
"reth-primitives/asm-keccak",
"alloy-primitives/asm-keccak",
"revm/asm-keccak",
]
[dependencies]
reth-chainspec.workspace = true
reth-primitives.workspace = true
reth-ethereum-primitives.workspace = true
reth-primitives-traits.workspace = true
reth-db = { workspace = true, features = ["mdbx", "test-utils", "disable-lock"] }
reth-db-api.workspace = true
reth-provider = { workspace = true, features = ["test-utils"] }
reth-stages.workspace = true
reth-static-file-types.workspace = true
reth-evm-ethereum.workspace = true
reth-ethereum-consensus.workspace = true
reth-revm = { workspace = true, features = ["std"] }

View File

@@ -8,10 +8,11 @@ use alloy_rlp::Decodable;
use rayon::iter::{ParallelBridge, ParallelIterator};
use reth_chainspec::ChainSpec;
use reth_ethereum_consensus::EthBeaconConsensus;
use reth_primitives::{BlockBody, SealedBlock, StaticFileSegment};
use reth_ethereum_primitives::Block;
use reth_primitives_traits::SealedBlock;
use reth_provider::{
providers::StaticFileWriter, test_utils::create_test_provider_factory_with_chain_spec,
DatabaseProviderFactory, HashingWriter, StaticFileProviderFactory,
DatabaseProviderFactory, HashingWriter, StaticFileProviderFactory, StaticFileSegment,
};
use reth_stages::{stages::ExecutionStage, ExecInput, Stage};
use std::{collections::BTreeMap, fs, path::Path, sync::Arc};
@@ -92,9 +93,9 @@ impl Case for BlockchainTestCase {
// Insert initial test state into the provider.
provider.insert_historical_block(
SealedBlock::<reth_primitives::Block>::from_sealed_parts(
SealedBlock::<Block>::from_sealed_parts(
case.genesis_block_header.clone().into(),
BlockBody::default(),
Default::default(),
)
.try_recover()
.unwrap(),
@@ -112,10 +113,9 @@ impl Case for BlockchainTestCase {
// Decode and insert blocks, creating a chain of blocks for the test case.
let last_block = case.blocks.iter().try_fold(None, |_, block| {
let decoded =
SealedBlock::<reth_primitives::Block>::decode(&mut block.rlp.as_ref())?;
let decoded = SealedBlock::<Block>::decode(&mut block.rlp.as_ref())?;
provider.insert_historical_block(decoded.clone().try_recover().unwrap())?;
Ok::<Option<SealedBlock>, Error>(Some(decoded))
Ok::<Option<SealedBlock<Block>>, Error>(Some(decoded))
})?;
provider
.static_file_provider()

View File

@@ -10,7 +10,7 @@ use reth_db_api::{
tables,
transaction::{DbTx, DbTxMut},
};
use reth_primitives::{Account as RethAccount, Bytecode, SealedHeader, StorageEntry};
use reth_primitives_traits::{Account as RethAccount, Bytecode, SealedHeader, StorageEntry};
use serde::Deserialize;
use std::{collections::BTreeMap, ops::Deref};

View File

@@ -12,7 +12,7 @@ repository.workspace = true
workspace = true
[dependencies]
reth-primitives = { workspace = true, features = ["secp256k1", "arbitrary"] }
reth-ethereum-primitives = { workspace = true, features = ["arbitrary", "std"] }
reth-primitives-traits = { workspace = true, features = ["secp256k1", "arbitrary"] }
alloy-genesis.workspace = true

View File

@@ -2,7 +2,7 @@
// TODO(rand): update ::random calls after rand_09 migration
use alloy_consensus::{Block, Header, SignableTransaction, Transaction as _, TxLegacy};
use alloy_consensus::{Header, SignableTransaction, Transaction as _, TxLegacy};
use alloy_eips::{
eip1898::BlockWithParent,
eip4895::{Withdrawal, Withdrawals},
@@ -11,11 +11,12 @@ use alloy_eips::{
use alloy_primitives::{Address, BlockNumber, Bytes, TxKind, B256, B64, U256};
pub use rand::Rng;
use rand::{distr::uniform::SampleRange, rngs::StdRng, SeedableRng};
use reth_primitives::{
Account, BlockBody, Log, Receipt, SealedBlock, SealedHeader, StorageEntry, Transaction,
TransactionSigned,
use reth_ethereum_primitives::{Block, BlockBody, Receipt, Transaction, TransactionSigned};
use reth_primitives_traits::{
crypto::secp256k1::sign_message, proofs, Account, Block as _, Log, SealedBlock, SealedHeader,
StorageEntry,
};
use reth_primitives_traits::{crypto::secp256k1::sign_message, proofs, Block as _};
use secp256k1::{Keypair, Secp256k1};
use std::{
cmp::{max, min},
@@ -201,7 +202,11 @@ pub fn generate_keys<R: Rng>(_rng: &mut R, count: usize) -> Vec<Keypair> {
/// transactions in the block.
///
/// The ommer headers are not assumed to be valid.
pub fn random_block<R: Rng>(rng: &mut R, number: u64, block_params: BlockParams) -> SealedBlock {
pub fn random_block<R: Rng>(
rng: &mut R,
number: u64,
block_params: BlockParams,
) -> SealedBlock<Block> {
// Generate transactions
let tx_count = block_params.tx_count.unwrap_or_else(|| rng.random::<u8>());
let transactions: Vec<TransactionSigned> =
@@ -261,7 +266,7 @@ pub fn random_block_range<R: Rng>(
rng: &mut R,
block_numbers: RangeInclusive<BlockNumber>,
block_range_params: BlockRangeParams,
) -> Vec<SealedBlock> {
) -> Vec<SealedBlock<Block>> {
let mut blocks =
Vec::with_capacity(block_numbers.end().saturating_sub(*block_numbers.start()) as usize);
for idx in block_numbers {
@@ -276,7 +281,7 @@ pub fn random_block_range<R: Rng>(
idx,
BlockParams {
parent: Some(
blocks.last().map(|block: &SealedBlock| block.hash()).unwrap_or(parent),
blocks.last().map(|block: &SealedBlock<Block>| block.hash()).unwrap_or(parent),
),
tx_count: Some(tx_count),
ommers_count: None,
@@ -304,7 +309,7 @@ pub fn random_changeset_range<'a, R: Rng, IBlk, IAcc>(
key_range: Range<u64>,
) -> (Vec<ChangeSet>, BTreeMap<Address, AccountState>)
where
IBlk: IntoIterator<Item = &'a SealedBlock>,
IBlk: IntoIterator<Item = &'a SealedBlock<Block>>,
IAcc: IntoIterator<Item = (Address, (Account, Vec<StorageEntry>))>,
{
let mut state: BTreeMap<_, _> = accounts