Skip to content

feat(cheatcodes): inversion of control for CheatcodesExecutor#13651

Closed
figtracer wants to merge 1 commit intofoundry-rs:masterfrom
figtracer:fig/cheatcodes-executor-inversion
Closed

feat(cheatcodes): inversion of control for CheatcodesExecutor#13651
figtracer wants to merge 1 commit intofoundry-rs:masterfrom
figtracer:fig/cheatcodes-executor-inversion

Conversation

@figtracer
Copy link
Copy Markdown
Collaborator

Summary

  • Remove get_inspector() -> Box<dyn InspectorExt> from CheatcodesExecutor
  • Instead, the executor assembles the inspector internally and owns the operation
  • New methods: with_nested_evm, with_fresh_nested_evm, transact_on_db, transact_from_tx_on_db
  • InspectorExt no longer appears on the CheatcodesExecutor trait boundary

Stack: #13650 → PR 2/3 → #next

Depends on #13650

Test plan

  • cargo check passes (zero errors, zero warnings)
  • All cheatcode callsites updated mechanically

Copy link
Copy Markdown
Collaborator

@mablr mablr left a comment

Choose a reason for hiding this comment

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

We may skip this one to merge directly #13652 since NestedEvmExt is immediately replaced ? Is this okay @figtracer ?

The free function approach with a closure seems lighter.

@figtracer
Copy link
Copy Markdown
Collaborator Author

We may skip this one to merge directly #13652 since NestedEvmExt is immediately replaced ? Is this okay @figtracer ?

The free function approach with a closure seems lighter.

For sure, might be more contained this way

@figtracer figtracer force-pushed the fig/cheatcodes-executor-inversion branch 2 times, most recently from 443ed1f to a6a759b Compare March 7, 2026 07:51
Remove `get_inspector()` which returned `Box<dyn InspectorExt>` (Eth-bound).
Instead, the executor now assembles the inspector internally and owns
the entire operation:

- `with_nested_evm`: runs closure with nested EVM cloned from context
- `with_fresh_nested_evm`: runs closure with fresh EVM from raw db+env
- `transact_on_db`: replays historical transaction
- `transact_from_tx_on_db`: executes a TransactionRequest

`InspectorExt` no longer appears on the `CheatcodesExecutor` trait boundary.
It only lives inside the impl bodies of `InspectorStackInner` and
`TransparentCheatcodesExecutor`.
@figtracer figtracer force-pushed the fig/cheatcodes-executor-inversion branch from a6a759b to ddc8e38 Compare March 7, 2026 07:56
@figtracer figtracer closed this Mar 7, 2026
@github-project-automation github-project-automation Bot moved this to Done in Foundry Mar 7, 2026
@figtracer figtracer deleted the fig/cheatcodes-executor-inversion branch March 7, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants