From d15157c987098a4f2f65361590effd873ec219c8 Mon Sep 17 00:00:00 2001 From: dark horse Date: Wed, 16 Oct 2024 16:50:03 -0400 Subject: [PATCH] Add logging for transaction handling in consensus and REST module. --- node/consensus/src/lib.rs | 9 +++++++++ node/rest/src/routes.rs | 3 +++ 2 files changed, 12 insertions(+) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 30cef14098..f3fb12c299 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -371,15 +371,18 @@ impl Consensus { // Check that the transaction is not a fee transaction. if transaction.is_fee() { + tracing::info!("\n\n Txn is a fee transaction, skipping tx: '{}'", fmt_id(transaction_id)); bail!("Transaction '{}' is a fee transaction {}", fmt_id(transaction_id), "(skipping)".dimmed()); } // Check if the transaction was recently seen. if self.seen_transactions.lock().put(transaction_id, ()).is_some() { + tracing::info!("\n\n Returning early, txn was already seen: '{}'", fmt_id(transaction_id)); // If the transaction was recently seen, return early. return Ok(()); } // Check if the transaction already exists in the ledger. if self.ledger.contains_transmission(&TransmissionID::Transaction(transaction_id, checksum))? { + tracing::info!("\n\n Returning early, txn already exists in the ledger: '{}'", fmt_id(transaction_id)); bail!("Transaction '{}' exists in the ledger {}", fmt_id(transaction_id), "(skipping)".dimmed()); } // Add the transaction to the memory pool. @@ -396,6 +399,7 @@ impl Consensus { // If the memory pool of this node is full, return early. let num_unconfirmed_transmissions = self.num_unconfirmed_transmissions(); if num_unconfirmed_transmissions >= Primary::::MAX_TRANSMISSIONS_TOLERANCE { + tracing::info!("\n\n Returning early, node mem pool is full."); return Ok(()); } // Retrieve the transactions. @@ -425,6 +429,7 @@ impl Consensus { // Iterate over the transactions. for transaction in transactions.into_iter() { let transaction_id = transaction.id(); + tracing::info!("\n\n Adding the unconfirmed txn to the mem pool: '{}'", fmt_id(transaction_id)); trace!("Adding unconfirmed transaction '{}' to the memory pool...", fmt_id(transaction_id)); // Send the unconfirmed transaction to the primary. if let Err(e) = @@ -432,6 +437,10 @@ impl Consensus { { // If the BFT is synced, then log the warning. if self.bft.is_synced() { + tracing::info!( + "\n\n BFT not synced, failed to add to the mempool the tx: '{}'", + fmt_id(transaction_id) + ); warn!( "Failed to add unconfirmed transaction '{}' to the memory pool - {e}", fmt_id(transaction_id) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index a646ef2047..71979fb1fc 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -367,6 +367,7 @@ impl, R: Routing> Rest { ) -> Result { // Do not process the transaction if the node is too far behind. if rest.routing.num_blocks_behind() > SYNC_LENIENCY { + tracing::info!("\n\n Node > 10 blocks behind, Tx not broadcasted: '{}'", fmt_id(tx.id())); return Err(RestError(format!("Unable to broadcast transaction '{}' (node is syncing)", fmt_id(tx.id())))); } @@ -376,12 +377,14 @@ impl, R: Routing> Rest { // TODO: Should this be a blocking task? let buffer = Vec::with_capacity(3000); if tx.write_le(LimitedWriter::new(buffer, N::MAX_TRANSACTION_SIZE)).is_err() { + tracing::info!("\n\n Txn size exceeds the byte limit: '{}'", fmt_id(tx.id())); return Err(RestError("Transaction size exceeds the byte limit".to_string())); } // If the consensus module is enabled, add the unconfirmed transaction to the memory pool. if let Some(consensus) = rest.consensus { // Add the unconfirmed transaction to the memory pool. + tracing::info!("\n\n Adding unconfirmed transaction to the mem pool: '{}'", fmt_id(tx.id())); consensus.add_unconfirmed_transaction(tx.clone()).await?; }