Skip to content

Charge the state-independent CALL costs first - #1668

Merged
chfast merged 1 commit into
masterfrom
evm/call-gas-charge-order
Aug 22, 2026
Merged

Charge the state-independent CALL costs first#1668
chfast merged 1 commit into
masterfrom
evm/call-gas-charge-order

Conversation

@chfast

@chfast chfast commented Aug 20, 2026

Copy link
Copy Markdown
Member

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.

@codspeed-hq

codspeed-hq Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 129 untouched benchmarks


Comparing evm/call-gas-charge-order (ea6ee1c) with master (afe75b5)

Open in CodSpeed

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.72%. Comparing base (afe75b5) to head (ea6ee1c).

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           
Flag Coverage Δ
eest-develop 88.60% <100.00%> (ø)
eest-develop-gmp 26.51% <100.00%> (ø)
eest-legacy 17.09% <33.33%> (-0.02%) ⬇️
eest-libsecp256k1 28.78% <100.00%> (ø)
eest-stable 88.60% <100.00%> (ø)
evmone-unittests 93.44% <73.33%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
core 96.11% <100.00%> (ø)
tooling 91.96% <ø> (ø)
tests 99.80% <ø> (ø)
Files with missing lines Coverage Δ
lib/evmone/instructions_calls.cpp 99.27% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chfast
chfast force-pushed the evm/call-gas-charge-order branch 2 times, most recently from 3b5deb6 to 0d35b52 Compare August 22, 2026 17:18
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
chfast force-pushed the evm/call-gas-charge-order branch from 0d35b52 to ea6ee1c Compare August 22, 2026 17:21
@chfast chfast changed the title Charge the state-independent CALL costs before accessing state Charge the state-independent CALL costs first Aug 22, 2026
@chfast
chfast requested a balanced review from Copilot August 22, 2026 17:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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};

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EEST coverage is very good here.

@chfast
chfast merged commit c8d6705 into master Aug 22, 2026
26 checks passed
@chfast
chfast deleted the evm/call-gas-charge-order branch August 22, 2026 18:09
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.

2 participants