From 6ccb7a741fd1d01b060a210022cc465e3c444a5d Mon Sep 17 00:00:00 2001 From: Alexandru Vasile Date: Tue, 28 Apr 2026 14:57:34 +0000 Subject: [PATCH 1/2] sync: Force peers into ancestry search when blocks are not locally known Signed-off-by: Alexandru Vasile --- .../client/network/sync/src/strategy/chain_sync.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/substrate/client/network/sync/src/strategy/chain_sync.rs b/substrate/client/network/sync/src/strategy/chain_sync.rs index 9f38929a42729..a6b5e9d798ba8 100644 --- a/substrate/client/network/sync/src/strategy/chain_sync.rs +++ b/substrate/client/network/sync/src/strategy/chain_sync.rs @@ -517,10 +517,15 @@ where return None; } - // The node is continuing a known fork if either the block itself is known, the - // parent is known or the block references the previously announced `best_hash`. - let continues_known_fork = - known || known_parent || announce.header.parent_hash() == &peer.best_hash; + // The node is continuing a known fork if either the block itself is know or the + // parent is known. + // + // We cannot follow the fork any longer when the parent of the announcement is + // the peer's current best, because the peer's current best is updated from the announcement + // itself and not from the block import. This means that if the parent is the peer's current + // best, the peer might be announcing a new fork that we haven't seen before, and we + // cannot be sure that it continues a known fork. + let continues_known_fork = known || known_parent; let peer_info = is_best.then(|| { // update their best block From d63a47e88ed3d8658e8fe94fb245d845a648b358 Mon Sep 17 00:00:00 2001 From: Alexandru Vasile Date: Tue, 28 Apr 2026 15:13:11 +0000 Subject: [PATCH 2/2] Update comment Signed-off-by: Alexandru Vasile --- substrate/client/network/sync/src/strategy/chain_sync.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/substrate/client/network/sync/src/strategy/chain_sync.rs b/substrate/client/network/sync/src/strategy/chain_sync.rs index a6b5e9d798ba8..4794972f60858 100644 --- a/substrate/client/network/sync/src/strategy/chain_sync.rs +++ b/substrate/client/network/sync/src/strategy/chain_sync.rs @@ -520,11 +520,8 @@ where // The node is continuing a known fork if either the block itself is know or the // parent is known. // - // We cannot follow the fork any longer when the parent of the announcement is - // the peer's current best, because the peer's current best is updated from the announcement - // itself and not from the block import. This means that if the parent is the peer's current - // best, the peer might be announcing a new fork that we haven't seen before, and we - // cannot be sure that it continues a known fork. + // We cannot follow the fork by simply looking at the peer best hash, since that + // can be re-announced by the peer from a different fork entirely. let continues_known_fork = known || known_parent; let peer_info = is_best.then(|| {