Skip to content

Commit

Permalink
fix: make sure we only prune unfinalized data (wrt hive) (#6788)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
Co-authored-by: pc <pc@pcs-MacBook-Pro.local>
  • Loading branch information
3 people authored Feb 26, 2024
1 parent 81c10b4 commit 17ad869
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions crates/prune/src/segments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,18 @@ impl PruneInput {
.unwrap_or(0);

let to_tx_number = match provider.block_body_indices(self.to_block)? {
Some(body) => body,
Some(body) => {
let last_tx = body.last_tx_num();
if last_tx + body.tx_count() == 0 {
// Prevents a scenario where the pruner correctly starts at a finalized block,
// but the first transaction (tx_num = 0) only appears on an unfinalized one.
// Should only happen on a test/hive scenario.
return Ok(None)
}
last_tx
}
None => return Ok(None),
}
.last_tx_num();
};

let range = from_tx_number..=to_tx_number;
if range.is_empty() {
Expand Down

0 comments on commit 17ad869

Please sign in to comment.