feat(blockchain): defer early gossip messages to their production interval#318
Draft
MegaRedHand wants to merge 1 commit intomainfrom
Draft
feat(blockchain): defer early gossip messages to their production interval#318MegaRedHand wants to merge 1 commit intomainfrom
MegaRedHand wants to merge 1 commit intomainfrom
Conversation
…erval Gossip attestations arriving before their slot has started locally are rejected with `AttestationTooFarInFuture` and dropped today, wasting the peer's work even though the next slot tick is at most a few seconds away. Buffer them via `send_after` and replay each message at the interval an honest validator would have produced it (interval 1 of slot S for single attestations, interval 2 for aggregated). Bounds on receipt prevent abuse: messages more than MAX_DEFER_FUTURE_SLOTS (4) ahead are dropped, and the in-flight retry budget is capped at MAX_DEFERRED_GOSSIP_MESSAGES (1024). Refs #307
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.
Summary
AttestationTooFarInFutureand dropped, wasting the peer's signature and re-aggregation work.send_afterand replays each message at exactly the interval an honest validator would have produced it (interval 1 of slotSfor single attestations, interval 2 for aggregated).MAX_DEFER_FUTURE_SLOTS(4) ahead are dropped, and the in-flight retry budget is capped atMAX_DEFERRED_GOSSIP_MESSAGES(1024).Closes (potentially) #307.
We don't have direct evidence that early-gossip arrivals actually happen at meaningful rates on our network. Before merging this we should:
AttestationTooFarInFuturerejections (cheap diagnostic, separate PR).:5054/metrics.The recent leanSpec PR #682 (branch
port/leanspec-682-tighten-attestation-future-bound) tightens the bound from a full slot to ~800ms of clock skew. Once that lands, this rejection becomes much easier to hit at the edge, which would tilt the answer toward "yes, fix it." Suggested ordering: land the diagnostic counter, land #682, measure, then decide on this PR.Implementation notes
RetryDeferredAttestation/RetryDeferredAggregatedare scheduled withsend_after(delay, …)wheredelayis computed by the pure functiondefer_delay(store_time, slot, interval_in_slot).deferred_gossip_count: usizeonBlockChainServerbounds in-flight retry timers; the count is incremented on enqueue and decremented when the retry handler runs.defer_delayand the retry-target intervals are unit-tested in a newdefer_testsmodule inlib.rs(production-interval timing for both kinds, slot-window edge, past-interval collapse to zero).is_gossip_too_earlymirrorsstore::validate_attestation_data's rejection rule, and only future-slot messages divert to the retry path.Test plan
cargo fmt --allcargo clippy --workspace --all-targets -- -D warningscargo test --workspace --release— 327 passed, 6 ignored, 0 failedlean_attestations_rejected_too_early_totalcounter and observe on devnet