Repository navigation
fix(floodsub): use monotonic sequence numbers - #3672
Merged
Merged
Conversation
Seed the sequence number from the wall clock in nanoseconds and increment it, as the pubsub spec requires, instead of picking random values.
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.
Description
floodsub picked a random 64-bit sequence number for each message and encoded it with leading zero bytes removed, so about 1 in 256 messages went out with a sequence number shorter than 8 bytes. gossipsub peers using
fallbackToFloodsubreject any sequence number that is not exactly 8 bytes, so those messages were dropped silently. This is also why thegossipsub fallbacks to floodsubpublish tests time out intermittently.The pubsub spec requires a linearly increasing 64-bit big-endian sequence number. floodsub now uses a counter seeded from the wall clock in nanoseconds, the same as gossipsub, go-libp2p and rust-libp2p. The seed is above 2^56, so the sequence number always encodes to 8 bytes, and it keeps increasing across restarts for validators that drop non-increasing sequence numbers.
Notes & open questions
randomSeqnois renamed tonextSeqno. It is internal (not in the package exports).Change checklist