-
Notifications
You must be signed in to change notification settings - Fork 404
refactor(spec-specs): Refactor specs to be more coherent wrt gas acco… #1897
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
refactor(spec-specs): Refactor specs to be more coherent wrt gas acco… #1897
Conversation
ed12ccc to
6740794
Compare
| gas_cost = GAS_COLD_SLOAD if is_cold_access else GAS_WARM_ACCESS | ||
|
|
||
| charge_gas(evm, gas_cost) | ||
| if (evm.message.current_target, key) in evm.accessed_storage_keys: |
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 actually brings the changes back to what it used to be (no changes once PR'd to forks/amsterdam) as there is no need to alter the logic here.
| current_value = get_storage(state, evm.message.current_target, key) | ||
|
|
||
| if is_cold_access: | ||
| gas_cost = Uint(0) |
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 also returns the logic to what it is, no need to change this unless we want the is_cold_access check on all operations. I think we can decide this on the isolated PR as well. I'd rather not alter too much of the underlying code in our changes so we can more easily rebase up to eip-7928.
| code_address = final_address | ||
| disable_precompiles = is_delegated | ||
|
|
||
| if is_delegated: |
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.
Much more succinct. All opcodes here should have a similar flow.
| return True, address, delegated_address, delegation_gas_cost | ||
|
|
||
|
|
||
| def read_delegation_target(evm: Evm, delegated_address: Address) -> Bytes: |
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 unnecessary. By the time we get code for the code_address, we already have either the original address or the delegated address as the code_address, so we can simply call get_account(state, code_address).code, essentially.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## eips/amsterdam/eip-7928 #1897 +/- ##
==========================================================
Coverage ? 86.25%
==========================================================
Files ? 538
Lines ? 34561
Branches ? 3224
==========================================================
Hits ? 29809
Misses ? 4165
Partials ? 587
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:
|
be73122 to
ba0eec1
Compare
3da8833 to
187483e
Compare
|
I'm going to merge this as it's in a much cleaner state than the current specs and actually fixes a bug for CALL in static context where we should do this static check as early as we can, once I added a test here for this as well. We should put up a subsequent PR if we'd like to make any amendments to this design before we factor out these changes into its own changeset to PR against We should make sure to reference these changes when reviewing a subsequent PR. |
60fcfcc
into
ethereum:eips/amsterdam/eip-7928
🗒️ Description
I went back through and refactored the specs to be more succinct wrt gas accounting, in an effort to move these changes out of this branch and into its own PR to be applied across all forks.
I have similar changes without the BAL tracking in its own branch and I think this will make it easier to agree on here, refactor there, and then eventually to rebase these changes back into here once we agree on a good design.
A good idea for reviewers here is to diff against
forks/amsterdaminstead ofeips/amsterdam-eip-7928so we can see the minimal set of changes required to the underlying base spec.Note: This is still a WIP as I'm going to look back over and make sure I didn't miss anything but putting it here early so we can have eyes on it.
🔗 Related Issues or PRs
N/A.
✅ Checklist
toxchecks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:uvx tox -e statictype(scope):.Cute Animal Picture