Skip to content
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

Fix for Vyper immutables transformations #22

Merged
merged 7 commits into from
Jan 8, 2025

Conversation

marcocastignoli
Copy link
Contributor

Vyper immutables transformation value is not limited of 32 bytes length. We should drop that part of the constraint in order to support Vyper contracts.

@kuzdogan
Copy link
Member

kuzdogan commented Jan 8, 2025

Hmm right this is because we infer the immutables in Solidity from immutableReferences and each reference is a 32byte word, but with Vyper there's no such output and we extract it by looking at the end of the onchain runtime bytecode, right?

@marcocastignoli
Copy link
Contributor Author

Hmm right this is because we infer the immutables in Solidity from immutableReferences and each reference is a 32byte word, but with Vyper there's no such output and we extract it by looking at the end of the onchain runtime bytecode, right?

Right 👍

Copy link
Member

@kuzdogan kuzdogan left a comment

Choose a reason for hiding this comment

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

Makes sense for me.

Just, please update the live DB schemas too

Plus, tests are failing

Copy link
Contributor

@rimrakhimov rimrakhimov left a comment

Choose a reason for hiding this comment

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

Looks great for me! Just curious why did I put this 32 bytes condition in the first place :) Is it the case that Solidity immutable variables always are 32 bytes?

@marcocastignoli
Copy link
Contributor Author

Looks great for me! Just curious why did I put this 32 bytes condition in the first place :) Is it the case that Solidity immutable variables always are 32 bytes?

I assumed it as true looking at that constraint

@marcocastignoli marcocastignoli merged commit 8ad3216 into master Jan 8, 2025
1 check passed
@marcocastignoli marcocastignoli deleted the fix-vyper-immutable-transformation branch January 8, 2025 09:52
@kuzdogan
Copy link
Member

kuzdogan commented Jan 8, 2025

Looks great for me! Just curious why did I put this 32 bytes condition in the first place :) Is it the case that Solidity immutable variables always are 32 bytes?

It seems so: "For these values, 32 bytes are reserved, even if they would fit in fewer bytes. Due to this, constant values can sometimes be cheaper than immutable values"

https://docs.soliditylang.org/en/latest/contracts.html#constant-and-immutable-state-variables

@kuzdogan
Copy link
Member

kuzdogan commented Jan 8, 2025

@marcocastignoli This also makes me realize, one condition the optimizer sometimes puts constants in bytecode is when it reaches 32 bytes. Only then it probably makes sense costwise. This seems necessary but does not always lead to being written in the bytecode

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.

3 participants