-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Storage layout specifier docs #15892
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
Conversation
50ba958 to
88792ee
Compare
|
Please link to the issue in PR description. |
| a contract definition, either after or before the inheritance specifier. | ||
| It can be given at most once. | ||
| The ``base-slot-expression`` must be an expression consisting of number literals | ||
| that can be evaluated at compile time and yield in a rational value in the range of ``uint256``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps another section describing that the max number of available storage slots will be (uint256::max - user defined base slot address + 1), and that a revert will be triggered in case an attempt is made to exceed the maximum number of available slots.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a revert. A compilation error.
803a4b2 to
74f84d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this page still says that the storage always starts at zero:
Except for dynamically-sized arrays and mappings (see below), data is stored contiguously item after item starting with the first state variable, which is stored in slot ``0``. For each variable,
Please also check if there's anything in the rest of the text that needs updating too.
8c93ccf to
4034c14
Compare
5ccc7d7 to
cbd4ad8
Compare
5e46227 to
05b0efb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a final pass over the PR, doing proofreading, fixing some grammar and generally rewording things to sound nicer. I also added some diagrams to your example (this is what I meant by showing the layout) and also extended the example to show more things (dynamic variables, more complex packing, etc.)
I pushed that as fixups just now. Please take a look and if you're fine with it, please squash, rebase and we can merge.
Part of #597/#15727.