feat: add InspectorFor trait to enable multi-context EVM factories - #297
Draft
stevencartavia wants to merge 1 commit into
Draft
stevencartavia wants to merge 1 commit into
stevencartavia wants to merge 1 commit into
Conversation
mablr
reviewed
Feb 21, 2026
mablr
left a comment
Contributor
There was a problem hiding this comment.
I think that customizable inspector is required by the current Foundry Evm design. And I haven't found so far any prettier way to do so directly in Foundry.
Comment on lines
+298
to
+306
| type Evm: Evm< | ||
| DB = DB, | ||
| Tx = <Self as EvmFactory>::Tx, | ||
| HaltReason = <Self as EvmFactory>::HaltReason, | ||
| Error = <Self as EvmFactory>::Error<DB::Error>, | ||
| Spec = <Self as EvmFactory>::Spec, | ||
| BlockEnv = <Self as EvmFactory>::BlockEnv, | ||
| Precompiles = <Self as EvmFactory>::Precompiles, | ||
| Inspector = I, |
Contributor
There was a problem hiding this comment.
I guess there's no other way than type erasure to implement Foundry's EitherEvm. The question is whether we're going to keep this pattern.
There was a problem hiding this comment.
it serves as a good bridge for eventually removing it in the future but i think we should keep it now
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces
InspectorFor<DB, I>, a new trait that separates factory metadata (EvmFactory) from inspector compatibility. The motivation is unblockingBlockExecutorFactoryfor multi-context EVM factories likeEitherEvm— the currenttype Context<DB>generic associated type onEvmFactorymakes it impossible to express dual inspector bounds (I: Inspector<EthEvmContext<DB>> + Inspector<OpContext<DB>>), which are required by foundry's enum EVM dispatcher.BlockExecutorFactory::create_executoris updated to bound onF::EvmFactory: InspectorFor<&mut State<DB>, I>instead. It makes multi-context EVM factories possible here and is a step toward network-agnostic block execution.Path forward:
type Evm<DB, I>andtype Context<DB>GATs, implementInspectorFor<DB, I>whereI: Inspector<OpContext<DB>>EitherEvmFactorywrapping existing EVM creation logic, wireTransactionExecutorasBlockExecutorFactoryPR Checklist