Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
Receipt roots
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Oct 17, 2023
1 parent d4b0fcf commit fe28b53
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions crates/primitives/src/proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,27 @@ pub fn calculate_receipt_root_ref<T>(receipts: &[&T]) -> B256
where
for<'a> ReceiptWithBloomRef<'a>: From<&'a T>,
{
#[cfg(feature = "optimism")]
{
// There is a minor bug in op-geth and op-erigon where in the Regolith hardfork,
// the receipt root calculation does not include the deposit nonce in the receipt
// encoding. This will be fixd in the next hardfork, however for now, we must strip
// the deposit nonce from the receipts before calculating the receipt root.
let receipts = receipts
.iter()
.map(|r| {
let mut r = r.clone();
r.receipt.deposit_nonce = None;
r
})
.collect::<Vec<_>>();

ordered_trie_root_with_encoder(&receipts, |r, buf| {
ReceiptWithBloomRef::from(r).encode_inner(buf, false)
})
}

#[cfg(not(feature = "optimism"))]
ordered_trie_root_with_encoder(receipts, |r, buf| {
ReceiptWithBloomRef::from(r).encode_inner(buf, false)
})
Expand Down

0 comments on commit fe28b53

Please sign in to comment.