From 00f97f34ad3cd4c9e51ab7af13068965e2da9ad3 Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Wed, 6 Mar 2024 12:38:36 +0100 Subject: [PATCH] fix(staged-sync): correctly calculate total entries in bodies checkpoint (#6992) --- crates/stages/src/stages/bodies.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/stages/src/stages/bodies.rs b/crates/stages/src/stages/bodies.rs index 312c465798..9cf8112747 100644 --- a/crates/stages/src/stages/bodies.rs +++ b/crates/stages/src/stages/bodies.rs @@ -346,8 +346,7 @@ fn stage_checkpoint( // 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), + total: provider.static_file_provider().count_entries::()? as u64, }) } @@ -397,7 +396,7 @@ mod tests { total // seeded headers })) }, done: false }) if block_number < 200 && - processed == 1 + batch_size && total == previous_stage + processed == batch_size + 1 && total == previous_stage + 1 ); assert!(runner.validate_execution(input, output.ok()).is_ok(), "execution validation"); } @@ -436,7 +435,7 @@ mod tests { })) }, done: true - }) if processed == total && total == previous_stage + }) if processed + 1 == total && total == previous_stage + 1 ); assert!(runner.validate_execution(input, output.ok()).is_ok(), "execution validation"); } @@ -472,7 +471,7 @@ mod tests { total })) }, done: false }) if block_number >= 10 && - processed == 1 + batch_size && total == previous_stage + processed - 1 == batch_size && total == previous_stage + 1 ); let first_run_checkpoint = first_run.unwrap().checkpoint; @@ -493,7 +492,7 @@ mod tests { total })) }, done: true }) if block_number > first_run_checkpoint.block_number && - processed == total && total == previous_stage + processed + 1 == total && total == previous_stage + 1 ); assert_matches!( runner.validate_execution(input, output.ok()), @@ -534,7 +533,7 @@ mod tests { total })) }, done: true }) if block_number == previous_stage && - processed == total && total == previous_stage + processed + 1 == total && total == previous_stage + 1 ); let checkpoint = output.unwrap().checkpoint; runner @@ -560,7 +559,7 @@ mod tests { processed: 1, total })) - }}) if total == previous_stage + }}) if total == previous_stage + 1 ); assert_matches!(runner.validate_unwind(input), Ok(_), "unwind validation");