Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions crates/evm/src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,28 @@ pub trait BlockExecutor {

self.apply_post_execution_changes()
}

/// Like [`execute_block`], but with a custom closure to process each transaction.
///
/// For instance, this enables capturing per-transaction performance metrics.
fn execute_block_with_transaction_closure<F, Tx>(
mut self,
transactions: impl IntoIterator<Item = Tx>,
mut f: F,
Comment on lines +327 to +328
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the reth pr, then what would be more useful here if this accepts an iterator of results, then we can avoid the collect

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it's actually quite important because doing collect on the iterator in reth is pretty expensive, because that iterator is yielding transactions that are decoded in parallel

) -> Result<(Self::Evm, BlockExecutionResult<Self::Receipt>), BlockExecutionError>
where
Self: Sized,
Tx: ExecutableTx<Self>,
F: FnMut(&mut Self, Tx) -> Result<u64, BlockExecutionError>,
{
self.apply_pre_execution_changes()?;

for tx in transactions {
f(&mut self, tx)?;
}

self.finish()
}
}

/// A helper trait encapsulating the constraints on [`BlockExecutor`] produced by the
Expand Down