Pad all sent TCP frames to the same size via ChunkedMessageQueue#4446
Pad all sent TCP frames to the same size via ChunkedMessageQueue#4446tnull wants to merge 3 commits intolightningdevkit:mainfrom
ChunkedMessageQueue#4446Conversation
|
👋 Thanks for assigning @TheBlueMatt as a reviewer! |
65a1bf5 to
a305971
Compare
ChunkedMessageQueue for message paddingChunkedMessageQueue
48bb745 to
64e28db
Compare
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
|
🔔 1st Reminder Hey @TheBlueMatt! This PR has been waiting for your review. |

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