Charge the state-independent CALL costs first - #1668
Merged
Conversation
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1668 +/- ##
=======================================
Coverage 97.72% 97.72%
=======================================
Files 171 171
Lines 15666 15666
Branches 3625 3625
=======================================
Hits 15310 15310
Misses 269 269
Partials 87 87
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This was referenced Aug 20, 2026
chfast
force-pushed
the
evm/call-gas-charge-order
branch
2 times, most recently
from
August 22, 2026 17:18
3b5deb6 to
0d35b52
Compare
The static-mode check and the memory expansion and value transfer costs need no state, but were applied after the EIP-7702 delegation lookup, which reads the target's code. Charge them first and begin the state accesses only once they are paid for, as execution-specs does for CALL in Amsterdam. Gas totals and the 63/64 split are unchanged; only the reported halt status can differ, and an exceptional halt consumes all gas either way.
chfast
force-pushed
the
evm/call-gas-charge-order
branch
from
August 22, 2026 17:21
0d35b52 to
ea6ee1c
Compare
There was a problem hiding this comment.
Pull request overview
Reorders CALL processing so state-independent checks and costs occur before account and EIP-7702 delegation access.
Changes:
- Performs static-mode and memory checks earlier.
- Charges value transfer before state access.
- Preserves total gas and 63/64 forwarding behavior.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+104
to
+107
| if constexpr (HAS_VALUE_ARG) | ||
| { | ||
| if (has_value && (gas_left -= CALL_VALUE_COST) < 0) | ||
| return {EVMC_OUT_OF_GAS, gas_left}; |
Member
Author
There was a problem hiding this comment.
The EEST coverage is very good here.
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.
The static-mode check and the memory expansion and value transfer costs
need no state, but were applied after the EIP-7702 delegation lookup,
which reads the target's code. Charge them first and begin the state
accesses only once they are paid for, as execution-specs does for CALL
in Amsterdam. Gas totals and the 63/64 split are unchanged; only the
reported halt status can differ, and an exceptional halt consumes all
gas either way.