Merged
Conversation
Some node software does not advertise full node service when in regtest mode. We only want to check services when we're not running in regression test mode.
There was a problem with the previous code used to select a sync peer when none exists, which happens if we lose our sync peer or if we fail to establish a sync peer. The early exit statement didn't first re-check if the peer is a possible syncCandidate before exiting. This would have been fine if 'syncCandidate' wasn't also possibly being changed in the following 'peer.LastBlock() < best.Height' conditional. This fix allows peer nodes to become sync candidates at a later time if they were ever marked as a non-sync peer candidate. This could happen if previously checked peer was behind, and then later surpassed our node.
zquestz
approved these changes
May 20, 2021
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.
There are two improvements here for the peer manager.
The first commit fixes an issue where in regtest mode bchd wouldn't connect to some other nodes that don't advertise full node service in while in regtest mode. This behavior was already baked in, but it was broken by my previous commit 9392a9 adding
sm.regTestSyncAnyHost.The second commit addresses an issue where some peers may become valid sync peers but the peer's
syncCandidateis stuck at false because at some time their block height was less than ours (see manager.go new line 354).