diff --git a/gossip/src/crds.rs b/gossip/src/crds.rs index 719bc138479096..dfac43d85087ea 100644 --- a/gossip/src/crds.rs +++ b/gossip/src/crds.rs @@ -677,36 +677,39 @@ impl CrdsDataStats { } } + if let GossipRoute::PushMessage(from) = route { + if should_report_message_signature(&entry.value.signature) { + report_gossip_crds_sample_push("gossip_crds_sample", entry, from); + } + } else if let GossipRoute::PullResponse = route { + if should_report_message_signature(&entry.value.signature) { + datapoint_info!( + "gossip_crds_sample_pull", + ( + "origin", + entry.value.pubkey().to_string().get(..8), + Option + ), + ( + "signature", + entry.value.signature.to_string().get(..8), + Option + ) + ); + } + } + } + + fn record_fail(&mut self, entry: &VersionedCrdsValue, route: GossipRoute) { + self.fails[Self::ordinal(entry)] += 1; let GossipRoute::PushMessage(from) = route else { return; }; - if should_report_message_signature(&entry.value.signature) { - datapoint_info!( - "gossip_crds_sample", - ( - "origin", - entry.value.pubkey().to_string().get(..8), - Option - ), - ( - "signature", - entry.value.signature.to_string().get(..8), - Option - ), - ( - "from", - from.to_string().get(..8), - Option - ) - ); + report_gossip_crds_sample_push("gossip_crds_sample_fail", entry, from); } } - fn record_fail(&mut self, entry: &VersionedCrdsValue) { - self.fails[Self::ordinal(entry)] += 1; - } - fn ordinal(entry: &VersionedCrdsValue) -> usize { match &entry.value.data { CrdsData::LegacyContactInfo(_) => 0, @@ -742,8 +745,8 @@ impl CrdsStats { match route { GossipRoute::LocalMessage => (), GossipRoute::PullRequest => (), - GossipRoute::PushMessage(_) => self.push.record_fail(entry), - GossipRoute::PullResponse => self.pull.record_fail(entry), + GossipRoute::PushMessage(_) => self.push.record_fail(entry, route), + GossipRoute::PullResponse => self.pull.record_fail(entry, route), } } } @@ -757,6 +760,32 @@ fn should_report_message_signature(signature: &Signature) -> bool { u64::from_le_bytes(bytes).trailing_zeros() >= SIGNATURE_SAMPLE_LEADING_ZEROS } +#[inline] +fn report_gossip_crds_sample_push( + metric_label: &'static str, + entry: &VersionedCrdsValue, + from: &Pubkey, +) { + datapoint_info!( + metric_label, + ( + "origin", + entry.value.pubkey().to_string().get(..8), + Option + ), + ( + "signature", + entry.value.signature.to_string().get(..8), + Option + ), + ( + "from", + from.to_string().get(..8), + Option + ) + ); +} + #[cfg(test)] mod tests { use {