Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make sure we only prune unfinalized data (wrt hive) #6788

Merged
merged 5 commits into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading