refactor: finalize proofs mod move from reth-primitives to reth-primitives-traits (#13875)

This commit is contained in:
Léa Narzis
2025-01-22 21:15:47 +01:00
committed by GitHub
parent 3b0e70a512
commit 6c762565b8
16 changed files with 30 additions and 41 deletions

View File

@ -18,12 +18,14 @@ use rand::{thread_rng, Rng};
use reth_chainspec::{ChainSpec, EthereumHardfork, MIN_TRANSACTION_GAS};
use reth_execution_types::{Chain, ExecutionOutcome};
use reth_primitives::{
proofs::{calculate_receipt_root, calculate_transaction_root, calculate_withdrawals_root},
transaction::SignedTransactionIntoRecoveredExt,
BlockBody, EthPrimitives, NodePrimitives, Receipt, Receipts, Recovered, RecoveredBlock,
SealedBlock, SealedHeader, Transaction, TransactionSigned,
transaction::SignedTransactionIntoRecoveredExt, BlockBody, EthPrimitives, NodePrimitives,
Receipt, Receipts, Recovered, RecoveredBlock, SealedBlock, SealedHeader, Transaction,
TransactionSigned,
};
use reth_primitives_traits::{
proofs::{calculate_receipt_root, calculate_transaction_root, calculate_withdrawals_root},
Account,
};
use reth_primitives_traits::Account;
use reth_storage_api::NodePrimitivesProvider;
use reth_trie::{root::state_root_unhashed, updates::TrieUpdates, HashedPostState};
use revm::{db::BundleState, primitives::AccountInfo};

View File

@ -340,7 +340,8 @@ mod tests {
use alloy_primitives::{Address, Bytes, PrimitiveSignature as Signature, U256};
use rand::Rng;
use reth_chainspec::ChainSpecBuilder;
use reth_primitives::{proofs, BlockBody, Transaction, TransactionSigned};
use reth_primitives::{BlockBody, Transaction, TransactionSigned};
use reth_primitives_traits::proofs;
fn mock_blob_tx(nonce: u64, num_blobs: usize) -> TransactionSigned {
let mut rng = rand::thread_rng();

View File

@ -19,9 +19,9 @@ use reth_evm::{
};
use reth_payload_validator::ExecutionPayloadValidator;
use reth_primitives::{
proofs, transaction::SignedTransactionIntoRecoveredExt, Block, BlockBody, Receipt, Receipts,
transaction::SignedTransactionIntoRecoveredExt, Block, BlockBody, Receipt, Receipts,
};
use reth_primitives_traits::{block::Block as _, SignedTransaction};
use reth_primitives_traits::{block::Block as _, proofs, SignedTransaction};
use reth_provider::{BlockReader, ExecutionOutcome, ProviderError, StateProviderFactory};
use reth_revm::{
database::StateProviderDatabase,

View File

@ -270,7 +270,7 @@ mod tests {
use super::*;
use alloy_primitives::B256;
use reth_chainspec::{ChainSpec, ChainSpecBuilder};
use reth_primitives::proofs;
use reth_primitives_traits::proofs;
fn header_with_gas_limit(gas_limit: u64) -> SealedHeader {
let header = reth_primitives::Header { gas_limit, ..Default::default() };

View File

@ -31,11 +31,13 @@ use reth_payload_builder::{EthBuiltPayload, EthPayloadBuilderAttributes};
use reth_payload_builder_primitives::PayloadBuilderError;
use reth_payload_primitives::PayloadBuilderAttributes;
use reth_primitives::{
proofs::{self},
Block, BlockBody, EthereumHardforks, InvalidTransactionError, Receipt, RecoveredBlock,
TransactionSigned,
};
use reth_primitives_traits::{Block as _, SignedTransaction};
use reth_primitives_traits::{
proofs::{self},
Block as _, SignedTransaction,
};
use reth_revm::database::StateProviderDatabase;
use reth_storage_api::StateProviderFactory;
use reth_transaction_pool::{

View File

@ -28,9 +28,9 @@ use reth_payload_builder_primitives::PayloadBuilderError;
use reth_payload_primitives::PayloadBuilderAttributes;
use reth_payload_util::{NoopPayloadTransactions, PayloadTransactions};
use reth_primitives::{
proofs, transaction::SignedTransactionIntoRecoveredExt, Block, BlockBody, SealedHeader,
transaction::SignedTransactionIntoRecoveredExt, Block, BlockBody, SealedHeader,
};
use reth_primitives_traits::{block::Block as _, RecoveredBlock};
use reth_primitives_traits::{block::Block as _, proofs, RecoveredBlock};
use reth_provider::{
HashedPostStateProvider, ProviderError, StateProofProvider, StateProviderFactory,
StateRootProvider,

View File

@ -15,6 +15,7 @@ workspace = true
# reth
reth-chainspec.workspace = true
reth-primitives.workspace = true
reth-primitives-traits.workspace = true
reth-transaction-pool.workspace = true
reth-provider.workspace = true
reth-payload-builder.workspace = true

View File

@ -19,7 +19,8 @@ use reth_evm::state_change::post_block_withdrawals_balance_increments;
use reth_payload_builder::{KeepPayloadJobAlive, PayloadId, PayloadJob, PayloadJobGenerator};
use reth_payload_builder_primitives::PayloadBuilderError;
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadKind};
use reth_primitives::{proofs, NodePrimitives, SealedHeader};
use reth_primitives::{NodePrimitives, SealedHeader};
use reth_primitives_traits::proofs;
use reth_provider::{BlockReaderIdExt, CanonStateNotification, StateProviderFactory};
use reth_revm::cached::CachedReads;
use reth_tasks::TaskSpawner;

View File

@ -21,7 +21,6 @@ reth-static-file-types.workspace = true
# ethereum
alloy-consensus.workspace = true
alloy-primitives = { workspace = true, features = ["rand", "rlp"] }
alloy-trie = { workspace = true, features = ["serde"] }
# for eip-4844
c-kzg = { workspace = true, features = ["serde"], optional = true }
@ -66,7 +65,6 @@ std = [
"alloy-primitives/std",
"once_cell/std",
"serde/std",
"alloy-trie/std",
"reth-ethereum-forks/std",
"derive_more/std",
"serde_json/std",
@ -87,7 +85,6 @@ arbitrary = [
"reth-primitives-traits/arbitrary",
"alloy-consensus/arbitrary",
"alloy-primitives/arbitrary",
"alloy-trie/arbitrary",
"reth-ethereum-primitives/arbitrary",
"reth-codecs/arbitrary"
]

View File

@ -22,7 +22,6 @@
extern crate alloc;
mod block;
pub mod proofs;
mod receipt;
pub use reth_static_file_types as static_file;
pub mod transaction;

View File

@ -1,18 +0,0 @@
//! Helper function for calculating Merkle proofs and hashes.
pub use alloy_trie::root::ordered_trie_root_with_encoder;
pub use alloy_consensus::proofs::calculate_receipt_root;
/// Calculate a transaction root.
///
/// `(rlp(index), encoded(tx))` pairs.
#[doc(inline)]
pub use alloy_consensus::proofs::calculate_transaction_root;
/// Calculates the root hash of the withdrawals.
#[doc(inline)]
pub use alloy_consensus::proofs::calculate_withdrawals_root;
/// Calculates the root hash for ommer/uncle headers.
#[doc(inline)]
pub use alloy_consensus::proofs::calculate_ommers_root;

View File

@ -49,6 +49,7 @@ parking_lot.workspace = true
reth-ethereum-engine-primitives.workspace = true
reth-provider = { workspace = true, features = ["test-utils"] }
reth-primitives.workspace = true
reth-primitives-traits.workspace = true
reth-payload-builder = { workspace = true, features = ["test-utils"] }
reth-tokio-util.workspace = true
reth-testing-utils.workspace = true

View File

@ -8,7 +8,8 @@ use alloy_rpc_types_engine::{
PayloadError,
};
use assert_matches::assert_matches;
use reth_primitives::{proofs, Block, SealedBlock, SealedHeader, TransactionSigned};
use reth_primitives::{Block, SealedBlock, SealedHeader, TransactionSigned};
use reth_primitives_traits::proofs;
use reth_rpc_types_compat::engine::payload::{block_to_payload, block_to_payload_v1};
use reth_testing_utils::generators::{
self, random_block, random_block_range, BlockParams, BlockRangeParams, Rng,

View File

@ -5,7 +5,8 @@ use alloy_eips::{eip7685::EMPTY_REQUESTS_HASH, merge::BEACON_NONCE};
use alloy_primitives::U256;
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_evm::ConfigureEvm;
use reth_primitives::{logs_bloom, proofs::calculate_transaction_root, BlockBody, Receipt};
use reth_primitives::{logs_bloom, BlockBody, Receipt};
use reth_primitives_traits::proofs::calculate_transaction_root;
use reth_provider::{
BlockReader, BlockReaderIdExt, ChainSpecProvider, ProviderBlock, ProviderReceipt, ProviderTx,
StateProviderFactory,