Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: bump app v1.0.0-rc0 #2253

Merged
merged 51 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
3295453
chore!: bump to celestia-app v0.14.0-rc0
rootulp Mar 31, 2023
a135598
fix tests
rootulp Mar 31, 2023
769f48e
wip: mark tests that need fixing
rootulp Mar 31, 2023
647c90e
wip: debug TestService_GetSharesByNamespace
rootulp Apr 7, 2023
3382a47
celestia-node depends on ignoreMaxNs
rootulp Apr 7, 2023
2af019a
chore: remove 8 from sha256Namespace8Flagged
rootulp Apr 10, 2023
56f2ff5
fix: TestService_GetSharesByNamespace
rootulp Apr 10, 2023
4a4be1c
feat: verifyAny row root
rootulp Apr 10, 2023
c0cfc7f
revert: getter.go b/c modifying celestia-app parity namespace
rootulp Apr 10, 2023
f515546
revert: unnecessary changes b/c parity namespace id in celestia-app
rootulp Apr 10, 2023
e81ed85
fix TestSharesRoundTrip
rootulp Apr 10, 2023
62ab0d4
fix: TestQuadrantOrder
rootulp Apr 10, 2023
4460faa
fix: TestReadEDS
rootulp Apr 10, 2023
0e988cf
Merge branch 'main' into rp/bump-celestia-app
rootulp Apr 10, 2023
551b0da
chore: prefer crypto/rand over math/rand
rootulp Apr 10, 2023
f3b5d9f
chore: upgrade to celestia-app v0.14.0-rc2
rootulp Apr 13, 2023
d9a573c
Merge branch 'main' into rp/bump-celestia-app
rootulp Apr 13, 2023
0a9c80c
fix comment
rootulp Apr 13, 2023
f934f9e
fix: lint
rootulp Apr 14, 2023
24d253e
Merge branch 'main' into rp/bump-celestia-app
rootulp Apr 14, 2023
23a611d
fix: TestShrexGetter
rootulp Apr 14, 2023
0b37134
fix: GetSharesByNamespace
rootulp Apr 14, 2023
d3a6243
fix: TestExchange_RequestND_NotFound
rootulp Apr 14, 2023
2e1e5ce
fix: TestStoreGetter
rootulp Apr 14, 2023
9cee800
fix: TestService_GetSharesByNamespace
rootulp Apr 14, 2023
c505103
fix: TestRetriever_ByzantineError
rootulp Apr 14, 2023
df4d5f1
chore: address @wondertan feedback
rootulp Apr 17, 2023
18117b7
Merge branch 'main' into rp/bump-celestia-app
rootulp Apr 17, 2023
ed41784
Merge branch 'main' into rp/bump-celestia-app
rootulp Apr 18, 2023
4f3e0ee
chore: upgrade to celestia-app v0.15.0-rc0
rootulp May 3, 2023
d560d2e
Merge branch 'main' into rp/bump-celestia-app
rootulp May 3, 2023
4e8befd
Merge branch 'main' into rp/bump-celestia-app
rootulp May 4, 2023
8754e37
Merge branch 'main' into rp/bump-celestia-app
rootulp May 8, 2023
0edb12f
Merge branch 'main' into rp/bump-celestia-app
rootulp May 16, 2023
2f49138
fix: merge conflict
rootulp May 16, 2023
f5e8aae
Merge branch 'main' into evan/bump-app-v1
evan-forbes May 24, 2023
c764023
fix: tests
evan-forbes May 24, 2023
2da101a
feat!: bump app to latest main
evan-forbes May 24, 2023
80964fd
fix: tests
evan-forbes May 24, 2023
727f946
fix: linter
evan-forbes May 25, 2023
3d9d777
chore: bump tag
evan-forbes May 25, 2023
a52164f
fix: linter
evan-forbes May 25, 2023
74da567
chore: cleanup
evan-forbes May 25, 2023
7c17cbc
chore: remove unnecessary append
evan-forbes May 25, 2023
01bbd0d
chore: remove unused testdata
evan-forbes May 25, 2023
256f34b
chore: use local fields
evan-forbes May 25, 2023
0d841f6
chore: typo
evan-forbes May 25, 2023
1678099
chore: docs
evan-forbes May 26, 2023
385c3f3
Merge branch 'main' into evan/bump-app-v1
evan-forbes May 26, 2023
b57e78e
fix review comments
Wondertan May 29, 2023
21ca1db
Merge branch 'main' into evan/bump-app-v1
Wondertan May 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion api/gateway/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ func (h *Handler) getShares(ctx context.Context, height uint64, nID namespace.ID
}

