-
Notifications
You must be signed in to change notification settings - Fork 997
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
Full support for tuples #665
Comments
I would lean toward favoring pythonic notation because the rest of the spec uses it. Why is including the data length on these arrays a "nuisance"? Is there any loss other than a tiny increase in size of the hashed item? |
I think the idea to use SSZ everywhere (as opposed to the lower-level
In addition to the above, I would say that we want SSZ to be maximally friendly to merkleisation with the hope of SSZ becoming a standard. It's also slightly more efficient and friendly for the fixed-size components of
Right, we should use whatever notation is most Pythonic! :)
Basically. I communicated the idea in Go because I'm not sure what the Python equivalent is. |
I think in Python a fixed-size list is called a "tuple". |
Off this topic
|
I vote for the following notation:
|
In theory a fork could change the state list lengths.
Not sure I understand this 😂
I do intend to fine-tune all the constant towards the end. But as mentioned above, the sizes are not fixed forever.
Agreed! |
I was saying I was afraid that I'm putting more unnecessary requirements and make it a more complicated design in the early stage. 😆
It seems we will need extra code to handle length extension. And the "suture" between the forks is less clean. For example state.latest_block_roots[slot % LATEST_BLOCK_ROOTS_LENGTH]
LATEST_BLOCK_ROOTS_LENGTH: 8
after processed block 15
when processed block 16
[root_8, root_11, ...., root_14, root_15]
get_block_root(state, slot) can get block root between [state.slot - LATEST_BLOCK_ROOTS_LENGTH, state.slot) = [15-8, 15)
get_block_root(state, 11) = state.latest_block_roots[slot % LATEST_BLOCK_ROOTS_LENGTH] = root_11
####
Increase `LATEST_BLOCK_ROOTS_LENGTH` from 8 to 16
LATEST_BLOCK_ROOTS_LENGTH: 16
after processed block 15
[root_9, root_11, ...., root_14, ZERO_HASH, .... ZERO_HASH]
get_block_root(state, slot) can get block root between [state.slot - LATEST_BLOCK_ROOTS_LENGTH, state.slot) = [15-16, 15) <--- oh no We would need to either (i) fill the missing empty spots in the new array in the fork slot or (ii) prevent the empty spots from being accessed before they are filled in the future slots. |
That seems reasonable. |
* Implement tuples and a chunk-size reduction to 32 bytes (see #665 and #679) * Simplify presentation where appropriate. For example, deserialisation is implicit from serialisation (similar to `bls_sign` being implicit from `bls_verify`) and is left as an implementation exercise. * Dramatically reduce spec size and hopefully improve readability.
SSZ has full support for lists, but only partial support for arrays (specifically, it can support arrays of bytes with
bytesN
). I'd argue we want full support for fixed-sized arrays. The reason is that fixed-sized arrays appear in various places where we do not want to mix in the array length. One example is when computing theshard_data_root
, and another one appeared here. Other examples includelatest_randao_mixes
,latest_block_roots
,latest_active_index_roots
,latest_slashed_balances
which are all fixed size, and where including the data length is a nuisance.Ideally we want to use
hash_tree_root
overmerkle_root
pretty much everywhere, and support for fixed-sized arrays will allow this.(Side note regarding Go: In go we have "arrays" with the
[n]
notation for a fixedn
. For example[32]byte
would be the equivalent ofBytes32
. We also have "slices" with the[]
which have dynamic size. My suggestion is to define SSZ for slices and arrays.)The text was updated successfully, but these errors were encountered: