-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: CheatcodesExecutor
+ vm.deployCode
#8181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
CheatcodesExecutor
CheatcodesExecutor
+ vm.deployCode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits
Motivation
Some of the cheatcodes require creating and executing separate EVM frames. Examples of such cheatcodes are
deployCode
andassertEqCall
from forge-std andvm.transact
.Current structure does not allow us to correctly execute such frames because we don't have access to complete
Inspector
instance. Because of that, for example,vm.transact
does not produce any traces at the moment.Solution
This PR adds
CheatcodesExecutor
trait which is passed tocall
hook onCheatcodes
. Its implementors should implementget_inspector
method which accepts&mut Cheatcodes
and returnsInspector
instance.InspectorStack
is divided intoInspectorStackInner
andCheatcodes
to allow separateimpl CheatcodesExecutor for InspectorStackInner
.Cheatcodes
impl ofInspector
was inlined andcall
hook is modified to acceptCheatcodesExecutor
.This PR adjusts
DatabaseExt
trait to allow usage ofdyn DatabaseExt
asDB: DatabaseExt
and changestransact_inner
and other methods creating inner EVMs to using&mut dyn DB
instead of&mut DB
to allowDatabaseExt::transact
to 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,
deployCode
impl does work already