fix(vm): EIP-150 63/64 + call stipend for precompile outbound Call; add legacy opt-out and tests#277
Open
lbayas wants to merge 3 commits intoava-labs:mainfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #224
Why this should be merged
Outbound PrecompileEnvironment.Call should match normal CALL semantics on post‑EIP‑150 rulesets: cap transferable gas with the 63/64 rule and apply the call‑value stipend when value is non‑zero. Without that, stateful precompiles can over‑fund nested calls or diverge from what the EVM does for ordinary contracts, which is surprising for integrators and hard to reason about for security. This change aligns behaviour with the spec and with EVM.Call, while keeping an explicit, deprecated escape hatch for legacy deployments.
How this works
When EIP‑150 applies, precompile Call now follows the same outbound gas path as the CALL opcode (63/64 of remaining gas as an upper bound, plus CallStipend when a non‑zero value is transferred). vm.WithLegacyOutboundCallGas() is a CallOption that restores the old behaviour for a single call: parent is charged the full gas argument and the callee receives that full amount (no 63/64 cap, no stipend). New precompiles should rely on the default; the option exists only for backwards compatibility.
How this was tested
go test on core/vm via
go test -count=1 ./core/...(this will include contracts.libevm_test.go cases that cover outbound Call with and without WithLegacyOutboundCallGas)