Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 54 additions & 25 deletions gossip/src/crds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>
),
(
"signature",
entry.value.signature.to_string().get(..8),
Option<String>
)
);
}
}
}

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<String>
),
(
"signature",
entry.value.signature.to_string().get(..8),
Option<String>
),
(
"from",
from.to_string().get(..8),
Option<String>
)
);
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,
Expand Down Expand Up @@ -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),
}
}
}
Expand All @@ -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<String>
),
(
"signature",
entry.value.signature.to_string().get(..8),
Option<String>
),
(
"from",
from.to_string().get(..8),
Option<String>
)
);
}

#[cfg(test)]
mod tests {
use {
Expand Down