Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 5c86f89

Browse files
author
Greg Cusack
authored
Add from field for message tracking (#32725)
* we only want to report received message signatures on PUSH requests, not PULL requests * woops accidently had it has LocalMessage not PushMessage * switch from match to if let statement * convert if let to matches macro * add in from field in PushMessage for message tracking * update with cargo fmt * remove display for gossip route and add lifetime param to pubkey reference in gossiproute enum * forgot to run fmt
1 parent b9a2030 commit 5c86f89

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

gossip/src/crds.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ pub enum CrdsError {
9696
}
9797

9898
#[derive(Clone, Copy)]
99-
pub enum GossipRoute {
99+
pub enum GossipRoute<'a> {
100100
LocalMessage,
101101
PullRequest,
102102
PullResponse,
103-
PushMessage,
103+
PushMessage(/*from:*/ &'a Pubkey),
104104
}
105105

106106
type CrdsCountsArray = [usize; 12];
@@ -301,7 +301,7 @@ impl Crds {
301301
if entry.get().value_hash != value.value_hash {
302302
self.purged.push_back((value.value_hash, now));
303303
Err(CrdsError::InsertFailed)
304-
} else if matches!(route, GossipRoute::PushMessage) {
304+
} else if matches!(route, GossipRoute::PushMessage(_)) {
305305
let entry = entry.get_mut();
306306
entry.num_push_dups = entry.num_push_dups.saturating_add(1);
307307
Err(CrdsError::DuplicatePush(entry.num_push_dups))
@@ -678,9 +678,11 @@ impl CrdsDataStats {
678678
}
679679
}
680680

681-
if matches!(route, GossipRoute::PushMessage)
682-
&& should_report_message_signature(&entry.value.signature)
683-
{
681+
let GossipRoute::PushMessage(from) = route else {
682+
return;
683+
};
684+
685+
if should_report_message_signature(&entry.value.signature) {
684686
datapoint_info!(
685687
"gossip_crds_sample",
686688
(
@@ -692,6 +694,11 @@ impl CrdsDataStats {
692694
"signature",
693695
entry.value.signature.to_string().get(..8),
694696
Option<String>
697+
),
698+
(
699+
"from",
700+
from.to_string().get(..8),
701+
Option<String>
695702
)
696703
);
697704
}
@@ -725,7 +732,7 @@ impl CrdsStats {
725732
match route {
726733
GossipRoute::LocalMessage => (),
727734
GossipRoute::PullRequest => (),
728-
GossipRoute::PushMessage => self.push.record_insert(entry, route),
735+
GossipRoute::PushMessage(_) => self.push.record_insert(entry, route),
729736
GossipRoute::PullResponse => self.pull.record_insert(entry, route),
730737
}
731738
}
@@ -734,7 +741,7 @@ impl CrdsStats {
734741
match route {
735742
GossipRoute::LocalMessage => (),
736743
GossipRoute::PullRequest => (),
737-
GossipRoute::PushMessage => self.push.record_fail(entry),
744+
GossipRoute::PushMessage(_) => self.push.record_fail(entry),
738745
GossipRoute::PullResponse => self.pull.record_fail(entry),
739746
}
740747
}

gossip/src/crds_gossip_push.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl CrdsGossipPush {
144144
continue;
145145
}
146146
let origin = value.pubkey();
147-
match crds.insert(value, now, GossipRoute::PushMessage) {
147+
match crds.insert(value, now, GossipRoute::PushMessage(&from)) {
148148
Ok(()) => {
149149
received_cache.record(origin, from, /*num_dups:*/ 0);
150150
origins.insert(origin);

0 commit comments

Comments
 (0)