From 76c34cb27be56c79a7289cd5b699037e622f4d0f Mon Sep 17 00:00:00 2001 From: goshawk-3 Date: Wed, 3 Jul 2024 14:42:28 +0300 Subject: [PATCH] node: Address comments --- node/benches/accept.rs | 2 +- node/src/chain.rs | 2 +- node/src/chain/header_validation.rs | 19 ++++++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/node/benches/accept.rs b/node/benches/accept.rs index c47af1430d..e8cf66fa51 100644 --- a/node/benches/accept.rs +++ b/node/benches/accept.rs @@ -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, diff --git a/node/src/chain.rs b/node/src/chain.rs index a238e2edfe..7971cb8133 100644 --- a/node/src/chain.rs +++ b/node/src/chain.rs @@ -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}; diff --git a/node/src/chain/header_validation.rs b/node/src/chain/header_validation.rs index 8cb00f38a7..5d5183fbd2 100644 --- a/node/src/chain/header_validation.rs +++ b/node/src/chain/header_validation.rs @@ -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 @@ -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(), @@ -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(), @@ -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> { - 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(), @@ -263,7 +264,7 @@ impl<'a, DB: database::DB> Validator<'a, DB> { provisioners: &Provisioners, prev_block_seed: Seed, ) -> anyhow::Result> { - let (_, _, v_committee, r_committee) = verify_success_att( + let (_, _, v_committee, r_committee) = verify_block_att( blk.prev_block_hash, prev_block_seed, provisioners, @@ -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,