grandpa: filter some telemetry events on larger voter sets (#4700)

This commit is contained in:
André Silva
2020-01-21 21:14:44 +00:00
committed by Bastian Köcher
parent 9d556a69ef
commit c1750c5c28
@@ -106,6 +106,11 @@ mod benefit {
pub(super) const PER_EQUIVOCATION: i32 = 10;
}
/// If the voter set is larger than this value some telemetry events are not
/// sent to avoid increasing usage resource on the node and flooding the
/// telemetry server (e.g. received votes, received commits.)
const TELEMETRY_VOTERS_LIMIT: usize = 10;
/// A handle to the network.
///
/// Something that provides both the capabilities needed for the `gossip_network::Network` trait as
@@ -308,6 +313,7 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
return Ok(None);
}
if voters.len() <= TELEMETRY_VOTERS_LIMIT {
match &msg.message.message {
PrimaryPropose(propose) => {
telemetry!(CONSENSUS_INFO; "afg.received_propose";
@@ -331,6 +337,7 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
);
},
};
}
Ok(Some(msg.message))
}
@@ -474,11 +481,13 @@ fn incoming_global<B: BlockT>(
format!("{}", a)
}).collect();
if voters.len() <= TELEMETRY_VOTERS_LIMIT {
telemetry!(CONSENSUS_INFO; "afg.received_commit";
"contains_precommits_signed_by" => ?precommits_signed_by,
"target_number" => ?msg.message.target_number.clone(),
"target_hash" => ?msg.message.target_hash.clone(),
);
}
if let Err(cost) = check_compact_commit::<B>(
&msg.message,