Skip to content

Commit

Permalink
add fixes after resolving of merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Dec 9, 2024
1 parent 65acd76 commit 29dcf79
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 21 deletions.
5 changes: 3 additions & 2 deletions blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"errors"
"fmt"

"github.com/tendermint/tendermint/crypto/merkle"
coretypes "github.com/tendermint/tendermint/types"

"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/celestiaorg/go-square/merkle"
"github.com/celestiaorg/go-square/v2/inclusion"
libshare "github.com/celestiaorg/go-square/v2/share"
"github.com/celestiaorg/nmt"
coretypes "github.com/tendermint/tendermint/types"
)

var errEmptyShares = errors.New("empty shares")
Expand Down
7 changes: 4 additions & 3 deletions blob/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto/merkle"

"github.com/celestiaorg/go-square/merkle"
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/celestiaorg/go-square/v2/inclusion"
libshare "github.com/celestiaorg/go-square/v2/share"
)
Expand All @@ -28,7 +29,7 @@ func TestBlob(t *testing.T) {
expectedRes: func(t *testing.T) {
require.NotEmpty(t, blob)
require.NotEmpty(t, blob[0].Namespace())
require.NotEmpty(t, blob[0].Data)
require.NotEmpty(t, blob[0].Data())
require.NotEmpty(t, blob[0].Commitment)
},
},
Expand All @@ -38,7 +39,7 @@ func TestBlob(t *testing.T) {
comm, err := inclusion.CreateCommitment(
blob[0].Blob,
merkle.HashFromByteSlices,
subtreeRootThreshold,
appconsts.DefaultSubtreeRootThreshold,
)
require.NoError(t, err)
assert.Equal(t, blob[0].Commitment, Commitment(comm))
Expand Down
3 changes: 2 additions & 1 deletion blob/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"errors"
"fmt"

"github.com/tendermint/tendermint/crypto/merkle"

"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/celestiaorg/go-square/merkle"
"github.com/celestiaorg/go-square/v2/inclusion"
libshare "github.com/celestiaorg/go-square/v2/share"
)
Expand Down
5 changes: 3 additions & 2 deletions blob/repro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package blob
import (
"testing"

"github.com/celestiaorg/go-square/merkle"
"github.com/tendermint/tendermint/crypto/merkle"
coretypes "github.com/tendermint/tendermint/types"

"github.com/celestiaorg/nmt"
"github.com/celestiaorg/nmt/pb"
coretypes "github.com/tendermint/tendermint/types"
)

