Skip to content

Implement EIP-8038: "State-access gas cost update" - #1731

Merged
chfast merged 1 commit into
masterfrom
amsterdam/8038
Sep 22, 2026
Merged

chfast merged 1 commit into
masterfrom
amsterdam/8038

Conversation

@chfast

@chfast chfast commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Reprice state access and split it into access and write components.
https://eips.ethereum.org/EIPS/eip-8038

  • COLD_ACCOUNT_ACCESS rises 2600 -> 3000; COLD_STORAGE_ACCESS (2100)
    and WARM_ACCESS (100) are unchanged.
  • New ACCOUNT_WRITE (9000) prices account mutations: CALL_VALUE becomes
    ACCOUNT_WRITE + CALL_STIPEND (11300), SELFDESTRUCT sending a balance
    to a dead beneficiary pays it, and CREATE/CREATE2 pay CREATE_ACCESS
    (12000) in place of the flat 32000.
  • New STORAGE_WRITE (10000) makes the first SSTORE change to a slot
    cost 10100 for both set and reset, its cold surcharge now matches
    SLOAD, and the clear refund becomes 11616.
  • EXTCODESIZE and EXTCODECOPY pay an extra WARM_ACCESS for their
    second database read.
  • Access-list entries cost 2900 per address and 2000 per storage key.

@codspeed

codspeed Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 2.71%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 128 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ baseline/analyse/main/sha1_shifts 11.5 µs 11.2 µs +2.71%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing amsterdam/8038 (1baca41) with master (4029845)

Open in CodSpeed

@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.12195% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.98%. Comparing base (4029845) to head (1baca41).

Files with missing lines Patch % Lines
lib/evmone/instructions.hpp 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1731      +/-   ##
==========================================
- Coverage   97.99%   97.98%   -0.01%     
==========================================
  Files         181      182       +1     
  Lines       16759    16778      +19     
  Branches     3827     3832       +5     
==========================================
+ Hits        16423    16440      +17     
- Misses        249      250       +1     
- Partials       87       88       +1     
Flag Coverage Δ
eest-develop 81.98% <76.92%> (-0.06%) ⬇️
eest-develop-gmp 25.90% <48.78%> (+0.02%) ⬆️
eest-legacy 17.12% <24.39%> (+0.02%) ⬆️
eest-libsecp256k1 28.11% <48.78%> (+0.02%) ⬆️
eest-stable 81.95% <76.92%> (-0.06%) ⬇️
evmone-unittests 94.39% <95.12%> (-0.01%) ⬇️

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

