-
Notifications
You must be signed in to change notification settings - Fork 512
Bolt 1: Clarify the definition of tu fields #1073
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
Bolt 1: Clarify the definition of tu fields #1073
Conversation
Which implementations require leading zeros to be truncated? From a quick look at CLN and LND, they appear to work fine for untruncated integers. |
Eclair requires those values to be minimally-encoded, but I never realized the spec didn't make it a requirement... I don't see any good reason to keep the redundant leading zeros, if we're using a truncated integer that's specifically because we want to remove them, right? So I'd be inclined to accept this PR to make eclair's behavior official 😄 |
SGTM |
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.
ACK 60b77f6
Actually afaict, cln does check on leading zero bytes and fails if there are any. The following lines from
Also, sorry for the (maybe) wrong terminology, I was in believe that the Let me know if you would like me to change the wording. |
Ah, you're right. I completely skipped over that check.
I also assumed it meant "truncated unsigned integer". |
ACK on the changes, could also be an opportunity to add some basic test vectors here to tighten things up. |
If I understand the following lines from the Lines 709 to 715 in 50b2df2
Lines 791 to 799 in 50b2df2
Maybe we can further clarify it by providing separate test vectors for the fundamental tuXX type. But if people already are using the given set of test vectors the cases should be covered and the rewording of the definition might be sufficient to grasp the requirements of those fields.
|
4c527aa
to
45e4cbb
Compare
Truncated integer fields, e.g. tu16 cannot have leading zeros judging by the implementations of the parsers, which are used across the different ln implementations. The `can` imposed that it is not necessary to truncate the fields to values of information. Signed-off-by: Peter Neuroth <[email protected]> Bolt 1: Add where tuXX fields may be used. As truncated integers are not limited to TLV records with single values (e.g. onion-routing payload type 8 - payment data) we want to further clarify where the tuXX fields can be used. Signed-off-by: Peter Neuroth <[email protected]>
45e4cbb
to
bf97a79
Compare
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.
ACK bf97a79
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.
ACK bf97a79
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.
ACK bf97a79
Ack bf97a79 |
The sentence
..., leading zeros in integers can be omitted
in the Bolt 1 fundamental type section: https://github.com/lightning/bolts/blob/50b2df24a27879e8329712c275db78876fd022fe/01-messaging.md#fundamental-types imposes that it is not necessary, but optional to truncate leading zeros intuXX
fields.Having a look at the
tuXX
parsers across the ln implementations, it seems that it is expected to omit leading zeros.This PR tries to find a better explanation/definition to avoid uncertainties.