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

Report new received crds signatures and their respective origins to metrics #32504

Merged
merged 28 commits into from
Jul 20, 2023
Merged
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
84ac269
screwed up old branch and syncing with upstream branch
Jul 11, 2023
c23e5c0
add fixed size ring buff instead of variable sized vecdeque for repor…
Jul 12, 2023
6166f59
modify difficulty to take in n 0 bits and check if signature ending e…
Jul 14, 2023
5116f36
update to only push every 18 trailing zero bits. and clean up
Jul 14, 2023
b81f7c3
report origin with signature. and set trailing 0s to 8 for local testing
Jul 14, 2023
27a899d
change back to 18 trailing zeros and rm unused imports
Jul 14, 2023
2d4d251
run cargo rmt
Jul 14, 2023
13aad24
run ./scripts/cargo-for-all-lock-files.sh tree
Jul 14, 2023
3360748
allow integer arithmetic for bit comparison
Jul 14, 2023
c09b643
rm unused lifetime
Jul 14, 2023
66a7336
rm duplicate entry?
Jul 14, 2023
d2ef0d0
re implement ring buf
Jul 14, 2023
15956f0
put ringbuf in sorted order
Jul 14, 2023
0908dc3
ringbuf in cargo.toml now in sorted order
Jul 15, 2023
65bcb06
Merge branch 'master' into coverage-reporting-v2
Jul 15, 2023
4e15905
rm ring buf, refactor, fix trailing zero bug
Jul 17, 2023
b505537
fix bug in trailing zeros. was comparing wrong ones
Jul 17, 2023
0b0d90f
fix needless range loop bug
Jul 17, 2023
8603569
fix bug
Jul 17, 2023
886f39e
change trailing zero checking to build in methods and only report fir…
Jul 18, 2023
5068f9d
report full origin string and first 8 bytes of signature
Jul 18, 2023
1550d26
set SIGNATURE_SAMPLE_TRAILING_ZEROS back to 18
Jul 18, 2023
4613833
forgot to run cargo tree
Jul 18, 2023
9e2e843
avoid panic and change working
Jul 19, 2023
f94afc8
rm bs58
Jul 19, 2023
616326b
pass in Option<String> into datapoint_info
Jul 19, 2023
61151c1
shorten metric names
Jul 19, 2023
da2db53
Merge branch 'master' into coverage-reporting-v2
Jul 20, 2023
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
33 changes: 33 additions & 0 deletions gossip/src/crds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use {
clock::Slot,
hash::{hash, Hash},
pubkey::Pubkey,
signature::Signature,
},
std::{
cmp::Ordering,
Expand All @@ -56,6 +57,13 @@ use {
const CRDS_SHARDS_BITS: u32 = 12;
// Number of vote slots to track in an lru-cache for metrics.
const VOTE_SLOTS_METRICS_CAP: usize = 100;
// Required number of leading zero bits for crds signature to get reported to influx
// mean new push messages received per minute per node
// testnet: ~500k,
// mainnet: ~280k
// target: 1 signature reported per minute
// log2(500k) = ~18.9.
const SIGNATURE_SAMPLE_LEADING_ZEROS: u32 = 19;

pub struct Crds {
/// Stores the map of labels and values
Expand Down Expand Up @@ -669,6 +677,22 @@ impl CrdsDataStats {
self.votes.put(slot, num_nodes + 1);
}
}

if should_report_message_signature(&entry.value.signature) {
datapoint_info!(
"cluster_info_crds_message_signatures",
(
"crds_origin",
entry.value.pubkey().to_string().get(..8).unwrap(),
gregcusack marked this conversation as resolved.
Show resolved Hide resolved
String
),
(
"crds_signature",
entry.value.signature.to_string().get(..8).unwrap(),
String
)
);
}
}

fn record_fail(&mut self, entry: &VersionedCrdsValue) {
Expand Down Expand Up @@ -714,6 +738,15 @@ impl CrdsStats {
}
}

/// check if first SIGNATURE_SAMPLE_LEADING_ZEROS bits of signature are 0
#[inline]
fn should_report_message_signature(signature: &Signature) -> bool {
let Some(Ok(bytes)) = signature.as_ref().get(..8).map(<[u8; 8]>::try_from) else {
return false;
};
u64::from_le_bytes(bytes).trailing_zeros() >= SIGNATURE_SAMPLE_LEADING_ZEROS
}

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