Do not update peer information if ancestor search is in progress (#12631)

* Do not update peer information if ancestor search is in progress

If block announcement is received from a peer while ancestor search
for that same peer is still in progress, do not update the peer's best
hash and best number as that causes the ancestor search to yield
different information from what was expected and can cause, for example,
a fork of lower height not be be downloaded.

* Block until peers are in sync
This commit is contained in:
Aaro Altonen
2022-11-08 00:57:29 +02:00
committed by GitHub
parent 1ed70004e7
commit df54463521
2 changed files with 9 additions and 5 deletions
+5 -5
View File
@@ -2043,17 +2043,17 @@ where
return PollBlockAnnounceValidation::Nothing { is_best, who, announce }
};
if let PeerSyncState::AncestorSearch { .. } = peer.state {
trace!(target: "sync", "Peer state is ancestor search.");
return PollBlockAnnounceValidation::Nothing { is_best, who, announce }
}
if is_best {
// update their best block
peer.best_number = number;
peer.best_hash = hash;
}
if let PeerSyncState::AncestorSearch { .. } = peer.state {
trace!(target: "sync", "Peer state is ancestor search.");
return PollBlockAnnounceValidation::Nothing { is_best, who, announce }
}
// If the announced block is the best they have and is not ahead of us, our common number
// is either one further ahead or it's the one they just announced, if we know about it.
if is_best {