feat: CheatcodesExecutor + vm.deployCode#8181
Conversation
There was a problem hiding this comment.
I see,
this removes the inspector impl from cheatcodes and adds the functions natively, so that we can also pass the CheatcodesExecutor (StackInner), this way we can invoke the evm from the Cheatcodes and keep inspecting with the stack.
so this introduces an additional layer in the stack.
I think this should work, and isn't too bad if we document this properly, the downside is additional complexity.
I thought about alternative approaches, but I couldn't come up with anything.
the stateful precompiles limitation might become an issue down the road
I don't think this has significant performance impacts
wdyt @DaniPopes
|
Added two |
CheatcodesExecutorCheatcodesExecutor + vm.deployCode
mattsse
left a comment
There was a problem hiding this comment.
I think this is a great solution.
I think we could add back the inspector impl to Cheatcodes be calling its call function with a noop Cheatcodesexecutor or an empty stack?
pending @DaniPopes
|
Added |
Motivation
Some of the cheatcodes require creating and executing separate EVM frames. Examples of such cheatcodes are
deployCodeandassertEqCallfrom forge-std andvm.transact.Current structure does not allow us to correctly execute such frames because we don't have access to complete
Inspectorinstance. Because of that, for example,vm.transactdoes not produce any traces at the moment.Solution
This PR adds
CheatcodesExecutortrait which is passed tocallhook onCheatcodes. Its implementors should implementget_inspectormethod which accepts&mut Cheatcodesand returnsInspectorinstance.InspectorStackis divided intoInspectorStackInnerandCheatcodesto allow separateimpl CheatcodesExecutor for InspectorStackInner.Cheatcodesimpl ofInspectorwas inlined andcallhook is modified to acceptCheatcodesExecutor.This PR adjusts
DatabaseExttrait to allow usage ofdyn DatabaseExtasDB: DatabaseExtand changestransact_innerand other methods creating inner EVMs to using&mut dyn DBinstead of&mut DBto allowDatabaseExt::transactto acceptInspector<Backend>.The only limitation currently is that we can't pass
ContextPrecompiles<DB>to inner context.ContextPrecompiles<DB>can't be used asContextPrecompiles<&mut dyn DB>andContextPrecompiles<&mut DB>doesn't work because it's invariant over&mut DB. This might be an issue if we decide to implement stateful precompiles which should be persisted when entering inner EVM context.Marking as WIP for now, however,
deployCodeimpl does work already