-
Notifications
You must be signed in to change notification settings - Fork 7
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
Slots documentation #315
Slots documentation #315
Conversation
70be1c1
to
0c28d5c
Compare
pub(crate) fn mapping(slot: Bytes32, key: Bytes32) -> Bytes32; | ||
``` | ||
|
||
Calculates slot number of value corresponding to a mapping `key`. `Slot` argument is the storage location of the mapping calculated after applying storage layout rules. |
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.
Slot number doesn't make sense. Slot itself is a number.
Calculates THE slot
Of A value
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.
How slot if calculated is irrelevant in the context of this function. It deals with calculating it's return value. You can mention that it concatenates & hashes
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 wanted to include the explanation of what is this slot argument, because we need to emphasise the difference between this argument and the one with the same name in the function mentioned later.
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.
There will be a link to documentation about solidity storage layout where concatenation and hashing will be explained. So I don't think we need to repeat that here.
|
||
Calculates slot number where element at `index` in dynamic array is located. `Slot` argument is the storage location of the dynamic array calculated after applying storage layout rules. `Size` defines the size of elements in the array. | ||
|
||
- There is an analogical function where `slot` argument is a precalculated slot of the first element in the array: |
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.
Let's describe - when is the other function useful. Some example code in Sol.
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.
Actually there is an example of usage for this function below.
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.
Let's do the last sync round of review tomorrow morning
@@ -72,3 +72,11 @@ pub fn sub_array_equals<TItem, SUBARRAY_LEN, ARRAY_LEN>( | |||
} | |||
result | |||
} | |||
|
|||
pub fn slice_to_array<LENGTH>(slice: [u8]) -> [u8; LENGTH] { |
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.
ethereum/circuits/lib/README.md
Outdated
U256 is a structure to use as a type for big numbers. | ||
It is used when dealing with numbers up to 2<sup>256</sup>. They can exceed Field maximum value. | ||
|
||
[There](.src/uint256.nr) is an unoptimized implementation of this type using two U128 structures. Optimized version will appear in Noir. | ||
|
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.
This should mention - why are U256 useful. That they are a word size in ETH and therefore a basic type used in both storage and slot values calculations
uin256.nr
from misc to main part of libraryslot_test.nr
and fixed wrong order of arguments given todynamic_array
functionfield_to_bytes32
function fromfield.nr
tobytes32.nr
file