From 89790445ce33db460d0a6052cfe732812b76c951 Mon Sep 17 00:00:00 2001 From: George Danezis Date: Tue, 2 Aug 2022 21:52:26 +0300 Subject: [PATCH] [sui-core] Better consensus adaptor logs (#3663) * Better consensus adaptor logs * As per review use tap Co-authored-by: George Danezis --- crates/sui-core/src/consensus_adapter.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/sui-core/src/consensus_adapter.rs b/crates/sui-core/src/consensus_adapter.rs index 86484c89c7ed5..6151d2cb3fc5e 100644 --- a/crates/sui-core/src/consensus_adapter.rs +++ b/crates/sui-core/src/consensus_adapter.rs @@ -24,6 +24,7 @@ use sui_types::{ error::{SuiError, SuiResult}, messages::ConsensusTransaction, }; +use tap::prelude::*; use tokio::{ sync::{ mpsc::{Receiver, Sender}, @@ -33,6 +34,7 @@ use tokio::{ time::{timeout, Duration}, }; use tracing::debug; +use tracing::log::error; #[cfg(test)] #[path = "unit_tests/consensus_tests.rs"] @@ -170,7 +172,10 @@ impl ConsensusAdapter { .clone() .submit_transaction(TransactionProto { transaction: bytes }) .await - .map_err(|e| SuiError::ConsensusConnectionBroken(format!("{:?}", e)))?; + .map_err(|e| SuiError::ConsensusConnectionBroken(format!("{:?}", e))) + .tap_err(|r| { + error!("Submit transaction failed with: {:?}", r); + })?; } // Wait for the consensus to sequence the certificate and assign locks to shared objects. @@ -427,7 +432,8 @@ impl CheckpointConsensusAdapter { let future = Self::waiter(waiter, self.retry_delay, deliver); waiting.push(future); } - Err(_) => { + Err(e) => { + error!("Checkpoint fragment submit failed: {:?}", e); self.buffer.push_back((serialized, sequence_number)); break; } @@ -452,14 +458,14 @@ impl CheckpointConsensusAdapter { // Add the fragment to the buffer. let transaction = ConsensusTransaction::Checkpoint(Box::new(fragment)); let serialized = bincode::serialize(&transaction) - .expect("Failed to serialize consensus tx"); + .expect("Failed to serialize checkpoint fragment"); self.buffer.push_front((serialized, sequence_number)); }, // Listen to checkpoint fragments who failed to be sequenced and need retries. Some((outcome, identifier)) = waiting.next() => { if let Err(error) = outcome { - tracing::debug!("Failed to sequence transaction: {error}"); + tracing::debug!("Failed to sequence checkpoint fragment: {error}"); let (serialized_transaction, checkpoint_sequence_number) = identifier; self.buffer.push_back((serialized_transaction, checkpoint_sequence_number)); }