mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-09 15:28:01 -05:00
chore: Replace remaining uses of reth_primitives with reth_primitives_traits (#15704)
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -3088,11 +3088,13 @@ dependencies = [
|
|||||||
"reth-db",
|
"reth-db",
|
||||||
"reth-db-api",
|
"reth-db-api",
|
||||||
"reth-ethereum-consensus",
|
"reth-ethereum-consensus",
|
||||||
|
"reth-ethereum-primitives",
|
||||||
"reth-evm-ethereum",
|
"reth-evm-ethereum",
|
||||||
"reth-primitives",
|
"reth-primitives-traits",
|
||||||
"reth-provider",
|
"reth-provider",
|
||||||
"reth-revm",
|
"reth-revm",
|
||||||
"reth-stages",
|
"reth-stages",
|
||||||
|
"reth-static-file-types",
|
||||||
"revm",
|
"revm",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -9956,7 +9958,7 @@ dependencies = [
|
|||||||
"alloy-primitives 1.0.0",
|
"alloy-primitives 1.0.0",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"rand 0.9.0",
|
"rand 0.9.0",
|
||||||
"reth-primitives",
|
"reth-ethereum-primitives",
|
||||||
"reth-primitives-traits",
|
"reth-primitives-traits",
|
||||||
"secp256k1",
|
"secp256k1",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ pub trait SignedTransaction:
|
|||||||
|
|
||||||
/// Recover signer from signature and hash.
|
/// Recover signer from signature and hash.
|
||||||
///
|
///
|
||||||
/// Returns `RecoveryError` if the transaction's signature is invalid following [EIP-2](https://eips.ethereum.org/EIPS/eip-2), see also `reth_primitives::transaction::recover_signer`.
|
/// Returns `RecoveryError` if the transaction's signature is invalid following [EIP-2](https://eips.ethereum.org/EIPS/eip-2), see also `reth_primitive_traits::crypto::secp256k1::recover_signer`.
|
||||||
///
|
///
|
||||||
/// Note:
|
/// Note:
|
||||||
///
|
///
|
||||||
@@ -72,7 +72,7 @@ pub trait SignedTransaction:
|
|||||||
/// value_.
|
/// value_.
|
||||||
///
|
///
|
||||||
/// Returns `RecoveryError` if the transaction's signature is invalid, see also
|
/// Returns `RecoveryError` if the transaction's signature is invalid, see also
|
||||||
/// `reth_primitives::transaction::recover_signer_unchecked`.
|
/// `reth_primitive_traits::crypto::secp256k1::recover_signer_unchecked`.
|
||||||
fn recover_signer_unchecked(&self) -> Result<Address, RecoveryError> {
|
fn recover_signer_unchecked(&self) -> Result<Address, RecoveryError> {
|
||||||
self.recover_signer_unchecked_with_buf(&mut Vec::new())
|
self.recover_signer_unchecked_with_buf(&mut Vec::new())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
use alloy_primitives::hex_literal::hex;
|
use alloy_primitives::hex_literal::hex;
|
||||||
use alloy_rlp::Decodable;
|
use alloy_rlp::Decodable;
|
||||||
use criterion::{criterion_group, criterion_main, Criterion};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
use reth_primitives::TransactionSigned;
|
use reth_ethereum_primitives::TransactionSigned;
|
||||||
use reth_primitives_traits::SignedTransaction;
|
use reth_primitives_traits::SignedTransaction;
|
||||||
|
|
||||||
/// Benchmarks the recovery of the public key from the ECDSA message using criterion.
|
/// Benchmarks the recovery of the public key from the ECDSA message using criterion.
|
||||||
|
|||||||
@@ -14,18 +14,19 @@ workspace = true
|
|||||||
[features]
|
[features]
|
||||||
ef-tests = []
|
ef-tests = []
|
||||||
asm-keccak = [
|
asm-keccak = [
|
||||||
"reth-primitives/asm-keccak",
|
|
||||||
"alloy-primitives/asm-keccak",
|
"alloy-primitives/asm-keccak",
|
||||||
"revm/asm-keccak",
|
"revm/asm-keccak",
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
reth-chainspec.workspace = true
|
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 = { workspace = true, features = ["mdbx", "test-utils", "disable-lock"] }
|
||||||
reth-db-api.workspace = true
|
reth-db-api.workspace = true
|
||||||
reth-provider = { workspace = true, features = ["test-utils"] }
|
reth-provider = { workspace = true, features = ["test-utils"] }
|
||||||
reth-stages.workspace = true
|
reth-stages.workspace = true
|
||||||
|
reth-static-file-types.workspace = true
|
||||||
reth-evm-ethereum.workspace = true
|
reth-evm-ethereum.workspace = true
|
||||||
reth-ethereum-consensus.workspace = true
|
reth-ethereum-consensus.workspace = true
|
||||||
reth-revm = { workspace = true, features = ["std"] }
|
reth-revm = { workspace = true, features = ["std"] }
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ use alloy_rlp::Decodable;
|
|||||||
use rayon::iter::{ParallelBridge, ParallelIterator};
|
use rayon::iter::{ParallelBridge, ParallelIterator};
|
||||||
use reth_chainspec::ChainSpec;
|
use reth_chainspec::ChainSpec;
|
||||||
use reth_ethereum_consensus::EthBeaconConsensus;
|
use reth_ethereum_consensus::EthBeaconConsensus;
|
||||||
use reth_primitives::{BlockBody, SealedBlock, StaticFileSegment};
|
use reth_ethereum_primitives::Block;
|
||||||
|
use reth_primitives_traits::SealedBlock;
|
||||||
use reth_provider::{
|
use reth_provider::{
|
||||||
providers::StaticFileWriter, test_utils::create_test_provider_factory_with_chain_spec,
|
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 reth_stages::{stages::ExecutionStage, ExecInput, Stage};
|
||||||
use std::{collections::BTreeMap, fs, path::Path, sync::Arc};
|
use std::{collections::BTreeMap, fs, path::Path, sync::Arc};
|
||||||
@@ -92,9 +93,9 @@ impl Case for BlockchainTestCase {
|
|||||||
|
|
||||||
// Insert initial test state into the provider.
|
// Insert initial test state into the provider.
|
||||||
provider.insert_historical_block(
|
provider.insert_historical_block(
|
||||||
SealedBlock::<reth_primitives::Block>::from_sealed_parts(
|
SealedBlock::<Block>::from_sealed_parts(
|
||||||
case.genesis_block_header.clone().into(),
|
case.genesis_block_header.clone().into(),
|
||||||
BlockBody::default(),
|
Default::default(),
|
||||||
)
|
)
|
||||||
.try_recover()
|
.try_recover()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
@@ -112,10 +113,9 @@ impl Case for BlockchainTestCase {
|
|||||||
|
|
||||||
// Decode and insert blocks, creating a chain of blocks for the test case.
|
// Decode and insert blocks, creating a chain of blocks for the test case.
|
||||||
let last_block = case.blocks.iter().try_fold(None, |_, block| {
|
let last_block = case.blocks.iter().try_fold(None, |_, block| {
|
||||||
let decoded =
|
let decoded = SealedBlock::<Block>::decode(&mut block.rlp.as_ref())?;
|
||||||
SealedBlock::<reth_primitives::Block>::decode(&mut block.rlp.as_ref())?;
|
|
||||||
provider.insert_historical_block(decoded.clone().try_recover().unwrap())?;
|
provider.insert_historical_block(decoded.clone().try_recover().unwrap())?;
|
||||||
Ok::<Option<SealedBlock>, Error>(Some(decoded))
|
Ok::<Option<SealedBlock<Block>>, Error>(Some(decoded))
|
||||||
})?;
|
})?;
|
||||||
provider
|
provider
|
||||||
.static_file_provider()
|
.static_file_provider()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use reth_db_api::{
|
|||||||
tables,
|
tables,
|
||||||
transaction::{DbTx, DbTxMut},
|
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 serde::Deserialize;
|
||||||
use std::{collections::BTreeMap, ops::Deref};
|
use std::{collections::BTreeMap, ops::Deref};
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ repository.workspace = true
|
|||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
reth-primitives = { workspace = true, features = ["secp256k1", "arbitrary"] }
|
reth-ethereum-primitives = { workspace = true, features = ["arbitrary", "std"] }
|
||||||
reth-primitives-traits = { workspace = true, features = ["secp256k1", "arbitrary"] }
|
reth-primitives-traits = { workspace = true, features = ["secp256k1", "arbitrary"] }
|
||||||
|
|
||||||
alloy-genesis.workspace = true
|
alloy-genesis.workspace = true
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// TODO(rand): update ::random calls after rand_09 migration
|
// 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::{
|
use alloy_eips::{
|
||||||
eip1898::BlockWithParent,
|
eip1898::BlockWithParent,
|
||||||
eip4895::{Withdrawal, Withdrawals},
|
eip4895::{Withdrawal, Withdrawals},
|
||||||
@@ -11,11 +11,12 @@ use alloy_eips::{
|
|||||||
use alloy_primitives::{Address, BlockNumber, Bytes, TxKind, B256, B64, U256};
|
use alloy_primitives::{Address, BlockNumber, Bytes, TxKind, B256, B64, U256};
|
||||||
pub use rand::Rng;
|
pub use rand::Rng;
|
||||||
use rand::{distr::uniform::SampleRange, rngs::StdRng, SeedableRng};
|
use rand::{distr::uniform::SampleRange, rngs::StdRng, SeedableRng};
|
||||||
use reth_primitives::{
|
use reth_ethereum_primitives::{Block, BlockBody, Receipt, Transaction, TransactionSigned};
|
||||||
Account, BlockBody, Log, Receipt, SealedBlock, SealedHeader, StorageEntry, Transaction,
|
use reth_primitives_traits::{
|
||||||
TransactionSigned,
|
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 secp256k1::{Keypair, Secp256k1};
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{max, min},
|
cmp::{max, min},
|
||||||
@@ -201,7 +202,11 @@ pub fn generate_keys<R: Rng>(_rng: &mut R, count: usize) -> Vec<Keypair> {
|
|||||||
/// transactions in the block.
|
/// transactions in the block.
|
||||||
///
|
///
|
||||||
/// The ommer headers are not assumed to be valid.
|
/// 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
|
// Generate transactions
|
||||||
let tx_count = block_params.tx_count.unwrap_or_else(|| rng.random::<u8>());
|
let tx_count = block_params.tx_count.unwrap_or_else(|| rng.random::<u8>());
|
||||||
let transactions: Vec<TransactionSigned> =
|
let transactions: Vec<TransactionSigned> =
|
||||||
@@ -261,7 +266,7 @@ pub fn random_block_range<R: Rng>(
|
|||||||
rng: &mut R,
|
rng: &mut R,
|
||||||
block_numbers: RangeInclusive<BlockNumber>,
|
block_numbers: RangeInclusive<BlockNumber>,
|
||||||
block_range_params: BlockRangeParams,
|
block_range_params: BlockRangeParams,
|
||||||
) -> Vec<SealedBlock> {
|
) -> Vec<SealedBlock<Block>> {
|
||||||
let mut blocks =
|
let mut blocks =
|
||||||
Vec::with_capacity(block_numbers.end().saturating_sub(*block_numbers.start()) as usize);
|
Vec::with_capacity(block_numbers.end().saturating_sub(*block_numbers.start()) as usize);
|
||||||
for idx in block_numbers {
|
for idx in block_numbers {
|
||||||
@@ -276,7 +281,7 @@ pub fn random_block_range<R: Rng>(
|
|||||||
idx,
|
idx,
|
||||||
BlockParams {
|
BlockParams {
|
||||||
parent: Some(
|
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),
|
tx_count: Some(tx_count),
|
||||||
ommers_count: None,
|
ommers_count: None,
|
||||||
@@ -304,7 +309,7 @@ pub fn random_changeset_range<'a, R: Rng, IBlk, IAcc>(
|
|||||||
key_range: Range<u64>,
|
key_range: Range<u64>,
|
||||||
) -> (Vec<ChangeSet>, BTreeMap<Address, AccountState>)
|
) -> (Vec<ChangeSet>, BTreeMap<Address, AccountState>)
|
||||||
where
|
where
|
||||||
IBlk: IntoIterator<Item = &'a SealedBlock>,
|
IBlk: IntoIterator<Item = &'a SealedBlock<Block>>,
|
||||||
IAcc: IntoIterator<Item = (Address, (Account, Vec<StorageEntry>))>,
|
IAcc: IntoIterator<Item = (Address, (Account, Vec<StorageEntry>))>,
|
||||||
{
|
{
|
||||||
let mut state: BTreeMap<_, _> = accounts
|
let mut state: BTreeMap<_, _> = accounts
|
||||||
|
|||||||
Reference in New Issue
Block a user