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(pruner): fix find algo so that it does not pass a malformed range into GetRangeByHeight call #3828

Merged
merged 6 commits into from
Oct 28, 2024
6 changes: 4 additions & 2 deletions pruner/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ func (s *Service) findPruneableHeaders(
return nil, err
}

if lastPruned.Height() == estimatedCutoffHeight {
walldiss marked this conversation as resolved.
Show resolved Hide resolved
if lastPruned.Height() >= estimatedCutoffHeight {
// nothing left to prune
return nil, nil
}

log.Debugw("finder: fetching header range", "last pruned", lastPruned.Height(),
"target height", estimatedCutoffHeight)

headers, err := s.getter.GetRangeByHeight(ctx, lastPruned, estimatedCutoffHeight)
// GetRangeByHeight requests (from:to), where `to` is non-inclusive, we need
// to request one more header than the estimated cutoff
headers, err := s.getter.GetRangeByHeight(ctx, lastPruned, estimatedCutoffHeight+1)
if err != nil {
log.Errorw("failed to get range from header store", "from", lastPruned.Height(),
"to", estimatedCutoffHeight, "error", err)
Expand Down