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: Specify that extensions to existing messages must use TLV #714
Conversation
Open question: should the TLV stream be prefixed with its length or not? It seems like the gossip_queries tlv streams today don't prefix with the length (length is inferred from the overall message length). The inconvenient when we don't prefix with the length is that we completely remove the possibility of having another bag of uninterpreted bytes at the end of the message (if we decide some day that we want to extend messages with something else than TLV). Maybe we don't care, maybe we do :) I'm leaning towards removing the tlv stream length prefix: in that case this PR makes even more sense to do now, because we don't want to have some messages be extended with a TLV stream and others extended differently, that would be a big mess. WDYT @rustyrussell @cfromknecht @sstone ? UPDATED: removed the length prefix in |
If we limit message extensions to be TLV-based we should definitely drop the length prefix. I'd like to point out that there is a small caveat for gossip broadcast messages ( Other than that small wording issue, I'm definitely in favor of consolidating towards TLVs. |
I added two commits:
|
Do you think we should re-work It could be done in an interesting backwards-compatible way:
|
Sounds easiest just to make it a mandatoy field? (similar to what this PR specifies now) Why would doing this "hack" make the migration to TLV simpler? Is |
Thanks for the comment @halseth.
If we change the format of
Then we have a smooth upgrade path and we clean-up the spec by moving this field inside a TLV stream, because it will result in the exact same encoding as today. Since valid scripts have a length < 253, they will be encoded as either Does that make sense? The more I think about it, the less hackish it seems. I think it nicely cleans up that field that otherwise feels a bit out of place, being optional but not a TLV.
It's the only one that's a bit painful to handle. See 274a965 for details (especially the commit message). The two other optional fields are quite easy to simply make mandatory or not touch. |
The spec already prepared a hook to add additional information to existing messages (additional bytes at the end of a message must be ignored). Since we're using TLV in many places, it would make sense to use that optional additional space at the end of each message to allow an optional tlv stream. We keep the "additional bytes must be ignored" rule for what happens after that tlv stream, giving us extra flexibility to add another type of optional content to existing messages later if needed.
Clarify that extension bytes are included in signatures.
This applies to: - option_upfront_shutdown_script: if you're not interested, just set the length to 0 - channel_reestablish commitment points: it makes sense to always include those regardless of whether `option_dataloss_protect` or `option_static_remotekey` are set No need to change the `channel_update`'s `htlc_maximum_msat` because the `message_flags` encode its presence/absence. It can still be either included or omitted without causing issues to the extension stream.
@TheBlueMatt made a point that always parsing a TLV stream even when you don't expect anything is cumbersome. If you don't expect any extension, you may ignore the tlv stream. @rustyrussell noticed an unnecessary requirement now that TLV stream isn't length-prefixed.
This makes more sense for future work. It gives us more room to change the encoding or remove it.
I made If you all prefer, I can instead simply make the field mandatory, but please do consider the TLV option. Here are all the cases listed to show that backwards-compatibility fully works (but honestly you can easily convince yourself without going through all examples). With
|
Last call for reviewers! As agreed during the previous meeting (where @rustyrussell and @Roasbeef ack-ed), I'll merge this PR probably tomorrow if no-one complains :) I've implemented this in eclair and tested compatibility with lnd v0.9.1-beta.rc1 and c-lightning v0.8.1. |
Make DLP data mandatory in ChannelReestablish. We make them mandatory to allow extending the message with TLVs. Make upfront_shutdown_script a TLV record that we always include in open_channel / accept_channel. See lightning/bolts#714.
There weren't any explicit approvals on this :/ The general idea was acknowledged as being likely feasible (the backwards compat), but I (dunno about Rusty) haven't had a chance to actually closely review the changes. |
I must admit I'm a bit surprised there...
And then the tracking issue (#735) was updated with the meeting actions, one of which was to merge this PR after a few days if no new reviewer objected to it. If I had misunderstood your ACK, why didn't you say so when I created an action item to merge the PR? IRC isn't a perfect medium of communication so I thought that meant you had reviewed the change, which is my fault for interpreting this incorrectly, but you could have corrected this right when I said I'd merge the PR, or anytime after the meeting on the tracking issue? We'd been discussing this PR for the last 3 meetings. The latest releases of lnd, c-lightning and eclair have already all implemented and shipped that behavior (sending a |
I reverted the commit for now. Will re-open this PR on monday and we'll take it from there. |
The spec already prepared a hook to add additional information to existing
messages (additional bytes at the end of a message must be ignored).
Since we're using TLV in many places, it would make sense to use that optional
additional space at the end of each message to allow an optional tlv stream.
We keep the "additional bytes must be ignored" rule for what happens after that
tlv stream, giving us extra flexibility to add another type of optional content
to existing messages later if needed.
This was already proposed in #630 but rejected. I found additional reasons to
specify this now rather than on a per-message basis. We don't want to have two
competing and incompatible ways of extending existing messages.
Imagine node A and node B are peers, both running experiments by leveraging the
"ignore additional data" rule. However node A uses a TLV stream (as proposed in
this PR) while node B uses a different encoding. Unluckily node B also started his
encoding with something that can be interpreted as a varint, so node A interprets
this as a TLV stream, but it decodes as a two-bytes even number (which has a 50%
chance of happening). She (validly) thinks it's an even TLV she doesn't understand,
so she fails the connection and closes the channels.
This is a major inconvenience when experimenting with message extensions. I believe
what this PR proposes is reasonable and prevents these competing encodings to mess
up experimentations.