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

chore: bump celestia app v1.0.0-rc9 #2458

Merged
merged 7 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion core/eds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func TestEmptySquareWithZeroTxs(t *testing.T) {
eds, err = app.ExtendBlock(data, appconsts.LatestVersion)
require.NoError(t, err)

dah := da.NewDataAvailabilityHeader(eds)
dah, err := da.NewDataAvailabilityHeader(eds)
require.NoError(t, err)
assert.Equal(t, share.EmptyRoot().Hash(), dah.Hash())
}
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ require (
github.com/BurntSushi/toml v1.3.2
github.com/alecthomas/jsonschema v0.0.0-20200530073317-71f438968921
github.com/benbjohnson/clock v1.3.5
github.com/celestiaorg/celestia-app v1.0.0-rc8
github.com/celestiaorg/celestia-app v1.0.0-rc9
github.com/celestiaorg/go-fraud v0.1.0
github.com/celestiaorg/go-header v0.2.11
github.com/celestiaorg/go-libp2p-messenger v0.2.0
github.com/celestiaorg/nmt v0.17.0
github.com/celestiaorg/rsmt2d v0.9.0
github.com/celestiaorg/rsmt2d v0.10.0
github.com/cosmos/cosmos-sdk v0.46.13
github.com/cosmos/cosmos-sdk/api v0.1.0
github.com/cristalhq/jwt v1.2.0
Expand Down Expand Up @@ -330,10 +330,10 @@ require (
)

replace (
github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.15.0-sdk-v0.46.13
github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.16.0-sdk-v0.46.13
github.com/filecoin-project/dagstore => github.com/celestiaorg/dagstore v0.0.0-20230413141458-735ab09a15d6
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
// broken goleveldb needs to be replaced for the cosmos-sdk and celestia-app
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.23.0-tm-v0.34.28
github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.24.0-tm-v0.34.28
)
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,12 @@ github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/celestiaorg/celestia-app v1.0.0-rc8 h1:bBQY8tR3DCc8uA7c2ney4AeWwEn9Ob1lc1QryGKVF2M=
github.com/celestiaorg/celestia-app v1.0.0-rc8/go.mod h1:X0R6s+LvfusZu+jBj/2SbTm4Nb/H1R2MD1CnR4fwQno=
github.com/celestiaorg/celestia-core v1.23.0-tm-v0.34.28 h1:G7/rq6xTnuFf3XsVZEcl/Sa6vtagm9NQNhaUaSgjvy0=
github.com/celestiaorg/celestia-core v1.23.0-tm-v0.34.28/go.mod h1:J/GsBjoTZaFz71VeyrLZbG8rV+Rzi6oFEUZUipQ97hQ=
github.com/celestiaorg/cosmos-sdk v1.15.0-sdk-v0.46.13 h1:vaQKgaOm0w58JAvOgn2iDohqjH7kvvRqVKiMcBDWifA=
github.com/celestiaorg/cosmos-sdk v1.15.0-sdk-v0.46.13/go.mod h1:G9XkhOJZde36FH0kt/1ayg4ZaioZEQmmRfMa/zQig0I=
github.com/celestiaorg/celestia-app v1.0.0-rc9 h1:6xDYE+OziXO/rLeYy/MutnJpE8M2sIPryZ/ifSWUmdc=
github.com/celestiaorg/celestia-app v1.0.0-rc9/go.mod h1:aGFnIIdA30DtFzznYbcfMdNnXiUebfEUkkrQu8imC3I=
github.com/celestiaorg/celestia-core v1.24.0-tm-v0.34.28 h1:eXS3v26nob8Xs2+flKHVxcTzhzQW44KgTcooR3OxnK4=
github.com/celestiaorg/celestia-core v1.24.0-tm-v0.34.28/go.mod h1:J/GsBjoTZaFz71VeyrLZbG8rV+Rzi6oFEUZUipQ97hQ=
github.com/celestiaorg/cosmos-sdk v1.16.0-sdk-v0.46.13 h1:N1PrCWcYkaODeIQyyVBmDKDTwiQWZ31bgtTEYIGeby8=
github.com/celestiaorg/cosmos-sdk v1.16.0-sdk-v0.46.13/go.mod h1:xpBZc/OYZ736hp0IZlBGNUhEgCD9C+bKs8yNLZibyv0=
github.com/celestiaorg/dagstore v0.0.0-20230413141458-735ab09a15d6 h1:/yCwMCoOPcYCiG18u8/1pv5eXF04xczoQO3sR0bKsgM=
github.com/celestiaorg/dagstore v0.0.0-20230413141458-735ab09a15d6/go.mod h1:ta/DlqIH10bvhwqJIw51Nq3QU4XVMp6pz3f0Deve9fM=
github.com/celestiaorg/go-fraud v0.1.0 h1:v6mZvlmf2J5ELZfPnrtmmOvKbaYIUs/erDWPO8NbZyY=
Expand All @@ -366,8 +366,8 @@ github.com/celestiaorg/nmt v0.17.0 h1:/k8YLwJvuHgT/jQ435zXKaDX811+sYEMXL4B/vYdSL
github.com/celestiaorg/nmt v0.17.0/go.mod h1:ZndCeAR4l9lxm7W51ouoyTo1cxhtFgK+4DpEIkxRA3A=
github.com/celestiaorg/quantum-gravity-bridge v1.3.0 h1:9zPIp7w1FWfkPnn16y3S4FpFLnQtS7rm81CUVcHEts0=
github.com/celestiaorg/quantum-gravity-bridge v1.3.0/go.mod h1:6WOajINTDEUXpSj5UZzod16UZ96ZVB/rFNKyM+Mt1gI=
github.com/celestiaorg/rsmt2d v0.9.0 h1:kon78I748ZqjNzI8OAqPN+2EImuZuanj/6gTh8brX3o=
github.com/celestiaorg/rsmt2d v0.9.0/go.mod h1:E06nDxfoeBDltWRvTR9dLviiUZI5/6mLXAuhSJzz3Iw=
github.com/celestiaorg/rsmt2d v0.10.0 h1:8dprr6CW5mCk5YPnbiLdirojw9YsJOE+XB+GORb8sT0=
github.com/celestiaorg/rsmt2d v0.10.0/go.mod h1:BiCZkCJfhDHUEOJKXUeu+CudjluecKvRTqHcuxKvodc=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
Expand Down
10 changes: 8 additions & 2 deletions header/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,18 @@ func MakeExtendedHeader(
vals *core.ValidatorSet,
eds *rsmt2d.ExtendedDataSquare,
) (*ExtendedHeader, error) {
var dah DataAvailabilityHeader
var (
dah DataAvailabilityHeader
err error
)
switch eds {
case nil:
dah = EmptyDAH()
default:
dah = da.NewDataAvailabilityHeader(eds)
dah, err = da.NewDataAvailabilityHeader(eds)
}
if err != nil {
return nil, err
}

eh := &ExtendedHeader{
Expand Down
6 changes: 4 additions & 2 deletions header/headertest/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ func FraudMaker(t *testing.T, faultHeight int64, bServ blockservice.BlockService
func ExtendedHeaderFromEDS(t *testing.T, height uint64, eds *rsmt2d.ExtendedDataSquare) *header.ExtendedHeader {
valSet, vals := RandValidatorSet(10, 10)
gen := RandRawHeader(t)
dah := da.NewDataAvailabilityHeader(eds)
dah, err := da.NewDataAvailabilityHeader(eds)
require.NoError(t, err)

gen.DataHash = dah.Hash()
gen.ValidatorsHash = valSet.Hash()
Expand Down Expand Up @@ -355,7 +356,8 @@ func CreateFraudExtHeader(
square := edstest.RandByzantineEDS(t, len(eh.DAH.RowRoots))
err := ipld.ImportEDS(context.Background(), square, serv)
require.NoError(t, err)
dah := da.NewDataAvailabilityHeader(square)
dah, err := da.NewDataAvailabilityHeader(square)
require.NoError(t, err)
eh.DAH = &dah
eh.RawHeader.DataHash = dah.Hash()
return eh, square
Expand Down
7 changes: 5 additions & 2 deletions nodebuilder/share/constructors.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ func newModule(getter share.Getter, avail share.Availability) Module {
// ensureEmptyCARExists adds an empty EDS to the provided EDS store.
func ensureEmptyCARExists(ctx context.Context, store *eds.Store) error {
emptyEDS := share.EmptyExtendedDataSquare()
emptyDAH := da.NewDataAvailabilityHeader(emptyEDS)
emptyDAH, err := da.NewDataAvailabilityHeader(emptyEDS)
if err != nil {
return err
}

err := store.Put(ctx, emptyDAH.Hash(), emptyEDS)
err = store.Put(ctx, emptyDAH.Hash(), emptyEDS)
if errors.Is(err, dagstore.ErrShardExists) {
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion nodebuilder/share/share_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func Test_EmptyCARExists(t *testing.T) {
require.NoError(t, err)

eds := share.EmptyExtendedDataSquare()
dah := da.NewDataAvailabilityHeader(eds)
dah, err := da.NewDataAvailabilityHeader(eds)
require.NoError(t, err)

// add empty EDS to store
err = ensureEmptyCARExists(ctx, edsStore)
Expand Down
6 changes: 3 additions & 3 deletions nodebuilder/tests/swamp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ type Config struct {
// 100ms
func DefaultConfig() *Config {
cfg := core.DefaultTestConfig()
// target height duration lower than this tend to be flakier
cfg.Tendermint.Consensus.TargetHeightDuration = 200 * time.Millisecond
// timeout commit lower than this tend to be flakier
cfg.Tendermint.Consensus.TimeoutCommit = 200 * time.Millisecond
return &Config{
cfg,
}
Expand All @@ -31,7 +31,7 @@ func WithBlockTime(t time.Duration) Option {
// for empty block
c.Tendermint.Consensus.CreateEmptyBlocksInterval = t
// for filled block
c.Tendermint.Consensus.TargetHeightDuration = t
c.Tendermint.Consensus.TimeoutCommit = t
c.Tendermint.Consensus.SkipTimeoutCommit = false
}
}
3 changes: 2 additions & 1 deletion share/availability/light/availability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ func TestGetShares(t *testing.T) {

eds, err := getter.GetEDS(ctx, dah)
require.NoError(t, err)
gotDAH := da.NewDataAvailabilityHeader(eds)
gotDAH, err := da.NewDataAvailabilityHeader(eds)
require.NoError(t, err)

require.True(t, dah.Equals(&gotDAH))
}
Expand Down
3 changes: 2 additions & 1 deletion share/availability/test/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ func RandFillBS(t *testing.T, n int, bServ blockservice.BlockService) *share.Roo
func FillBS(t *testing.T, bServ blockservice.BlockService, shares []share.Share) *share.Root {
eds, err := ipld.AddShares(context.TODO(), shares, bServ)
require.NoError(t, err)
dah := da.NewDataAvailabilityHeader(eds)
dah, err := da.NewDataAvailabilityHeader(eds)
require.NoError(t, err)
return &dah
}

Expand Down
8 changes: 5 additions & 3 deletions share/eds/byzantine/bad_encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ func TestBadEncodingFraudProof(t *testing.T) {
bServ := mdutils.Bserv()

square := edstest.RandByzantineEDS(t, 16)
dah := da.NewDataAvailabilityHeader(square)
err := ipld.ImportEDS(ctx, square, bServ)
dah, err := da.NewDataAvailabilityHeader(square)
require.NoError(t, err)
err = ipld.ImportEDS(ctx, square, bServ)
require.NoError(t, err)

var errRsmt2d *rsmt2d.ErrByzantineData
Expand Down Expand Up @@ -55,7 +56,8 @@ func TestIncorrectBadEncodingFraudProof(t *testing.T) {
eds, err := ipld.AddShares(ctx, shares, bServ)
require.NoError(t, err)

dah := da.NewDataAvailabilityHeader(eds)
dah, err := da.NewDataAvailabilityHeader(eds)
require.NoError(t, err)

// get an arbitrary row
row := uint(squareSize / 2)
Expand Down
6 changes: 4 additions & 2 deletions share/eds/byzantine/share_proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func TestGetProof(t *testing.T) {
in, err := ipld.AddShares(ctx, shares, bServ)
require.NoError(t, err)

dah := da.NewDataAvailabilityHeader(in)
dah, err := da.NewDataAvailabilityHeader(in)
require.NoError(t, err)
var tests = []struct {
roots [][]byte
}{
Expand Down Expand Up @@ -63,7 +64,8 @@ func TestGetProofs(t *testing.T) {
in, err := ipld.AddShares(ctx, shares, bServ)
require.NoError(t, err)

dah := da.NewDataAvailabilityHeader(in)
dah, err := da.NewDataAvailabilityHeader(in)
require.NoError(t, err)
for _, root := range dah.ColumnRoots {
rootCid := ipld.MustCidFromNamespacedSha256(root)
data := make([][]byte, 0, in.Width())
Expand Down
24 changes: 20 additions & 4 deletions share/eds/eds.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ func initializeWriter(ctx context.Context, eds *rsmt2d.ExtendedDataSquare, w io.
return nil, fmt.Errorf("recomputing data square: %w", err)
}
// compute roots
eds.RowRoots()
_, err = eds.RowRoots()
if err != nil {
return nil, fmt.Errorf("computing row roots: %w", err)
}
// commit the batch to DAG
err = batchAdder.Commit()
if err != nil {
Expand Down Expand Up @@ -231,8 +234,18 @@ func prependNamespace(quadrant int, shr share.Share) []byte {

// rootsToCids converts the EDS's Row and Column roots to CIDs.
func rootsToCids(eds *rsmt2d.ExtendedDataSquare) ([]cid.Cid, error) {
var err error
roots := append(eds.RowRoots(), eds.ColRoots()...)
rowRoots, err := eds.RowRoots()
if err != nil {
return nil, err
}
colRoots, err := eds.ColRoots()
if err != nil {
return nil, err
}

roots := make([][]byte, 0, len(rowRoots)+len(colRoots))
roots = append(roots, rowRoots...)
roots = append(roots, colRoots...)
adlerjohn marked this conversation as resolved.
Show resolved Hide resolved
rootCids := make([]cid.Cid, len(roots))
for i, r := range roots {
rootCids[i], err = ipld.CidFromNamespacedSha256(r)
Expand Down Expand Up @@ -283,7 +296,10 @@ func ReadEDS(ctx context.Context, r io.Reader, root share.DataHash) (eds *rsmt2d
return nil, fmt.Errorf("share: computing eds: %w", err)
}

newDah := da.NewDataAvailabilityHeader(eds)
newDah, err := da.NewDataAvailabilityHeader(eds)
if err != nil {
return nil, err
}
if !bytes.Equal(newDah.Hash(), root) {
return nil, fmt.Errorf(
"share: content integrity mismatch: imported root %s doesn't match expected root %s",
Expand Down
36 changes: 27 additions & 9 deletions share/eds/eds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,25 @@ func TestInnerNodeBatchSize(t *testing.T) {

func TestReadWriteRoundtrip(t *testing.T) {
eds := writeRandomEDS(t)
dah := da.NewDataAvailabilityHeader(eds)
dah, err := da.NewDataAvailabilityHeader(eds)
require.NoError(t, err)
f := openWrittenEDS(t)
defer f.Close()

loaded, err := ReadEDS(context.Background(), f, dah.Hash())
require.NoError(t, err, "error reading EDS from file")
require.Equal(t, eds.RowRoots(), loaded.RowRoots())
require.Equal(t, eds.ColRoots(), loaded.ColRoots())

rowRoots, err := eds.RowRoots()
require.NoError(t, err)
loadedRowRoots, err := loaded.RowRoots()
require.NoError(t, err)
require.Equal(t, rowRoots, loadedRowRoots)

colRoots, err := eds.ColRoots()
require.NoError(t, err)
loadedColRoots, err := loaded.ColRoots()
require.NoError(t, err)
require.Equal(t, colRoots, loadedColRoots)
}

func TestReadEDS(t *testing.T) {
Expand All @@ -187,17 +198,22 @@ func TestReadEDS(t *testing.T) {

loaded, err := ReadEDS(context.Background(), f, dah.Hash())
require.NoError(t, err, "error reading EDS from file")
require.Equal(t, dah.RowRoots, loaded.RowRoots())
require.Equal(t, dah.ColumnRoots, loaded.ColRoots())
rowRoots, err := loaded.RowRoots()
require.NoError(t, err)
require.Equal(t, dah.RowRoots, rowRoots)
colRoots, err := loaded.ColRoots()
require.NoError(t, err)
require.Equal(t, dah.ColumnRoots, colRoots)
}

func TestReadEDSContentIntegrityMismatch(t *testing.T) {
writeRandomEDS(t)
dah := da.NewDataAvailabilityHeader(edstest.RandEDS(t, 4))
dah, err := da.NewDataAvailabilityHeader(edstest.RandEDS(t, 4))
require.NoError(t, err)
f := openWrittenEDS(t)
defer f.Close()

_, err := ReadEDS(context.Background(), f, dah.Hash())
_, err = ReadEDS(context.Background(), f, dah.Hash())
require.ErrorContains(t, err, "share: content integrity mismatch: imported root")
}

Expand All @@ -209,7 +225,8 @@ func BenchmarkReadWriteEDS(b *testing.B) {
b.Cleanup(cancel)
for originalDataWidth := 4; originalDataWidth <= 64; originalDataWidth *= 2 {
eds := edstest.RandEDS(b, originalDataWidth)
dah := da.NewDataAvailabilityHeader(eds)
dah, err := da.NewDataAvailabilityHeader(eds)
require.NoError(b, err)
b.Run(fmt.Sprintf("Writing %dx%d", originalDataWidth, originalDataWidth), func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
Expand Down Expand Up @@ -280,7 +297,8 @@ func createTestData(t *testing.T, testDir string) { //nolint:unused
err = WriteEDS(ctx, eds, f)
require.NoError(t, err, "writing EDS to file")
f.Close()
dah := da.NewDataAvailabilityHeader(eds)
dah, err := da.NewDataAvailabilityHeader(eds)
require.NoError(t, err)

header, err := json.MarshalIndent(dah, "", "")
require.NoError(t, err, "marshaling example root")
Expand Down
14 changes: 12 additions & 2 deletions share/eds/ods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ func TestODSReaderReconstruction(t *testing.T) {
// reconstruct EDS from ODSReader
loaded, err := ReadEDS(ctx, odsR, dah.Hash())
assert.NoError(t, err)
require.Equal(t, eds.RowRoots(), loaded.RowRoots())
require.Equal(t, eds.ColRoots(), loaded.ColRoots())

rowRoots, err := eds.RowRoots()
require.NoError(t, err)
loadedRowRoots, err := loaded.RowRoots()
require.NoError(t, err)
require.Equal(t, rowRoots, loadedRowRoots)

colRoots, err := eds.ColRoots()
require.NoError(t, err)
loadedColRoots, err := loaded.ColRoots()
require.NoError(t, err)
require.Equal(t, colRoots, loadedColRoots)
}
8 changes: 5 additions & 3 deletions share/eds/retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (r *Retriever) newSession(ctx context.Context, dah *da.DataAvailabilityHead
return &tree
}

square, err := rsmt2d.ImportExtendedDataSquare(make([][]byte, size*size), share.DefaultRSMT2DCodec(), treeFn)
square, err := rsmt2d.NewExtendedDataSquare(share.DefaultRSMT2DCodec(), treeFn, uint(size), share.Size)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -283,10 +283,12 @@ func (rs *retrievalSession) doRequest(ctx context.Context, q *quadrant) {
if rs.isReconstructed() {
return
}
if rs.square.GetCell(uint(x), uint(y)) != nil {
if err := rs.square.SetCell(uint(x), uint(y), share); err != nil {
// safe to ignore as:
// * share size already verified
// * the same share might come from either Row or Col
return
}
rs.square.SetCell(uint(x), uint(y), share)
// if we have >= 1/4 of the square we can start trying to Reconstruct
// TODO(@Wondertan): This is not an ideal way to know when to start
// reconstruction and can cause idle reconstruction tries in some cases,
Expand Down
Loading
Loading