Skip to content

Commit

Permalink
fix(pruner): fix find algo so that it does not pass a malformed range…
Browse files Browse the repository at this point in the history
… into `GetRangeByHeight` call (#3828)
  • Loading branch information
renaynay authored Oct 28, 2024
1 parent 08ca0ed commit 097fcab
Showing 1 changed file with 4 additions and 2 deletions.
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 {
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

0 comments on commit 097fcab

Please sign in to comment.