You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@atoulme and/or @cleishm, if you wouldn't mind giving a little thought to the below proposal, I'd be most appreciative. I've spent a little bit mulling this over and plan to take a first stab at a PR shortly, but in the meantime an extra set of eyes doesn't hurt.
Description
The SSZ spec was rewritten as part of the eth2-specs v0.5.1 release to include both fixed-length and variable-length arrays/lists. Following the python notation used in the eth2-specs, and for the sake of clarity, fixed-length arrays/lists will be referred to as "tuples" and variable-length array/lists will be referred to as "lists".
(Not so) Quick Background
Firstly, the SSZ spec has a limited number of base types:
uintN (where N is in 8, 16, 32, 64, 128, or 256) a N bit unsigned integer
bool A Boolean (True or False)
byte == uint8 byte is an alias for uint8
Composite types from these include:
tuple, represented as [type, N] a fixed-length homogenous collection of N values
list, represented as [type] a variable-length homogenous collection of values
Some derived values, therefore are:
bytes == ["byte"] A variable-length collection of byte types (uint8 types by extension)
bytesN == ["byte", N] A fixed-length collection of byte types with N length
The implications of the above are that "list" requires a length mixin, where as a "tuple" does not.
Proposed Changes
When Java bytes are serialized (i.e. when recursively serializing a Cava Bytes type), they should be serialized as a uint8.
A Cava Bytes type of length 1 should be serialized as a uint8. [still undecided on this one]
A Cava Bytes type of length >1 should be treated and serialized as a "list".
All fixed length Cava BytesN types (i.e. Bytes32) should be treated and serialized as a "tuple".
Support will be added for serializing Bytes... (varags list) as either a "list" or a "tuple"
The proposed method of achieving this is overloading the relevant functions with an additional length parameter.
Support will be added for serializing List<? extends Bytes> as either a "list" or a "tuple".
The proposed method of achieving this is overloading the relevant functions with an additional length parameter.
@atoulme and/or @cleishm, if you wouldn't mind giving a little thought to the below proposal, I'd be most appreciative. I've spent a little bit mulling this over and plan to take a first stab at a PR shortly, but in the meantime an extra set of eyes doesn't hurt.
Description
The SSZ spec was rewritten as part of the eth2-specs v0.5.1 release to include both fixed-length and variable-length arrays/lists. Following the python notation used in the eth2-specs, and for the sake of clarity, fixed-length arrays/lists will be referred to as "tuples" and variable-length array/lists will be referred to as "lists".
(Not so) Quick Background
uintN(whereNis in 8, 16, 32, 64, 128, or 256)a N bit unsigned integer
boolA Boolean (True or False)
byte==uint8byte is an alias for uint8
tuple, represented as[type, N]a fixed-length homogenous collection of N values
list, represented as[type]a variable-length homogenous collection of values
bytes==["byte"]A variable-length collection of byte types (uint8 types by extension)
bytesN==["byte", N]A fixed-length collection of byte types with N length
The implications of the above are that "list" requires a length mixin, where as a "tuple" does not.
Proposed Changes
bytes are serialized (i.e. when recursively serializing a CavaBytestype), they should be serialized as auint8.Bytestype of length 1 should be serialized as auint8. [still undecided on this one]Bytestype of length >1 should be treated and serialized as a "list".BytesNtypes (i.e.Bytes32) should be treated and serialized as a "tuple".Bytes...(varags list) as either a "list" or a "tuple"lengthparameter.List<? extends Bytes>as either a "list" or a "tuple".lengthparameter.Additional Information
See https://github.com/ethereum/eth2.0-specs/blob/v0.5.1/specs/simple-serialize.md.