Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

TIP-21 Serialization Primitives #41

Merged
merged 7 commits into from
Jul 13, 2022
Merged

Conversation

Wollac
Copy link
Contributor

@Wollac Wollac commented Nov 22, 2021

This RFC describes the serialization concepts in one document instead of scattered across all the RFCs.

Rendered Version

Copy link
Member

@luca-moser luca-moser left a 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:
image

| 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. |
Copy link
Member

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.

Copy link
Contributor Author

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.

@lzpap lzpap changed the title RFC: Serialization Primitives TIP-21 Serialization Primitives Dec 15, 2021
@alexsporn alexsporn merged commit c19a714 into iotaledger:main Jul 13, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants