mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: remove op-flagged arguments from receipt root calc (#6517)
This commit is contained in:
@ -69,14 +69,13 @@ pub fn calculate_withdrawals_root(withdrawals: &[Withdrawal]) -> B256 {
|
||||
}
|
||||
|
||||
/// Calculates the receipt root for a header.
|
||||
#[cfg(not(feature = "optimism"))]
|
||||
pub fn calculate_receipt_root(receipts: &[ReceiptWithBloom]) -> B256 {
|
||||
ordered_trie_root_with_encoder(receipts, |r, buf| r.encode_inner(buf, false))
|
||||
}
|
||||
|
||||
/// Calculates the receipt root for a header.
|
||||
#[cfg(feature = "optimism")]
|
||||
pub fn calculate_receipt_root(
|
||||
pub fn calculate_receipt_root_optimism(
|
||||
receipts: &[ReceiptWithBloom],
|
||||
chain_spec: &crate::ChainSpec,
|
||||
timestamp: u64,
|
||||
@ -109,7 +108,6 @@ pub fn calculate_receipt_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.
|
||||
#[cfg(not(feature = "optimism"))]
|
||||
pub fn calculate_receipt_root_ref(receipts: &[&Receipt]) -> B256 {
|
||||
ordered_trie_root_with_encoder(receipts, |r, buf| {
|
||||
ReceiptWithBloomRef::from(*r).encode_inner(buf, false)
|
||||
@ -120,7 +118,7 @@ pub fn calculate_receipt_root_ref(receipts: &[&Receipt]) -> B256 {
|
||||
///
|
||||
/// NOTE: Prefer [calculate_receipt_root] if you have log blooms memoized.
|
||||
#[cfg(feature = "optimism")]
|
||||
pub fn calculate_receipt_root_ref(
|
||||
pub fn calculate_receipt_root_ref_optimism(
|
||||
receipts: &[&Receipt],
|
||||
chain_spec: &crate::ChainSpec,
|
||||
timestamp: u64,
|
||||
@ -263,11 +261,10 @@ pub mod triehash {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[cfg(not(feature = "optimism"))]
|
||||
use crate::proofs::calculate_receipt_root;
|
||||
use crate::{
|
||||
bloom,
|
||||
constants::EMPTY_ROOT_HASH,
|
||||
hex_literal::hex,
|
||||
proofs::{calculate_receipt_root, calculate_transaction_root},
|
||||
bloom, constants::EMPTY_ROOT_HASH, hex_literal::hex, proofs::calculate_transaction_root,
|
||||
Address, Block, GenesisAccount, Log, Receipt, ReceiptWithBloom, TxType, B256, GOERLI,
|
||||
HOLESKY, MAINNET, SEPOLIA, U256,
|
||||
};
|
||||
@ -543,13 +540,14 @@ mod tests {
|
||||
bloom: Bloom(hex!("00000000000000000000000000000000400000000000000000000000000000000000004000000000000001000000000000000002000000000100000000000000000000000000000000000008000000000000000000000000000000000000000004000000020000000000000000000800000000000000000000000010200100200008000002000000000000000000800000000000000000000002000000000000000000000000000000080000000000000000000000004000000000000000000000000002000000000000000000000000000000000000200000000000000020002000000000000000002000000000000000000000000000000000000000000000").into()),
|
||||
},
|
||||
];
|
||||
let root = calculate_receipt_root(&receipts, OP_GOERLI.as_ref(), case.1);
|
||||
let root = calculate_receipt_root_optimism(&receipts, OP_GOERLI.as_ref(), case.1);
|
||||
assert_eq!(root, case.2);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "optimism")]
|
||||
#[test]
|
||||
fn check_receipt_root() {
|
||||
fn check_receipt_root_optimism() {
|
||||
let logs = vec![Log { address: Address::ZERO, topics: vec![], data: Default::default() }];
|
||||
let bloom = bloom!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
|
||||
let receipt = ReceiptWithBloom {
|
||||
@ -558,21 +556,32 @@ mod tests {
|
||||
success: true,
|
||||
cumulative_gas_used: 102068,
|
||||
logs,
|
||||
#[cfg(feature = "optimism")]
|
||||
deposit_nonce: None,
|
||||
#[cfg(feature = "optimism")]
|
||||
deposit_receipt_version: None,
|
||||
},
|
||||
bloom,
|
||||
};
|
||||
let receipt = vec![receipt];
|
||||
let root = calculate_receipt_root(
|
||||
&receipt,
|
||||
#[cfg(feature = "optimism")]
|
||||
crate::OP_GOERLI.as_ref(),
|
||||
#[cfg(feature = "optimism")]
|
||||
0,
|
||||
);
|
||||
let root = calculate_receipt_root_optimism(&receipt, crate::OP_GOERLI.as_ref(), 0);
|
||||
assert_eq!(root, b256!("fe70ae4a136d98944951b2123859698d59ad251a381abc9960fa81cae3d0d4a0"));
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "optimism"))]
|
||||
#[test]
|
||||
fn check_receipt_root_optimism() {
|
||||
let logs = vec![Log { address: Address::ZERO, topics: vec![], data: Default::default() }];
|
||||
let bloom = bloom!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
|
||||
let receipt = ReceiptWithBloom {
|
||||
receipt: Receipt {
|
||||
tx_type: TxType::EIP2930,
|
||||
success: true,
|
||||
cumulative_gas_used: 102068,
|
||||
logs,
|
||||
},
|
||||
bloom,
|
||||
};
|
||||
let receipt = vec![receipt];
|
||||
let root = calculate_receipt_root(&receipt);
|
||||
assert_eq!(root, b256!("fe70ae4a136d98944951b2123859698d59ad251a381abc9960fa81cae3d0d4a0"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user