func dataFromShares(input []share.Share) (data [][]byte, err error) {
sequences, err := shares.ParseShares(input)
appShares, err := shares.FromBytes(input)
if err != nil {
return nil, err
}
sequences, err := shares.ParseShares(appShares, false)
if err != nil {
return nil, err
}
Expand Down
132 changes: 27 additions & 105 deletions api/gateway/share_test.go
Original file line number Diff line number Diff line change
@@ -1,123 +1,45 @@
package gateway

import (
"bytes"
"testing"

"github.com/stretchr/testify/assert"

"github.com/celestiaorg/celestia-app/pkg/appconsts"
"github.com/celestiaorg/celestia-app/pkg/namespace"
"github.com/celestiaorg/celestia-app/pkg/shares"
"github.com/stretchr/testify/require"
coretypes "github.com/tendermint/tendermint/types"
)

func Test_dataFromShares(t *testing.T) {
type testCase struct {
name string
input [][]byte
want [][]byte
wantErr bool
input := [][]byte{
[]byte("beep"),
[]byte("beeap"),
[]byte("BEEEEAHP"),
}

smallTxInput := padShare([]uint8{
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, // namespace id
0x1, // info byte
0x0, 0x0, 0x0, 0x2, // 1 byte (unit) + 1 byte (unit length) = 2 bytes sequence length
0x0, 0x0, 0x0, 17, // reserved bytes
0x1, // unit length of first transaction
0xa, // data of first transaction
})
smallTxData := []byte{0x1, 0xa}

largeTxInput := [][]byte{
fillShare([]uint8{
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, // namespace id
0x1, // info byte
0x0, 0x0, 0x2, 0x2, // 512 (unit) + 2 (unit length) = 514 sequence length
0x0, 0x0, 0x0, 17, // reserved bytes
128, 4, // unit length of transaction is 512
}, 0xc), // data of transaction
padShare(append([]uint8{
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, // namespace id
0x0, // info byte
0x0, 0x0, 0x0, 0x0, // reserved bytes
}, bytes.Repeat([]byte{0xc}, 19)..., // continuation data of transaction
)),
ns := namespace.RandomBlobNamespace()
sss := shares.NewSparseShareSplitter()
for _, i := range input {
b := coretypes.Blob{
Data: i,
Wondertan marked this conversation as resolved.
Show resolved Hide resolved
NamespaceID: ns.ID,
NamespaceVersion: ns.Version,
ShareVersion: appconsts.ShareVersionZero,
}
err := sss.Write(b)
require.NoError(t, err)
}
largeTxData := []byte{128, 4}
largeTxData = append(largeTxData, bytes.Repeat([]byte{0xc}, 512)...)

largePfbTxInput := [][]byte{
fillShare([]uint8{
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, // namespace id
0x1, // info byte
0x0, 0x0, 0x2, 0x2, // 512 (unit) + 2 (unit length) = 514 sequence length
0x0, 0x0, 0x0, 17, // reserved bytes
128, 4, // unit length of transaction is 512
}, 0xc), // data of transaction
padShare(append([]uint8{
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, // namespace id
0x0, // info byte
0x0, 0x0, 0x0, 0x0, // reserved bytes
}, bytes.Repeat([]byte{0xc}, 19)..., // continuation data of transaction
)),
}
largePfbTxData := []byte{128, 4}
largePfbTxData = append(largePfbTxData, bytes.Repeat([]byte{0xc}, 512)...)
sssShares := sss.Export()

testCases := []testCase{
{
name: "empty",
input: [][]byte{},
want: nil,
wantErr: false,
},
{
name: "returns an error when shares contain two different namespaces",
input: [][]byte{
{0, 0, 0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 2},
},
want: nil,
wantErr: true,
},
{
name: "returns raw data of a single tx share",
input: [][]byte{smallTxInput},
want: [][]byte{smallTxData},
wantErr: false,
},
{
name: "returns raw data of a large tx that spans two shares",
input: largeTxInput,
want: [][]byte{largeTxData},
wantErr: false,
},
{
name: "returns raw data of a large PFB tx that spans two shares",
input: largePfbTxInput,
want: [][]byte{largePfbTxData},
wantErr: false,
},
rawSSSShares := make([][]byte, len(sssShares))
for i := 0; i < len(sssShares); i++ {
d := sssShares[i].ToBytes()
rawSSSShares[i] = d
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
got, err := dataFromShares(tc.input)
if tc.wantErr {
assert.Error(t, err)
return
}
assert.Equal(t, tc.want, got)
})
}
}

// padShare returns a share padded with trailing zeros.
func padShare(share []byte) (paddedShare []byte) {
return fillShare(share, 0)
}
parsedSSSShares, err := dataFromShares(rawSSSShares)
require.NoError(t, err)

// fillShare returns a share filled with filler so that the share length
// is equal to appconsts.ShareSize.
func fillShare(share []byte, filler byte) (paddedShare []byte) {
return append(share, bytes.Repeat([]byte{filler}, appconsts.ShareSize-len(share))...)
require.Equal(t, input, parsedSSSShares)
}
13 changes: 10 additions & 3 deletions core/eds.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"github.com/filecoin-project/dagstore"
"github.com/tendermint/tendermint/types"

"github.com/celestiaorg/celestia-app/pkg/appconsts"
"github.com/celestiaorg/celestia-app/pkg/da"
appshares "github.com/celestiaorg/celestia-app/pkg/shares"
"github.com/celestiaorg/celestia-app/pkg/square"
"github.com/celestiaorg/rsmt2d"

"github.com/celestiaorg/celestia-node/share"
Expand All @@ -22,12 +23,18 @@ func extendBlock(data types.Data) (*rsmt2d.ExtendedDataSquare, error) {
if len(data.Txs) == 0 && data.SquareSize == uint64(1) {
return nil, nil
}
shares, err := appshares.Split(data, true)

sqr, err := square.Construct(data.Txs.ToSliceOfBytes(), appconsts.MaxSquareSize)
Wondertan marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, err
}

return da.ExtendShares(data.SquareSize, appshares.ToBytes(shares))
shares := make([][]byte, len(sqr))
for i, s := range sqr {
shares[i] = s.ToBytes()
}

return da.ExtendShares(shares)
}

// storeEDS will only store extended block if it is not empty and doesn't already exist.
Expand Down
12 changes: 7 additions & 5 deletions core/eds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
func TestTrulyEmptySquare(t *testing.T) {
data := types.Data{
Txs: []types.Tx{},
Blobs: []types.Blob{},
SquareSize: 1,
}

Expand All @@ -27,17 +26,20 @@ func TestTrulyEmptySquare(t *testing.T) {
assert.Nil(t, eds)
}

// TestNonEmptySquareWithZeroTxs tests that a non-empty square with no
// transactions or blobs computes the correct data root (not the minimum DAH).
// TestNonZeroSquareSize tests that the DAH hash of a block with no transactions
// is equal to the DAH hash for an empty root even if SquareSize is set to
// something non-zero. Technically, this block data is invalid because the
// construction of the square is deterministic, and the rules which dictate the
// square size do not allow for empty block data. However, should that ever
// occur, we need to ensure that the correct data root is generated.
func TestNonEmptySquareWithZeroTxs(t *testing.T) {
renaynay marked this conversation as resolved.
Show resolved Hide resolved
data := types.Data{
Txs: []types.Tx{},
Wondertan marked this conversation as resolved.
Show resolved Hide resolved
Blobs: []types.Blob{},
SquareSize: 16,
}

eds, err := extendBlock(data)
require.NoError(t, err)
dah := da.NewDataAvailabilityHeader(eds)
assert.NotEqual(t, share.EmptyRoot().Hash(), dah.Hash())
assert.Equal(t, share.EmptyRoot().Hash(), dah.Hash())
}
2 changes: 1 addition & 1 deletion core/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/celestiaorg/celestia-app/testutil/testnode"
"github.com/celestiaorg/celestia-app/test/util/testnode"

"github.com/celestiaorg/celestia-node/header"
"github.com/celestiaorg/celestia-node/share/eds"
Expand Down
3 changes: 1 addition & 2 deletions core/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
tmrand "github.com/tendermint/tendermint/libs/rand"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/celestiaorg/celestia-app/testutil/testnode"
"github.com/celestiaorg/celestia-app/test/util/testnode"
)

// TestConfig encompasses all the configs required to run test Tendermint + Celestia App tandem.
Expand Down Expand Up @@ -79,7 +79,6 @@ func StartTestNodeWithConfig(t *testing.T, cfg *TestConfig) testnode.Context {
state,
kr,
"private",
nil,
)
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion core/testing_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/celestiaorg/celestia-app/testutil/testnode"
"github.com/celestiaorg/celestia-app/test/util/testnode"
)

