feat: implement EIP-7685 (#8424)

Co-authored-by: Oliver Nordbjerg <onbjerg@users.noreply.github.com>
Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Alexey Shekhirin
2024-05-28 15:06:28 +01:00
committed by GitHub
parent f6e1c7f76e
commit b4a1b733c9
83 changed files with 1053 additions and 214 deletions

View File

@ -4,9 +4,10 @@ use crate::{
constants::EMPTY_OMMER_ROOT_HASH,
keccak256,
trie::{HashBuilder, Nibbles, TrieAccount},
Address, Header, Receipt, ReceiptWithBloom, ReceiptWithBloomRef, TransactionSigned, Withdrawal,
B256, U256,
Address, Header, Receipt, ReceiptWithBloom, ReceiptWithBloomRef, Request, TransactionSigned,
Withdrawal, B256, U256,
};
use alloy_eips::eip7685::Encodable7685;
use alloy_rlp::Encodable;
use itertools::Itertools;
@ -69,6 +70,13 @@ pub fn calculate_receipt_root(receipts: &[ReceiptWithBloom]) -> B256 {
ordered_trie_root_with_encoder(receipts, |r, buf| r.encode_inner(buf, false))
}
/// Calculate [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685) requests root.
///
/// NOTE: The requests are encoded as `id + request`
pub fn calculate_requests_root(requests: &[Request]) -> B256 {
ordered_trie_root_with_encoder(requests, |item, buf| item.encode_7685(buf))
}
/// Calculates the receipt root for a header.
#[cfg(feature = "optimism")]
pub fn calculate_receipt_root_optimism(