Skip to content

refactor: fix import fragility for gas constants#4

Open
Carsons-Eels wants to merge 7 commits intointermediate_opcodesfrom
intermediate_opcodes_import_fix
Open

refactor: fix import fragility for gas constants#4
Carsons-Eels wants to merge 7 commits intointermediate_opcodesfrom
intermediate_opcodes_import_fix

Conversation

@Carsons-Eels
Copy link
Copy Markdown
Owner

@Carsons-Eels Carsons-Eels commented Mar 10, 2026

🗒️ 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 y pattern 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 y creates a new name ("y") in the local module namespace which points to the same object as x.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 x pattern so that the binding refers to the intended (now mutated) value.

🔗 Related Issues or PRs

✅ Checklist

Cute Animal Picture

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

Bengal Tiger by Prakash Aryal Pexel's Free to Use License

@marioevz
Copy link
Copy Markdown
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

@Carsons-Eels Carsons-Eels force-pushed the intermediate_opcodes branch 3 times, most recently from e427897 to 30525d8 Compare March 21, 2026 05:10
@Carsons-Eels Carsons-Eels force-pushed the intermediate_opcodes branch 3 times, most recently from caefd35 to c5c776e Compare March 31, 2026 17:02
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