Skip to content

Commit 883eb34

Browse files
authored
Fix reorg safe range calculations (#337)
1 parent f140674 commit 883eb34

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

core/src/indexer/fetch_logs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,23 +468,23 @@ async fn live_indexing_stream(
468468
let from_block = current_filter.from_block();
469469
if from_block > safe_block_number {
470470
if reorg_safe_distance.is_zero() {
471-
let block_distance = latest_block_number - from_block;
471+
let block_distance = from_block - latest_block_number;
472472
let is_outside_reorg_range = block_distance
473473
> reorg_safe_distance_for_chain(cached_provider.chain.id());
474474

475475
// it should never get under normal conditions outside the reorg range,
476476
// therefore, we log an error as means RCP state is not in sync with the blockchain
477477
if is_outside_reorg_range {
478478
error!(
479-
"{} - {} - LIVE INDEXING STEAM - RPC has gone back on latest block: rpc returned {}, last seen: {}",
479+
"{} - {} - LIVE INDEXING STREAM - RPC has gone back on latest block: rpc returned {}, last seen: {}",
480480
info_log_name,
481481
IndexingEventProgressStatus::Live.log(),
482482
latest_block_number,
483483
from_block
484484
);
485485
} else {
486486
info!(
487-
"{} - {} - LIVE INDEXING STEAM - RPC has gone back on latest block: rpc returned {}, last seen: {}",
487+
"{} - {} - LIVE INDEXING STREAM - RPC has gone back on latest block: rpc returned {}, last seen: {}",
488488
info_log_name,
489489
IndexingEventProgressStatus::Live.log(),
490490
latest_block_number,
@@ -493,7 +493,7 @@ async fn live_indexing_stream(
493493
}
494494
} else {
495495
info!(
496-
"{} - {} - LIVE INDEXING STEAM - not in safe reorg block range yet block: {} > range: {}",
496+
"{} - {} - LIVE INDEXING STREAM - not in safe reorg block range yet block: {} > range: {}",
497497
info_log_name,
498498
IndexingEventProgressStatus::Live.log(),
499499
from_block,

core/src/indexer/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ async fn live_indexing_for_contract_event_dependencies(
402402
// check reorg distance and skip if not safe
403403
if from_block > safe_block_number {
404404
if reorg_safe_distance.is_zero() {
405-
let block_distance = latest_block_number - from_block;
405+
let block_distance = from_block - latest_block_number;
406406
let is_outside_reorg_range =
407407
block_distance > reorg_safe_distance_for_chain(cached_provider.chain.id());
408408

documentation/docs/pages/docs/changelog.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Bug fixes
1010
-------------------------------------------------
11+
fix: reorg safe range calculation for out-of-range an error message
1112

1213
### Breaking changes
1314
-------------------------------------------------

0 commit comments

Comments
 (0)