diff --git a/node/components/bft/src/chonky_bft/proposal.rs b/node/components/bft/src/chonky_bft/proposal.rs index d854adc3..7da6962c 100644 --- a/node/components/bft/src/chonky_bft/proposal.rs +++ b/node/components/bft/src/chonky_bft/proposal.rs @@ -223,7 +223,6 @@ impl StateMachine { // Update the state machine. self.view_number = message.view().number; - metrics::METRICS.replica_view_number.set(self.view_number.0); self.phase = validator::Phase::Commit; self.high_vote = Some(commit_vote.clone()); match &message.justification { diff --git a/node/components/bft/src/chonky_bft/timeout.rs b/node/components/bft/src/chonky_bft/timeout.rs index 4e6783da..43bb4919 100644 --- a/node/components/bft/src/chonky_bft/timeout.rs +++ b/node/components/bft/src/chonky_bft/timeout.rs @@ -1,5 +1,6 @@ use super::StateMachine; -use std::collections::HashSet; +use crate::metrics; +use std::{cmp::max, collections::HashSet}; use zksync_concurrency::{ctx, error::Wrap, time}; use zksync_consensus_network::io::ConsensusInputMessage; use zksync_consensus_roles::validator; @@ -141,7 +142,7 @@ impl StateMachine { .await .wrap("process_commit_qc()")?; } - self.high_timeout_qc = self.high_timeout_qc.clone().max(Some(timeout_qc.clone())); + self.high_timeout_qc = max(Some(timeout_qc.clone()), self.high_timeout_qc.clone()); // Start a new view. self.start_new_view(ctx, message.view.number.next()).await?; @@ -179,6 +180,7 @@ impl StateMachine { // Log the event. tracing::info!("Timed out at view {}", self.view_number); + metrics::METRICS.replica_view_number.set(self.view_number.0); Ok(()) } diff --git a/node/components/bft/src/metrics.rs b/node/components/bft/src/metrics.rs index abfa82e7..248b57c9 100644 --- a/node/components/bft/src/metrics.rs +++ b/node/components/bft/src/metrics.rs @@ -54,6 +54,7 @@ pub(crate) struct ProcessingLatencyLabels { #[metrics(prefix = "consensus")] pub(crate) struct ConsensusMetrics { /// Number of the current view of the replica. + #[metrics(unit = Unit::Seconds)] pub(crate) replica_view_number: Gauge, /// Number of the last finalized block observed by the node. pub(crate) finalized_block_number: Gauge, diff --git a/node/libs/roles/src/validator/messages/leader_proposal.rs b/node/libs/roles/src/validator/messages/leader_proposal.rs index 6e0b4983..e05c6668 100644 --- a/node/libs/roles/src/validator/messages/leader_proposal.rs +++ b/node/libs/roles/src/validator/messages/leader_proposal.rs @@ -70,7 +70,7 @@ impl ProposalJustification { .map_err(ProposalJustificationVerifyError::Commit), ProposalJustification::Timeout(qc) => qc .verify(genesis) - .map_err(|err|ProposalJustificationVerifyError::Timeout(err,qc.clone())), + .map_err(ProposalJustificationVerifyError::Timeout), } } @@ -130,8 +130,8 @@ impl ProposalJustification { #[derive(thiserror::Error, Debug)] pub enum ProposalJustificationVerifyError { /// Invalid timeout QC. - #[error("Invalid timeout QC: {0:#}: {1:?}")] - Timeout(TimeoutQCVerifyError,TimeoutQC), + #[error("Invalid timeout QC: {0:#}")] + Timeout(TimeoutQCVerifyError), /// Invalid commit QC. #[error("Invalid commit QC: {0:#}")] Commit(CommitQCVerifyError),