[Fix] Add grace period before starting block sync #3249
Merged
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.
Motivation
This PR simply adds an additional grace period for the nodes to wait before attempting to call
try_block_sync
.Ideally,
try_block_sync
isn't called until the firstPrimaryPing
message is received, however in the initial bootup of validators, the nodes need to consider themselves synced to send thePrimaryPing
in the first place. Hence, the heuristic wait approach.This is needed because we've observed that during bootup, nodes were (occasionally) incorrectly setting themselves as synced and when they were in fact much further behind than the other validators. This caused them to incorrectly start processing proposals and certificates from the other validators instead of actually syncing.
Here is an example of an observed sequence of logs that should not happen:
Upon further debugging, this seems to happen when the validator node call
try_block_sync
before receiving block locators from peers via aEvent::PrimaryPing
. The call totry_block_sync
makes the node think it's synced since there are no block locators to sync from, and thus starts processing proposals/certificates from peers.