From 7bcf2ec6c7398c4556af5b3a8bc9efb2379261c0 Mon Sep 17 00:00:00 2001 From: johnreedv Date: Thu, 5 Dec 2024 14:04:52 -0800 Subject: [PATCH 1/2] log drand deserialization --- pallets/drand/src/lib.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/pallets/drand/src/lib.rs b/pallets/drand/src/lib.rs index 2acda3567e..085b5c278c 100644 --- a/pallets/drand/src/lib.rs +++ b/pallets/drand/src/lib.rs @@ -255,7 +255,7 @@ pub mod pallet { fn offchain_worker(block_number: BlockNumberFor) { log::debug!("Drand OCW working on block: {:?}", block_number); if let Err(e) = Self::fetch_drand_pulse_and_send_unsigned(block_number) { - log::debug!("Drand: Failed to fetch pulse from drand. {:?}", e); + log::warn!("Drand: Failed to fetch pulse from drand. {:?}", e); } } } @@ -392,7 +392,13 @@ impl Pallet { let mut last_stored_round = LastStoredRound::::get(); let latest_pulse_body = Self::fetch_drand_latest().map_err(|_| "Failed to query drand")?; let latest_unbounded_pulse: DrandResponseBody = serde_json::from_str(&latest_pulse_body) - .map_err(|_| "Drand: Failed to serialize response body to pulse")?; + .map_err(|_| { + log::warn!( + "Drand: Response that failed to deserialize: {}", + latest_pulse_body + ); + "Drand: Failed to serialize response body to pulse" + })?; let latest_pulse = latest_unbounded_pulse .try_into_pulse() .map_err(|_| "Drand: Received pulse contains invalid data")?; @@ -417,7 +423,14 @@ impl Pallet { let pulse_body = Self::fetch_drand_by_round(round) .map_err(|_| "Drand: Failed to query drand for round")?; let unbounded_pulse: DrandResponseBody = serde_json::from_str(&pulse_body) - .map_err(|_| "Drand: Failed to serialize response body to pulse")?; + .map_err(|_| { + log::warn!( + "Drand: Response that failed to deserialize for round {}: {}", + round, + pulse_body + ); + "Drand: Failed to serialize response body to pulse" + })?; let pulse = unbounded_pulse .try_into_pulse() .map_err(|_| "Drand: Received pulse contains invalid data")?; From 63ff23aeebba9af25188e7fecee7fa29c6c9278c Mon Sep 17 00:00:00 2001 From: johnreedv Date: Thu, 5 Dec 2024 15:09:18 -0800 Subject: [PATCH 2/2] revert to debug --- pallets/drand/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/drand/src/lib.rs b/pallets/drand/src/lib.rs index 085b5c278c..435f419987 100644 --- a/pallets/drand/src/lib.rs +++ b/pallets/drand/src/lib.rs @@ -255,7 +255,7 @@ pub mod pallet { fn offchain_worker(block_number: BlockNumberFor) { log::debug!("Drand OCW working on block: {:?}", block_number); if let Err(e) = Self::fetch_drand_pulse_and_send_unsigned(block_number) { - log::warn!("Drand: Failed to fetch pulse from drand. {:?}", e); + log::debug!("Drand: Failed to fetch pulse from drand. {:?}", e); } } }