-
Notifications
You must be signed in to change notification settings - Fork 375
feat(tests): unify gas cost variable #1776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: forks/osaka
Are you sure you want to change the base?
feat(tests): unify gas cost variable #1776
Conversation
| 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 |
There was a problem hiding this comment.
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 sequneceThis 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.
| @classmethod | ||
| def op_cost( | ||
| cls, opcode: Opcodes, *, block_number: int = 0, timestamp: int = 0 | ||
| ) -> int: |
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🗒️ 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
toxchecks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:uvx tox -e statictype(scope):.mkdocs servelocally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.@ported_frommarker.Cute Animal Picture