refactor: fix import fragility for gas constants#4
Open
Carsons-Eels wants to merge 7 commits intointermediate_opcodesfrom
Open
refactor: fix import fragility for gas constants#4Carsons-Eels wants to merge 7 commits intointermediate_opcodesfrom
Carsons-Eels wants to merge 7 commits intointermediate_opcodesfrom
Conversation
…more clearly differentiate between intermediate constants and existing ones
Add 39 GAS_OPCODE_* fields to the GasCosts dataclass and update opcode_gas_map() in all forks to reference per-opcode fields instead of shared tier constants.
5 tasks
Collaborator
|
The only issue I see with this approach is the fact that we depend on new code to adhere to this standard of imports, and if they don't, nothing will fail until we try to reprice something. Perhaps an enum is a good alternative? or a dictionary. Because this forces the way of importing. cc @SamWilsn |
e427897 to
30525d8
Compare
caefd35 to
c5c776e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🗒️ Description
Adds import fixes for all gas constants not covered by #2396
When the fast repricing (#2331) modifies the values of the gas constants, it does that while the program is starting up (runtime). Right now we use the
from x import ypattern to import these constants, which, depending on the order that those statements execute, could lead to an incorrect reference when the repricing happens.from x import ycreates a new name ("y") in the local module namespace which points to the same object asx.y, but the refs are independent. So if a module imports a gas constant before the repricing patches it, that module's name stays bound to the original int so it never sees the updated value.This fixes it by switching the way imports are done to use the
import xpattern so that the binding refers to the intended (now mutated) value.🔗 Related Issues or PRs
✅ Checklist
toxchecks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:uvx tox -e statictype(scope):.Cute Animal Picture
Bengal Tiger by Prakash Aryal Pexel's Free to Use License