From 19f532baf827d46a3ffc84d90fb640fbdbaa72b3 Mon Sep 17 00:00:00 2001 From: refcell Date: Sun, 16 Jun 2024 18:57:53 -0400 Subject: [PATCH] fix(examples): clean up trusted sync logging (#263) --- examples/trusted-sync/src/cli.rs | 6 +++--- examples/trusted-sync/src/main.rs | 14 ++++++++------ examples/trusted-sync/src/validation.rs | 1 - 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/examples/trusted-sync/src/cli.rs b/examples/trusted-sync/src/cli.rs index cf7167e12..41a940794 100644 --- a/examples/trusted-sync/src/cli.rs +++ b/examples/trusted-sync/src/cli.rs @@ -9,13 +9,13 @@ pub struct Cli { #[arg(long, short, help = "Verbosity level (0-4)", action = ArgAction::Count)] pub v: u8, /// The l1 rpc URL - #[clap(long)] + #[clap(long, short = '1')] pub l1_rpc_url: Option, /// The l2 rpc URL - #[clap(long)] + #[clap(long, short = '2')] pub l2_rpc_url: Option, /// The Beacon URL - #[clap(long)] + #[clap(long, short)] pub beacon_url: Option, /// The l2 block to start from. #[clap(long, short, help = "Starting l2 block, defaults to chain genesis if none specified")] diff --git a/examples/trusted-sync/src/main.rs b/examples/trusted-sync/src/main.rs index 4366266f5..9592f5615 100644 --- a/examples/trusted-sync/src/main.rs +++ b/examples/trusted-sync/src/main.rs @@ -13,6 +13,8 @@ const L1_RPC_URL: &str = "L1_RPC_URL"; const L2_RPC_URL: &str = "L2_RPC_URL"; const BEACON_URL: &str = "BEACON_URL"; +const LOG_TARGET: &str = "trusted-sync"; + #[tokio::main] async fn main() -> Result<()> { let cfg = crate::cli::Cli::parse(); @@ -61,8 +63,8 @@ async fn sync(cli_cfg: crate::cli::Cli) -> Result<()> { // Continuously step on the pipeline and validate payloads. loop { - info!(target: "loop", "Validated payload attributes number {}", derived_attributes_count); - info!(target: "loop", "Pending l2 safe head num: {}", cursor.block_info.number); + info!(target: LOG_TARGET, "Validated payload attributes number {}", derived_attributes_count); + info!(target: LOG_TARGET, "Pending l2 safe head num: {}", cursor.block_info.number); match pipeline.step(cursor).await { Ok(_) => info!(target: "loop", "Stepped derivation pipeline"), Err(e) => warn!(target: "loop", "Error stepping derivation pipeline: {:?}", e), @@ -70,14 +72,14 @@ async fn sync(cli_cfg: crate::cli::Cli) -> Result<()> { if let Some(attributes) = pipeline.next_attributes() { if !validator.validate(&attributes).await { - error!(target: "loop", "Failed payload validation: {}", attributes.parent.block_info.hash); + error!(target: LOG_TARGET, "Failed payload validation: {}", attributes.parent.block_info.hash); return Ok(()); } derived_attributes_count += 1; match l2_provider.l2_block_info_by_number(cursor.block_info.number + 1).await { Ok(bi) => cursor = bi, Err(e) => { - error!(target: "loop", "Failed to fetch next pending l2 safe head: {}, err: {:?}", cursor.block_info.number + 1, e); + error!(target: LOG_TARGET, "Failed to fetch next pending l2 safe head: {}, err: {:?}", cursor.block_info.number + 1, e); } } println!( @@ -86,9 +88,9 @@ async fn sync(cli_cfg: crate::cli::Cli) -> Result<()> { attributes.attributes.timestamp, pipeline.origin().unwrap().number, ); - info!(target: "loop", "attributes: {:#?}", attributes); + info!(target: LOG_TARGET, "attributes: {:#?}", attributes); } else { - debug!(target: "loop", "No attributes to validate"); + debug!(target: LOG_TARGET, "No attributes to validate"); } } } diff --git a/examples/trusted-sync/src/validation.rs b/examples/trusted-sync/src/validation.rs index d6dfae102..e9fa5fb70 100644 --- a/examples/trusted-sync/src/validation.rs +++ b/examples/trusted-sync/src/validation.rs @@ -84,7 +84,6 @@ impl OnlineValidator { let expected = attributes.parent.block_info.number + 1; let tag = BlockNumberOrTag::from(expected); let payload = self.get_payload(tag).await.unwrap(); - tracing::debug!("Check payload against: {:?}", payload); attributes.attributes == payload } }