-
Notifications
You must be signed in to change notification settings - Fork 2
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
refactor: PrecompileEnvironment.{,Use,Refund}Gas()
in lieu of args
#73
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.
Nicely done, just a few nits mostly about libevm new code errors wrapping
This forms part of a broader, long-term direction of feature parity between precompiled and bytecode contracts, exposed via vm.PrecompileEnvironment.
What's the context here, do we require this to sync coreth/subnet-evm with geth? Or is this more of a long term we can do after syncing thing? - not criticizing at all, just trying to better understand it 😉
Co-authored-by: Quentin McGaw <[email protected]> Signed-off-by: Arran Schlosberg <[email protected]>
Co-authored-by: Quentin McGaw <[email protected]> Signed-off-by: Arran Schlosberg <[email protected]>
Not a current need at all. I noticed that we were edging closer and closer to parity between stateful precompiles and regular Solidity so wanted to close the gap. |
Why this should be merged
Aligns precompiled contracts with the pattern used in
vm.EVMInterpreter
for regular contracts and simplifies gas accounting by using existing mechanisms. The most notable simplification occurs when there are multiple error paths that return early and have to account for consumed gas (any local solution would likely just mirror this one).This forms part of a broader, long-term direction of feature parity between precompiled and bytecode contracts, exposed via
vm.PrecompileEnvironment
.The
vm.Contract.Value()
method is also exposed as a natural accompaniment to this change.How this works
The original signature for
vm.PrecompiledStatefulContract
received the amount of gas available and then returned the amount remaining; this has been removed in lieu of exposing the existingvm.Contract.UseGas()
method via thevm.PrecompileEnvironment
. A newlegacy
package wraps the old signature and converts it to a new one soava-labs/coreth
doesn't need to be refactored.How this was tested
Existing unit test modified to use the
legacy
adaptor.