Skip to content

Commit

Permalink
node: Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
goshawk-3 committed Jul 3, 2024
1 parent 15579b7 commit 76c34cb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion node/benches/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub fn verify_block_att(c: &mut Criterion) {
),
move |b| {
b.to_async(FuturesExecutor).iter(|| async {
chain::verify_success_att(
chain::verify_block_att(
[0u8; 32],
tip_header.seed,
&provisioners,
Expand Down
2 changes: 1 addition & 1 deletion node/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{LongLivedService, Message};
use anyhow::Result;
use async_trait::async_trait;
use dusk_consensus::commons::ConsensusError;
pub use header_validation::verify_success_att;
pub use header_validation::verify_block_att;
use node_data::ledger::{to_str, BlockWithLabel, Label};
use node_data::message::AsyncQueue;
use node_data::message::{Payload, Topics};
Expand Down
19 changes: 10 additions & 9 deletions node/src/chain/header_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
let prev_block_voters =
self.verify_prev_block_cert(candidate_block).await?;

let mut tip_block_voters = vec![];
let mut candidate_block_voters = vec![];
if !disable_winner_att_check {
tip_block_voters = self.verify_winning_att(candidate_block).await?;
candidate_block_voters =
self.verify_success_att(candidate_block).await?;
}

let pni = self.verify_failed_iterations(candidate_block).await?;
Ok((pni, prev_block_voters, tip_block_voters))
Ok((pni, prev_block_voters, candidate_block_voters))
}

/// Verifies any non-attestation field
Expand Down Expand Up @@ -174,7 +175,7 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
Ok::<_, anyhow::Error>(prior_tip.header().seed)
})?;

let (_, _, v_committee, r_committee) = verify_success_att(
let (_, _, v_committee, r_committee) = verify_block_att(
self.prev_header.prev_block_hash,
prev_block_seed,
self.provisioners.prev(),
Expand Down Expand Up @@ -218,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_success_att(
let (_, rat_quorum, _, _) = verify_block_att(
self.prev_header.hash,
self.prev_header.seed,
self.provisioners.current(),
Expand All @@ -237,11 +238,11 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
Ok(candidate_block.iteration - failed_atts)
}

pub async fn verify_winning_att(
pub async fn verify_success_att(
&self,
candidate_block: &'a ledger::Header,
) -> anyhow::Result<Vec<VoterWithCredits>> {
let (_, _, v_committee, r_committee) = verify_success_att(
let (_, _, v_committee, r_committee) = verify_block_att(
self.prev_header.hash,
self.prev_header.seed,
self.provisioners.current(),
Expand All @@ -263,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_success_att(
let (_, _, v_committee, r_committee) = verify_block_att(
blk.prev_block_hash,
prev_block_seed,
provisioners,
Expand All @@ -277,7 +278,7 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
}
}

pub async fn verify_success_att(
pub async fn verify_block_att(
prev_block_hash: [u8; 32],
curr_seed: Signature,
curr_eligible_provisioners: &Provisioners,
Expand Down

0 comments on commit 76c34cb

Please sign in to comment.