Skip to content

Commit

Permalink
Merge pull request #1985 from dusk-network/fix-1905
Browse files Browse the repository at this point in the history
node: Check Certificate is Success Attestation
  • Loading branch information
herr-seppia authored Jul 18, 2024
2 parents a355a17 + 22a58fc commit a5f7c3c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 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::{Committee, CommitteeSet};
use dusk_consensus::user::provisioners::{ContextProvisioners, Provisioners};
use execution_core::stake::EPOCH;
use node_data::ledger::{to_str, Fault, InvalidFault, Seed, Signature};
use node_data::message::payload::RatificationResult;
use node_data::message::payload::{RatificationResult, Vote};
use node_data::message::ConsensusHeader;
use node_data::{ledger, StepName};
use std::sync::Arc;
Expand Down Expand Up @@ -168,13 +168,22 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
}

let prev_block_seed = self.db.read().await.view(|v| {
let prior_tip =
Ledger::fetch_block_by_height(&v, self.prev_header.height - 1)?
.ok_or_else(|| anyhow::anyhow!("could not fetch block"))?;

Ok::<_, anyhow::Error>(prior_tip.header().seed)
v.fetch_block_header(&self.prev_header.prev_block_hash)?
.ok_or_else(|| anyhow::anyhow!("Header not found"))
.map(|h| h.seed)
})?;

let cert_result = candidate_block.prev_block_cert.result;
let prev_block_hash = candidate_block.prev_block_hash;

match candidate_block.prev_block_cert.result {
RatificationResult::Success(Vote::Valid(hash))
if hash == prev_block_hash => {}
_ => anyhow::bail!(
"Invalid result for previous block hash: {cert_result:?}"
),
}

let (_, _, voters) = verify_block_att(
self.prev_header.prev_block_hash,
prev_block_seed,
Expand Down

0 comments on commit a5f7c3c

Please sign in to comment.