-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Output the storage layout of a contract via storageLayout artifact #7589
Conversation
Missing
|
From #3736 (comment): |
Might not be necessary if both |
Did you check #4017 (comment)? |
@axic Yes. Since this PR is simpler I considered that it might be the case that we want the storage layout to look simpler as well, since the comment you mentioned says that the flat structure would simplify recursive data structures. |
It's too tempting to go ahead and implement the Struct case as well, it's too close :p |
2b8f2d1
to
7d5bb89
Compare
This is ready for review. |
495875e
to
5ba3597
Compare
@ekpyron removed |
5ba3597
to
69f9dc6
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.
Looks good to me, but the documentation is lacking... do we want to fix that here?
Should we explicitly document this as "experimental and subject to change in non-breaking releases" for now and communicate with the "debugging format working group" about this, since there will be overlap? |
Fine with me |
Not sure about it myself |
{"contracts":{"fileA":{"A":{"storageLayout":{"storage":[{"ast_id":"2","contract":"A","label":"x","offset":"0","slot":"0","type":"t_uint64"},{"ast_id":"4","contract":"A","label":"y","offset":"8","slot":"0","type":"t_uint128"},{"ast_id":"6","contract":"A","label":"z","offset":"0","slot":"1","type":"t_uint128"},{"ast_id":"8","contract":"A","label":"addr","offset":"0","slot":"2","type":"t_address"},{"ast_id":"12","contract":"A","label":"array","offset":"0","slot":"3","type":"t_array(t_uint256)2_storage"}],"types":{"t_address":{"encoding":"inplace","label":"address","numberOfBytes":"20","numberOfSlots":"1"},"t_array(t_uint256)2_storage":{"base":"t_uint256","encoding":"inplace","label":"uint256[2]","numberOfBytes":"32","numberOfSlots":"2"},"t_uint128":{"encoding":"inplace","label":"uint128","numberOfBytes":"16","numberOfSlots":"1"},"t_uint256":{"encoding":"inplace","label":"uint256","numberOfBytes":"32","numberOfSlots":"1"},"t_uint64":{"encoding":"inplace","label":"uint64","numberOfBytes":"8","numberOfSlots":"1"}}}}}},"errors":[{"component":"general","formattedMessage":"fileA:1:1: Warning: Source file does not specify required compiler version! | ||
contract A { uint64 x; uint128 y; uint128 z; address addr; uint[2] array; } | ||
^-------------------------------------------------------------------------^ | ||
","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":75,"file":"fileA","start":0},"type":"Warning"}],"sources":{"fileA":{"id":0}}} |
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.
@chriseth I don't remember precisely, but is this message Source file does not specify required compiler version!...
suppose to be removed automatically?
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.
yes, it should be removed.
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.
Ah, no, it's not, only the recommended compiler version is removed.
69f9dc6
to
4aed2b5
Compare
I don't think we should wait for #7665 with this. |
Adding the "to discuss" label for deciding about the "still subject to change" thing. |
We might not need the "still subject to change" thing, if we create wrappers in solc-js later. |
@ekpyron I'm strongly against the |
decb20c
to
a1699ee
Compare
@chriseth updated all comments |
Build error. |
a1699ee
to
29bd378
Compare
@chriseth tests passing |
Do we also want a command line option? |
29bd378
to
5f43b8d
Compare
|
||
|
||
{ | ||
"astId": 2, |
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.
Changed these to be numbers again and added some spaces.
- ``bytes``: single slot or Keccak-256 hash-based depending on the data size (see :ref:`above <bytes-and-string>`). | ||
|
||
- ``label`` is the canonical type name. | ||
- ``numberOfBytes`` is the number of used bytes (as a decimal string). Note that if ``numberOfBytes > 32`` this means that more than one slot is used. |
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.
Added string clarification.
Fixes #3736