Skip to content

Commit

Permalink
fix(trusted-sync): Remove Panics (#413)
Browse files Browse the repository at this point in the history
* fix(trusted-sync): don't expect in main loop

* fixes
  • Loading branch information
refcell authored Aug 2, 2024
1 parent 4ef271b commit 4e57dd3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions examples/trusted-sync/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,12 @@ async fn sync(cli: cli::Cli) -> Result<()> {
metrics::FAST_FORWARD_BLOCK.set(cursor.block_info.number as i64);
metrics::FAST_FORWARD_TIMESTAMP.set(timestamp as i64);
if let Ok(c) = l2_provider.l2_block_info_by_number(latest - 100).await {
let l1_block_info = l1_provider
.block_info_by_number(c.l1_origin.number)
.await
.expect("Failed to fetch L1 block info for fast forward");
let Ok(l1_block_info) =
l1_provider.block_info_by_number(c.l1_origin.number).await
else {
error!(target: LOG_TARGET, "Failed to fetch L2 block info for fast forward");
continue;
};
info!(target: LOG_TARGET, "Resetting pipeline with l1 block info: {:?}", l1_block_info);
if let Err(e) = pipeline.reset(c.block_info, l1_block_info).await {
error!(target: LOG_TARGET, "Failed to reset pipeline: {:?}", e);
Expand All @@ -160,10 +162,12 @@ async fn sync(cli: cli::Cli) -> Result<()> {
.l2_block_info_by_number(cursor.block_info.number - 100)
.await
{
let l1_block_info = l1_provider
.block_info_by_number(c.l1_origin.number)
.await
.expect("Failed to fetch L1 block info for fast forward");
let Ok(l1_block_info) =
l1_provider.block_info_by_number(c.l1_origin.number).await
else {
error!(target: LOG_TARGET, "Failed to fetch L2 block info for walkback");
continue;
};
info!(target: LOG_TARGET, "Resetting pipeline with l1 block info: {:?}", l1_block_info);
if let Err(e) = pipeline.reset(c.block_info, l1_block_info).await {
error!(target: LOG_TARGET, "Failed to reset pipeline: {:?}", e);
Expand Down

0 comments on commit 4e57dd3

Please sign in to comment.