From c8df172063db916712955fe6cad94d71523b3260 Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin Date: Tue, 5 Mar 2024 19:20:44 +0000 Subject: [PATCH] fix(stages): calculate checkpoints from static files (#6973) --- crates/stages/src/stages/bodies.rs | 6 +++++- crates/stages/src/stages/sender_recovery.rs | 5 ++++- crates/stages/src/stages/tx_lookup.rs | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/stages/src/stages/bodies.rs b/crates/stages/src/stages/bodies.rs index 459eace720..312c465798 100644 --- a/crates/stages/src/stages/bodies.rs +++ b/crates/stages/src/stages/bodies.rs @@ -343,7 +343,11 @@ fn stage_checkpoint( ) -> ProviderResult { Ok(EntitiesCheckpoint { processed: provider.count_entries::()? as u64, - total: (provider.count_entries::()? as u64).saturating_sub(1), + // Count only static files entries. If we count the database entries too, we may have + // duplicates. We're sure that the static files have all entries that database has, + // because we run the `StaticFileProducer` before starting the pipeline. + total: (provider.static_file_provider().count_entries::()? as u64) + .saturating_sub(1), }) } diff --git a/crates/stages/src/stages/sender_recovery.rs b/crates/stages/src/stages/sender_recovery.rs index 79e4263661..6ec8f71cb3 100644 --- a/crates/stages/src/stages/sender_recovery.rs +++ b/crates/stages/src/stages/sender_recovery.rs @@ -221,7 +221,10 @@ fn stage_checkpoint( // matching the actual number of processed transactions. To fix that, we add the // number of pruned `TransactionSenders` entries. processed: provider.count_entries::()? as u64 + pruned_entries, - total: provider.count_entries::()? as u64, + // Count only static files entries. If we count the database entries too, we may have + // duplicates. We're sure that the static files have all entries that database has, + // because we run the `StaticFileProducer` before starting the pipeline. + total: provider.static_file_provider().count_entries::()? as u64, }) } diff --git a/crates/stages/src/stages/tx_lookup.rs b/crates/stages/src/stages/tx_lookup.rs index ac68997541..ef1f51eefa 100644 --- a/crates/stages/src/stages/tx_lookup.rs +++ b/crates/stages/src/stages/tx_lookup.rs @@ -219,7 +219,10 @@ fn stage_checkpoint( // number of pruned `TransactionHashNumbers` entries. processed: provider.count_entries::()? as u64 + pruned_entries, - total: provider.count_entries::()? as u64, + // Count only static files entries. If we count the database entries too, we may have + // duplicates. We're sure that the static files have all entries that database has, + // because we run the `StaticFileProducer` before starting the pipeline. + total: provider.static_file_provider().count_entries::()? as u64, }) }