diff --git a/consensus/src/user/provisioners.rs b/consensus/src/user/provisioners.rs index 934941f6d1..696872f18b 100644 --- a/consensus/src/user/provisioners.rs +++ b/consensus/src/user/provisioners.rs @@ -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 } } diff --git a/node-data/src/ledger/attestation.rs b/node-data/src/ledger/attestation.rs index edc8e3ed93..c670792c01 100644 --- a/node-data/src/ledger/attestation.rs +++ b/node-data/src/ledger/attestation.rs @@ -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 { diff --git a/node/src/databroker.rs b/node/src/databroker.rs index 83860e69ea..6ea97e9c0e 100644 --- a/node/src/databroker.rs +++ b/node/src/databroker.rs @@ -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;