Skip to content

Commit ddca887

Browse files
handle empty hash
1 parent effd9ec commit ddca887

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

dash/src/sml/masternode_list_engine/mod.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,18 @@ impl MasternodeListEngine {
401401

402402
let can_verify_previous = quorum_snapshot_and_mn_list_diff_at_h_minus_4c.is_some();
403403

404-
let h_height = self
405-
.block_container
406-
.get_height(&mn_list_diff_h.block_hash)
407-
.ok_or(QuorumValidationError::RequiredBlockNotPresent(mn_list_diff_h.block_hash))?;
408-
let tip_height = self
409-
.block_container
410-
.get_height(&mn_list_diff_tip.block_hash)
411-
.ok_or(QuorumValidationError::RequiredBlockNotPresent(mn_list_diff_tip.block_hash))?;
404+
let h_height = self.block_container.get_height(&mn_list_diff_h.block_hash).ok_or(
405+
QuorumValidationError::RequiredBlockNotPresent(
406+
mn_list_diff_h.block_hash,
407+
"getting height at diff h".to_string(),
408+
),
409+
)?;
410+
let tip_height = self.block_container.get_height(&mn_list_diff_tip.block_hash).ok_or(
411+
QuorumValidationError::RequiredBlockNotPresent(
412+
mn_list_diff_tip.block_hash,
413+
"getting height at diff tip".to_string(),
414+
),
415+
)?;
412416
let rotation_quorum_type = last_commitment_per_index
413417
.first()
414418
.map(|quorum_entry| quorum_entry.llmq_type)

dash/src/sml/masternode_list_engine/non_rotated_quorum_construction.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ impl MasternodeListEngine {
2323
))
2424
}
2525
} else {
26-
Err(QuorumValidationError::RequiredBlockNotPresent(*block_hash))
26+
Err(QuorumValidationError::RequiredBlockNotPresent(
27+
*block_hash,
28+
"looking for masternode list and height for block hash 8 blocks ago".to_string(),
29+
))
2730
}
2831
}
2932

dash/src/sml/masternode_list_engine/rotated_quorum_construction.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ impl MasternodeListEngine {
3535
else {
3636
return Err(QuorumValidationError::RequiredBlockNotPresent(
3737
quorum.quorum_entry.quorum_hash,
38+
"getting height when finding rotated masternodes for quorum".to_string(),
3839
));
3940
};
4041
let llmq_type = quorum.quorum_entry.llmq_type;
@@ -82,7 +83,7 @@ impl MasternodeListEngine {
8283
self.block_container.get_height(&quorum.quorum_entry.quorum_hash)
8384
else {
8485
return Err(QuorumValidationError::RequiredBlockNotPresent(
85-
quorum.quorum_entry.quorum_hash,
86+
quorum.quorum_entry.quorum_hash, "getting height for a quorum hash when trying to find rotated masternodes for quorums".to_string()
8687
));
8788
};
8889
let llmq_type = quorum.quorum_entry.llmq_type;
@@ -145,7 +146,10 @@ impl MasternodeListEngine {
145146
for quorum in &qr_info.last_commitment_per_index {
146147
let Some(quorum_block_height) = self.block_container.get_height(&quorum.quorum_hash)
147148
else {
148-
return Err(QuorumValidationError::RequiredBlockNotPresent(quorum.quorum_hash));
149+
return Err(QuorumValidationError::RequiredBlockNotPresent(
150+
quorum.quorum_hash,
151+
"getting required cl_sig heights".to_string(),
152+
));
149153
};
150154
let llmq_params = quorum.llmq_type.params();
151155
let quorum_index = quorum_block_height % llmq_params.dkg_params.interval;
@@ -164,6 +168,7 @@ impl MasternodeListEngine {
164168
else {
165169
return Err(QuorumValidationError::RequiredBlockNotPresent(
166170
quorum.quorum_hash,
171+
"getting height for quorum hash for diff at h minus 4c".to_string(),
167172
));
168173
};
169174
let llmq_params = quorum.llmq_type.params();

dash/src/sml/quorum_entry/qualified_quorum_entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl QualifiedQuorumEntry {
6868
/// * `result` - A `Result` containing either success (`Ok`) or a `QuorumValidationError`.
6969
pub fn update_quorum_status(&mut self, result: Result<(), QuorumValidationError>) {
7070
match result {
71-
Err(QuorumValidationError::RequiredBlockNotPresent(block_hash)) => {
71+
Err(QuorumValidationError::RequiredBlockNotPresent(block_hash, _)) => {
7272
self.verified = LLMQEntryVerificationStatus::Skipped(
7373
LLMQEntryVerificationSkipStatus::UnknownBlock(block_hash),
7474
);

dash/src/sml/quorum_validation_error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ pub enum ClientDataRetrievalError {
2424
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
2525
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
2626
pub enum QuorumValidationError {
27-
#[error("Required block not present: {0}")]
28-
RequiredBlockNotPresent(BlockHash),
27+
#[error("Required block not present: {0} ({1})")]
28+
RequiredBlockNotPresent(BlockHash, String),
2929

3030
#[error("Required block height not present: {0}")]
3131
RequiredBlockHeightNotPresent(CoreBlockHeight),

0 commit comments

Comments
 (0)