Refuse to start warp sync when too few peer slots are configured#12287
Open
dimartiro wants to merge 1 commit into
Open
Refuse to start warp sync when too few peer slots are configured#12287dimartiro wants to merge 1 commit into
dimartiro wants to merge 1 commit into
Conversation
f657f49 to
a37ff50
Compare
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
Closes #10222.
Warp sync only begins once at least
min_peers_to_start_warp_syncfull-node peers (3 by default) are connected. However, a node could be started with--sync=warpand a peer-slot configuration that can never reach that threshold — e.g.--in-peers 0 --out-peers 0— in which case it would silently get stuck forever, waiting for peers it has no room to accept:Fix
At sync-engine startup (
SyncingEngine::new, which already returns aResult), the node now fails fast with an actionable error when warp sync is requested but the configured peer slots can never reach the threshold, instead of hanging. The check accounts for reserved nodes, since they connect outside of the regular inbound/outbound slot limits and also count towards the warp sync threshold.The validation lives in a small pure helper,
ensure_warp_sync_can_start, so it is easy to unit-test in isolation.