From ac9e356af468916a783f88681a5293e7470882ba Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sat, 20 Apr 2024 19:15:15 -0400 Subject: [PATCH] Correct log targets in tendermint-machine --- coordinator/tributary/tendermint/src/lib.rs | 40 +++++++++++++++---- .../tributary/tendermint/src/message_log.rs | 3 +- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/coordinator/tributary/tendermint/src/lib.rs b/coordinator/tributary/tendermint/src/lib.rs index c7cf069a2..a240d13aa 100644 --- a/coordinator/tributary/tendermint/src/lib.rs +++ b/coordinator/tributary/tendermint/src/lib.rs @@ -313,11 +313,16 @@ impl TendermintMachine { 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 @@ -598,7 +603,11 @@ impl TendermintMachine { ); 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)) => { @@ -692,7 +701,12 @@ impl TendermintMachine { (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 @@ -763,7 +777,12 @@ impl TendermintMachine { // 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); @@ -827,14 +846,18 @@ impl TendermintMachine { ((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); } @@ -849,7 +872,10 @@ impl TendermintMachine { 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); } diff --git a/coordinator/tributary/tendermint/src/message_log.rs b/coordinator/tributary/tendermint/src/message_log.rs index e045189bb..3959852d8 100644 --- a/coordinator/tributary/tendermint/src/message_log.rs +++ b/coordinator/tributary/tendermint/src/message_log.rs @@ -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}; @@ -27,7 +26,7 @@ impl MessageLog { 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" );