From 78a60194ebfc80c1a5b619cc9dee46a05609a035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Fri, 8 Feb 2019 09:34:50 +0000 Subject: [PATCH] Fix block justification response handling (#1729) * core: sync: dont report peers on empty justification response * core: sync: log dispatched block justification requests --- substrate/core/network/src/sync.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/substrate/core/network/src/sync.rs b/substrate/core/network/src/sync.rs index 35ce217472..9193051322 100644 --- a/substrate/core/network/src/sync.rs +++ b/substrate/core/network/src/sync.rs @@ -93,6 +93,8 @@ impl PendingJustifications { return; } + let initial_pending_requests = self.pending_requests.len(); + // clean up previous failed requests so we can retry again for (_, requests) in self.previous_requests.iter_mut() { requests.retain(|(_, instant)| instant.elapsed() < JUSTIFICATION_RETRY_WAIT); @@ -173,6 +175,11 @@ impl PendingJustifications { } self.pending_requests.append(&mut unhandled_requests); + + trace!(target: "sync", "Dispatched {} justification requests ({} pending)", + initial_pending_requests - self.pending_requests.len(), + self.pending_requests.len(), + ); } /// Queue a justification request (without dispatching it). @@ -534,12 +541,12 @@ impl ChainSync { ); }, None => { - let msg = format!( - "Provided empty response for justification request {:?}", + // we might have asked the peer for a justification on a block that we thought it had + // (regardless of whether it had a justification for it or not). + trace!(target: "sync", "Peer {:?} provided empty response for justification request {:?}", + who, hash, ); - - protocol.report_peer(who, Severity::Useless(msg)); return; }, }