Components Coverage Δ
core 95.94% <92.30%> (-0.03%) ⬇️
tooling 94.30% <ø> (ø)
tests 99.81% <100.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
lib/evmone/instructions_calls.cpp 95.26% <100.00%> (+0.08%) ⬆️
lib/evmone/instructions_storage.cpp 93.93% <ø> (ø)
lib/evmone/instructions_traits.hpp 100.00% <100.00%> (ø)
test/state/state.cpp 98.59% <100.00%> (+0.03%) ⬆️
test/unittests/evm_storage_test.cpp 100.00% <100.00%> (ø)
...ttests/state_transition_eip7778_block_gas_test.cpp 100.00% <100.00%> (ø)
...ttests/state_transition_eip8037_state_gas_test.cpp 100.00% <100.00%> (ø)
test/unittests/state_transition_tx_test.cpp 100.00% <100.00%> (ø)
test/unittests/tooling_t8n_test.cpp 100.00% <100.00%> (ø)
lib/evmone/instructions.hpp 98.83% <71.42%> (-0.47%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chfast
chfast force-pushed the amsterdam/8038 branch 5 times, most recently from b52f025 to ec55933 Compare September 22, 2026 10:27
@chfast
chfast requested a balanced review from Copilot September 22, 2026 10:28

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.

Copilot review overview

🟡 Changes recommended

The block RLP remains stale and Amsterdam authorization processing still uses legacy gas pricing.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Implements Amsterdam’s EIP-8038 state-access gas repricing across opcode execution, storage accounting, transaction costs, and tests.

Changes:

  • Adds named account/storage access and write costs.
  • Reprices calls, creation, self-destruct, EXTCODE operations, SSTORE, and access lists.
  • Updates gas expectations and blockchain fixtures.
File Description
lib/​evmone/​instructions_traits.hpp Defines EIP-8038 costs and opcode pricing.
lib/​evmone/​instructions.hpp Applies account-access and SELFDESTRUCT charges.
lib/​evmone/​instructions_calls.cpp Reprices calls and delegation access.
lib/​evmone/​instructions_storage.cpp Updates SSTORE costs and refunds.
test/​state/​state.cpp Reprices Amsterdam access lists.
test/​unittests/​tooling_t8n_test.cpp Updates refund accounting expectation.
test/​unittests/​state_transition_tx_test.cpp Updates access-list tests.
test/​unittests/​state_transition_eip8037_state_gas_test.cpp Adjusts state-gas scenarios.
test/​unittests/​state_transition_eip7778_block_gas_test.cpp Updates block-gas refund test.
test/​integration/​evmone-cli/​test/​blockchaintest/​eip7778_block_gas.json Updates expected block outputs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/state/state.cpp
Comment thread lib/evmone/instructions_traits.hpp
@chfast
chfast force-pushed the amsterdam/8038 branch 2 times, most recently from a908886 to c9fd9f3 Compare September 22, 2026 11:48
@chfast
chfast requested a balanced review from Copilot September 22, 2026 11:53

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.

Copilot review overview

🟡 Changes recommended

Several consensus-critical gas schedules and OOG branches lack direct regression coverage.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 3 Medium severity · 1 Low severity

Open (5)
Resolved since last review (1)

Comment thread lib/evmone/instructions.hpp Outdated
Comment thread lib/evmone/instructions_storage.cpp
Comment thread lib/evmone/instructions_traits.hpp
@chfast
chfast force-pushed the amsterdam/8038 branch 2 times, most recently from 373e5b7 to 0e031dd Compare September 22, 2026 12:50
@chfast
chfast requested a balanced review from Copilot September 22, 2026 12:50

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.

Copilot review overview

🟡 Changes recommended

Several consensus-critical Amsterdam gas paths lack direct boundary tests.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 5 Medium severity · 1 Low severity

Open (7)

Comment thread lib/evmone/instructions.hpp
Comment thread lib/evmone/instructions_traits.hpp
Reprice state access and split it into access and write components.
https://eips.ethereum.org/EIPS/eip-8038

- COLD_ACCOUNT_ACCESS rises 2600 -> 3000; COLD_STORAGE_ACCESS (2100)
  and WARM_ACCESS (100) are unchanged.
- New ACCOUNT_WRITE (9000) prices account mutations: CALL_VALUE becomes
  ACCOUNT_WRITE + CALL_STIPEND (11300), SELFDESTRUCT sending a balance
  to a dead beneficiary pays it, and CREATE/CREATE2 pay CREATE_ACCESS
  (12000) in place of the flat 32000.
- New STORAGE_WRITE (10000) makes the first SSTORE change to a slot
  cost 10100 for both set and reset, its cold surcharge now matches
  SLOAD, and the clear refund becomes 11616.
- EXTCODESIZE and EXTCODECOPY pay an extra WARM_ACCESS for their
  second database read.
- Access-list entries cost 2900 per address and 2000 per storage key.
@chfast
chfast requested a balanced review from Copilot September 22, 2026 13:43
@chfast

chfast commented Sep 22, 2026

Copy link
Copy Markdown
Member Author

@codspeedbot explain why performance improved

@codspeed

codspeed Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

@codspeedbot explain why performance improved

Short answer: this one is not caused by your change — it is a runner-environment artifact, and the +2.71% should be ignored.

What the profiles show

Comparing the flamegraphs of baseline/analyse/main/sha1_shifts between master (4029845) and 1baca41:

Frame BASE HEAD Δ
_int_malloc (glibc, self) 2.29 µs 1.93 µs −0.36 µs
unlink_chunk (glibc, self) 0.29 µs 0.23 µs −0.06 µs
__memcpy_avx_unaligned_erms (glibc, self) 2.75 µs 2.86 µs +0.11 µs
analyze_jumpdests (evmone, self) 1.910 µs 1.912 µs ~0
total 11.5 µs 11.2 µs −0.31 µs

The entire gain comes from glibc's allocator; the evmone code in the benchmark is unchanged. analyze_jumpdests is identical down to its instruction component (829.6 ns vs 829.9 ns), i.e. it executed exactly the same work, and evmone::baseline::analyze self time is flat (86.7 ns vs 90.4 ns). Inside _int_malloc the shift is almost entirely in the memory component (2.1 µs → 1.8 µs), not instructions — a cache/layout effect, not less work.

Why the environment differs

The comparison report flags a toolchain difference between the two runs: the build IDs of libc.so.6, libm.so.6 and ld-linux-x86-64.so.2 changed between base and head, so the two runs linked against different glibc builds. A different glibc gives a different malloc code path and a different memory layout, which in Simulation mode changes the modeled cache behaviour of the allocator — exactly where the 0.3 µs lives. All other baseline/analyse/* benchmarks stayed flat; sha1_shifts is simply the one whose allocation sizes fell on the right side of the noise threshold.

Why the PR cannot affect this benchmark anyway

The diff touches only lib/evmone/instructions.hpp, instructions_calls.cpp, instructions_storage.cpp, instructions_traits.hpp and test/state code. baseline/analyse only exercises evmone::baseline::analyze, which allocates the padded code buffer, copies the code and scans for JUMPDESTs — it never consults the gas cost tables, so repricing state access has no reachable effect on it. Consistently, every baseline/execute/* benchmark is untouched too: none of them hits a state-access opcode.

Nothing to fix here, and no changes were pushed to the branch.

Summary
  • Warming up the performance wizard...
  • Investigate the sha1_shifts analyse improvement — Compared flamegraphs: the whole delta sits in glibc _int_malloc, user code is bit-for-bit identical
  • Check whether the PR can affect code analysis — PR touches no file on the baseline analysis path; analyze() is gas-cost independent
  • Reply with the explanation — Reply with the explanation
  • Handling comment — Comment handling finished successfully

Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot.

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.

Copilot review overview

🔵 Needs a closer look

Consensus-critical gas accounting changes require final human validation against the EIP specification and execution tests.

Review effort: Balanced
Findings: None

Resolved since last review (7)

@chfast
chfast merged commit 6d6b912 into master Sep 22, 2026
24 of 26 checks passed
@chfast
chfast deleted the amsterdam/8038 branch September 22, 2026 14:34
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