Skip to content

Commit

Permalink
Correct log targets in tendermint-machine
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Apr 20, 2024
1 parent bba7d2a commit ac9e356
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
40 changes: 33 additions & 7 deletions coordinator/tributary/tendermint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,16 @@ impl<N: Network + 'static> TendermintMachine<N> {
let time_until_round_end = round_end.instant().saturating_duration_since(Instant::now());
if time_until_round_end == Duration::ZERO {
log::trace!(
target: "tendermint",
"resetting when prior round ended {}ms ago",
Instant::now().saturating_duration_since(round_end.instant()).as_millis(),
);
}
log::trace!("sleeping until round ends in {}ms", time_until_round_end.as_millis());
log::trace!(
target: "tendermint",
"sleeping until round ends in {}ms",
time_until_round_end.as_millis(),
);
sleep(time_until_round_end).await;

// Clear our outbound message queue
Expand Down Expand Up @@ -598,7 +603,11 @@ impl<N: Network + 'static> TendermintMachine<N> {
);
let id = block.id();
let proposal = self.network.add_block(block, commit).await;
log::trace!("added block {} (produced by machine)", hex::encode(id.as_ref()));
log::trace!(
target: "tendermint",
"added block {} (produced by machine)",
hex::encode(id.as_ref()),
);
self.reset(msg.round, proposal).await;
}
Err(TendermintError::Malicious(sender, evidence)) => {
Expand Down Expand Up @@ -692,7 +701,12 @@ impl<N: Network + 'static> TendermintMachine<N> {
(msg.round == self.block.round().number) &&
(msg.data.step() == Step::Propose)
{
log::trace!("received Propose for block {}, round {}", msg.block.0, msg.round.0);
log::trace!(
target: "tendermint",
"received Propose for block {}, round {}",
msg.block.0,
msg.round.0,
);
}

// If this is a precommit, verify its signature
Expand Down Expand Up @@ -763,7 +777,12 @@ impl<N: Network + 'static> TendermintMachine<N> {
// 55-56
// Jump, enabling processing by the below code
if self.block.log.round_participation(msg.round) > self.weights.fault_threshold() {
log::debug!("jumping from round {} to round {}", self.block.round().number.0, msg.round.0);
log::debug!(
target: "tendermint",
"jumping from round {} to round {}",
self.block.round().number.0,
msg.round.0,
);

// Jump to the new round.
let proposer = self.round(msg.round, None);
Expand Down Expand Up @@ -827,14 +846,18 @@ impl<N: Network + 'static> TendermintMachine<N> {
((threshold_weight - participation) > (threshold_weight / 10))
{
log::trace!(
target: "tendermint",
"close to setting prevote timeout, participation: {}, needed: {}",
participation,
threshold_weight
threshold_weight,
);
}
// 34-35
if participation >= threshold_weight {
log::trace!("setting timeout for prevote due to sufficient participation");
log::trace!(
target: "tendermint",
"setting timeout for prevote due to sufficient participation",
);
self.block.round_mut().set_timeout(Step::Prevote);
}

Expand All @@ -849,7 +872,10 @@ impl<N: Network + 'static> TendermintMachine<N> {
if matches!(msg.data, Data::Precommit(_)) &&
self.block.log.has_participation(self.block.round().number, Step::Precommit)
{
log::trace!("setting timeout for precommit due to sufficient participation");
log::trace!(
target: "tendermint",
"setting timeout for precommit due to sufficient participation",
);
self.block.round_mut().set_timeout(Step::Precommit);
}

Expand Down
3 changes: 1 addition & 2 deletions coordinator/tributary/tendermint/src/message_log.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{sync::Arc, collections::HashMap};

use log::debug;
use parity_scale_codec::Encode;

use crate::{ext::*, RoundNumber, Step, DataFor, TendermintError, SignedMessageFor, Evidence};
Expand All @@ -27,7 +26,7 @@ impl<N: Network> MessageLog<N> {
let step = msg.data.step();
if let Some(existing) = msgs.get(&step) {
if existing.msg.data != msg.data {
debug!(
log::debug!(
target: "tendermint",
"Validator sent multiple messages for the same block + round + step"
);
Expand Down

0 comments on commit ac9e356

Please sign in to comment.