Skip to content

Commit 5249339

Browse files
committed
refactor: classify three more missing-infrastructure errors as Skipped
Adds From-impl arms for `RequiredRotatedChainLockSigNotPresent` (singular), `RequiredChainLockNotPresent`, and `VerifyingMasternodeListNotPresent`, all of which represent missing caller-provided infrastructure rather than bad quorum data. Without these arms they incorrectly fell through to `Invalid`, which would cause callers to treat infrastructure-missing situations as genuine quorum corruption. Introduces a singular `MissingRotationChainLockSig(u8, BlockHash)` skip variant mirroring the singular/plural pair on `QuorumValidationError`. The two emit sites carry genuinely different shapes (per-offset diff hash for the singular case, quorum hash for the plural), so collapsing them into one variant would be lossy. Addresses CodeRabbit review comment on PR #125 #125 (comment)
1 parent e064ef8 commit 5249339

1 file changed

Lines changed: 58 additions & 1 deletion

File tree

dash/src/sml/llmq_entry_verification.rs

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ pub enum LLMQEntryVerificationSkipStatus {
2525
/// `rotation_sig` and `feed_qr_info` can't populate the 4-sig tuple for
2626
/// the quorums in `lastCommitmentPerIndex`.
2727
MissingRotationChainLockSigs(QuorumHash),
28+
/// A specific rotation chain-lock signature at offset `h - n` was not
29+
/// present for the masternode diff at the given block hash. The first
30+
/// field is the rotation offset, the second is the diff block hash.
31+
/// Distinct from `MissingRotationChainLockSigs`, which covers the case
32+
/// where the entire 4-sig tuple is absent.
33+
MissingRotationChainLockSig(u8, BlockHash),
2834
OtherContext(String),
2935
}
3036

@@ -47,6 +53,12 @@ impl Display for LLMQEntryVerificationSkipStatus {
4753
LLMQEntryVerificationSkipStatus::MissingRotationChainLockSigs(quorum_hash) => {
4854
format!("MissingRotationChainLockSigs({})", quorum_hash)
4955
}
56+
LLMQEntryVerificationSkipStatus::MissingRotationChainLockSig(
57+
offset,
58+
block_hash,
59+
) => {
60+
format!("MissingRotationChainLockSig(h - {}, {})", offset, block_hash)
61+
}
5062
LLMQEntryVerificationSkipStatus::OtherContext(message) => {
5163
format!("OtherContext({message})")
5264
}
@@ -76,17 +88,26 @@ impl From<QuorumValidationError> for LLMQEntryVerificationStatus {
7688
Self::Skipped(LLMQEntryVerificationSkipStatus::UnknownBlock(block_hash))
7789
}
7890
QuorumValidationError::RequiredMasternodeListNotPresent(height)
79-
| QuorumValidationError::RequiredBlockHeightNotPresent(height) => {
91+
| QuorumValidationError::RequiredBlockHeightNotPresent(height)
92+
| QuorumValidationError::VerifyingMasternodeListNotPresent(height) => {
8093
Self::Skipped(LLMQEntryVerificationSkipStatus::MissedList(height))
8194
}
8295
QuorumValidationError::RequiredSnapshotNotPresent(hash) => {
8396
Self::Skipped(LLMQEntryVerificationSkipStatus::MissingSnapshot(hash))
8497
}
98+
QuorumValidationError::RequiredChainLockNotPresent(_, block_hash) => {
99+
Self::Skipped(LLMQEntryVerificationSkipStatus::UnknownBlock(block_hash))
100+
}
85101
QuorumValidationError::RequiredRotatedChainLockSigsNotPresent(quorum_hash) => {
86102
Self::Skipped(LLMQEntryVerificationSkipStatus::MissingRotationChainLockSigs(
87103
quorum_hash,
88104
))
89105
}
106+
QuorumValidationError::RequiredRotatedChainLockSigNotPresent(offset, block_hash) => {
107+
Self::Skipped(LLMQEntryVerificationSkipStatus::MissingRotationChainLockSig(
108+
offset, block_hash,
109+
))
110+
}
90111
other => Self::Invalid(other),
91112
}
92113
}
@@ -175,6 +196,42 @@ mod tests {
175196
);
176197
}
177198

199+
#[test]
200+
fn required_rotated_chain_lock_sig_not_present_maps_to_skipped() {
201+
let hash = dummy_hash(4);
202+
let status: LLMQEntryVerificationStatus =
203+
QuorumValidationError::RequiredRotatedChainLockSigNotPresent(2, hash).into();
204+
assert_eq!(
205+
status,
206+
LLMQEntryVerificationStatus::Skipped(
207+
LLMQEntryVerificationSkipStatus::MissingRotationChainLockSig(2, hash),
208+
)
209+
);
210+
}
211+
212+
#[test]
213+
fn required_chain_lock_not_present_maps_to_skipped_unknown_block() {
214+
let hash = dummy_hash(5);
215+
let status: LLMQEntryVerificationStatus =
216+
QuorumValidationError::RequiredChainLockNotPresent(7, hash).into();
217+
assert_eq!(
218+
status,
219+
LLMQEntryVerificationStatus::Skipped(LLMQEntryVerificationSkipStatus::UnknownBlock(
220+
hash,
221+
))
222+
);
223+
}
224+
225+
#[test]
226+
fn verifying_masternode_list_not_present_maps_to_skipped_missed_list() {
227+
let status: LLMQEntryVerificationStatus =
228+
QuorumValidationError::VerifyingMasternodeListNotPresent(123).into();
229+
assert_eq!(
230+
status,
231+
LLMQEntryVerificationStatus::Skipped(LLMQEntryVerificationSkipStatus::MissedList(123))
232+
);
233+
}
234+
178235
#[test]
179236
fn other_error_maps_to_invalid() {
180237
let status: LLMQEntryVerificationStatus =

0 commit comments

Comments
 (0)