diff --git a/blob/blob.go b/blob/blob.go index 76635d6539..f56c78c7fa 100644 --- a/blob/blob.go +++ b/blob/blob.go @@ -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") diff --git a/blob/blob_test.go b/blob/blob_test.go index 221e2d8395..af4290997f 100644 --- a/blob/blob_test.go +++ b/blob/blob_test.go @@ -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" ) @@ -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) }, }, @@ -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)) diff --git a/blob/parser.go b/blob/parser.go index 5d9e29738b..5154334f87 100644 --- a/blob/parser.go +++ b/blob/parser.go @@ -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" ) diff --git a/blob/repro_test.go b/blob/repro_test.go index d3161f9c59..c3cd468e89 100644 --- a/blob/repro_test.go +++ b/blob/repro_test.go @@ -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. diff --git a/blob/service_test.go b/blob/service_test.go index de9b0f2728..28777de70e 100644 --- a/blob/service_test.go +++ b/blob/service_test.go @@ -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" @@ -416,10 +419,10 @@ 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, @@ -427,7 +430,7 @@ func TestBlobService_Get(t *testing.T) { 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 @@ -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) @@ -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 } diff --git a/header/header.go b/header/header.go index b44447ce42..122b46558f 100644 --- a/header/header.go +++ b/header/header.go @@ -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)) } diff --git a/nodebuilder/blob/blob.go b/nodebuilder/blob/blob.go index 2a7b12ea23..7c41fe33b9 100644 --- a/nodebuilder/blob/blob.go +++ b/nodebuilder/blob/blob.go @@ -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) } diff --git a/nodebuilder/share/share.go b/nodebuilder/share/share.go index 3220acb39d..7805d3783e 100644 --- a/nodebuilder/share/share.go +++ b/nodebuilder/share/share.go @@ -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"` } @@ -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) } } @@ -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