Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 0 additions & 13 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,3 @@ macro_rules! res_unwrap_or_continue {
}
};
}

/// Helper macro to unwrap an option or continue the loop with a tracing event.
macro_rules! opt_unwrap_or_continue {
($option:expr, $span:expr, $level:ident!($($arg:tt)*)) => {
match $option {
Some(value) => value,
None => {
span_scoped!($span, $level!($($arg)*));
continue;
}
}
};
}
21 changes: 11 additions & 10 deletions src/tasks/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use alloy::{
};
use backon::{ExponentialBuilder, Retryable};
use core::time::Duration;
use eyre::{WrapErr, eyre};
use init4_bin_base::deps::{
opentelemetry::trace::TraceContextExt, tracing_opentelemetry::OpenTelemetrySpanExt,
};
Expand Down Expand Up @@ -309,7 +310,13 @@ impl EnvTask {

let get_host_block_header = || {
let provider = self.host_provider.clone();
async move { provider.get_header_by_number(host_block_number.into()).await }
async move {
provider
.get_header_by_number(host_block_number.into())
.await
.wrap_err("failed to fetch host block header")?
.ok_or_else(|| eyre!("host block not yet available"))
}
};
let backoff = ExponentialBuilder::default()
.with_factor(2.0)
Expand All @@ -320,7 +327,7 @@ impl EnvTask {
.retry(backoff)
.notify(|error, duration| {
tracing::warn!(
?error,
error = format!("{error:#}"),
retry_in_ms = duration.as_millis(),
"host block fetch failed, retrying"
);
Expand Down Expand Up @@ -352,16 +359,10 @@ impl EnvTask {
Ok(_) => {}
}

let host_block_opt = res_unwrap_or_continue!(
let host_header = res_unwrap_or_continue!(
host_block_res,
span,
error!("error fetching previous host block - skipping block construction")
);

let host_header = opt_unwrap_or_continue!(
host_block_opt,
span,
warn!("previous host block not found - skipping block construction")
warn!("failed to fetch previous host block - skipping block construction")
);

span.record("confirmed.host.hash", host_header.hash.to_string());
Expand Down