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

chore(examples): Add logs to trusted-sync #415

Merged
merged 4 commits into from
Aug 12, 2024
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
6 changes: 5 additions & 1 deletion crates/derive/src/stages/channel_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ impl BatchReader {
let decompressed_reader = &mut self.decompressed.as_slice()[self.cursor..].as_ref();
let bytes = Bytes::decode(decompressed_reader).ok()?;
crate::set!(BATCH_COMPRESSION_RATIO, (raw_len as i64) * 100 / bytes.len() as i64);
let batch = Batch::decode(&mut bytes.as_ref(), cfg).unwrap();
let Ok(batch) = Batch::decode(&mut bytes.as_ref(), cfg) else {
error!(target: "batch-reader", "Failed to decode batch, skipping batch");
crate::inc!(BATCH_READER_ERRORS, &["failed_to_decode_batch"]);
return None;
};

// Confirm that brotli decompression was performed *after* the Fjord hardfork.
if brotli_used && !cfg.is_fjord_active(batch.timestamp()) {
Expand Down
10 changes: 6 additions & 4 deletions examples/trusted-sync/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,11 @@ async fn sync(cli: cli::Cli) -> Result<()> {
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
continue;
}
warn!(target: LOG_TARGET, "Failed to validate payload attributes after {} retries", retries);
retries = 0;
metrics::FAILED_PAYLOAD_DERIVATION.inc();
let _ = pipeline.next(); // Take the attributes and continue
warn!(target: LOG_TARGET, "Consumed payload attributes and continuing");
continue;
}
Err(e) => {
Expand Down Expand Up @@ -276,13 +278,13 @@ async fn sync(cli: cli::Cli) -> Result<()> {
let derived = attributes.parent.block_info.number as i64 + 1;
metrics::SAFE_L2_HEAD.set(derived);
metrics::DERIVED_ATTRIBUTES_COUNT.inc();
println!(
"Validated Payload Attributes {} [L2 Block Num: {}] [L2 Timestamp: {}] [L1 Origin Block Num: {}]",
info!(
target: LOG_TARGET,
"Validated Payload Attributes {} [L2 Block Num: {}] [L2 Timestamp: {}] [L1 Origin Block Num: {:?}]",
metrics::DERIVED_ATTRIBUTES_COUNT.get(),
derived,
attributes.attributes.timestamp,
pipeline.origin().unwrap().number,
pipeline.origin().map(|n| n.number),
);
debug!(target: LOG_TARGET, "attributes: {:#?}", attributes);
}
}
Loading