Skip to content

Commit

Permalink
Merge pull request #2157 from dusk-network/fix-2125
Browse files Browse the repository at this point in the history
node: Missing validations
  • Loading branch information
goshawk-3 authored Sep 6, 2024
2 parents f2b8fc0 + d7a26f0 commit 267c094
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
11 changes: 8 additions & 3 deletions consensus/src/user/provisioners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,14 @@ impl<'a> CommitteeGenerator<'a> {
.eligibles(round)
.map(|(p, stake)| (p, stake.clone()));

Self {
members: BTreeMap::from_iter(eligibles),
}
let members = BTreeMap::from_iter(eligibles);

debug_assert!(
!members.is_empty(),
"No provisioners are eligible for the committee"
);

Self { members }
} else {
Self { members }
}
Expand Down
13 changes: 12 additions & 1 deletion node-data/src/ledger/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,18 @@ impl StepVotes {
}

pub fn is_empty(&self) -> bool {
self.bitset == 0 || self.aggregate_signature.is_zeroed()
if self.bitset == 0 {
debug_assert!(
self.aggregate_signature.is_zeroed(),
"inconsistent struct, signature"
);
}

if self.aggregate_signature.is_zeroed() {
debug_assert_eq!(self.bitset, 0, "inconsistent struct, bitset");
}

self.bitset == 0 && self.aggregate_signature.is_zeroed()
}

pub fn aggregate_signature(&self) -> &Signature {
Expand Down
14 changes: 14 additions & 0 deletions node/src/databroker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,25 @@ impl DataBrokerSrv {
.header()
.height;

let mut prev_block_hash = m.locator;

loop {
locator += 1;
match t.fetch_block_hash_by_height(locator)? {
Some(bh) => {
let header =
t.fetch_block_header(&bh)?.ok_or_else(
|| anyhow!("block header not found"),
)?;

if header.prev_block_hash != prev_block_hash {
return Err(anyhow::anyhow!(
"inconsistent chain"
));
}

inv.add_block_from_hash(bh);
prev_block_hash = bh;
}
None => {
break;
Expand Down

0 comments on commit 267c094

Please sign in to comment.