From bb0736cdba4babbe6e777846bcd7ea3428163580 Mon Sep 17 00:00:00 2001
From: Arkadiy Paronyan <arkady.paronyan@gmail.com>
Date: Mon, 11 Nov 2019 01:23:41 +0100
Subject: [PATCH] Allow ancient fork download after ancestry search (#4080)

---
 substrate/core/network/src/protocol/sync.rs | 4 ----
 substrate/core/network/src/test/sync.rs     | 4 ++--
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/substrate/core/network/src/protocol/sync.rs b/substrate/core/network/src/protocol/sync.rs
index aa4714d0d5a..12839136a50 100644
--- a/substrate/core/network/src/protocol/sync.rs
+++ b/substrate/core/network/src/protocol/sync.rs
@@ -704,12 +704,8 @@ impl<B: BlockT> ChainSync<B> {
 								matching_hash,
 								peer.common_number,
 							);
-							let client = &self.client;
 							if peer.common_number < peer.best_number
 								&& peer.best_number < self.best_queued_number
-								&& matching_hash.and_then(
-									|h| client.block_status(&BlockId::Hash(h)).ok()
-								).unwrap_or(BlockStatus::Unknown) != BlockStatus::InChainPruned
 							{
 								trace!(target: "sync", "Added fork target {} for {}" , peer.best_hash, who);
 								self.fork_targets
diff --git a/substrate/core/network/src/test/sync.rs b/substrate/core/network/src/test/sync.rs
index 072099d6f7f..9868bd0ed2b 100644
--- a/substrate/core/network/src/test/sync.rs
+++ b/substrate/core/network/src/test/sync.rs
@@ -617,9 +617,9 @@ fn syncs_header_only_forks() {
 	net.peer(1).push_blocks(4, false);
 
 	net.block_until_sync(&mut runtime);
-	// Peer 1 won't sync the small fork because common block state is missing
+	// Peer 1 will sync the small fork even though common block state is missing
 	assert_eq!(9, net.peer(0).blocks_count());
-	assert_eq!(7, net.peer(1).blocks_count());
+	assert_eq!(9, net.peer(1).blocks_count());
 
 	// Request explicit header-only sync request for the ancient fork.
 	let first_peer_id = net.peer(0).id();
-- 
GitLab