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: write to any storage slot #23

Merged
merged 3 commits into from
Jun 7, 2023
Merged

feat: write to any storage slot #23

merged 3 commits into from
Jun 7, 2023

Conversation

enitrat
Copy link
Collaborator

@enitrat enitrat commented Jun 6, 2023

Closes #17
In this example, we demonstrate how we can compute storage addresses onchain with the poseidon hash function, and write to any slot with storage syscalls.

@swapnilraj are there any security issues to consider with this implementation? I think that the output of poseidon is a felt252 so I restricted addresses sizes to 250 bits.

I believe that in the future storage addresses will be computed with Poseidon, so it makes even more sense to use it here.
From there, can use this contract to demonstrate how to create an EternalStorage contract.

@swapnilraj
Copy link

I don't see any security considerations from using the poseidon hash and the 250 bit mask. I remember seeing similar Cairo 0 code.
It would be nice to implement the StorageAccess trait for a storage variable and replace its storage to use the Poseidon hash function. This would also be ideal for the EternalStorage pattern UX from the user's perspective if they can interact with their storage variables using normal Cairo syntax but have eternal storage slots for their variables.
Would it be too much to ask for a Map PoC as well?
Happy to see these changes in a following PR.

@enitrat enitrat merged commit 7ca6798 into main Jun 7, 2023
@enitrat enitrat deleted the feat/write-any-slot branch June 16, 2023 12:14
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.

feat: Write to any slot
2 participants