Pad all sent TCP frames to the same size via ChunkedMessageQueue#4446
Open
tnull wants to merge 3 commits intolightningdevkit:mainfrom
Open
Pad all sent TCP frames to the same size via ChunkedMessageQueue#4446tnull wants to merge 3 commits intolightningdevkit:mainfrom
ChunkedMessageQueue#4446tnull wants to merge 3 commits intolightningdevkit:mainfrom
Conversation
|
👋 Thanks for assigning @TheBlueMatt as a reviewer! |
65a1bf5 to
a305971
Compare
ChunkedMessageQueue for message paddingChunkedMessageQueue
48bb745 to
64e28db
Compare
Contributor
Author
b3c711d to
8dee6f5
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4446 +/- ##
==========================================
+ Coverage 85.88% 85.98% +0.10%
==========================================
Files 159 159
Lines 104302 104850 +548
Branches 104302 104850 +548
==========================================
+ Hits 89578 90157 +579
+ Misses 12222 12188 -34
- Partials 2502 2505 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add `BorrowedVecWriter`, `encrypt_with_header_0s_at`, `encrypt_message_into`, and `encrypt_buffer_into` to `PeerChannelEncryptor` to support encrypting messages directly into a shared buffer at arbitrary offsets. Define `ChunkedMessageQueue` struct in `peer_handler` with a contiguous byte buffer that will replace the current `pending_outbound_buffer` / `gossip_broadcast_buffer` dual-queue system. The queue pads all outgoing traffic into fixed-size `CHUNK_SIZE` chunks using Ping messages as filler, so an observer sees only constant-size writes on the wire. Ping padding uses `ponglen = 65533` to suppress Pong responses per BOLT-1. Co-Authored-By: HAL 9000
Replace `pending_outbound_buffer`, `pending_outbound_buffer_first_msg_offset`, and `gossip_broadcast_buffer` fields in `Peer` with a single `message_queue: ChunkedMessageQueue`. Co-Authored-By: HAL 9000
Add five new tests: - `test_chunked_message_queue_ping_padding`: verifies chunk alignment for various message sizes - `test_chunked_message_queue_small_remainder_overflow`: verifies the two-Ping edge case when remainder < `MIN_ENCRYPTED_PING_SIZE` - `test_chunked_message_queue_chunk_alignment`: verifies alignment after encrypting multiple real messages - `test_chunked_message_queue_buffer_compaction`: verifies `maybe_compact` correctly drains sent bytes - `test_chunked_message_queue_pending_msg_bytes_tracking`: verifies that `pending_msg_bytes` tracks real message bytes and is unaffected by padding Also extract a `get_test_encryptor` helper to reduce boilerplate across the new tests. Co-Authored-By: HAL 9000 Signed-off-by: Elias Rohrer <dev@tnull.de>
8dee6f5 to
d8de722
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

In this PR we implement padding all sent TCP frames to the same size by ensuring all writes happen in chunks of length
CHUNK_SIZEand any remainders are filled by adequately sizedPingmessages.This approach operating on the network-layer was discussed in the spec call and seems to be preferred by everybody. Hence it supersedes the approach taken in #4248.
TODO