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

feat!: improve storage slot allocation #10320

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

feat!: improve storage slot allocation #10320

wants to merge 3 commits into from

Conversation

nventuro
Copy link
Contributor

@nventuro nventuro commented Nov 29, 2024

Closes #5736
Closes #8659

We currently allocate storage slots for state variables by assuming they are generic over a type T which implements the Serialize<N> trait, and then provide N slots. This is incorrect for some state variables (notably SharedMutable).

This changes that scheme for one in which state variables implement the Storage<N> trait with whatever value they choose, and that N is the one that gets selected for their allocation. All state variables currently use the N from the serialization of their inner type (until we do #5492), so in practice nothing changes so far (but we become ready to perform that work).

I also added a simple test for the storage allocation scheme, which should be very helpful in the future as we make this more complex down the line. I also cleaned up some small warnings I found along the way, and removed the weird exception for #8659, which apparently was unnecessary - it may just be a renmant from some older version of the codebase.

edit: I tried to make the test a bit more thorough using dynamic lengths and got some unexpected errors, I'm looking into those.

@nventuro nventuro added the e2e-all CI: Enables this CI job. label Nov 29, 2024
@AztecProtocol AztecProtocol deleted a comment from github-actions bot Nov 29, 2024
@nventuro
Copy link
Contributor Author

nventuro commented Dec 2, 2024

I opened noir-lang/noir#6681 describing the issue I encountered.

Copy link
Contributor

@Thunkar Thunkar left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e-all CI: Enables this CI job.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix PublicMutable storage slot allocation refactor(StateVariables): Migrate Storage<T> to Storage<N>
2 participants