// Reported at https://github.com/celestiaorg/celestia-node/issues/3731.
Expand Down
20 changes: 12 additions & 8 deletions blob/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ import (
ds_sync "github.com/ipfs/go-datastore/sync"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto/merkle"
bytes2 "github.com/tendermint/tendermint/libs/bytes"
tmrand "github.com/tendermint/tendermint/libs/rand"
coretypes "github.com/tendermint/tendermint/types"

"github.com/celestiaorg/celestia-app/v3/app"
"github.com/celestiaorg/celestia-app/v3/app/encoding"
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
pkgproof "github.com/celestiaorg/celestia-app/v3/pkg/proof"
"github.com/celestiaorg/celestia-app/v3/pkg/user"
"github.com/celestiaorg/celestia-app/v3/pkg/wrapper"
"github.com/celestiaorg/celestia-app/v3/test/util/testfactory"
blobtypes "github.com/celestiaorg/celestia-app/v3/x/blob/types"
"github.com/celestiaorg/go-header/store"
"github.com/celestiaorg/go-square/merkle"
libsquare "github.com/celestiaorg/go-square/v2"
"github.com/celestiaorg/go-square/v2/inclusion"
libshare "github.com/celestiaorg/go-square/v2/share"
Expand Down Expand Up @@ -416,18 +419,18 @@ func TestBlobService_Get(t *testing.T) {
name: "internal error",
doFn: func() (interface{}, error) {
ctrl := gomock.NewController(t)
shareService := service.shareGetter
shareGetterMock := shareMock.NewMockModule(ctrl)
shareGetterMock.EXPECT().
GetSharesByNamespace(gomock.Any(), gomock.Any(), gomock.Any()).
innerGetter := service.shareGetter
getterWrapper := mock.NewMockGetter(ctrl)
getterWrapper.EXPECT().
GetNamespaceData(gomock.Any(), gomock.Any(), gomock.Any()).
DoAndReturn(
func(
ctx context.Context, h *header.ExtendedHeader, ns libshare.Namespace,
) (shwap.NamespaceData, error) {
if ns.Equals(blobsWithDiffNamespaces[0].Namespace()) {
return nil, errors.New("internal error")
}
return shareService.GetSharesByNamespace(ctx, h, ns)
return innerGetter.GetNamespaceData(ctx, h, ns)
}).AnyTimes()

service.shareGetter = getterWrapper
Expand Down Expand Up @@ -1089,6 +1092,7 @@ func delimLen(size uint64) int {
lenBuf := make([]byte, binary.MaxVarintLen64)
return binary.PutUvarint(lenBuf, size)
}

func TestBlobVerify(t *testing.T) {
_, blobs, nss, eds, _, _, dataRoot := edstest.GenerateTestBlock(t, 200, 10)

Expand Down Expand Up @@ -1293,7 +1297,7 @@ func proveCommitment(
}

// compute the subtree roots of the blob shares
subtreeRoots, err := inclusion.GenerateSubtreeRoots(blb, appconsts.SubtreeRootThreshold(appVersion))
subtreeRoots, err := inclusion.GenerateSubtreeRoots(blb, appconsts.DefaultSubtreeRootThreshold)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion header/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (eh *ExtendedHeader) UnmarshalBinary(data []byte) error {
// Uses tendermint encoder for tendermint compatibility.
func (eh *ExtendedHeader) MarshalJSON() ([]byte, error) {
// alias the type to avoid going into recursion loop
// because tmjson.Marshal invokes custom json marshalling
// because tmjson.Marshal invokes custom json marshaling
type Alias ExtendedHeader
return tmjson.Marshal((*Alias)(eh))
}
Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Module interface {
GetProof(_ context.Context, height uint64, _ libshare.Namespace, _ blob.Commitment) (*blob.Proof, error)
// Included checks whether a blob's given commitment(Merkle subtree root) is included at
// given height and under the namespace.
Included(_ context.Context, height uint64, _ share.Namespace, _ *blob.Proof, _ blob.Commitment) (bool, error)
Included(_ context.Context, height uint64, _ libshare.Namespace, _ *blob.Proof, _ blob.Commitment) (bool, error)
// Subscribe to published blobs from the given namespace as they are included.
Subscribe(_ context.Context, _ libshare.Namespace) (<-chan *blob.SubscriptionResponse, error)
}
Expand Down
6 changes: 3 additions & 3 deletions nodebuilder/share/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var _ Module = (*API)(nil)
// the data root.
type RangeResult struct {
// Shares the queried shares.
Shares []share.Share `json:"shares"`
Shares []libshare.Share `json:"shares"`
// Proof the proof of Shares up to the data root.
Proof *types.ShareProof `json:"proof"`
}
Expand All @@ -38,7 +38,7 @@ func (r RangeResult) Verify(dataRoot []byte) error {
}

for index, data := range r.Shares {
if !bytes.Equal(data, r.Proof.Data[index]) {
if !bytes.Equal(data.ToBytes(), r.Proof.Data[index]) {
return fmt.Errorf("mismatching share %d between the range result and the proof", index)
}
}
Expand Down Expand Up @@ -158,7 +158,7 @@ func (m module) SharesAvailable(ctx context.Context, height uint64) error {
return m.avail.SharesAvailable(ctx, header)
}

func (m module) GetRange(ctx context.Context, height uint64, start, end int) (*GetRangeResult, error) {
func (m module) GetRange(ctx context.Context, height uint64, start, end int) (*RangeResult, error) {
extendedDataSquare, err := m.GetEDS(ctx, height)
if err != nil {
return nil, err
Expand Down

0 comments on commit 29dcf79

Please sign in to comment.