Skip to content

Commit

Permalink
chore(examples): Add logs to trusted-sync (#415)
Browse files Browse the repository at this point in the history
* chore(examples): add trusted-sync logs

* fixes

* fixes

* fix(trusted-sync): tracing over prints
  • Loading branch information
refcell authored Aug 12, 2024
1 parent 21999e8 commit b61a397
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
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);
}
}

0 comments on commit b61a397

Please sign in to comment.