From a6c0f03999f47a80c8e5abe418d3ee8ce6acef39 Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Tue, 25 Jul 2023 23:12:50 -0400 Subject: [PATCH] Add debug logs to iot packet verifier (#579) * Add a bunch of debug logs to iot packet verifier * Fmt --- iot_packet_verifier/src/daemon.rs | 3 +++ iot_packet_verifier/src/verifier.rs | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/iot_packet_verifier/src/daemon.rs b/iot_packet_verifier/src/daemon.rs index 194b4fca4..51d8e784d 100644 --- a/iot_packet_verifier/src/daemon.rs +++ b/iot_packet_verifier/src/daemon.rs @@ -21,6 +21,7 @@ use tokio::{ signal, sync::{mpsc::Receiver, Mutex}, }; +use tracing::debug; struct Daemon { pool: Pool, @@ -68,7 +69,9 @@ impl Daemon { &self.invalid_packets, ) .await?; + debug!("Committing transaction"); transaction.commit().await?; + debug!("Committing files"); self.valid_packets.commit().await?; self.invalid_packets.commit().await?; diff --git a/iot_packet_verifier/src/verifier.rs b/iot_packet_verifier/src/verifier.rs index d2edf99a3..a95f32da1 100644 --- a/iot_packet_verifier/src/verifier.rs +++ b/iot_packet_verifier/src/verifier.rs @@ -19,6 +19,7 @@ use tokio::{ task::JoinError, time::{sleep_until, Duration, Instant}, }; +use tracing::debug; pub struct Verifier { pub debiter: D, @@ -64,13 +65,17 @@ where tokio::pin!(reports); while let Some(report) = reports.next().await { + debug!(%report.received_timestamp, "Processing packet report"); + let debit_amount = payload_size_to_dc(report.payload_size as u64); + debug!(%report.oui, "Fetching payer"); let payer = self .config_server .fetch_org(report.oui, &mut org_cache) .await .map_err(VerificationError::ConfigError)?; + debug!(%payer, "Debiting payer"); let remaining_balance = self .debiter .debit_if_sufficient(&payer, debit_amount) @@ -78,10 +83,14 @@ where .map_err(VerificationError::DebitError)?; if let Some(remaining_balance) = remaining_balance { + debug!(%debit_amount, "Adding debit amount to pending burns"); + pending_burns .add_burned_amount(&payer, debit_amount) .await .map_err(VerificationError::BurnError)?; + + debug!("Writing valid packet report"); valid_packets .write(ValidPacket { packet_timestamp: report.timestamp(), @@ -94,12 +103,14 @@ where .map_err(VerificationError::ValidPacketWriterError)?; if remaining_balance < minimum_allowed_balance { + debug!(%report.oui, "Disabling org"); self.config_server .disable_org(report.oui) .await .map_err(VerificationError::ConfigError)?; } } else { + debug!("Writing invalid packet report"); invalid_packets .write(InvalidPacket { payload_size: report.payload_size,