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 1/3] 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) From f5d9d3a00aba1efef3fcba359c4de07a10a06047 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Mon, 28 Oct 2024 17:44:05 +0100 Subject: [PATCH 2/3] chore(share): remove unused ShareWithProof (#3893) --- share/share.go | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/share/share.go b/share/share.go index d7f0bb2ca5..7bfcd40a99 100644 --- a/share/share.go +++ b/share/share.go @@ -2,9 +2,6 @@ package share import ( "github.com/celestiaorg/celestia-app/v3/pkg/appconsts" - libshare "github.com/celestiaorg/go-square/v2/share" - "github.com/celestiaorg/nmt" - "github.com/celestiaorg/rsmt2d" ) // DefaultRSMT2DCodec sets the default rsmt2d.Codec for shares. @@ -13,28 +10,3 @@ var DefaultRSMT2DCodec = appconsts.DefaultCodec // MaxSquareSize is currently the maximum size supported for unerasured data in // rsmt2d.ExtendedDataSquare. var MaxSquareSize = appconsts.SquareSizeUpperBound(appconsts.LatestVersion) - -// ShareWithProof contains data with corresponding Merkle Proof -type ShareWithProof struct { //nolint: revive - // Share is a full data including namespace - libshare.Share - // Proof is a Merkle Proof of current share - Proof *nmt.Proof - // Axis is a type of axis against which the share proof is computed - Axis rsmt2d.Axis -} - -// Validate validates inclusion of the share under the given root CID. -func (s *ShareWithProof) Validate(rootHash []byte, x, y, edsSize int) bool { - isParity := x >= edsSize/2 || y >= edsSize/2 - namespace := libshare.ParitySharesNamespace - if !isParity { - namespace = s.Share.Namespace() - } - return s.Proof.VerifyInclusion( - NewSHA256Hasher(), - namespace.Bytes(), - [][]byte{s.Share.ToBytes()}, - rootHash, - ) -} From c913b13dafc541e5202074e5839293e88fc66f44 Mon Sep 17 00:00:00 2001 From: Vlad <13818348+walldiss@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:32:32 +0100 Subject: [PATCH 3/3] fix(share/availability): propagate errors from light availability properly (#3888) --- share/availability/light/availability.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/share/availability/light/availability.go b/share/availability/light/availability.go index 3665711d1f..def56d346b 100644 --- a/share/availability/light/availability.go +++ b/share/availability/light/availability.go @@ -3,6 +3,7 @@ package light import ( "context" "errors" + "fmt" "sync" "github.com/ipfs/go-datastore" @@ -123,19 +124,19 @@ func (la *ShareAvailability) SharesAvailable(ctx context.Context, header *header } wg.Wait() - if errors.Is(ctx.Err(), context.Canceled) { - // Availability did not complete due to context cancellation, return context error instead of - // share.ErrNotAvailable - return ctx.Err() - } - // store the result of the sampling session bs := encodeSamples(failedSamples) la.dsLk.Lock() err = la.ds.Put(ctx, key, bs) la.dsLk.Unlock() if err != nil { - log.Errorw("Failed to store sampling result", "error", err) + return fmt.Errorf("failed to store sampling result: %w", err) + } + + if errors.Is(ctx.Err(), context.Canceled) { + // Availability did not complete due to context cancellation, return context error instead of + // share.ErrNotAvailable + return ctx.Err() } // if any of the samples failed, return an error