Skip to content

Commit 7bcf2ec

Browse files
committed
log drand deserialization
1 parent a202f44 commit 7bcf2ec

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

pallets/drand/src/lib.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ pub mod pallet {
255255
fn offchain_worker(block_number: BlockNumberFor<T>) {
256256
log::debug!("Drand OCW working on block: {:?}", block_number);
257257
if let Err(e) = Self::fetch_drand_pulse_and_send_unsigned(block_number) {
258-
log::debug!("Drand: Failed to fetch pulse from drand. {:?}", e);
258+
log::warn!("Drand: Failed to fetch pulse from drand. {:?}", e);
259259
}
260260
}
261261
}
@@ -392,7 +392,13 @@ impl<T: Config> Pallet<T> {
392392
let mut last_stored_round = LastStoredRound::<T>::get();
393393
let latest_pulse_body = Self::fetch_drand_latest().map_err(|_| "Failed to query drand")?;
394394
let latest_unbounded_pulse: DrandResponseBody = serde_json::from_str(&latest_pulse_body)
395-
.map_err(|_| "Drand: Failed to serialize response body to pulse")?;
395+
.map_err(|_| {
396+
log::warn!(
397+
"Drand: Response that failed to deserialize: {}",
398+
latest_pulse_body
399+
);
400+
"Drand: Failed to serialize response body to pulse"
401+
})?;
396402
let latest_pulse = latest_unbounded_pulse
397403
.try_into_pulse()
398404
.map_err(|_| "Drand: Received pulse contains invalid data")?;
@@ -417,7 +423,14 @@ impl<T: Config> Pallet<T> {
417423
let pulse_body = Self::fetch_drand_by_round(round)
418424
.map_err(|_| "Drand: Failed to query drand for round")?;
419425
let unbounded_pulse: DrandResponseBody = serde_json::from_str(&pulse_body)
420-
.map_err(|_| "Drand: Failed to serialize response body to pulse")?;
426+
.map_err(|_| {
427+
log::warn!(
428+
"Drand: Response that failed to deserialize for round {}: {}",
429+
round,
430+
pulse_body
431+
);
432+
"Drand: Failed to serialize response body to pulse"
433+
})?;
421434
let pulse = unbounded_pulse
422435
.try_into_pulse()
423436
.map_err(|_| "Drand: Received pulse contains invalid data")?;

0 commit comments

Comments
 (0)