diff --git a/substrate/client/network/sync/src/lib.rs b/substrate/client/network/sync/src/lib.rs index 29c4bc840b..3f1cbebd57 100644 --- a/substrate/client/network/sync/src/lib.rs +++ b/substrate/client/network/sync/src/lib.rs @@ -2708,9 +2708,7 @@ where break } - if result.is_err() { - has_error = true; - } + has_error |= result.is_err(); match result { Ok(BlockImportStatus::ImportedKnown(number, who)) => @@ -2721,9 +2719,7 @@ where if aux.clear_justification_requests { trace!( target: "sync", - "Block imported clears all pending justification requests {}: {:?}", - number, - hash, + "Block imported clears all pending justification requests {number}: {hash:?}", ); self.clear_justification_requests(); } @@ -2731,9 +2727,7 @@ where if aux.needs_justification { trace!( target: "sync", - "Block imported but requires justification {}: {:?}", - number, - hash, + "Block imported but requires justification {number}: {hash:?}", ); self.request_justification(&hash, number); } @@ -2793,25 +2787,26 @@ where output.push(Err(BadPeer(peer, rep::INCOMPLETE_HEADER))); output.extend(self.restart()); }, - Err(BlockImportError::VerificationFailed(who, e)) => + Err(BlockImportError::VerificationFailed(who, e)) => { + let extra_message = + who.map_or_else(|| "".into(), |peer| format!(" received from ({peer})")); + + warn!( + target: "sync", + "💔 Verification failed for block {hash:?}{extra_message}: {e:?}", + ); + if let Some(peer) = who { - warn!( - target: "sync", - "💔 Verification failed for block {:?} received from peer: {}, {:?}", - hash, - peer, - e, - ); output.push(Err(BadPeer(peer, rep::VERIFICATION_FAIL))); - output.extend(self.restart()); - }, + } + + output.extend(self.restart()); + }, Err(BlockImportError::BadBlock(who)) => if let Some(peer) = who { warn!( target: "sync", - "💔 Block {:?} received from peer {} has been blacklisted", - hash, - peer, + "💔 Block {hash:?} received from peer {peer} has been blacklisted", ); output.push(Err(BadPeer(peer, rep::BAD_BLOCK))); }, @@ -2819,10 +2814,10 @@ where // This may happen if the chain we were requesting upon has been discarded // in the meantime because other chain has been finalized. // Don't mark it as bad as it still may be synced if explicitly requested. - trace!(target: "sync", "Obsolete block {:?}", hash); + trace!(target: "sync", "Obsolete block {hash:?}"); }, e @ Err(BlockImportError::UnknownParent) | e @ Err(BlockImportError::Other(_)) => { - warn!(target: "sync", "💔 Error importing block {:?}: {}", hash, e.unwrap_err()); + warn!(target: "sync", "💔 Error importing block {hash:?}: {}", e.unwrap_err()); self.state_sync = None; self.warp_sync = None; output.extend(self.restart());