Repository navigation
Conversation
EventQueueSerWrapper cast the queue length to u16, so a queue with 65,536 or more events was restored truncated on restart (65,536 events came back empty). Write and read the count as CollectionLength, which keeps the two-byte encoding below 65,535 and uses the 0xffff extension above it, and bound the reader's preallocation. Add round-trip tests at 65,534, 65,535, 65,536 and 65,540 events and a test that small queues keep the legacy encoding. Written with AI assistance (Claude); reviewed and tested locally. Fixes lightningdevkit#1138. Co-authored-by: Claude <noreply@anthropic.com>
|
I've assigned @tnull as a reviewer! |
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.
Fixes #1138.
EventQueueSerWrapperwrote the queue length asu16, while still writing every event, soEventQueueDeserWrapperrestored a truncated queue: 65,536 persisted events came back empty and 65,540 came back as 4.This switches both wrappers to
lightning::util::ser::CollectionLength, as suggested in the issue:0xffffmarker followed by the remainder;Tests (in
event::tests):event_queue_round_trips_around_u16_max: full round trip at 65,534, 65,535, 65,536 and 65,540 events. It fails onmain(65,536 events decode as 0) and passes with this change;event_queue_keeps_legacy_encoding_below_u16_max: a small queue encodes to the same bytes as the legacyu16format and decodes from them.cargo test --libpasses locally (203 tests); I didn't run the integration tests, which need bitcoind/electrs.AI disclosure: written with AI assistance (Claude); I reviewed the change and ran the tests above.
🤖 Generated with Claude Code