Skip to content

feat: exec hooks - #282

Open
loocapro wants to merge 2 commits into
alloy-rs:mainfrom
loocapro:feat/exec-before-after-hooks
Open

feat: exec hooks#282
loocapro wants to merge 2 commits into
alloy-rs:mainfrom
loocapro:feat/exec-before-after-hooks

Conversation

@loocapro

@loocapro loocapro commented Feb 7, 2026

Copy link
Copy Markdown

Motivation

Add before/after execution hooks to BlockExecutor, with no-op defaults and minimal overhead:

  • Zero-cost abstraction: Hooks default to no-op, so callers pay nothing when they don’t use them.
  • Simple API: Use .before(|evm, tx| ...) and .after(|evm, result| ...) to add hooks.

Solution

Added a new before and after trait method for BlockExecutor in order to set custom behaviour. New API:

 let executor = factory.create_executor(evm, ctx);

 let gas_used = executor
     .before(|evm, tx| { Ok(()) })
     .after(|evm, result| { Ok(()) })
     .execute_transaction(&recovered_tx)?;

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant