Skip to content

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
lbayas:feat/224-precompile-outbound-call-63-64-rule
Open

fix(vm): EIP-150 63/64 + call stipend for precompile outbound Call; add legacy opt-out and tests#277
lbayas wants to merge 3 commits intoava-labs:mainfrom
lbayas:feat/224-precompile-outbound-call-63-64-rule

Conversation

@lbayas
Copy link
Copy Markdown

@lbayas lbayas commented Mar 25, 2026

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)

@lbayas lbayas marked this pull request as ready for review March 25, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Respect 63/64 rule in vm.callContract

1 participant