Skip to content

Commit

Permalink
[Consensus Observer] Enable info logs for messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLind committed Jul 17, 2024
1 parent 625a4a3 commit 442ea17
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions consensus/src/consensus_observer/observer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ use tokio::{sync::mpsc::UnboundedSender, time::interval};
use tokio_stream::wrappers::IntervalStream;

// Whether to log messages at the info level (useful for debugging)
const LOG_MESSAGES_AT_INFO_LEVEL: bool = false;
const LOG_MESSAGES_AT_INFO_LEVEL: bool = true;

/// The consensus observer receives consensus updates and propagates them to the execution pipeline
pub struct ConsensusObserver {
Expand Down Expand Up @@ -413,6 +413,14 @@ impl ConsensusObserver {

/// Finalizes the ordered block by sending it to the execution pipeline
async fn finalize_ordered_block(&mut self, ordered_block: OrderedBlock) {
info!(
LogSchema::new(LogEntry::ConsensusObserver).message(&format!(
"Forwarding ordered blocks to the execution pipeline: {}",
ordered_block.proof_block_info()
))
);

// Send the ordered block to the execution pipeline
if let Err(error) = self
.execution_client
.finalize_order(
Expand Down Expand Up @@ -627,7 +635,7 @@ impl ConsensusObserver {
if let Some(pending_block) = pending_block {
// If all payloads exist, add the commit decision to the pending blocks
if self.all_payloads_exist(pending_block.blocks()) {
debug!(
info!(
LogSchema::new(LogEntry::ConsensusObserver).message(&format!(
"Adding decision to pending block: {}",
commit_decision.proof_block_info()
Expand All @@ -638,7 +646,7 @@ impl ConsensusObserver {

// If we are not in sync mode, forward the commit decision to the execution pipeline
if !self.in_state_sync_mode() {
debug!(
info!(
LogSchema::new(LogEntry::ConsensusObserver).message(&format!(
"Forwarding commit decision to the execution pipeline: {}",
commit_decision.proof_block_info()
Expand Down Expand Up @@ -763,6 +771,13 @@ impl ConsensusObserver {
/// Processes the ordered block. This assumes the ordered block
/// has been sanity checked and that all payloads exist.
async fn process_ordered_block(&mut self, ordered_block: OrderedBlock) {
info!(
LogSchema::new(LogEntry::ConsensusObserver).message(&format!(
"Processing ordered block: {}",
ordered_block.proof_block_info()
))
);

// If the ordered block is for the current epoch, verify the proof
let epoch_state = self.get_epoch_state();
let verified_ordered_proof =
Expand Down Expand Up @@ -792,14 +807,6 @@ impl ConsensusObserver {

// If we verified the proof, and we're not in sync mode, finalize the ordered blocks
if verified_ordered_proof && !self.in_state_sync_mode() {
debug!(
LogSchema::new(LogEntry::ConsensusObserver).message(&format!(
"Forwarding blocks to the execution pipeline: {}",
ordered_block.proof_block_info()
))
);

// Finalize the ordered block
self.finalize_ordered_block(ordered_block).await;
}
} else {
Expand Down Expand Up @@ -872,8 +879,9 @@ impl ConsensusObserver {
self.wait_for_epoch_start().await;

// Verify the pending blocks for the new epoch
let new_epoch_state = self.get_epoch_state();
self.pending_ordered_blocks
.verify_pending_blocks(&current_epoch_state);
.verify_pending_blocks(&new_epoch_state);
}

// Reset and drop the sync handle
Expand Down

0 comments on commit 442ea17

Please sign in to comment.