Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log Drand Deserializion #1065

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions pallets/drand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pub mod pallet {
fn offchain_worker(block_number: BlockNumberFor<T>) {
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);
}
}
}
Expand Down Expand Up @@ -392,7 +392,13 @@ impl<T: Config> Pallet<T> {
let mut last_stored_round = LastStoredRound::<T>::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")?;
Expand All @@ -417,7 +423,14 @@ impl<T: Config> Pallet<T> {
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")?;
Expand Down
Loading