Skip to content

Stricter batching of commit_sig messages on the wire #3083

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

Merged
merged 3 commits into from
May 23, 2025

Conversation

t-bast
Copy link
Member

@t-bast t-bast commented May 14, 2025

There has been a lot of discussion on the spec about how we should batch commit_sig messages during splices. We reached an agreement to guarantee that the messages are sent together, without any other message in-between. See lightning/bolts@b5b5572 for more details.

Since our experimental splice version does not guarantee this, we start by:

  • ensuring that we correctly send batches of commit_sig messages, which is transparent for our peers
  • support reading batches of commit_sig messages that may have other messages in-between, to support the current experimental version while preparing a world where we always batch
  • in Use final spec values for splicing #2887, we then introduce the start_batch message (but we keep backwards-compatibility support)

This PR can be integrated right now, since it doesn't introduce any new spec messages or TLVs. I recommend reviewing it commit-by-commit (and read the commit messages). The first commit simply refactors the TransportHandler, because I initially hoped that we could support the batching there: but it turns out that because of our buffered reads of encrypted streams, this would be very complex, so I ended up handling batching in PeerConnection, but I thought the refactoring was still useful. Let me know if I should just drop that first commit.

t-bast added 2 commits May 14, 2025 11:04
The `TransportHandler` is a very old actor that we never refactored much
and needed a bit of clean-up. There is no reason to make it generic, it
only supports sending lightning messages on the wire. If we ever need to
make it generic in the future, we can easily do it, but for simplicity
it should only handle lightning messages for now.
We introduce a `CommitSigBatch` class to group `commit_sig` messages
when splice transactions are pending. We use this class to ensure that
all the `commit_sig` messages in the batch are sent together to our
peer, without any other messages in-between.
@t-bast t-bast force-pushed the splice-message-batch branch from 1171341 to ef6945b Compare May 14, 2025 13:35
@t-bast t-bast marked this pull request as ready for review May 14, 2025 15:08
@t-bast t-bast requested review from remyers and pm47 May 14, 2025 15:08
Copy link
Contributor

@remyers remyers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but I have a concern about allowing our peer to add arbitrary amounts of data to PeerConnection. Am I missing something that prevents this?

We move the incoming `commit_sig` batching logic outside of the channel
and into the `PeerConnection` instead. This slightly simplifies the
channel FSM and its tests, since the `PeerConnection` actor is simpler.

We unfortunately cannot easily do this in the `TransportHandler` because
of our buffered read of the encrypted messages, which may split batches
and make it more complex to correctly group messages.
@t-bast t-bast merged commit a1c6988 into master May 23, 2025
1 check passed
@t-bast t-bast deleted the splice-message-batch branch May 23, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants