Skip to content

Commit

Permalink
[sui-core] Better consensus adaptor logs (MystenLabs#3663)
Browse files Browse the repository at this point in the history
* Better consensus adaptor logs
* As per review use tap

Co-authored-by: George Danezis <[email protected]>
  • Loading branch information
gdanezis and George Danezis authored Aug 2, 2022
1 parent 65ee6d5 commit 8979044
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions crates/sui-core/src/consensus_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use sui_types::{
error::{SuiError, SuiResult},
messages::ConsensusTransaction,
};
use tap::prelude::*;
use tokio::{
sync::{
mpsc::{Receiver, Sender},
Expand All @@ -33,6 +34,7 @@ use tokio::{
time::{timeout, Duration},
};
use tracing::debug;
use tracing::log::error;

#[cfg(test)]
#[path = "unit_tests/consensus_tests.rs"]
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand All @@ -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));
}
Expand Down

0 comments on commit 8979044

Please sign in to comment.