diff --git a/substrate/client/consensus/beefy/src/communication/peers.rs b/substrate/client/consensus/beefy/src/communication/peers.rs index 2d801aceaa8a76bf1c31820493bbd20b4f93f8da..929cc0c650b3e26e90016512042d620cc40c6408 100644 --- a/substrate/client/consensus/beefy/src/communication/peers.rs +++ b/substrate/client/consensus/beefy/src/communication/peers.rs @@ -75,6 +75,11 @@ impl<B: Block> KnownPeers<B> { pub fn contains(&self, peer: &PeerId) -> bool { self.live.contains_key(peer) } + + /// Number of peers in the set. + pub fn len(&self) -> usize { + self.live.len() + } } #[cfg(test)] diff --git a/substrate/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs b/substrate/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs index e127e5a895905b212fda73b109714618b76367d9..95ecf35557a5189fae4cc117e71126d8c8076536 100644 --- a/substrate/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs +++ b/substrate/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs @@ -249,9 +249,16 @@ impl<B: Block, AuthorityId: AuthorityIdBound> OnDemandJustificationsEngine<B, Au if let Some(peer) = self.try_next_peer() { self.request_from_peer(peer, req_info); } else { + metric_inc!( + self.metrics, + beefy_on_demand_justification_no_peer_to_request_from + ); + + let num_cache = self.peers_cache.len(); + let num_live = self.live_peers.lock().len(); warn!( target: BEEFY_SYNC_LOG_TARGET, - "🥩 ran out of peers to request justif #{:?} from", block + "🥩 ran out of peers to request justif #{block:?} from num_cache={num_cache} num_live={num_live} err={err:?}", ); } // Report peer based on error type. @@ -265,7 +272,7 @@ impl<B: Block, AuthorityId: AuthorityIdBound> OnDemandJustificationsEngine<B, Au metric_inc!(self.metrics, beefy_on_demand_justification_good_proof); debug!( target: BEEFY_SYNC_LOG_TARGET, - "🥩 received valid on-demand justif #{:?} from {:?}", block, peer + "🥩 received valid on-demand justif #{block:?} from {peer:?}", ); let peer_report = PeerReport { who: peer, cost_benefit: benefit::VALIDATED_PROOF }; ResponseInfo::ValidProof(proof, peer_report)