From 423f631b05af83f16f85b42160b14ec10e512de5 Mon Sep 17 00:00:00 2001 From: Josh Lind Date: Wed, 17 Jul 2024 09:57:34 -0400 Subject: [PATCH] [Consensus Observer] Enable info logs for messages. --- consensus/src/consensus_observer/observer.rs | 46 +++++++++----------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/consensus/src/consensus_observer/observer.rs b/consensus/src/consensus_observer/observer.rs index 79081c0392a964..d058a27942377f 100644 --- a/consensus/src/consensus_observer/observer.rs +++ b/consensus/src/consensus_observer/observer.rs @@ -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 { @@ -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( @@ -576,20 +584,6 @@ impl ConsensusObserver { let last_block = self.get_last_block(); if commit_decision_epoch > last_block.epoch() || commit_decision_round > last_block.round() { - // If we're already in state sync mode, we should wait. This - // avoids sending multiple state sync requests concurrently. - if self.in_state_sync_mode() { - info!( - LogSchema::new(LogEntry::ConsensusObserver).message(&format!( - "Already waiting for state sync to reach target: {:?}. Dropping commit decision: {:?}!", - self.root.lock().commit_info(), - commit_decision.proof_block_info() - )) - ); - return; - } - - // Otherwise, we can start the state sync process info!( LogSchema::new(LogEntry::ConsensusObserver).message(&format!( "Started syncing to {}!", @@ -627,7 +621,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() @@ -638,7 +632,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() @@ -763,6 +757,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 = @@ -792,14 +793,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 { @@ -872,8 +865,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(¤t_epoch_state); + .verify_pending_blocks(&new_epoch_state); } // Reset and drop the sync handle