Skip to content

Commit

Permalink
beefy: Increment metric and add extra log details (paritytech#5075)
Browse files Browse the repository at this point in the history
This PR increments the beefy metric wrt no peers to query justification
from.
The metric is incremented when we submit a request to a known peer,
however that peer failed to provide a valid response, and there are no
further peers to query.

While at it, add a few extra details to identify the number of active
peers and cached peers, together with the request error

Part of:
- paritytech#4985
- paritytech#4925

---------

Signed-off-by: Alexandru Vasile <[email protected]>
  • Loading branch information
lexnv authored and TarekkMA committed Aug 2, 2024
1 parent 0e29241 commit ce7abba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions substrate/client/consensus/beefy/src/communication/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit ce7abba

Please sign in to comment.