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): trusted-sync tracing cleanup #263

Merged
merged 1 commit into from
Jun 16, 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: 3 additions & 3 deletions examples/trusted-sync/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
/// The l2 rpc URL
#[clap(long)]
#[clap(long, short = '2')]
pub l2_rpc_url: Option<String>,
/// The Beacon URL
#[clap(long)]
#[clap(long, short)]
pub beacon_url: Option<String>,
/// The l2 block to start from.
#[clap(long, short, help = "Starting l2 block, defaults to chain genesis if none specified")]
Expand Down
14 changes: 8 additions & 6 deletions examples/trusted-sync/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -61,23 +63,23 @@ 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),
}

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!(
Expand All @@ -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");
}
}
}
Expand Down
1 change: 0 additions & 1 deletion examples/trusted-sync/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Loading