Skip to content

Commit

Permalink
fix: bubble up validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell committed Jul 22, 2024
1 parent 00e6bc8 commit 5a65b4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions examples/trusted-sync/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;
use clap::Parser;
use kona_derive::{online::*, types::StageError};
use std::sync::Arc;
use tracing::{debug, error, info, warn};
use tracing::{debug, error, info, trace, warn};

mod cli;
mod metrics;
Expand Down Expand Up @@ -194,15 +194,15 @@ async fn sync(cli: cli::Cli) -> Result<()> {
}
}
}
info!(target: LOG_TARGET, "Stepping on cursor block number: {}", cursor.block_info.number);
trace!(target: LOG_TARGET, "Stepping on cursor block number: {}", cursor.block_info.number);
match pipeline.step(cursor).await {
StepResult::PreparedAttributes => {
metrics::PIPELINE_STEPS.with_label_values(&["success"]).inc();
info!(target: "loop", "Prepared attributes");
trace!(target: "loop", "Prepared attributes");
}
StepResult::AdvancedOrigin => {
metrics::PIPELINE_STEPS.with_label_values(&["origin_advance"]).inc();
info!(target: "loop", "Advanced origin");
trace!(target: "loop", "Advanced origin");
}
StepResult::OriginAdvanceErr(e) => {
metrics::PIPELINE_STEPS.with_label_values(&["origin_advance_failure"]).inc();
Expand All @@ -211,7 +211,7 @@ async fn sync(cli: cli::Cli) -> Result<()> {
StepResult::StepFailed(e) => match e {
StageError::NotEnoughData => {
metrics::PIPELINE_STEPS.with_label_values(&["not_enough_data"]).inc();
info!(target: "loop", "Not enough data to step derivation pipeline");
debug!(target: "loop", "Not enough data to step derivation pipeline");
}
_ => {
metrics::PIPELINE_STEPS.with_label_values(&["failure"]).inc();
Expand All @@ -223,7 +223,7 @@ async fn sync(cli: cli::Cli) -> Result<()> {
// Peek at the next prepared attributes and validate them.
if let Some(attributes) = pipeline.peek() {
match validator.validate(attributes).await {
Ok((true, _)) => info!(target: LOG_TARGET, "Validated payload attributes"),
Ok((true, _)) => trace!(target: LOG_TARGET, "Validated payload attributes"),
Ok((false, expected)) => {
error!(target: LOG_TARGET, "Failed payload validation. Derived payload attributes: {:?}, Expected: {:?}", attributes, expected);
metrics::FAILED_PAYLOAD_DERIVATION.inc();
Expand Down
1 change: 1 addition & 0 deletions examples/trusted-sync/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ impl OnlineValidator {
txs.push(tx);
} else {
warn!(target: "validation", "Failed to fetch transaction: {:?}", tx);
return Err(anyhow::anyhow!("Failed to fetch transaction"));
}
}
Ok((block.header, txs))
Expand Down

0 comments on commit 5a65b4d

Please sign in to comment.