Skip to content

Commit

Permalink
Merge branch 'main' into daser-log-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
walldiss authored Oct 28, 2024
2 parents ce61a2f + f5d9d3a commit 44cbe84
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 30 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
28 changes: 0 additions & 28 deletions share/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
)
}

0 comments on commit 44cbe84

Please sign in to comment.