From 851a292ed8afeed5993518db3bfa2bd204e0dfd5 Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Wed, 25 Oct 2023 16:11:23 +0200 Subject: [PATCH] minor fix of error formatting --- .../consensus/src/leader/replica_commit.rs | 2 +- .../consensus/src/leader/replica_prepare.rs | 22 +++++++++++-------- .../consensus/src/replica/leader_commit.rs | 6 ++--- .../consensus/src/replica/leader_prepare.rs | 8 +++---- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/node/actors/consensus/src/leader/replica_commit.rs b/node/actors/consensus/src/leader/replica_commit.rs index 5189c3ce..de8fbc56 100644 --- a/node/actors/consensus/src/leader/replica_commit.rs +++ b/node/actors/consensus/src/leader/replica_commit.rs @@ -26,7 +26,7 @@ pub(crate) enum Error { num_messages: usize, threshold: usize, }, - #[error("received replica commit message with invalid signature")] + #[error("invalid signature: {0:#}")] InvalidSignature(#[source] crypto::bls12_381::Error), } diff --git a/node/actors/consensus/src/leader/replica_prepare.rs b/node/actors/consensus/src/leader/replica_prepare.rs index eefd2c10..ac12a95d 100644 --- a/node/actors/consensus/src/leader/replica_prepare.rs +++ b/node/actors/consensus/src/leader/replica_prepare.rs @@ -10,28 +10,32 @@ use tracing::instrument; #[derive(thiserror::Error, Debug)] #[allow(clippy::missing_docs_in_private_items)] pub(crate) enum Error { - #[error("received replica prepare message for a past view/phase (current view: {current_view:?}, current phase: {current_phase:?})")] + #[error("past view/phase (current view: {current_view:?}, current phase: {current_phase:?})")] Old { current_view: validator::ViewNumber, current_phase: validator::Phase, }, - #[error("received replica prepare message for a view when we are not a leader")] + #[error("we are not a leader for this message's view")] WhenNotLeaderInView, - #[error("received replica prepare message that already exists (existing message: {existing_message:?}")] - Exists { existing_message: String }, - #[error("received replica prepare message while number of received messages below threshold. waiting for more (received: {num_messages:?}, threshold: {threshold:?}")] + #[error("duplicate message from a replica (existing message: {existing_message:?}")] + Exists { + existing_message: validator::ReplicaPrepare, + }, + #[error("number of received messages below threshold. waiting for more (received: {num_messages:?}, threshold: {threshold:?}")] NumReceivedBelowThreshold { num_messages: usize, threshold: usize, }, - #[error("received replica prepare message with high QC of a future view (high QC view: {high_qc_view:?}, current view: {current_view:?}")] + #[error( + "high QC of a future view (high QC view: {high_qc_view:?}, current view: {current_view:?}" + )] HighQCOfFutureView { high_qc_view: validator::ViewNumber, current_view: validator::ViewNumber, }, - #[error("received replica prepare message with invalid signature")] + #[error("invalid signature: {0:#}")] InvalidSignature(#[source] crypto::bls12_381::Error), - #[error("received replica prepare message with invalid high QC")] + #[error("invalid high QC: {0:#}")] InvalidHighQC(#[source] anyhow::Error), } @@ -69,7 +73,7 @@ impl StateMachine { .and_then(|x| x.get(author)) { return Err(Error::Exists { - existing_message: format!("{:?}", existing_message), + existing_message: existing_message.msg.clone(), }); } diff --git a/node/actors/consensus/src/replica/leader_commit.rs b/node/actors/consensus/src/replica/leader_commit.rs index 3e95d5cb..9d95ae40 100644 --- a/node/actors/consensus/src/replica/leader_commit.rs +++ b/node/actors/consensus/src/replica/leader_commit.rs @@ -20,11 +20,11 @@ pub(crate) enum Error { current_view: validator::ViewNumber, current_phase: validator::Phase, }, - #[error("invalid signature")] + #[error("invalid signature: {0:#}")] InvalidSignature(#[source] crypto::bls12_381::Error), - #[error("invalid justification")] + #[error("invalid justification: {0:#}")] InvalidJustification(#[source] anyhow::Error), - #[error("internal error: {0}")] + #[error("internal error: {0:#}")] Internal(#[from] anyhow::Error), } diff --git a/node/actors/consensus/src/replica/leader_prepare.rs b/node/actors/consensus/src/replica/leader_prepare.rs index f1749e39..432520fe 100644 --- a/node/actors/consensus/src/replica/leader_prepare.rs +++ b/node/actors/consensus/src/replica/leader_prepare.rs @@ -22,11 +22,11 @@ pub(crate) enum Error { current_view: validator::ViewNumber, current_phase: validator::Phase, }, - #[error("invalid signature")] + #[error("invalid signature: {0:#}")] InvalidSignature(#[source] crypto::bls12_381::Error), - #[error("invalid PrepareQC")] + #[error("invalid PrepareQC: {0:#}")] InvalidPrepareQC(#[source] anyhow::Error), - #[error("invalid high QC")] + #[error("invalid high QC: {0:#}")] InvalidHighQC(#[source] anyhow::Error), #[error( "high QC of a future view (high QC view: {high_qc_view:?}, current view: {current_view:?}" @@ -64,7 +64,7 @@ pub(crate) enum Error { ReproposalWhenFinalized, #[error("block re-proposal of invalid block")] ReproposalInvalidBlock, - #[error("internal error: {0}")] + #[error("internal error: {0:#}")] Internal(#[from] anyhow::Error), }