-
Notifications
You must be signed in to change notification settings - Fork 492
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 4: link to BOLT 1 for tlv_payload format #801
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.
Small comment about existing tooling to check, but otherwise I think it's a good idea to add the link to bolt 1.
|
||
1. tlvs: `tlv_payload` | ||
1. `tlv_stream`: `tlv_payload` |
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'm not sure @rustyrussell's tooling to automatically generate the C definitions from the spec will like that change
It is consistent: a stream may have length 0 if it contains no records. A record cannot be shorter than 2 bytes (1+ byte type, 1+ bytes length, 0+ bytes value). Though I have to admit that an empty stream is not really useful, it is valid. The interpretation and default behavior depends on the context. Allowing a zero-length stream allowed us for example to pretend messages always had a tlv stream attached to its end, and be backward compatible without any changes. |
Where the BOLT says "This is safe since no TLV value can ever be shorter than 2 bytes", I guess it should technically say "This is safe since Please correct me if I'm wrong. |
I see, I must've missed that you were referring to the onion (rereading I should have seen that, since you mention bolt4). Indeed a zero-length tlv stream in an onion doesn't make sense, and the comment refers to the former realm bytes being 0x00 (legacy payload) and 0x01 (escape hatch for future payload changes) are not going to be used with tlv streams. |
Well, the 'tlv_stream' vs 'tlv_record' nomenclature came a bit later (the We could use tlv_stream: instead of tlvs: everywhere, but then tools/extract-formats.py would need updating. |
Right, so either we update this tool in the same PR, or simply revert the naming change @bitonic-cjp |
I'm willing to try and see if I can consistently replace Going through the BOLTs, I found cases where I'm not sure how to read them and how to modify them. For instance, in BOLT 02 I find this usage:
Based on the previously listed items, [
Is this OK? Would this require more changes to existing tooling? |
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.
LGTM 🏆
The type names are global. So, accept_channel ends in an accept_channel_tlvs, which is defined to be a The name of the field in this case ( |
Based on @rustyrussell 's description above, I propose a change along the lines of
...which would mean the following:
I'll make these changes, together with the tooling changes, and add them to this pull request. |
Should be good now. |
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 d7e463d
It might seem a bit redundant, but for me it would have helped to have this link.
I assumed that the payload has the format of
tlv_stream
. Technically, this leads to a small inconsistency though: BOLT 4 says somewhere that "no TLV value can ever be shorter than 2 bytes", buttlv_stream
can technically consist of zerotlv_record
elements, resulting in zero bytes. I don't know if it is ever possible for a node to know what to do when it receives a zero-byte payload. It'd have to be some kind of (supposedly useful and well-defined) "default behavior" of the node.Closes #800