Skip to content

Commit

Permalink
node: Move merge_committees in verify_block_att
Browse files Browse the repository at this point in the history
  • Loading branch information
goshawk-3 committed Jul 3, 2024
1 parent 76c34cb commit 7a87345
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions node/src/chain/header_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
Ok::<_, anyhow::Error>(prior_tip.header().seed)
})?;

let (_, _, v_committee, r_committee) = verify_block_att(
let (_, _, voters) = verify_block_att(
self.prev_header.prev_block_hash,
prev_block_seed,
self.provisioners.prev(),
Expand All @@ -185,7 +185,7 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
)
.await?;

Ok(merge_committees(&v_committee, &r_committee))
Ok(voters)
}

/// Return the number of failed iterations that have no quorum in the
Expand Down Expand Up @@ -219,7 +219,7 @@ impl<'a, DB: database::DB> Validator<'a, DB> {

anyhow::ensure!(pk == &expected_pk, "Invalid generator. Expected {expected_pk:?}, actual {pk:?}");

let (_, rat_quorum, _, _) = verify_block_att(
let (_, rat_quorum, _) = verify_block_att(
self.prev_header.hash,
self.prev_header.seed,
self.provisioners.current(),
Expand All @@ -242,7 +242,7 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
&self,
candidate_block: &'a ledger::Header,
) -> anyhow::Result<Vec<VoterWithCredits>> {
let (_, _, v_committee, r_committee) = verify_block_att(
let (_, _, voters) = verify_block_att(
self.prev_header.hash,
self.prev_header.seed,
self.provisioners.current(),
Expand All @@ -252,7 +252,7 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
)
.await?;

Ok(merge_committees(&v_committee, &r_committee))
Ok(voters)
}

/// Extracts voters list of a block.
Expand All @@ -264,7 +264,7 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
provisioners: &Provisioners,
prev_block_seed: Seed,
) -> anyhow::Result<Vec<VoterWithCredits>> {
let (_, _, v_committee, r_committee) = verify_block_att(
let (_, _, voters) = verify_block_att(
blk.prev_block_hash,
prev_block_seed,
provisioners,
Expand All @@ -274,7 +274,7 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
)
.await?;

Ok(merge_committees(&v_committee, &r_committee))
Ok(voters)
}
}

Expand All @@ -285,7 +285,7 @@ pub async fn verify_block_att(
round: u64,
att: &ledger::Attestation,
iteration: u8,
) -> anyhow::Result<(QuorumResult, QuorumResult, Committee, Committee)> {
) -> anyhow::Result<(QuorumResult, QuorumResult, Vec<VoterWithCredits>)> {
let committee = RwLock::new(CommitteeSet::new(curr_eligible_provisioners));

let mut result = (QuorumResult::default(), QuorumResult::default());
Expand Down Expand Up @@ -355,7 +355,8 @@ pub async fn verify_block_att(
}
}

Ok((result.0, result.1, v_committee, r_committee))
let voters = merge_committees(&v_committee, &r_committee);
Ok((result.0, result.1, voters))
}

/// Merges two committees into a vector
Expand Down

0 comments on commit 7a87345

Please sign in to comment.