Skip to content

Conversation

@LouisTsai-Csie
Copy link
Collaborator

@LouisTsai-Csie LouisTsai-Csie commented Nov 11, 2025

🗒️ Description

Unify the gas cost variable name from Cancun to Osaka. Introduce a fork-dependent gas table.

The mapping for the EELS & EEST gas constant, I replace all the EEST variable name with the EELS naming, as this requires less effort. This documents the mapping: https://hackmd.io/@QmVpC8TxQ8a1nTCW46EsEQ/B1932RWy-x

🔗 Related Issues or PRs

Issue #1599

✅ Checklist

  • All: Ran fast tox checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    uvx tox -e static
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Considered adding an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.
  • Tests: For PRs implementing a missed test case, update the post-mortem document to add an entry the list.
  • Ported Tests: All converted JSON/YML tests from ethereum/tests or tests/static have been assigned @ported_from marker.

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

Comment on lines +198 to +208
def test_fork_consistency() -> None:
"""Test that Prague and Osaka have same base costs for common opcodes."""
code = Op.PUSH1(0x01) + Op.PUSH1(0x02) + Op.ADD

prague_calc = OpcodeGasCalculator(Prague)
osaka_calc = OpcodeGasCalculator(Osaka)

prague_gas = prague_calc.calculate(code)
osaka_gas = osaka_calc.calculate(code)

assert prague_gas == osaka_gas == 9 # 3 + 3 + 3
Copy link
Collaborator Author

@LouisTsai-Csie LouisTsai-Csie Nov 11, 2025

Choose a reason for hiding this comment

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

This is the example usage:

code = Op.PUSH0 + Op.PUSH0 + Op.ADD
prague_calc = OpcodeGasCalculator(Prague)
prague_gas = prague_calc.calculate(code)
# the total gas cost for the code sequnece

This could be extended to:

code = Op.PUSH0 + Op.PUSH0 + Op.ADD
calc = OpcodeGasCalculator(fork)
gas =calc.calculate(code)

This version could help us avoid hardcoding the gas cost. As i believe in the near future there would be gas repricing for ZkVM, and we do not want to update all the gas cost again.

@spencer-tb spencer-tb self-requested a review November 11, 2025 14:59
@LouisTsai-Csie LouisTsai-Csie self-assigned this Nov 11, 2025
@LouisTsai-Csie LouisTsai-Csie added C-enhance Category: an improvement or new feature S-needs-discussion Status: needs discussion labels Nov 11, 2025
Comment on lines +2372 to +2375
@classmethod
def op_cost(
cls, opcode: Opcodes, *, block_number: int = 0, timestamp: int = 0
) -> int:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to define this op_cost function for every fork to enable fork-dependent gas table feature.

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.14%. Comparing base (9563a51) to head (0f2fdd7).
⚠️ Report is 21 commits behind head on forks/osaka.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@               Coverage Diff               @@
##           forks/osaka    #1776      +/-   ##
===============================================
+ Coverage        86.07%   86.14%   +0.07%     
===============================================
  Files              743      743              
  Lines            44078    44261     +183     
  Branches          3894     3891       -3     
===============================================
+ Hits             37938    38127     +189     
+ Misses            5659     5656       -3     
+ Partials           481      478       -3     
Flag Coverage Δ
unittests 86.14% <100.00%> (+0.07%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-enhance Category: an improvement or new feature S-needs-discussion Status: needs discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants