Skip to content

Commit 5568f06

Browse files
authored
Avoid accidentally skipping blocks when switching to live sync (#363)
1 parent 2f3fa85 commit 5568f06

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

anchor/eth/src/sync.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,9 @@ impl SsvEventSyncer {
668668

669669
// If the relevant block was already processed, do not process it again. This can
670670
// happen if `block_header.number` was seen before due to a reorg.
671-
if relevant_block <= self.event_processor.db.state().get_last_processed_block() {
671+
let last_processed_block =
672+
self.event_processor.db.state().get_last_processed_block();
673+
if relevant_block <= last_processed_block {
672674
debug!(
673675
block_number = block_header.number,
674676
relevant_block, "Already synced block - likely reorg"
@@ -687,7 +689,12 @@ impl SsvEventSyncer {
687689
);
688690

689691
let mut logs = self
690-
.fetch_logs(relevant_block, relevant_block, contract_address, SSV_EVENTS)
692+
.fetch_logs(
693+
last_processed_block + 1,
694+
relevant_block,
695+
contract_address,
696+
SSV_EVENTS,
697+
)
691698
.await?;
692699

693700
self.set_block_timestamps(&mut logs).await?;

0 commit comments

Comments
 (0)