Namespace Storage
Hadrien Croubois (@Amxx) – Research Engineer @ OpenZeppelin
(for now and for a Verkle EVM)
The grammar of storage layouts
Given the linearized contract …
… take all the variables in order …
… and follow the grammar (with root 0)
Storage matters … when performing upgrades
Upgradeable smart contract needs to preserve a similar view of the storage layout across upgrades.
�A lot can potentially go wrong:
The gap approach
Used in @openzeppelin/contracts-upgradeable 3.x – 4.x
The namespace approach
Used in @openzeppelin/contracts-upgradeable 5.x
ERC-7201
ERC-7201: derivation of a new (safe) root
Going back to the grammar
What is not in the grammar for a root 0 ?
If n is small enough, and if keccak256 is a good hashing function, we just need to find a location that is not in Lroot, and use that as our new root.
ERC-7201 derivation explained
keccak256(keccak256(“openzeppelin.storage.Ownable”) - 1) & ~0xFF
“openzeppelin.storage.Ownable” | Seed |
keccak256(...) - 1 | Hash of the seed might collide if the seed matches a valid storage location is L0, so we subtract 1 to exit L0 |
keccak256(...) | Get a completely new space (so doing “+n”) don’t bring us back into L0 |
... & ~0xFF | Clean the last byte so our namespace starts at the beginning of a bucket |
What is a bucket?
Should Solidity (& Vyper) change their grammar?
Maybe!
Stateless Ethereum: How Verkle Trees Make Ethereum Lean and Mean by Guillaume Ballet
https://www.youtube.com/watch?v=Q7rStTKwuYs
Thursday,
Nov 16, 2023
Istanbul, Türkiye
Welcome to the Solidity Summit template!
First of all, thank you so much for being a speaker & sharing your knowledge with the audience! 💙
Please help us make Solidity Summit 2023 a high-quality and enjoyable conference experience for all by…
Looking forward to seeing your talk at the summit and don’t hesitate to reach out to us with any questions!
Of course you don’t have to use the template provided!
You can also use your own slide design by simply deleting all these slides and copy pasting in an existing presentation or creating your own from scratch!
There is a dark mode
…and a light mode
*(at the end of this presentation)
ADD YOUR TITLE HERE
SUBTITLE AND/OR SPEAKER INFO
This is a regular slide.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer eget volutpat eros, sit amet tristique enim. Aliquam nec odio eu ligula aliquam ultrices. Nulla fermentum dui nisl, ut tempus eros volutpat convallis.
This is a slide with two columns.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer eget volutpat eros, sit amet tristique enim. Aliquam nec odio eu ligula aliquam ultrices. Nulla fermentum dui nisl, ut tempus eros volutpat convallis.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer eget volutpat eros, sit amet tristique enim. Aliquam nec odio eu ligula aliquam ultrices. Nulla fermentum dui nisl, ut tempus eros volutpat convallis.
This is a split slide.
Space for subtitles.
Add text or a visualization here.
You can also use title only slides and add content of your choice!
Thursday,
Nov 16, 2023
Istanbul, Türkiye
ADD YOUR TITLE HERE
SUBTITLE AND/OR SPEAKER INFO
This is a regular slide.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer eget volutpat eros, sit amet tristique enim. Aliquam nec odio eu ligula aliquam ultrices. Nulla fermentum dui nisl, ut tempus eros volutpat convallis.
This is a slide with two columns.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer eget volutpat eros, sit amet tristique enim. Aliquam nec odio eu ligula aliquam ultrices. Nulla fermentum dui nisl, ut tempus eros volutpat convallis.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer eget volutpat eros, sit amet tristique enim. Aliquam nec odio eu ligula aliquam ultrices. Nulla fermentum dui nisl, ut tempus eros volutpat convallis.
This is a split slide.
Space for subtitles.
Add text or a visualization here.
You can also use title only slides and add content of your choice!
Thursday,
Nov 16, 2023
Istanbul, Türkiye