Skip to content

Commit

Permalink
adjusted metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
pompon0 committed Aug 9, 2024
1 parent 5ff6a00 commit d56cb00
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 38 deletions.
19 changes: 19 additions & 0 deletions node/actors/network/src/gossip/attestation/metrics.rs
Original file line number Diff line number Diff line change
@@ -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<u64>,

/// Number of members in the attester committee.
pub(crate) committee_size: vise::Gauge<usize>,

/// Number of votes collected for the current batch.
pub(crate) votes_collected: vise::Gauge<usize>,

/// Weight percentage (in range [0,1]) of votes collected for the current batch.
pub(crate) weight_collected: vise::Gauge<f64>,
}

#[vise::register]
pub(super) static METRICS: vise::Global<Metrics> = vise::Global::new();
15 changes: 15 additions & 0 deletions node/actors/network/src/gossip/attestation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(())
}
Expand Down
37 changes: 0 additions & 37 deletions node/actors/network/src/gossip/metrics.rs

This file was deleted.

1 change: 0 additions & 1 deletion node/actors/network/src/gossip/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub mod attestation;
mod fetch;
mod handshake;
pub mod loadtest;
mod metrics;
mod runner;
#[cfg(test)]
mod testonly;
Expand Down

0 comments on commit d56cb00

Please sign in to comment.