-
Notifications
You must be signed in to change notification settings - Fork 53
Conversation
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 think it would be useful if we can also add some notations for reflecting Subschema constraints
such as lexical order or uniqueness in order to make the RFCs overall shorter. Currently these things are always written as separate list items under the table notation.
Perhaps something like anyOf(lexical, unique)
and in cases such as a NativeToken
set anyOf(lexical, unique(NativeTokenID))
as in "unique on the NativeTokenID" (which is a tighter constraint than just unique
).
To fortify the case for lexical/unique, here a screenshot to show the duplication of information across the new output RFC:
| uint64 | An unsigned 64-bit integer encoded in Little Endian. | | ||
| uint256 | An unsigned 256 bits integer encoded in Little Endian. | | ||
| ByteArray[N] | A static size byte array of N bytes. | | ||
| ByteArray | A dynamically sized byte array. A leading uint32 denotes its length in bytes. | |
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.
In the current and next protocol we have cases where the byte array is denoted by a different type than uint32:
- Indexation feature block's tag bytes is denoted by a uint8
- Indexation payload (to be removed)'s index field is denoted by a uint16
Therefore I think it makes sense to change the notation from ByteArray
to something which includes the length denotation type, perhaps something like <uint8,uint16,uint32>ByteArray
as in "Variable Length Byte Array denoted by uintX". It might be clear that the length is meant in the notation, as the "ByteArray" name already implies an array of bytes and not of uintX.
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 am not sure this adds clarity. We've introduced the dynamic byte array as a primitive, so that it can be reused in various RFCs and this was also the motivation for using the fixed type of uint32. If this is no longer fixed and can vary, I would rather remove the dynamic byte array completely. In RFCs one would then introduce a new separate field Length
and the array then has the type ByteArray[Length]
. This is also how it is already done in the indexation payload in the message RFC.
text/0041-serialization-primitives/0041-serialization-primitives.md
Outdated
Show resolved
Hide resolved
* Add length type defs to ByteArray * Add clarification to atMostOneOfEach subschema
This RFC describes the serialization concepts in one document instead of scattered across all the RFCs.
Rendered Version