Skip to content

Commit 2bd764f

Browse files
authored
feat: add more InstantSend debug logs (#413)
There are still sometimes issues coming up with instant lock verification. This should help to identify them.
1 parent 12abdc2 commit 2bd764f

File tree

1 file changed

+52
-3
lines changed

1 file changed

+52
-3
lines changed

dash/src/sml/masternode_list_engine/message_request_verification.rs

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ impl MasternodeListEngine {
115115
// Only God and maybe Odysseus knows why (64 - n - 1)
116116
let quorum_index = quorum_index_mask & (selection_hash_64 >> (64 - n - 1)) as usize;
117117

118+
log::debug!(
119+
"IS lock quorum selection: txid={}, request_id={}, selection_hash_64={:#018x}, quorum_count={}, n={}, mask={:#x}, computed_index={}",
120+
instant_lock.txid,
121+
request_id,
122+
selection_hash_64,
123+
quorum_count,
124+
n,
125+
quorum_index_mask,
126+
quorum_index
127+
);
128+
118129
// Find the quorum by its quorum_index field.
119130
let quorum = quorums
120131
.iter()
@@ -126,6 +137,14 @@ impl MasternodeListEngine {
126137
)
127138
})?;
128139

140+
log::debug!(
141+
"IS lock selected quorum: hash={}, index={:?}, public_key={}, verified={:?}",
142+
quorum.quorum_entry.quorum_hash,
143+
quorum.quorum_entry.quorum_index,
144+
quorum.quorum_entry.quorum_public_key,
145+
quorum.verified
146+
);
147+
129148
Ok((quorum, request_id, quorum_index))
130149
}
131150

@@ -166,7 +185,7 @@ impl MasternodeListEngine {
166185
&self,
167186
instant_lock: &InstantLock,
168187
) -> Result<(), MessageVerificationError> {
169-
let (quorum, request_id, _) = self.is_lock_quorum(instant_lock)?;
188+
let (quorum, request_id, quorum_index) = self.is_lock_quorum(instant_lock)?;
170189

171190
let sign_id = instant_lock
172191
.sign_id(
@@ -176,9 +195,39 @@ impl MasternodeListEngine {
176195
)
177196
.map_err(|e| e.to_string())?;
178197

179-
quorum.verify_message_digest(sign_id.to_byte_array(), instant_lock.signature)?;
198+
log::debug!(
199+
"IS lock verify: txid={}, cyclehash={}, quorum_index={}, quorum_hash={}, sign_id={}, public_key={}, signature={}",
200+
instant_lock.txid,
201+
instant_lock.cyclehash,
202+
quorum_index,
203+
quorum.quorum_entry.quorum_hash,
204+
sign_id,
205+
quorum.quorum_entry.quorum_public_key,
206+
instant_lock.signature
207+
);
180208

181-
Ok(())
209+
match quorum.verify_message_digest(sign_id.to_byte_array(), instant_lock.signature) {
210+
Ok(()) => {
211+
log::info!(
212+
"IS lock verified: txid={}, quorum_index={}, quorum_hash={}",
213+
instant_lock.txid,
214+
quorum_index,
215+
quorum.quorum_entry.quorum_hash
216+
);
217+
Ok(())
218+
}
219+
Err(e) => {
220+
log::warn!(
221+
"IS lock verification failed: txid={}, quorum_index={}, quorum_hash={}, public_key={}, error={}",
222+
instant_lock.txid,
223+
quorum_index,
224+
quorum.quorum_entry.quorum_hash,
225+
quorum.quorum_entry.quorum_public_key,
226+
e
227+
);
228+
Err(e)
229+
}
230+
}
182231
}
183232

184233
/// Retrieves the potential quorum for verifying a ChainLock from the masternode list **before or at**

0 commit comments

Comments
 (0)