-
-
Notifications
You must be signed in to change notification settings - Fork 474
fix: bound SeenPayloadEnvelopeInput cache size to prevent OOM
#9489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lodekeeper can you confirm whether this exclude root is even needed, in what scenario can this be relevant with our current code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Walked the 5
add/addFromBidcall sites for the scenario where the just-inserted entry's slot is the strict minimum in the cache (the only case whereexcludeRootactually fires):excludeRoot?chain.ts:445(addFromBidat init)gossipHandlers.ts:191(gossip block)finalized_slot < head - 96(stalled finality) AND the block is on a non-canonical fork at a slot lower than every cache entry —validateGossipBlocklets that range throughdownloadByRange.ts:214(range sync seed)excludeRootonly protects the single entry being added in this call; sibling adds earlier in the same batch can still get evicted by the next add. Partial coverage.downloadByRoot.ts:119(parent root sync)api/impl/beacon/blocks/index.ts:116(publish API)So it's reachable but only in three narrow regimes: stalled-finality gossip on a low-slot non-canonical fork, out-of-order range-sync batches, and deep-reorg parent fetches.
One extra wrinkle worth flagging: even when
excludeRootfires, the protection only lasts until the nextadd()call — that next add doesn't know to exclude the previous entry, so it becomes the new lowest and gets evicted. SoexcludeRootis at most a 1-tick reprieve. For the gossip case in particular, the gap betweengossipHandlers.ts:191(block add) and the matching envelope lookup atgossipHandlers.ts:1141(PAYLOAD_ENVELOPE_INPUT_MISSINGthrow) can easily span several other gossip adds in a busy network, in which caseexcludeRootdoesn't actually save the lookup.Verdict: defensible to keep — costs almost nothing, plugs the immediate self-eviction path that the unit test exercises. But fair to drop too if you'd rather simplify; the OOM scenario this PR addresses (sequential catch-up) never enters the
excludeRootbranch since adds are always at the high end of the slot range. If we drop it I'd suggest a brief comment onpruneToMaxSizenoting that a single low-slot insert can be self-evicting, so callers shouldn't assumeadd()always succeeds.If you want a stronger guarantee for the gossip-block → envelope path specifically, the real fix is either (a) skip-prune on
addand prune at a clock-tick boundary, or (b) the local seed-map fallback incacheByRangeResponsesCodex suggested — both follow-up scope.