diff --git a/node/actors/network/src/gossip/attestation/metrics.rs b/node/actors/network/src/gossip/attestation/metrics.rs new file mode 100644 index 00000000..4e5137da --- /dev/null +++ b/node/actors/network/src/gossip/attestation/metrics.rs @@ -0,0 +1,19 @@ +/// Metrics related to the gossiping of L1 batch votes. +#[derive(Debug, vise::Metrics)] +#[metrics(prefix = "network_gossip_attestation")] +pub(crate) struct Metrics { + /// Batch to be attested. + pub(crate) batch_number: vise::Gauge, + + /// Number of members in the attester committee. + pub(crate) committee_size: vise::Gauge, + + /// Number of votes collected for the current batch. + pub(crate) votes_collected: vise::Gauge, + + /// Weight percentage (in range [0,1]) of votes collected for the current batch. + pub(crate) weight_collected: vise::Gauge, +} + +#[vise::register] +pub(super) static METRICS: vise::Global = vise::Global::new(); diff --git a/node/actors/network/src/gossip/attestation/mod.rs b/node/actors/network/src/gossip/attestation/mod.rs index 82c00d4b..e8fd6c87 100644 --- a/node/actors/network/src/gossip/attestation/mod.rs +++ b/node/actors/network/src/gossip/attestation/mod.rs @@ -5,6 +5,7 @@ use std::{cmp::Ordering, collections::HashSet, fmt, sync::Arc}; use zksync_concurrency::{ctx, sync}; use zksync_consensus_roles::attester; +mod metrics; #[cfg(test)] mod tests; @@ -201,6 +202,10 @@ impl StateWatch { let before = state.weight; let res = state.insert_votes(votes); if state.weight > before { + metrics::METRICS.votes_collected.set(state.votes.len()); + metrics::METRICS + .weight_collected + .set(state.weight as f64 / state.config.committee.total_weight() as f64); locked.send_replace(Some(state)); } res @@ -273,6 +278,16 @@ impl StateWatch { new.insert_vote(Arc::new(vote)).unwrap(); } } + metrics::METRICS + .batch_number + .set(new.config.batch_to_attest.number.0); + metrics::METRICS + .committee_size + .set(new.config.committee.len()); + metrics::METRICS.votes_collected.set(new.votes.len()); + metrics::METRICS + .weight_collected + .set(new.weight as f64 / new.config.committee.total_weight() as f64); locked.send_replace(Some(new)); Ok(()) } diff --git a/node/actors/network/src/gossip/metrics.rs b/node/actors/network/src/gossip/metrics.rs deleted file mode 100644 index d9df9d0a..00000000 --- a/node/actors/network/src/gossip/metrics.rs +++ /dev/null @@ -1,37 +0,0 @@ -/// Metrics related to the gossiping of L1 batch votes. -#[derive(Debug, vise::Metrics)] -#[metrics(prefix = "network_gossip_batch_votes")] -pub(crate) struct BatchVotesMetrics { - /// Number of members in the attester committee. - pub(crate) committee_size: vise::Gauge, - - /// Number of votes added to the tally. - /// - /// Its rate of change should correlate with the attester committee size, - /// save for any new joiner casting their historic votes in a burst. - pub(crate) votes_added: vise::Counter, - - /// Weight of votes added to the tally normalized by the total committee weight. - /// - /// Its rate of change should correlate with the attester committee weight and batch production rate, - /// that is, it should go up up by 1.0 with each new batch if everyone attests. - pub(crate) weight_added: vise::Counter, - - /// The minimum batch number we still expect votes for. - /// - /// This should go up as the main node indicates the finalisation of batches, - /// or as soon as batch QCs are found and persisted. - pub(crate) min_batch_number: vise::Gauge, - - /// Batch number in the last vote added to the register. - /// - /// This should go up as L1 batches are created, save for any temporary - /// outlier from lagging attesters or ones sending votes far in the future. - pub(crate) last_added_vote_batch_number: vise::Gauge, - - /// Batch number of the last batch signed by this attester. - pub(crate) last_signed_batch_number: vise::Gauge, -} - -#[vise::register] -pub(super) static BATCH_VOTES_METRICS: vise::Global = vise::Global::new(); diff --git a/node/actors/network/src/gossip/mod.rs b/node/actors/network/src/gossip/mod.rs index b9f7f124..aab2eacd 100644 --- a/node/actors/network/src/gossip/mod.rs +++ b/node/actors/network/src/gossip/mod.rs @@ -26,7 +26,6 @@ pub mod attestation; mod fetch; mod handshake; pub mod loadtest; -mod metrics; mod runner; #[cfg(test)] mod testonly;