/*
Expand Down
2 changes: 1 addition & 1 deletion das/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func (m *mockSampler) discover(ctx context.Context, newHeight uint64, emit liste
emit(ctx, &header.ExtendedHeader{
Commit: &types.Commit{},
RawHeader: header.RawHeader{Height: int64(newHeight)},
DAH: &header.DataAvailabilityHeader{RowsRoots: make([][]byte, 0)},
DAH: &header.DataAvailabilityHeader{RowRoots: make([][]byte, 0)},
})
}

Expand Down
4 changes: 2 additions & 2 deletions das/daser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ type benchGetterStub struct {

func newBenchGetter() benchGetterStub {
return benchGetterStub{header: &header.ExtendedHeader{
DAH: &header.DataAvailabilityHeader{RowsRoots: make([][]byte, 0)}}}
DAH: &header.DataAvailabilityHeader{RowRoots: make([][]byte, 0)}}}
}

func (m benchGetterStub) GetByHeight(context.Context, uint64) (*header.ExtendedHeader, error) {
Expand All @@ -362,7 +362,7 @@ func (m getterStub) GetByHeight(_ context.Context, height uint64) (*header.Exten
return &header.ExtendedHeader{
Commit: &types.Commit{},
RawHeader: header.RawHeader{Height: int64(height)},
DAH: &header.DataAvailabilityHeader{RowsRoots: make([][]byte, 0)}}, nil
DAH: &header.DataAvailabilityHeader{RowRoots: make([][]byte, 0)}}, nil
}

func (m getterStub) GetRangeByHeight(context.Context, uint64, uint64) ([]*header.ExtendedHeader, error) {
Expand Down
4 changes: 2 additions & 2 deletions das/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ func (m *metrics) observeSample(
}
m.sampleTime.Record(ctx, sampleTime.Seconds(),
attribute.Bool(failedLabel, err != nil),
attribute.Int(headerWidthLabel, len(h.DAH.RowsRoots)),
attribute.Int(headerWidthLabel, len(h.DAH.RowRoots)),
attribute.String(jobTypeLabel, string(jobType)),
)

m.sampled.Add(ctx, 1,
attribute.Bool(failedLabel, err != nil),
attribute.Int(headerWidthLabel, len(h.DAH.RowsRoots)),
attribute.Int(headerWidthLabel, len(h.DAH.RowRoots)),
attribute.String(jobTypeLabel, string(jobType)),
)

Expand Down
6 changes: 3 additions & 3 deletions das/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (w *worker) sample(ctx context.Context, timeout time.Duration, height uint6
"type", w.state.jobType,
"height", h.Height(),
"hash", h.Hash(),
"square width", len(h.DAH.RowsRoots),
"square width", len(h.DAH.RowRoots),
"data root", h.DAH.String(),
"err", err,
"finished (s)", time.Since(start),
Expand Down Expand Up @@ -150,7 +150,7 @@ func (w *worker) sample(ctx context.Context, timeout time.Duration, height uint6
"type", w.state.jobType,
"height", h.Height(),
"hash", h.Hash(),
"square width", len(h.DAH.RowsRoots),
"square width", len(h.DAH.RowRoots),
"data root", h.DAH.String(),
"finished (s)", time.Since(start),
)
Expand Down Expand Up @@ -179,7 +179,7 @@ func (w *worker) getHeader(ctx context.Context, height uint64) (*header.Extended
"got header from header store",
"height", h.Height(),
"hash", h.Hash(),
"square width", len(h.DAH.RowsRoots),
"square width", len(h.DAH.RowRoots),
"data root", h.DAH.String(),
"finished (s)", time.Since(start),
)
Expand Down
Loading