Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve logging in StackerDBListener #5747

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
### Changed

- Miner will include other transactions in blocks with tenure extend transactions (#5760)
- Various logging improvements

## [3.1.0.0.4]

Expand Down
10 changes: 5 additions & 5 deletions testnet/stacks-node/src/nakamoto_node/signer_coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ impl SignerCoordinator {
block_signer_sighash,
EVENT_RECEIVER_POLL,
|status| {
status.total_weight_signed < self.weight_threshold
status.total_weight_approved < self.weight_threshold
&& status
.total_reject_weight
.total_weight_rejected
.saturating_add(self.weight_threshold)
<= self.total_weight
},
Expand Down Expand Up @@ -341,18 +341,18 @@ impl SignerCoordinator {
};

if block_status
.total_reject_weight
.total_weight_rejected
.saturating_add(self.weight_threshold)
> self.total_weight
{
info!(
"{}/{} signers vote to reject block",
block_status.total_reject_weight, self.total_weight;
block_status.total_weight_rejected, self.total_weight;
"block_signer_sighash" => %block_signer_sighash,
);
counters.bump_naka_rejected_blocks();
return Err(NakamotoNodeError::SignersRejected);
} else if block_status.total_weight_signed >= self.weight_threshold {
} else if block_status.total_weight_approved >= self.weight_threshold {
info!("Received enough signatures, block accepted";
"block_signer_sighash" => %block_signer_sighash,
);
Expand Down
37 changes: 24 additions & 13 deletions testnet/stacks-node/src/nakamoto_node/stackerdb_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ pub static EVENT_RECEIVER_POLL: Duration = Duration::from_millis(500);
pub struct BlockStatus {
pub responded_signers: HashSet<StacksPublicKey>,
pub gathered_signatures: BTreeMap<u32, MessageSignature>,
pub total_weight_signed: u32,
pub total_reject_weight: u32,
pub total_weight_approved: u32,
pub total_weight_rejected: u32,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -312,14 +312,17 @@ impl StackerDBListener {
"signer_slot_id" => slot_id,
"signature" => %signature,
"signer_weight" => signer_entry.weight,
"total_weight_signed" => block.total_weight_signed,
"total_weight_approved" => block.total_weight_approved,
"percent_approved" => block.total_weight_approved as f64 / self.total_weight as f64 * 100.0,
"total_weight_rejected" => block.total_weight_rejected,
"percent_rejected" => block.total_weight_rejected as f64 / self.total_weight as f64 * 100.0,
);
continue;
}

if !block.gathered_signatures.contains_key(&slot_id) {
block.total_weight_signed = block
.total_weight_signed
block.total_weight_approved = block
.total_weight_approved
.checked_add(signer_entry.weight)
.expect("FATAL: total weight signed exceeds u32::MAX");
}
Expand All @@ -330,14 +333,18 @@ impl StackerDBListener {
"signer_slot_id" => slot_id,
"signature" => %signature,
"signer_weight" => signer_entry.weight,
"total_weight_signed" => block.total_weight_signed,
"total_weight_approved" => block.total_weight_approved,
"percent_approved" => block.total_weight_approved as f64 / self.total_weight as f64 * 100.0,
"total_weight_rejected" => block.total_weight_rejected,
"percent_rejected" => block.total_weight_rejected as f64 / self.total_weight as f64 * 100.0,
"weight_threshold" => self.weight_threshold,
"tenure_extend_timestamp" => tenure_extend_timestamp,
"server_version" => metadata.server_version,
);
block.gathered_signatures.insert(slot_id, signature);
block.responded_signers.insert(signer_pubkey);

if block.total_weight_signed >= self.weight_threshold {
if block.total_weight_approved >= self.weight_threshold {
// Signal to anyone waiting on this block that we have enough signatures
cvar.notify_all();
}
Expand Down Expand Up @@ -378,8 +385,8 @@ impl StackerDBListener {
}
};
block.responded_signers.insert(rejected_pubkey);
block.total_reject_weight = block
.total_reject_weight
block.total_weight_rejected = block
.total_weight_rejected
.checked_add(signer_entry.weight)
.expect("FATAL: total weight rejected exceeds u32::MAX");

Expand All @@ -389,15 +396,19 @@ impl StackerDBListener {
"signer_slot_id" => slot_id,
"signature" => %rejected_data.signature,
"signer_weight" => signer_entry.weight,
"total_weight_signed" => block.total_weight_signed,
"total_weight_approved" => block.total_weight_approved,
"percent_approved" => block.total_weight_approved as f64 / self.total_weight as f64 * 100.0,
"total_weight_rejected" => block.total_weight_rejected,
"percent_rejected" => block.total_weight_rejected as f64 / self.total_weight as f64 * 100.0,
"weight_threshold" => self.weight_threshold,
"reason" => rejected_data.reason,
"reason_code" => %rejected_data.reason_code,
"tenure_extend_timestamp" => rejected_data.response_data.tenure_extend_timestamp,
"server_version" => rejected_data.metadata.server_version,
);

if block
.total_reject_weight
.total_weight_rejected
.saturating_add(self.weight_threshold)
> self.total_weight
{
Expand Down Expand Up @@ -479,8 +490,8 @@ impl StackerDBListenerComms {
let block_status = BlockStatus {
responded_signers: HashSet::new(),
gathered_signatures: BTreeMap::new(),
total_weight_signed: 0,
total_reject_weight: 0,
total_weight_approved: 0,
total_weight_rejected: 0,
};
blocks.insert(block.signer_signature_hash(), block_status);
}
Expand Down
Loading