Skip to content

Commit 37b8fea

Browse files
committed
chore: improve logging in StackerDBListener
Log the approved weight and the rejected weight and make the naming consistent.
1 parent a46254d commit 37b8fea

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

testnet/stacks-node/src/nakamoto_node/signer_coordinator.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,9 @@ impl SignerCoordinator {
298298
block_signer_sighash,
299299
EVENT_RECEIVER_POLL,
300300
|status| {
301-
status.total_weight_signed < self.weight_threshold
301+
status.total_weight_approved < self.weight_threshold
302302
&& status
303-
.total_reject_weight
303+
.total_weight_rejected
304304
.saturating_add(self.weight_threshold)
305305
<= self.total_weight
306306
},
@@ -341,18 +341,18 @@ impl SignerCoordinator {
341341
};
342342

343343
if block_status
344-
.total_reject_weight
344+
.total_weight_rejected
345345
.saturating_add(self.weight_threshold)
346346
> self.total_weight
347347
{
348348
info!(
349349
"{}/{} signers vote to reject block",
350-
block_status.total_reject_weight, self.total_weight;
350+
block_status.total_weight_rejected, self.total_weight;
351351
"block_signer_sighash" => %block_signer_sighash,
352352
);
353353
counters.bump_naka_rejected_blocks();
354354
return Err(NakamotoNodeError::SignersRejected);
355-
} else if block_status.total_weight_signed >= self.weight_threshold {
355+
} else if block_status.total_weight_approved >= self.weight_threshold {
356356
info!("Received enough signatures, block accepted";
357357
"block_signer_sighash" => %block_signer_sighash,
358358
);

testnet/stacks-node/src/nakamoto_node/stackerdb_listener.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ pub static EVENT_RECEIVER_POLL: Duration = Duration::from_millis(500);
5454
pub struct BlockStatus {
5555
pub responded_signers: HashSet<StacksPublicKey>,
5656
pub gathered_signatures: BTreeMap<u32, MessageSignature>,
57-
pub total_weight_signed: u32,
58-
pub total_reject_weight: u32,
57+
pub total_weight_approved: u32,
58+
pub total_weight_rejected: u32,
5959
}
6060

6161
#[derive(Debug, Clone)]
@@ -312,14 +312,15 @@ impl StackerDBListener {
312312
"signer_slot_id" => slot_id,
313313
"signature" => %signature,
314314
"signer_weight" => signer_entry.weight,
315-
"total_weight_signed" => block.total_weight_signed,
315+
"total_weight_approved" => block.total_weight_approved,
316+
"total_weight_rejected" => block.total_weight_rejected,
316317
);
317318
continue;
318319
}
319320

320321
if !block.gathered_signatures.contains_key(&slot_id) {
321-
block.total_weight_signed = block
322-
.total_weight_signed
322+
block.total_weight_approved = block
323+
.total_weight_approved
323324
.checked_add(signer_entry.weight)
324325
.expect("FATAL: total weight signed exceeds u32::MAX");
325326
}
@@ -330,14 +331,15 @@ impl StackerDBListener {
330331
"signer_slot_id" => slot_id,
331332
"signature" => %signature,
332333
"signer_weight" => signer_entry.weight,
333-
"total_weight_signed" => block.total_weight_signed,
334+
"total_weight_approved" => block.total_weight_approved,
335+
"total_weight_rejected" => block.total_weight_rejected,
334336
"tenure_extend_timestamp" => tenure_extend_timestamp,
335337
"server_version" => metadata.server_version,
336338
);
337339
block.gathered_signatures.insert(slot_id, signature);
338340
block.responded_signers.insert(signer_pubkey);
339341

340-
if block.total_weight_signed >= self.weight_threshold {
342+
if block.total_weight_approved >= self.weight_threshold {
341343
// Signal to anyone waiting on this block that we have enough signatures
342344
cvar.notify_all();
343345
}
@@ -378,8 +380,8 @@ impl StackerDBListener {
378380
}
379381
};
380382
block.responded_signers.insert(rejected_pubkey);
381-
block.total_reject_weight = block
382-
.total_reject_weight
383+
block.total_weight_rejected = block
384+
.total_weight_rejected
383385
.checked_add(signer_entry.weight)
384386
.expect("FATAL: total weight rejected exceeds u32::MAX");
385387

@@ -389,15 +391,16 @@ impl StackerDBListener {
389391
"signer_slot_id" => slot_id,
390392
"signature" => %rejected_data.signature,
391393
"signer_weight" => signer_entry.weight,
392-
"total_weight_signed" => block.total_weight_signed,
394+
"total_weight_approved" => block.total_weight_approved,
395+
"total_weight_rejected" => block.total_weight_rejected,
393396
"reason" => rejected_data.reason,
394397
"reason_code" => %rejected_data.reason_code,
395398
"tenure_extend_timestamp" => rejected_data.response_data.tenure_extend_timestamp,
396399
"server_version" => rejected_data.metadata.server_version,
397400
);
398401

399402
if block
400-
.total_reject_weight
403+
.total_weight_rejected
401404
.saturating_add(self.weight_threshold)
402405
> self.total_weight
403406
{
@@ -479,8 +482,8 @@ impl StackerDBListenerComms {
479482
let block_status = BlockStatus {
480483
responded_signers: HashSet::new(),
481484
gathered_signatures: BTreeMap::new(),
482-
total_weight_signed: 0,
483-
total_reject_weight: 0,
485+
total_weight_approved: 0,
486+
total_weight_rejected: 0,
484487
};
485488
blocks.insert(block.signer_signature_hash(), block_status);
486489
}

0 commit comments

Comments
 (0)