From 5ecf29e3f1865ea86c8f8ff1a6cbc71ff392761e Mon Sep 17 00:00:00 2001 From: Herr Seppia Date: Wed, 7 Aug 2024 13:05:58 +0200 Subject: [PATCH] consensus: change verify_step_vote to return anyhow --- consensus/src/quorum/verifiers.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/consensus/src/quorum/verifiers.rs b/consensus/src/quorum/verifiers.rs index 5693cb937a..fd454a6e92 100644 --- a/consensus/src/quorum/verifiers.rs +++ b/consensus/src/quorum/verifiers.rs @@ -5,7 +5,7 @@ // Copyright (c) DUSK NETWORK. All rights reserved. use node_data::bls::PublicKey; -use node_data::ledger::{Seed, StepVotes}; +use node_data::ledger::{to_str, Seed, StepVotes}; use node_data::message::payload::{self, Vote}; use node_data::message::{ConsensusHeader, StepMessage}; use node_data::{Serializable, StepName}; @@ -31,7 +31,7 @@ pub async fn verify_step_votes( committees_set: &RwLock>, seed: Seed, step: StepName, -) -> Result<(QuorumResult, Vec), StepSigError> { +) -> anyhow::Result<(QuorumResult, Vec)> { let round = header.round; let iteration = header.iteration; @@ -65,11 +65,21 @@ pub async fn verify_step_votes( let committee = set.get(&cfg).expect("committee to be created"); let (quorum_result, voters) = - verify_votes(header, step, vote, sv, committee)?; + verify_votes(header, step, vote, sv, committee) + .map_err(|e| anyhow::anyhow!( + "invalid {:?}, vote = {:?}, round = {}, iter = {}, seed = {}, sv = {:?}, err = {}", + step, + vote, + header.round, + header.iteration, + to_str(seed.inner()), + sv, + e + ))?; + Ok((quorum_result, voters)) } -#[derive(Default)] pub struct QuorumResult { pub total: usize, pub target_quorum: usize,