From 649f6e5e9f2d05083ca3dcadb1d2c60727a1f512 Mon Sep 17 00:00:00 2001 From: Joel Liu <83172559+csdtowards@users.noreply.github.com> Date: Thu, 10 Oct 2024 22:02:20 +0800 Subject: [PATCH] Fix the dead loop problem (#228) * Fix the dead loop problem * keep parent block of log_latest_block_number block * avoid overflow --- node/log_entry_sync/src/sync_manager/log_entry_fetcher.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/node/log_entry_sync/src/sync_manager/log_entry_fetcher.rs b/node/log_entry_sync/src/sync_manager/log_entry_fetcher.rs index 93239e3..54a05b7 100644 --- a/node/log_entry_sync/src/sync_manager/log_entry_fetcher.rs +++ b/node/log_entry_sync/src/sync_manager/log_entry_fetcher.rs @@ -178,7 +178,10 @@ impl LogEntryFetcher { if let Some(finalized_block_number) = finalized_block_number { let safe_block_number = std::cmp::min( - std::cmp::min(log_latest_block_number, finalized_block_number), + std::cmp::min( + log_latest_block_number.saturating_sub(1), + finalized_block_number, + ), processed_block_number, ); let mut pending_keys = vec![]; @@ -657,7 +660,7 @@ async fn check_watch_process( ); match provider.get_block(*progress - 1).await { Ok(Some(v)) => { - v.hash.expect("parent block hash expect exist"); + break v.hash.expect("parent block hash expect exist"); } Ok(None) => { panic!("parent block {} expect exist", *progress - 1);