Skip to content

evm: Refactor the state-access cost constants - #1732

Merged
chfast merged 1 commit into
masterfrom
evm/access-cost-refactor
Sep 22, 2026
Merged

chfast merged 1 commit into
masterfrom
evm/access-cost-refactor

Conversation

@chfast

@chfast chfast commented Sep 22, 2026

Copy link
Copy Markdown
Member
  • Rename to the EIP-8038 parameter names: WARM_ACCESS, COLD_STORAGE_ACCESS and COLD_ACCOUNT_ACCESS. The EIP-2929 names are misleading: WARM_STORAGE_READ_COST is charged for warm account accesses too (BALANCE, CALL, EXT), not only storage reads.
  • Rename the derived constant to ADDITIONAL_COLD_ACCOUNT_ACCESS and give its storage counterpart, so far a local in SLOAD, the name ADDITIONAL_COLD_STORAGE_ACCESS in the instruction traits.
  • Drop the redundant instr:: qualification; every use of these constants is already inside evmone::instr::core.
  • Move CALL_VALUE_COST and ACCOUNT_CREATION_COST out of the global namespace into the anonymous one.
  • Read the SSTORE cold surcharge from the per-revision storage cost table instead of hardcoding it at the use site.

No behaviour change.

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

🟢 Approval recommended

The refactoring consistently preserves existing gas-cost calculations and leaves no unresolved issues.

Review effort: Balanced
Findings: None

What changed in this PR

Refactors state-access gas constants to clearer EIP terminology without changing behavior.

Changes:

  • Renames warm and cold account/storage access constants.
  • Centralizes SLOAD and SSTORE cold surcharges.
  • Restricts CALL-related constants to local scope.
File Description
lib/​evmone/​instructions.hpp Uses renamed account-access constants.
lib/​evmone/​instructions_traits.hpp Defines renamed and derived access-cost constants.
lib/​evmone/​instructions_storage.cpp Sources storage cold costs from revision data.
lib/​evmone/​instructions_calls.cpp Updates constants and narrows CALL constant scope.
test/​unittests/​state_transition_eip8037_state_gas_test.cpp Updates the renamed test constant reference.

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

@codspeed

codspeed Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 129 untouched benchmarks


Comparing evm/access-cost-refactor (69790f5) with master (e2290c6)

Open in CodSpeed

- Rename to the EIP-8038 parameter names: WARM_ACCESS,
  COLD_STORAGE_ACCESS and COLD_ACCOUNT_ACCESS. The EIP-2929 names are
  misleading: WARM_STORAGE_READ_COST is charged for warm account
  accesses too (BALANCE, *CALL, EXT*), not only storage reads.
- Rename the derived constant to ADDITIONAL_COLD_ACCOUNT_ACCESS and
  give its storage counterpart, so far a local in SLOAD, the name
  ADDITIONAL_COLD_STORAGE_ACCESS in the instruction traits.
- Drop the redundant instr:: qualification; every use of these
  constants is already inside evmone::instr::core.
- Move CALL_VALUE_COST and ACCOUNT_CREATION_COST out of the global
  namespace into the anonymous one.
- Read the SSTORE cold surcharge from the per-revision storage cost
  table instead of hardcoding it at the use site.

No behaviour change.

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

🟢 Approval recommended

The refactor consistently updates all references while preserving existing gas calculations.

Review effort: Balanced
Findings: None

@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.99%. Comparing base (e2290c6) to head (69790f5).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1732      +/-   ##
==========================================
- Coverage   97.99%   97.99%   -0.01%     
==========================================
  Files         181      181              
  Lines       16762    16759       -3     
  Branches     3827     3827              
==========================================
- Hits        16426    16423       -3     
  Misses        249      249              
  Partials       87       87              
Flag Coverage Δ
eest-develop 82.03% <91.66%> (-0.01%) ⬇️
eest-develop-gmp 25.88% <91.66%> (-0.02%) ⬇️
eest-legacy 17.09% <16.66%> (-0.01%) ⬇️
eest-libsecp256k1 28.09% <91.66%> (-0.02%) ⬇️
eest-stable 82.00% <91.66%> (-0.01%) ⬇️
evmone-unittests 94.40% <100.00%> (-0.01%) ⬇️

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

Components Coverage Δ
core 95.97% <100.00%> (-0.01%) ⬇️
tooling 94.30% <ø> (ø)
tests 99.81% <ø> (ø)
Files with missing lines Coverage Δ
lib/evmone/instructions.hpp 99.29% <100.00%> (ø)
lib/evmone/instructions_calls.cpp 95.18% <100.00%> (-0.03%) ⬇️
lib/evmone/instructions_storage.cpp 93.93% <100.00%> (-0.35%) ⬇️
...ttests/state_transition_eip8037_state_gas_test.cpp 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chfast
chfast merged commit 4029845 into master Sep 22, 2026
26 checks passed
@chfast
chfast deleted the evm/access-cost-refactor branch September 22, 2026 10:17
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