diff --git a/crates/evm/execution-types/src/chain.rs b/crates/evm/execution-types/src/chain.rs index 3cde0eaa79..e235141cf2 100644 --- a/crates/evm/execution-types/src/chain.rs +++ b/crates/evm/execution-types/src/chain.rs @@ -2,9 +2,9 @@ use crate::ExecutionOutcome; use alloc::{borrow::Cow, collections::BTreeMap, vec::Vec}; -use alloy_consensus::{transaction::Recovered, BlockHeader}; +use alloy_consensus::{transaction::Recovered, BlockHeader, TxReceipt}; use alloy_eips::{eip1898::ForkBlock, eip2718::Encodable2718, BlockNumHash}; -use alloy_primitives::{Address, BlockHash, BlockNumber, TxHash}; +use alloy_primitives::{Address, BlockHash, BlockNumber, Log, TxHash}; use core::{fmt, ops::RangeInclusive}; use reth_primitives_traits::{ transaction::signed::SignedTransaction, Block, BlockBody, IndexedTx, NodePrimitives, @@ -184,6 +184,19 @@ impl Chain { self.execution_outcome.receipts().iter() } + /// Returns an iterator over all receipts in the chain. + pub fn receipts_iter(&self) -> impl Iterator + '_ { + self.block_receipts_iter().flatten() + } + + /// Returns an iterator over all logs in the chain. + pub fn logs_iter(&self) -> impl Iterator + '_ + where + N::Receipt: TxReceipt, + { + self.receipts_iter().flat_map(|receipt| receipt.logs()) + } + /// Returns an iterator over all blocks in the chain with increasing block number. pub fn blocks_iter(&self) -> impl Iterator> + '_ { self.blocks().iter().map(|block| block.1)