refactor(evm): replace NestedEvmExt trait with free function#13652
refactor(evm): replace NestedEvmExt trait with free function#13652mattsse merged 2 commits intofoundry-rs:masterfrom
Conversation
d775a1c to
fc5b5b8
Compare
fc5b5b8 to
31da635
Compare
NestedEvmExt network-agnostic
mablr
left a comment
There was a problem hiding this comment.
Free function with_cloned_context looks good to me.
I'm not sure about adding another abstraction via CheatsCtxExt trait for the moment, as the bounds are still subject to change (eg: FoundryContextExt support only Ethereum EVM). Let's stabilize this first? wdyt @figtracer
imo we should proceed with this if it makes sense atm, if anything changes we come back to it? i believe that having this extra-bounded version of it can help to frame the problem in the future if that makes sense and we stack the more refined ergonomics on top of it |
dad5c49 to
af38a4b
Compare
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`.
Remove `InspectorExt` from `NestedEvmExt` entirely. The trait now handles only network-agnostic work (clone env + journal, split db borrow, write back). Callers build their own EVM inside a callback that receives `(&mut dyn DatabaseExt, Env, JournaledState)`. - Remove `new_nested_evm` from `NestedEvmExt` (callers call `new_evm_with_inspector` directly) - Remove `new_evm_with_existing_context` (dead code) - Update `InspectorStackInner` and `TransparentCheatcodesExecutor` to build `FoundryEvm` inside the callback - `CheatsCtxExt: NestedEvmExt` is now fully network-agnostic
af38a4b to
c9493ac
Compare
Summary
NestedEvmExttrait withwith_cloned_contextfree function(&mut dyn DatabaseExt, Env, JournaledState)new_nested_evmfrom trait andnew_evm_with_existing_context(dead code)CheatsCtxExtto justFoundryContextExtwith journal/db bounds (one less trait)Stack: #13650 → #13651 → PR 3/3
Depends on #13651
Test plan
cargo checkpasses (zero errors, zero warnings)InspectorStackInner,TransparentCheatcodesExecutor