From 097fcab91b3a846caddd79d0dbf0961668f722c5 Mon Sep 17 00:00:00 2001 From: rene <41963722+renaynay@users.noreply.github.com> Date: Mon, 28 Oct 2024 16:05:16 +0100 Subject: [PATCH] fix(pruner): fix find algo so that it does not pass a malformed range into `GetRangeByHeight` call (#3828) --- pruner/find.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pruner/find.go b/pruner/find.go index fd966d6c15..0104f24e78 100644 --- a/pruner/find.go +++ b/pruner/find.go @@ -31,7 +31,7 @@ func (s *Service) findPruneableHeaders( return nil, err } - if lastPruned.Height() == estimatedCutoffHeight { + if lastPruned.Height() >= estimatedCutoffHeight { // nothing left to prune return nil, nil } @@ -39,7 +39,9 @@ func (s *Service) findPruneableHeaders( 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)