Skip to content

Commit

Permalink
node: refactor verify_att
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Aug 7, 2024
1 parent 5ecf29e commit adea047
Showing 1 changed file with 7 additions and 45 deletions.
52 changes: 7 additions & 45 deletions node/src/chain/header_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use dusk_consensus::user::committee::CommitteeSet;
use dusk_consensus::user::provisioners::{ContextProvisioners, Provisioners};
use execution_core::stake::EPOCH;
use node_data::bls::PublicKey;
use node_data::ledger::{to_str, Fault, InvalidFault, Seed, Signature};
use node_data::ledger::{Fault, InvalidFault, Seed, Signature};
use node_data::message::payload::{RatificationResult, Vote};
use node_data::message::ConsensusHeader;
use node_data::{ledger, StepName};
Expand Down Expand Up @@ -356,70 +356,32 @@ pub async fn verify_att(
}
let committee = RwLock::new(CommitteeSet::new(curr_eligible_provisioners));

let mut result = (QuorumResult::default(), QuorumResult::default());

let validation_voters;
let ratification_voters;

let vote = att.result.vote();

// Verify validation
match verifiers::verify_step_votes(
let (val_result, validation_voters) = verifiers::verify_step_votes(
&consensus_header,
vote,
&att.validation,
&committee,
curr_seed,
StepName::Validation,
)
.await
{
Ok((validation_quorum_result, voters)) => {
result.0 = validation_quorum_result;
validation_voters = voters;
}
Err(e) => {
return Err(anyhow!(
"invalid validation, vote = {:?}, round = {}, iter = {}, seed = {}, sv = {:?}, err = {}",
vote,
consensus_header.round,
consensus_header.iteration,
to_str(curr_seed.inner()),
att.validation,
e
));
}
};
.await?;

// Verify ratification
match verifiers::verify_step_votes(
let (rat_result, ratification_voters) = verifiers::verify_step_votes(
&consensus_header,
vote,
&att.ratification,
&committee,
curr_seed,
StepName::Ratification,
)
.await
{
Ok((ratification_quorum_result, voters)) => {
result.1 = ratification_quorum_result;
ratification_voters = voters;
}
Err(e) => {
return Err(anyhow!(
"invalid ratification, vote = {:?}, round = {}, iter = {}, seed = {}, sv = {:?}, err = {}",
vote,
consensus_header.round,
consensus_header.iteration,
to_str(curr_seed.inner()),
att.ratification,
e,
));
}
}
.await?;

let voters = merge_voters(validation_voters, ratification_voters);
Ok((result.0, result.1, voters))
Ok((val_result, rat_result, voters))
}

/// Merges two Vec<Voter>, summing up the usize values if the PublicKey is
Expand Down

0 comments on commit adea047

Please sign in to comment.