Skip to content

Commit

Permalink
fix(staged-sync): correctly calculate total entries in bodies checkpo…
Browse files Browse the repository at this point in the history
…int (#6992)
  • Loading branch information
rkrasiuk committed Mar 6, 2024
1 parent 2d6ad17 commit 00f97f3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions crates/stages/src/stages/bodies.rs
Expand Up @@ -346,8 +346,7 @@ fn stage_checkpoint<DB: Database>(
// 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::<tables::Headers>()? as u64)
.saturating_sub(1),
total: provider.static_file_provider().count_entries::<tables::Headers>()? as u64,
})
}

Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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;

Expand All @@ -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()),
Expand Down Expand Up @@ -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
Expand All @@ -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");
Expand Down

0 comments on commit 00f97f3

Please sign in to comment.