-
Notifications
You must be signed in to change notification settings - Fork 12
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
Consider changing serialization of optional payload #401
Comments
You still need a |
Why would it not be possible to read the bytes on-demand from the stream? You know the layout of a Tagged Data Payload, so if there was an indication that it's present, you can try to
I haven't looked into how serix does this exactly, but something similar must be done when reading a Metadata Feature. You only know the So, without having dove deeper into serix, I don't get why we need the Payload Length specifiying the entire length of the following payload when the tagged data itself has a well-defined layout, just like a Metadata Feature. |
That comparison does not work. Because of the |
I am also in favour of removing the |
Maybe come to a final conclusion when we do #653 . |
We decided to keep the payload length, so we can skip parsing the payload if not needed. |
We could consider improving our serialization of optional types in serix, specifically of the optional payload in a Transaction Essence.
The Tagged Data Payload is optional, and the way we implement this optionality is by having a
Payload Length
prefix of type uint32 that, if 0, indicates that the type is absent. If it's there, the payload length holds the entire length of the optional payload, which is unnecessary. Additionally, we handle this payload specially in serix, which also seems unnecessary, and if removed, would reduce the serializer code size and its complexity.It would suffice to have a byte indicating whether the type is absent (e.g. 0) or present (e.g. 1), and then continue reading the schema of whatever type is specified since the next byte would be that type's prefix byte. This way, we wouldn't need special code for optional payloads, but would even enable optional types more generically.
See also https://github.com/iotaledger/tips/blob/main/tips/TIP-0020/tip-0020.md#serialized-layout for the layout of the current Transaction and how the optional payload is serialized, which still matches what we have in code today.
The text was updated successfully, but these errors were encountered: