refactor: mv proofs mod to reth-primitives-traits and split tests (#13871)

This commit is contained in:
Léa Narzis
2025-01-20 13:18:29 +01:00
committed by GitHub
parent f527b5a60d
commit d2ad477b0e
9 changed files with 184 additions and 27 deletions

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-eips = { workspace = true, features = ["serde"] }
alloy-trie = { workspace = true, features = ["serde"] }
# for eip-4844

View File

@ -1,9 +1,4 @@
//! Helper function for calculating Merkle proofs and hashes.
use crate::Receipt;
use alloy_consensus::TxReceipt;
use alloy_eips::eip2718::Encodable2718;
use alloy_primitives::B256;
pub use alloy_trie::root::ordered_trie_root_with_encoder;
pub use alloy_consensus::proofs::calculate_receipt_root;
@ -22,22 +17,16 @@ pub use alloy_consensus::proofs::calculate_withdrawals_root;
#[doc(inline)]
pub use alloy_consensus::proofs::calculate_ommers_root;
/// Calculates the receipt root for a header for the reference type of [Receipt].
///
/// NOTE: Prefer [`calculate_receipt_root`] if you have log blooms memoized.
pub fn calculate_receipt_root_no_memo(receipts: &[&Receipt]) -> B256 {
ordered_trie_root_with_encoder(receipts, |r, buf| r.with_bloom_ref().encode_2718(buf))
}
#[cfg(test)]
mod tests {
use super::*;
use crate::{Block, TxType};
use alloy_consensus::EMPTY_ROOT_HASH;
use alloy_genesis::GenesisAccount;
use alloy_primitives::{b256, bloom, hex_literal::hex, Address, Log, LogData, U256};
use alloy_primitives::{b256, bloom, hex_literal::hex, Address, Log, LogData, B256, U256};
use alloy_rlp::Decodable;
use reth_chainspec::{HOLESKY, MAINNET, SEPOLIA};
use reth_ethereum_primitives::Receipt;
use reth_trie_common::root::{state_root_ref_unhashed, state_root_unhashed};
use std::collections::HashMap;