From 4777a6b5f239fb5d8b10f6838b986a1eb6b89dc5 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Mon, 21 Jun 2021 14:27:22 +0300 Subject: [PATCH 01/25] refactor(p2p/ipld): move-in DAHeader Share --- p2p/ipld/header.go | 146 ++++++++++++++++++++++++++++++++++++++++ p2p/ipld/header_test.go | 17 +++++ p2p/ipld/share.go | 51 ++++++++++++++ 3 files changed, 214 insertions(+) create mode 100644 p2p/ipld/header.go create mode 100644 p2p/ipld/header_test.go create mode 100644 p2p/ipld/share.go diff --git a/p2p/ipld/header.go b/p2p/ipld/header.go new file mode 100644 index 0000000000..67f4530a33 --- /dev/null +++ b/p2p/ipld/header.go @@ -0,0 +1,146 @@ +package ipld + +import ( + "bytes" + "errors" + "fmt" + + "github.com/lazyledger/nmt/namespace" + "github.com/lazyledger/rsmt2d" + + "github.com/lazyledger/lazyledger-core/crypto/merkle" + "github.com/lazyledger/lazyledger-core/proto/tendermint/types" +) + +// DataAvailabilityHeader (DAHeader) contains the row and column roots of the erasure +// coded version of the data in Block.Data. +// Therefor the original Block.Data is arranged in a +// k × k matrix, which is then "extended" to a +// 2k × 2k matrix applying multiple times Reed-Solomon encoding. +// For details see Section 5.2: https://arxiv.org/abs/1809.09044 +// or the LazyLedger specification: +// https://github.com/lazyledger/lazyledger-specs/blob/master/specs/data_structures.md#availabledataheader +// Note that currently we list row and column roots in separate fields +// (different from the spec). +type DataAvailabilityHeader struct { + // RowRoot_j = root((M_{j,1} || M_{j,2} || ... || M_{j,2k} )) + RowsRoots NmtRoots `json:"row_roots"` + // ColumnRoot_j = root((M_{1,j} || M_{2,j} || ... || M_{2k,j} )) + ColumnRoots NmtRoots `json:"column_roots"` + // cached result of Hash() not to be recomputed + hash []byte +} + +// TODO(Wondertan): Should return single Hash/CID instead +func MakeDataHeader(eds *rsmt2d.ExtendedDataSquare) *DataAvailabilityHeader { + // generate the row and col roots using the EDS and nmt wrapper + rowRoots, colRoots := eds.RowRoots(), eds.ColumnRoots() + // create DAH + dah := &DataAvailabilityHeader{ + RowsRoots: make([]namespace.IntervalDigest, eds.Width()), + ColumnRoots: make([]namespace.IntervalDigest, eds.Width()), + } + // todo(evan): remove interval digests + // convert the roots to interval digests + for i := 0; i < len(rowRoots); i++ { + rowRoot, err := namespace.IntervalDigestFromBytes(NamespaceSize, rowRoots[i]) + if err != nil { + panic(err) + } + colRoot, err := namespace.IntervalDigestFromBytes(NamespaceSize, colRoots[i]) + if err != nil { + panic(err) + } + dah.RowsRoots[i] = rowRoot + dah.ColumnRoots[i] = colRoot + } + return dah +} + +type NmtRoots []namespace.IntervalDigest + +func (roots NmtRoots) Bytes() [][]byte { + res := make([][]byte, len(roots)) + for i := 0; i < len(roots); i++ { + res[i] = roots[i].Bytes() + } + return res +} + +func NmtRootsFromBytes(in [][]byte) (roots NmtRoots, err error) { + roots = make([]namespace.IntervalDigest, len(in)) + for i := 0; i < len(in); i++ { + roots[i], err = namespace.IntervalDigestFromBytes(NamespaceSize, in[i]) + if err != nil { + return roots, err + } + } + return +} + +// String returns hex representation of merkle hash of the DAHeader. +func (dah *DataAvailabilityHeader) String() string { + if dah == nil { + return "" + } + return fmt.Sprintf("%X", dah.Hash()) +} + +// Equals checks equality of two DAHeaders. +func (dah *DataAvailabilityHeader) Equals(to *DataAvailabilityHeader) bool { + return bytes.Equal(dah.Hash(), to.Hash()) +} + +// Hash computes and caches the merkle root of the row and column roots. +func (dah *DataAvailabilityHeader) Hash() []byte { + if dah == nil { + return merkle.HashFromByteSlices(nil) + } + if len(dah.hash) != 0 { + return dah.hash + } + + colsCount := len(dah.ColumnRoots) + rowsCount := len(dah.RowsRoots) + slices := make([][]byte, colsCount+rowsCount) + for i, rowRoot := range dah.RowsRoots { + slices[i] = rowRoot.Bytes() + } + for i, colRoot := range dah.ColumnRoots { + slices[i+colsCount] = colRoot.Bytes() + } + // The single data root is computed using a simple binary merkle tree. + // Effectively being root(rowRoots || columnRoots): + dah.hash = merkle.HashFromByteSlices(slices) + return dah.hash +} + +func (dah *DataAvailabilityHeader) ToProto() (*types.DataAvailabilityHeader, error) { + if dah == nil { + return nil, errors.New("nil DataAvailabilityHeader") + } + + dahp := new(types.DataAvailabilityHeader) + dahp.RowRoots = dah.RowsRoots.Bytes() + dahp.ColumnRoots = dah.ColumnRoots.Bytes() + return dahp, nil +} + +func DataAvailabilityHeaderFromProto(dahp *types.DataAvailabilityHeader) (dah *DataAvailabilityHeader, err error) { + if dahp == nil { + return nil, errors.New("nil DataAvailabilityHeader") + } + + dah = new(DataAvailabilityHeader) + dah.RowsRoots, err = NmtRootsFromBytes(dahp.RowRoots) + if err != nil { + return + } + + dah.ColumnRoots, err = NmtRootsFromBytes(dahp.ColumnRoots) + if err != nil { + return + } + + return +} diff --git a/p2p/ipld/header_test.go b/p2p/ipld/header_test.go new file mode 100644 index 0000000000..a925221349 --- /dev/null +++ b/p2p/ipld/header_test.go @@ -0,0 +1,17 @@ +package ipld + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// This follows RFC-6962, i.e. `echo -n '' | sha256sum` +var emptyBytes = []byte{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, + 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, + 0x78, 0x52, 0xb8, 0x55} + +func TestNilDataAvailabilityHeaderHashDoesntCrash(t *testing.T) { + assert.Equal(t, emptyBytes, (*DataAvailabilityHeader)(nil).Hash()) + assert.Equal(t, emptyBytes, new(DataAvailabilityHeader).Hash()) +} diff --git a/p2p/ipld/share.go b/p2p/ipld/share.go new file mode 100644 index 0000000000..65ada35b20 --- /dev/null +++ b/p2p/ipld/share.go @@ -0,0 +1,51 @@ +package ipld + +import "github.com/lazyledger/nmt/namespace" + +const ( + // MaxSquareSize is currently the maximum size supported for unerasured data in rsmt2d.ExtendedDataSquare. + MaxSquareSize = 128 + // ShareSize system wide default size for data shares. + ShareSize = 256 + // NamespaceSize is a system wide size for NMT namespaces. + // TODO(Wondertan): Should be part of IPLD/NMT plugin + NamespaceSize = 8 +) + +// TODO(Wondertan): +// Currently Share prepends namespace bytes while NamespaceShare just takes a copy of namespace +// separating it in separate field. This is really confusing for newcomers and even for those who worked with code, +// but had some time off of it. Instead, we shouldn't copy(1) and likely have only one type - NamespacedShare, as we +// don't support shares without namespace. + +// Share contains the raw share data without the corresponding namespace. +type Share []byte + +// TODO(Wondertan): Consider using alias to namespace.PrefixedData instead +// NamespacedShare extends a Share with the corresponding namespace. +type NamespacedShare struct { + Share + ID namespace.ID +} + +func (n NamespacedShare) NamespaceID() namespace.ID { + return n.ID +} + +func (n NamespacedShare) Data() []byte { + return n.Share +} + +// NamespacedShares is just a list of NamespacedShare elements. +// It can be used to extract the raw shares. +type NamespacedShares []NamespacedShare + +// Raw returns the raw shares that can be fed into the erasure coding +// library (e.g. rsmt2d). +func (ns NamespacedShares) Raw() [][]byte { + res := make([][]byte, len(ns)) + for i, nsh := range ns { + res[i] = nsh.Share + } + return res +} From 8bbbf91dcece2836eea235d956ee805a3ad82a45 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Mon, 21 Jun 2021 14:30:09 +0300 Subject: [PATCH 02/25] refactor(p2p/ipld): rework PutBlock API to PutData --- p2p/ipld/read.go | 54 ++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/p2p/ipld/read.go b/p2p/ipld/read.go index 45fa5d4986..ef3e3155c0 100644 --- a/p2p/ipld/read.go +++ b/p2p/ipld/read.go @@ -2,6 +2,7 @@ package ipld import ( "context" + "errors" "fmt" "math/rand" @@ -11,67 +12,46 @@ import ( "github.com/lazyledger/lazyledger-core/ipfs/plugin" "github.com/lazyledger/lazyledger-core/p2p/ipld/wrapper" - "github.com/lazyledger/lazyledger-core/types" - "github.com/lazyledger/lazyledger-core/types/consts" ) -const baseErrorMsg = "failure to retrieve block data:" +var ErrRetrieveTimeout = errors.New("retrieve data timeout") -var ErrEncounteredTooManyErrors = fmt.Errorf("%s %s", baseErrorMsg, "encountered too many errors") -var ErrTimeout = fmt.Errorf("%s %s", baseErrorMsg, "timeout") - -// RetrieveBlockData asynchronously fetches block data using the minimum number +// RetrieveData asynchronously fetches block data using the minimum number // of requests to IPFS. It fails if one of the random samples sampled is not available. -func RetrieveBlockData( +func RetrieveData( ctx context.Context, - dah *types.DataAvailabilityHeader, + dah *DataAvailabilityHeader, dag ipld.NodeGetter, codec rsmt2d.Codec, -) (types.Data, error) { +) (*rsmt2d.ExtendedDataSquare, error) { edsWidth := len(dah.RowsRoots) sc := newshareCounter(ctx, uint32(edsWidth)) - // convert the row and col roots into Cids rowRoots := dah.RowsRoots.Bytes() colRoots := dah.ColumnRoots.Bytes() - // sample 1/4 of the total extended square by sampling half of the leaves in // half of the rows for _, row := range uniqueRandNumbers(edsWidth/2, edsWidth) { for _, col := range uniqueRandNumbers(edsWidth/2, edsWidth) { rootCid, err := plugin.CidFromNamespacedSha256(rowRoots[row]) if err != nil { - return types.Data{}, err + return nil, err } go sc.retrieveShare(rootCid, true, row, col, dag) } } - // wait until enough data has been collected, too many errors encountered, // or the timeout is reached err := sc.wait() if err != nil { - return types.Data{}, err + return nil, err } - // flatten the square flattened := sc.flatten() - - tree := wrapper.NewErasuredNamespacedMerkleTree(uint64(edsWidth) / 2) - // repair the square - eds, err := rsmt2d.RepairExtendedDataSquare(rowRoots, colRoots, flattened, codec, tree.Constructor) - if err != nil { - return types.Data{}, err - } - - blockData, err := types.DataFromSquare(eds) - if err != nil { - return types.Data{}, err - } - - return blockData, nil + tree := wrapper.NewErasuredNamespacedMerkleTree(uint64(edsWidth) / 2) + return rsmt2d.RepairExtendedDataSquare(rowRoots, colRoots, flattened, codec, tree.Constructor) } // uniqueRandNumbers generates count unique random numbers with a max of max @@ -136,7 +116,7 @@ func newshareCounter(parentCtx context.Context, edsWidth uint32) *shareCounter { shares: make(map[index][]byte), edsWidth: edsWidth, minSharesNeeded: minSharesNeeded, - shareChan: make(chan indexedShare, 1), + shareChan: make(chan indexedShare, 512), errc: make(chan error, 1), ctx: ctx, cancel: cancel, @@ -159,7 +139,7 @@ func (sc *shareCounter) retrieveShare( } } - if len(data) < consts.ShareSize { + if len(data) < ShareSize { return } @@ -173,8 +153,7 @@ func (sc *shareCounter) retrieveShare( select { case <-sc.ctx.Done(): - default: - sc.shareChan <- indexedShare{data: data[consts.NamespaceSize:], index: index{row: rowIdx, col: colIdx}} + case sc.shareChan <- indexedShare{data: data[NamespaceSize:], index: index{row: rowIdx, col: colIdx}}: } } @@ -186,8 +165,11 @@ func (sc *shareCounter) wait() error { for { select { case <-sc.ctx.Done(): - return ErrTimeout - + err := sc.ctx.Err() + if err == context.DeadlineExceeded { + return ErrRetrieveTimeout + } + return err case share := <-sc.shareChan: _, has := sc.shares[share.index] // add iff it does not already exists From 0077eaac088495804b32519f3a7de151b09c4e50 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Mon, 21 Jun 2021 14:31:19 +0300 Subject: [PATCH 03/25] refactor(p2p/ipld): rework RetrieveData to the latest changes --- p2p/ipld/write.go | 63 ++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 36 deletions(-) diff --git a/p2p/ipld/write.go b/p2p/ipld/write.go index 44fa5dc11b..f9982d32a2 100644 --- a/p2p/ipld/write.go +++ b/p2p/ipld/write.go @@ -18,57 +18,47 @@ import ( "github.com/lazyledger/lazyledger-core/libs/log" "github.com/lazyledger/lazyledger-core/libs/sync" "github.com/lazyledger/lazyledger-core/p2p/ipld/wrapper" - "github.com/lazyledger/lazyledger-core/types" ) -// PutBlock posts and pins erasured block data to IPFS using the provided -// ipld.NodeAdder. Note: the erasured data is currently recomputed -// TODO this craves for refactor -func PutBlock( - ctx context.Context, - adder ipld.NodeAdder, - block *types.Block, - croute routing.ContentRouting, - logger log.Logger, -) error { - // recompute the shares - namespacedShares, _ := block.Data.ComputeShares() - shares := namespacedShares.RawShares() +// TODO(Wondertan) Improve API - // don't do anything if there is no data to put on IPFS +// PutData posts erasured block data to IPFS using the provided ipld.NodeAdder. +func PutData(ctx context.Context, shares NamespacedShares, adder ipld.NodeAdder) (*rsmt2d.ExtendedDataSquare, error) { if len(shares) == 0 { - return nil + return nil, fmt.Errorf("empty data") // empty block is not an empty Data } - // create nmt adder wrapping batch adder batchAdder := NewNmtNodeAdder(ctx, ipld.NewBatch(ctx, adder)) - // create the nmt wrapper to generate row and col commitments squareSize := uint32(math.Sqrt(float64(len(shares)))) tree := wrapper.NewErasuredNamespacedMerkleTree(uint64(squareSize), nmt.NodeVisitor(batchAdder.Visit)) - // recompute the eds - eds, err := rsmt2d.ComputeExtendedDataSquare(shares, rsmt2d.NewRSGF8Codec(), tree.Constructor) + eds, err := rsmt2d.ComputeExtendedDataSquare(shares.Raw(), rsmt2d.NewRSGF8Codec(), tree.Constructor) if err != nil { - return fmt.Errorf("failure to recompute the extended data square: %w", err) + return nil, fmt.Errorf("failure to recompute the extended data square: %w", err) } + // compute roots + eds.ColumnRoots() + // commit the batch to ipfs + return eds, batchAdder.Commit() +} + +func ProvideData( + ctx context.Context, + dah *DataAvailabilityHeader, + croute routing.ContentRouting, + logger log.Logger) error { // get row and col roots to be provided // this also triggers adding data to DAG - prov := newProvider(ctx, croute, int32(squareSize*4), logger.With("height", block.Height)) - for _, root := range eds.RowRoots() { - prov.Provide(plugin.MustCidFromNamespacedSha256(root)) + prov := newProvider(ctx, croute, int32(len(dah.RowsRoots)+len(dah.ColumnRoots)), logger) + for _, root := range dah.RowsRoots { + prov.Provide(plugin.MustCidFromNamespacedSha256(root.Bytes())) } - for _, root := range eds.ColumnRoots() { - prov.Provide(plugin.MustCidFromNamespacedSha256(root)) - } - // commit the batch to ipfs - err = batchAdder.Commit() - if err != nil { - return err + for _, root := range dah.ColumnRoots { + prov.Provide(plugin.MustCidFromNamespacedSha256(root.Bytes())) } // wait until we provided all the roots if requested - <-prov.Done() - return prov.Err() + return prov.Done() } var provideWorkers = 32 @@ -112,8 +102,9 @@ func (p *provider) Provide(id cid.Cid) { } } -func (p *provider) Done() <-chan struct{} { - return p.done +func (p *provider) Done() error { + <-p.done + return p.Err() } func (p *provider) Err() error { @@ -139,7 +130,7 @@ func (p *provider) worker() { p.errLk.Unlock() } - p.log.Error("failed to provide to DHT", "err", err.Error()) + p.log.Error("Failed to provide to DHT", "err", err.Error()) } p.provided() From d1f6619b66ba38c6cf0ed0b36d534a8d7219f740 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Mon, 21 Jun 2021 14:31:46 +0300 Subject: [PATCH 04/25] refactor(p2p/ipld): rework ValidateAvailability to the latest changes --- p2p/ipld/validate.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/p2p/ipld/validate.go b/p2p/ipld/validate.go index 94cdab066f..8f278b2644 100644 --- a/p2p/ipld/validate.go +++ b/p2p/ipld/validate.go @@ -7,9 +7,6 @@ import ( "time" ipld "github.com/ipfs/go-ipld-format" - "github.com/lazyledger/nmt/namespace" - - "github.com/lazyledger/lazyledger-core/types" ) // ValidationTimeout specifies timeout for DA validation during which data have to be found on the network, @@ -28,9 +25,9 @@ var ErrValidationFailed = errors.New("validation failed") func ValidateAvailability( ctx context.Context, dag ipld.NodeGetter, - dah *types.DataAvailabilityHeader, + dah *DataAvailabilityHeader, numSamples int, - onLeafValidity func(namespace.PrefixedData8), + onLeafValidity func(NamespacedShare), ) error { ctx, cancel := context.WithTimeout(ctx, ValidationTimeout) defer cancel() @@ -75,7 +72,7 @@ func ValidateAvailability( // the fact that we read the data, already gives us Merkle proof, // thus the data availability is successfully validated :) - onLeafValidity(r.data) + onLeafValidity(NamespacedShare{ID: r.data[:NamespaceSize], Share: r.data}) case <-ctx.Done(): err := ctx.Err() if err == context.DeadlineExceeded { From f6398556ab8d98fd9c208bc7eb08f5c3949dcd4d Mon Sep 17 00:00:00 2001 From: Wondertan Date: Mon, 21 Jun 2021 14:33:28 +0300 Subject: [PATCH 05/25] refactor(p2p/ipld): rework tests and test utilities to the latest API changes --- go.mod | 2 + ipfs/plugin/nmt.go | 2 +- p2p/ipld/net_test.go | 85 ++++++---- p2p/ipld/read_test.go | 192 ++++----------------- p2p/ipld/sample.go | 3 +- p2p/ipld/testing.go | 87 ++++++++++ p2p/ipld/validate_test.go | 25 +-- p2p/ipld/wrapper/nmt_wrapper.go | 2 + p2p/ipld/write_test.go | 284 ++++++++++++++------------------ 9 files changed, 308 insertions(+), 374 deletions(-) create mode 100644 p2p/ipld/testing.go diff --git a/go.mod b/go.mod index 9d61575803..596d3c66f3 100644 --- a/go.mod +++ b/go.mod @@ -56,6 +56,8 @@ require ( github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 + golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect + google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4 // indirect google.golang.org/grpc v1.38.0 ) diff --git a/ipfs/plugin/nmt.go b/ipfs/plugin/nmt.go index f42d15bf6b..48b962189b 100644 --- a/ipfs/plugin/nmt.go +++ b/ipfs/plugin/nmt.go @@ -380,7 +380,7 @@ func (l nmtLeafNode) Size() (uint64, error) { return 0, nil } -// CidFromNamespacedSha256 uses a hash from an nmt tree to create a cide +// CidFromNamespacedSha256 uses a hash from an nmt tree to create a CID func CidFromNamespacedSha256(namespacedHash []byte) (cid.Cid, error) { if got, want := len(namespacedHash), nmtHashSize; got != want { return cid.Cid{}, fmt.Errorf("invalid namespaced hash length, got: %v, want: %v", got, want) diff --git a/p2p/ipld/net_test.go b/p2p/ipld/net_test.go index 4e20652bf2..1019ccc738 100644 --- a/p2p/ipld/net_test.go +++ b/p2p/ipld/net_test.go @@ -18,11 +18,9 @@ import ( mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "golang.org/x/sync/errgroup" - "github.com/lazyledger/lazyledger-core/ipfs/plugin" "github.com/lazyledger/lazyledger-core/libs/log" - "github.com/lazyledger/lazyledger-core/types" - "github.com/lazyledger/lazyledger-core/types/consts" ) func TestDiscovery(t *testing.T) { @@ -32,17 +30,8 @@ func TestDiscovery(t *testing.T) { dhts := dhtNet(ctx, t, 2) dht1, dht2 := dhts[0], dhts[0] - data := generateRandomBlockData(64, consts.MsgShareSize-2) - b := &types.Block{ - Data: data, - LastCommit: &types.Commit{}, - } - b.Hash() - - id, err := plugin.CidFromNamespacedSha256(b.DataAvailabilityHeader.RowsRoots[0].Bytes()) - require.NoError(t, err) - - err = dht1.Provide(ctx, id, false) + id := RandNamespacedCID(t) + err := dht1.Provide(ctx, id, false) require.NoError(t, err) prvs, err := dht2.FindProviders(ctx, id) @@ -50,38 +39,70 @@ func TestDiscovery(t *testing.T) { assert.Equal(t, dht1.PeerID(), prvs[0].ID, "peer not found") } -func TestWriteDiscoveryReadData(t *testing.T) { - logger := log.TestingLogger() +func TestWriteDiscoveryValidateReadData(t *testing.T) { + const ( + netSize = 4 + edsSize = 4 // TODO(Wondertan): Increase size once race issue is fixed + samples = 16 + ) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() - dags, dhts := dagNet(ctx, t, 5) - blocks := make([]*types.Block, len(dags)) - for i, dag := range dags { - data := generateRandomBlockData(64, consts.MsgShareSize-2) - b := &types.Block{ - Data: data, - LastCommit: &types.Commit{}, - } - b.Hash() - blocks[i] = b + logger := log.TestingLogger() + dags, dhts := dagNet(ctx, t, netSize) - err := PutBlock(ctx, dag, blocks[i], dhts[i], logger) - require.NoError(t, err) + gp, execCtx := errgroup.WithContext(ctx) + eds := make([]*rsmt2d.ExtendedDataSquare, len(dags)) + for i, dag := range dags { + i, dag := i, dag + gp.Go(func() (err error) { + eds[i], err = PutData(execCtx, RandNamespacedShares(t, edsSize*edsSize), dag) + if err != nil { + return + } + return ProvideData(execCtx, MakeDataHeader(eds[i]), dhts[i], logger) + }) } + err := gp.Wait() + require.NoError(t, err) + gp, execCtx = errgroup.WithContext(ctx) for i, dag := range dags { if i == len(dags)-1 { i = 0 } + i, dag := i, dag + gp.Go(func() error { + exp := eds[i+1] + return ValidateAvailability(execCtx, dag, MakeDataHeader(exp), samples, func(NamespacedShare) {}) + }) + } + err = gp.Wait() + require.NoError(t, err) - exp := blocks[i+1] - actual, err := RetrieveBlockData(ctx, &exp.DataAvailabilityHeader, dag, rsmt2d.NewRSGF8Codec()) - assert.NoError(t, err) - assert.EqualValues(t, exp.Data.Txs, actual.Txs, "blocks are not equal") + gp, execCtx = errgroup.WithContext(ctx) + for i, dag := range dags { + if i == len(dags)-1 { + i = 0 + } + i, dag := i, dag + gp.Go(func() error { + exp := eds[i+1] + got, err := RetrieveData(execCtx, MakeDataHeader(exp), dag, rsmt2d.NewRSGF8Codec()) + if err != nil { + return err + } + assert.True(t, EqualEDS(exp, got)) + return nil + }) } + err = gp.Wait() + require.NoError(t, err) } +// TODO(Wondertan): Consider making utilities below as public + func dagNet(ctx context.Context, t *testing.T, num int) ([]ipld.DAGService, []*dht.IpfsDHT) { net := mocknet.New(ctx) _, medium := dagNode(ctx, t, net) diff --git a/p2p/ipld/read_test.go b/p2p/ipld/read_test.go index 690caf321c..8dc52d5107 100644 --- a/p2p/ipld/read_test.go +++ b/p2p/ipld/read_test.go @@ -4,27 +4,21 @@ import ( "bytes" "context" "crypto/sha256" - "fmt" "math" "math/rand" - "sort" "testing" "time" + "github.com/ipfs/go-cid" format "github.com/ipfs/go-ipld-format" mdutils "github.com/ipfs/go-merkledag/test" "github.com/lazyledger/nmt" - "github.com/lazyledger/nmt/namespace" "github.com/lazyledger/rsmt2d" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/lazyledger/lazyledger-core/ipfs" "github.com/lazyledger/lazyledger-core/ipfs/plugin" - "github.com/lazyledger/lazyledger-core/libs/log" "github.com/lazyledger/lazyledger-core/p2p/ipld/wrapper" - "github.com/lazyledger/lazyledger-core/types" - "github.com/lazyledger/lazyledger-core/types/consts" ) func TestGetLeafData(t *testing.T) { @@ -32,23 +26,19 @@ func TestGetLeafData(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() + dag := mdutils.Mock() - // generate random data for the nmt - data := generateRandNamespacedRawData(leaves, consts.NamespaceSize, consts.ShareSize) + // generate random shares for the nmt + shares := RandNamespacedShares(t, leaves) // create a random tree - dag := mdutils.Mock() - root, err := getNmtRoot(ctx, dag, data) - require.NoError(t, err) - - // compute the root and create a cid for the root hash - rootCid, err := plugin.CidFromNamespacedSha256(root.Bytes()) + root, err := getNmtRoot(ctx, dag, shares.Raw()) require.NoError(t, err) - for i, leaf := range data { - data, err := GetLeafData(ctx, rootCid, uint32(i), uint32(len(data)), dag) - assert.NoError(t, err) - assert.Equal(t, leaf, data) + for i, leaf := range shares { + data, err := GetLeafData(ctx, root, uint32(i), uint32(len(shares)), dag) + require.NoError(t, err) + assert.True(t, bytes.Equal(leaf.Share, data)) } } @@ -59,12 +49,12 @@ func TestBlockRecovery(t *testing.T) { extendedShareCount := extendedSquareWidth * extendedSquareWidth // generate test data - quarterShares := generateRandNamespacedRawData(shareCount, consts.NamespaceSize, consts.MsgShareSize) - allShares := generateRandNamespacedRawData(shareCount, consts.NamespaceSize, consts.MsgShareSize) + quarterShares := RandNamespacedShares(t, shareCount) + allShares := RandNamespacedShares(t, shareCount) testCases := []struct { name string - shares [][]byte + shares NamespacedShares expectErr bool errString string d int // number of shares to delete @@ -84,7 +74,7 @@ func TestBlockRecovery(t *testing.T) { tree := wrapper.NewErasuredNamespacedMerkleTree(squareSize) recoverTree := wrapper.NewErasuredNamespacedMerkleTree(squareSize) - eds, err := rsmt2d.ComputeExtendedDataSquare(tc.shares, rsmt2d.NewRSGF8Codec(), tree.Constructor) + eds, err := rsmt2d.ComputeExtendedDataSquare(tc.shares.Raw(), rsmt2d.NewRSGF8Codec(), tree.Constructor) require.NoError(t, err) // calculate roots using the first complete square @@ -116,21 +106,19 @@ func TestBlockRecovery(t *testing.T) { } func TestRetrieveBlockData(t *testing.T) { - logger := log.TestingLogger() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + dag := mdutils.Mock() + type test struct { name string squareSize int - expectErr bool - errStr string } tests := []test{ - {"Empty block", 1, false, ""}, - {"4 KB block", 4, false, ""}, - {"16 KB block", 8, false, ""}, - {"16 KB block timeout expected", 8, true, "not found"}, - {"max square size", consts.MaxSquareSize, false, ""}, + {"1x1(min)", 1}, + {"32x32(med)", 32}, + {"128x128(max)", MaxSquareSize}, } - for _, tc := range tests { // TODO(Wondertan): remove this if tc.squareSize > 8 { @@ -138,58 +126,18 @@ func TestRetrieveBlockData(t *testing.T) { } tc := tc - t.Run(fmt.Sprintf("%s size %d", tc.name, tc.squareSize), func(t *testing.T) { - ctx := context.Background() - dag := mdutils.Mock() - croute := ipfs.MockRouting() - - blockData := generateRandomBlockData(tc.squareSize*tc.squareSize, consts.MsgShareSize-2) - block := &types.Block{ - Data: blockData, - LastCommit: &types.Commit{}, - } - - // if an error is exected, don't put the block - if !tc.expectErr { - err := PutBlock(ctx, dag, block, croute, logger) - require.NoError(t, err) - } - - shareData, _ := blockData.ComputeShares() - rawData := shareData.RawShares() - - tree := wrapper.NewErasuredNamespacedMerkleTree(uint64(tc.squareSize)) - eds, err := rsmt2d.ComputeExtendedDataSquare(rawData, rsmt2d.NewRSGF8Codec(), tree.Constructor) + t.Run(tc.name, func(t *testing.T) { + shares := RandNamespacedShares(t, tc.squareSize*tc.squareSize) + in, err := PutData(ctx, shares, dag) require.NoError(t, err) - rawRowRoots := eds.RowRoots() - rawColRoots := eds.ColumnRoots() - rowRoots := rootsToDigests(rawRowRoots) - colRoots := rootsToDigests(rawColRoots) - - // limit with deadline retrieval specifically + // limit with deadline, specifically retrieval ctx, cancel := context.WithTimeout(ctx, time.Second*2) defer cancel() - rblockData, err := RetrieveBlockData( - ctx, - &types.DataAvailabilityHeader{ - RowsRoots: rowRoots, - ColumnRoots: colRoots, - }, - dag, - rsmt2d.NewRSGF8Codec(), - ) - - if tc.expectErr { - require.Error(t, err) - require.Contains(t, err.Error(), tc.errStr) - return - } + out, err := RetrieveData(ctx, MakeDataHeader(in), dag, rsmt2d.NewRSGF8Codec()) require.NoError(t, err) - - nsShares, _ := rblockData.ComputeShares() - assert.Equal(t, rawData, nsShares.RawShares()) + assert.True(t, EqualEDS(in, out)) }) } } @@ -212,46 +160,23 @@ func getNmtRoot( ctx context.Context, dag format.NodeAdder, namespacedData [][]byte, -) (namespace.IntervalDigest, error) { +) (cid.Cid, error) { na := NewNmtNodeAdder(ctx, format.NewBatch(ctx, dag)) - tree := nmt.New(sha256.New, nmt.NamespaceIDSize(consts.NamespaceSize), nmt.NodeVisitor(na.Visit)) + tree := nmt.New(sha256.New, nmt.NamespaceIDSize(NamespaceSize), nmt.NodeVisitor(na.Visit)) for _, leaf := range namespacedData { err := tree.Push(leaf) if err != nil { - return namespace.IntervalDigest{}, err - } - } - - return tree.Root(), na.Commit() -} - -// this code is copy pasted from the plugin, and should likely be exported in the plugin instead -func generateRandNamespacedRawData(total int, nidSize int, leafSize int) [][]byte { - data := make([][]byte, total) - for i := 0; i < total; i++ { - nid := make([]byte, nidSize) - _, err := rand.Read(nid) - if err != nil { - panic(err) + return cid.Undef, err } - data[i] = nid } - sortByteArrays(data) - for i := 0; i < total; i++ { - d := make([]byte, leafSize) - _, err := rand.Read(d) - if err != nil { - panic(err) - } - data[i] = append(data[i], d...) + // call Root early as it initiates saving + root := tree.Root() + if err := na.Commit(); err != nil { + return cid.Undef, err } - return data -} - -func sortByteArrays(src [][]byte) { - sort.Slice(src, func(i, j int) bool { return bytes.Compare(src[i], src[j]) < 0 }) + return plugin.CidFromNamespacedSha256(root.Bytes()) } // removes d shares from data @@ -268,52 +193,3 @@ func removeRandShares(data [][]byte, d int) [][]byte { } return data } - -func rootsToDigests(roots [][]byte) []namespace.IntervalDigest { - out := make([]namespace.IntervalDigest, len(roots)) - for i, root := range roots { - idigest, err := namespace.IntervalDigestFromBytes(consts.NamespaceSize, root) - if err != nil { - panic(err) - } - out[i] = idigest - } - return out -} - -func generateRandomBlockData(msgCount, msgSize int) types.Data { - var out types.Data - if msgCount == 1 { - return out - } - out.Messages = generateRandomMessages(msgCount-1, msgSize) - out.Txs = generateRandomContiguousShares(1) - return out -} - -func generateRandomMessages(count, msgSize int) types.Messages { - shares := generateRandNamespacedRawData(count, consts.NamespaceSize, msgSize) - msgs := make([]types.Message, count) - for i, s := range shares { - msgs[i] = types.Message{ - Data: s[consts.NamespaceSize:], - NamespaceID: s[:consts.NamespaceSize], - } - } - return types.Messages{MessagesList: msgs} -} - -func generateRandomContiguousShares(count int) types.Txs { - // the size of a length delimited tx that takes up an entire share - const adjustedTxSize = consts.TxShareSize - 2 - txs := make(types.Txs, count) - for i := 0; i < count; i++ { - tx := make([]byte, adjustedTxSize) - _, err := rand.Read(tx) - if err != nil { - panic(err) - } - txs[i] = types.Tx(tx) - } - return txs -} diff --git a/p2p/ipld/sample.go b/p2p/ipld/sample.go index 9777cb615d..42650ebc63 100644 --- a/p2p/ipld/sample.go +++ b/p2p/ipld/sample.go @@ -8,7 +8,6 @@ import ( "github.com/lazyledger/nmt/namespace" "github.com/lazyledger/lazyledger-core/ipfs/plugin" - "github.com/lazyledger/lazyledger-core/types" ) // Sample is a point in 2D space over square. @@ -25,7 +24,7 @@ func SampleSquare(squareWidth uint32, num int) []Sample { } // Leaf returns leaf info needed for retrieval using data provided with DAHeader. -func (s Sample) Leaf(dah *types.DataAvailabilityHeader) (cid.Cid, uint32, error) { +func (s Sample) Leaf(dah *DataAvailabilityHeader) (cid.Cid, uint32, error) { var ( leaf uint32 root namespace.IntervalDigest diff --git a/p2p/ipld/testing.go b/p2p/ipld/testing.go new file mode 100644 index 0000000000..7a864fc5e7 --- /dev/null +++ b/p2p/ipld/testing.go @@ -0,0 +1,87 @@ +package ipld + +import ( + "bytes" + "crypto/sha256" + "math" + mrand "math/rand" + "sort" + "testing" + + "github.com/ipfs/go-cid" + "github.com/lazyledger/rsmt2d" + "github.com/stretchr/testify/require" + + "github.com/lazyledger/lazyledger-core/ipfs/plugin" + "github.com/lazyledger/lazyledger-core/p2p/ipld/wrapper" +) + +// TODO(Wondertan): Move to rsmt2d +// TODO(Wondertan): Propose use of int by default instead of uint for the sake convenience and Golang practises +func EqualEDS(a *rsmt2d.ExtendedDataSquare, b *rsmt2d.ExtendedDataSquare) bool { + if a.Width() != b.Width() { + return false + } + + for i := uint(0); i < a.Width(); i++ { + ar, br := a.Row(i), b.Row(i) + for j := 0; j < len(ar); j++ { + if !bytes.Equal(ar[j], br[j]) { + return false + } + } + } + + return true +} + +// TODO(Wondertan): Move to NMT plugin +func RandNamespacedCID(t *testing.T) cid.Cid { + raw := make([]byte, NamespaceSize*2+sha256.Size) + _, err := mrand.Read(raw) // nolint:gosec // G404: Use of weak random number generator + require.NoError(t, err) + id, err := plugin.CidFromNamespacedSha256(raw) + require.NoError(t, err) + return id +} + +func RandEDS(t *testing.T, size int) *rsmt2d.ExtendedDataSquare { + shares := RandNamespacedShares(t, size*size) + // create the nmt wrapper to generate row and col commitments + squareSize := uint32(math.Sqrt(float64(len(shares)))) + tree := wrapper.NewErasuredNamespacedMerkleTree(uint64(squareSize)) + // recompute the eds + eds, err := rsmt2d.ComputeExtendedDataSquare(shares.Raw(), rsmt2d.NewRSGF8Codec(), tree.Constructor) + require.NoError(t, err, "failure to recompute the extended data square") + return eds +} + +func RandNamespacedShares(t *testing.T, total int) NamespacedShares { + if total&(total-1) != 0 { + t.Fatal("Namespace total must be power of 2") + } + + data := make([][]byte, total) + for i := 0; i < total; i++ { + nid := make([]byte, NamespaceSize) + _, err := mrand.Read(nid) // nolint:gosec // G404: Use of weak random number generator + require.NoError(t, err) + data[i] = nid + } + sortByteArrays(data) + + shares := make(NamespacedShares, total) + for i := 0; i < total; i++ { + shares[i].ID = data[i] + shares[i].Share = make([]byte, NamespaceSize+ShareSize) + copy(shares[i].Share[:NamespaceSize], data[i]) + _, err := mrand.Read(shares[i].Share[NamespaceSize:]) // nolint:gosec // G404: Use of weak random number generator + require.NoError(t, err) + } + + return shares +} + +func sortByteArrays(src [][]byte) { + sort.Slice(src, func(i, j int) bool { return bytes.Compare(src[i], src[j]) < 0 }) +} diff --git a/p2p/ipld/validate_test.go b/p2p/ipld/validate_test.go index c7e231e732..14260f97e0 100644 --- a/p2p/ipld/validate_test.go +++ b/p2p/ipld/validate_test.go @@ -6,41 +6,28 @@ import ( "time" mdutils "github.com/ipfs/go-merkledag/test" - "github.com/lazyledger/nmt/namespace" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - - "github.com/lazyledger/lazyledger-core/ipfs" - "github.com/lazyledger/lazyledger-core/libs/log" - "github.com/lazyledger/lazyledger-core/types" - "github.com/lazyledger/lazyledger-core/types/consts" ) // TODO(@Wondertan): Add test to simulate ErrValidationFailed func TestValidateAvailability(t *testing.T) { const ( - shares = 15 - squareSize = 8 - adjustedMsgSize = consts.MsgShareSize - 2 + shares = 16 + squareSize = 8 * 8 ) + dag := mdutils.Mock() ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - blockData := generateRandomBlockData(squareSize*squareSize, adjustedMsgSize) - block := &types.Block{ - Data: blockData, - LastCommit: &types.Commit{}, - } - block.Hash() - - dag := mdutils.Mock() - err := PutBlock(ctx, dag, block, ipfs.MockRouting(), log.TestingLogger()) + blockData := RandNamespacedShares(t, squareSize) + eds, err := PutData(ctx, blockData, dag) require.NoError(t, err) calls := 0 - err = ValidateAvailability(ctx, dag, &block.DataAvailabilityHeader, shares, func(data namespace.PrefixedData8) { + err = ValidateAvailability(ctx, dag, MakeDataHeader(eds), shares, func(share NamespacedShare) { calls++ }) assert.NoError(t, err) diff --git a/p2p/ipld/wrapper/nmt_wrapper.go b/p2p/ipld/wrapper/nmt_wrapper.go index 387475300c..3fad3d04e0 100644 --- a/p2p/ipld/wrapper/nmt_wrapper.go +++ b/p2p/ipld/wrapper/nmt_wrapper.go @@ -11,6 +11,8 @@ import ( "github.com/lazyledger/lazyledger-core/types/consts" ) +// TODO(Wondertan): Do we really need a separate package for this? + // emptyNamepsaceID occurs when a share is empty and indicates that var emptyNamespaceID = namespace.ID{0, 0, 0, 0, 0, 0, 0, 0} diff --git a/p2p/ipld/write_test.go b/p2p/ipld/write_test.go index d5e37faf6a..e8b7d7cad2 100644 --- a/p2p/ipld/write_test.go +++ b/p2p/ipld/write_test.go @@ -2,196 +2,156 @@ package ipld import ( "context" - mrand "math/rand" "testing" "time" mdutils "github.com/ipfs/go-merkledag/test" - "github.com/lazyledger/nmt" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - abci "github.com/lazyledger/lazyledger-core/abci/types" - "github.com/lazyledger/lazyledger-core/crypto/tmhash" - "github.com/lazyledger/lazyledger-core/ipfs" "github.com/lazyledger/lazyledger-core/ipfs/plugin" - "github.com/lazyledger/lazyledger-core/libs/log" - tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" - "github.com/lazyledger/lazyledger-core/types" - "github.com/lazyledger/lazyledger-core/types/consts" ) func TestPutBlock(t *testing.T) { - logger := log.TestingLogger() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() dag := mdutils.Mock() - croute := ipfs.MockRouting() - - maxOriginalSquareSize := consts.MaxSquareSize / 2 - maxShareCount := maxOriginalSquareSize * maxOriginalSquareSize testCases := []struct { - name string - blockData types.Data - expectErr bool - errString string + name string + squareSize int }{ - {"no leaves", generateRandomMsgOnlyData(0), false, ""}, - {"single leaf", generateRandomMsgOnlyData(1), false, ""}, - {"16 leaves", generateRandomMsgOnlyData(16), false, ""}, - {"max square size", generateRandomMsgOnlyData(maxShareCount), false, ""}, + {"1x1(min)", 1}, + {"32x32(med)", 32}, + {"128x128(max)", MaxSquareSize}, } - ctx := context.Background() for _, tc := range testCases { tc := tc - - block := &types.Block{Data: tc.blockData} - t.Run(tc.name, func(t *testing.T) { - err := PutBlock(ctx, dag, block, croute, logger) - if tc.expectErr { - require.Error(t, err) - require.Contains(t, err.Error(), tc.errString) - return - } - + eds, err := PutData(ctx, RandNamespacedShares(t, tc.squareSize*tc.squareSize), dag) require.NoError(t, err) - timeoutCtx, cancel := context.WithTimeout(ctx, time.Second) + ctx, cancel := context.WithTimeout(ctx, time.Second) defer cancel() - block.Hash() - for _, rowRoot := range block.DataAvailabilityHeader.RowsRoots.Bytes() { + for _, rowRoot := range MakeDataHeader(eds).RowsRoots.Bytes() { // recreate the cids using only the computed roots cid, err := plugin.CidFromNamespacedSha256(rowRoot) - if err != nil { - t.Error(err) - } + require.NoError(t, err) // retrieve the data from IPFS - _, err = dag.Get(timeoutCtx, cid) - if err != nil { - t.Errorf("Root not found: %s", cid.String()) - } + _, err = dag.Get(ctx, cid) + require.NoError(t, err) } }) } } -type preprocessingApp struct { - abci.BaseApplication -} - -func (app *preprocessingApp) PreprocessTxs( - req abci.RequestPreprocessTxs) abci.ResponsePreprocessTxs { - time.Sleep(time.Second * 2) - randTxs := generateRandTxs(64, 256) - randMsgs := generateRandNamespacedRawData(128, nmt.DefaultNamespaceIDLen, 256) - randMessages := toMessageSlice(randMsgs) - return abci.ResponsePreprocessTxs{ - Txs: append(req.Txs, randTxs...), - Messages: &tmproto.Messages{MessagesList: randMessages}, - } -} -func generateRandTxs(num int, size int) [][]byte { - randMsgs := generateRandNamespacedRawData(num, nmt.DefaultNamespaceIDLen, size) - for _, msg := range randMsgs { - copy(msg[:nmt.DefaultNamespaceIDLen], consts.TxNamespaceID) - } - return randMsgs -} - -func toMessageSlice(msgs [][]byte) []*tmproto.Message { - res := make([]*tmproto.Message, len(msgs)) - for i := 0; i < len(msgs); i++ { - res[i] = &tmproto.Message{NamespaceId: msgs[i][:nmt.DefaultNamespaceIDLen], Data: msgs[i][nmt.DefaultNamespaceIDLen:]} - } - return res -} - -func TestDataAvailabilityHeaderRewriteBug(t *testing.T) { - logger := log.TestingLogger() - dag := mdutils.Mock() - croute := ipfs.MockRouting() - - txs := types.Txs{} - l := len(txs) - bzs := make([][]byte, l) - for i := 0; i < l; i++ { - bzs[i] = txs[i] - } - app := &preprocessingApp{} - - // See state.CreateProposalBlock to understand why we do this here: - processedBlockTxs := app.PreprocessTxs(abci.RequestPreprocessTxs{Txs: bzs}) - ppt := processedBlockTxs.GetTxs() - - pbmessages := processedBlockTxs.GetMessages() - - lp := len(ppt) - processedTxs := make(types.Txs, lp) - if lp > 0 { - for i := 0; i < l; i++ { - processedTxs[i] = ppt[i] - } - } - - messages := types.MessagesFromProto(pbmessages) - lastID := makeBlockIDRandom() - h := int64(3) - - voteSet, _, vals := randVoteSet(h-1, 1, tmproto.PrecommitType, 10, 1) - commit, err := types.MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now()) - assert.NoError(t, err) - block := types.MakeBlock(1, processedTxs, nil, nil, messages, commit) - block.Hash() - - hash1 := block.DataAvailabilityHeader.Hash() - - ctx := context.TODO() - err = PutBlock(ctx, dag, block, croute, logger) - if err != nil { - t.Fatal(err) - } - - block.Hash() - hash2 := block.DataAvailabilityHeader.Hash() - assert.Equal(t, hash1, hash2) - -} - -func generateRandomMsgOnlyData(msgCount int) types.Data { - out := make([]types.Message, msgCount) - for i, msg := range generateRandNamespacedRawData(msgCount, consts.NamespaceSize, consts.MsgShareSize-2) { - out[i] = types.Message{NamespaceID: msg[:consts.NamespaceSize], Data: msg[consts.NamespaceSize:]} - } - return types.Data{ - Messages: types.Messages{MessagesList: out}, - } -} - -func makeBlockIDRandom() types.BlockID { - var ( - blockHash = make([]byte, tmhash.Size) - partSetHash = make([]byte, tmhash.Size) - ) - mrand.Read(blockHash) - mrand.Read(partSetHash) - return types.BlockID{ - Hash: blockHash, - PartSetHeader: types.PartSetHeader{ - Total: 123, - Hash: partSetHash, - }, - } -} - -func randVoteSet( - height int64, - round int32, - signedMsgType tmproto.SignedMsgType, - numValidators int, - votingPower int64, -) (*types.VoteSet, *types.ValidatorSet, []types.PrivValidator) { - valSet, privValidators := types.RandValidatorSet(numValidators, votingPower) - return types.NewVoteSet("test_chain_id", height, round, signedMsgType, valSet), valSet, privValidators -} +// TODO(Wondertan): Find a proper place for this test +// type preprocessingApp struct { +// abci.BaseApplication +// } +// +// func (app *preprocessingApp) PreprocessTxs( +// req abci.RequestPreprocessTxs) abci.ResponsePreprocessTxs { +// time.Sleep(time.Second * 2) +// randTxs := generateRandTxs(64, 256) +// randMsgs := generateRandNamespacedRawData(128, nmt.DefaultNamespaceIDLen, 256) +// randMessages := toMessageSlice(randMsgs) +// return abci.ResponsePreprocessTxs{ +// Txs: append(req.Txs, randTxs...), +// Messages: &tmproto.Messages{MessagesList: randMessages}, +// } +// } +// func generateRandTxs(num int, size int) [][]byte { +// randMsgs := generateRandNamespacedRawData(num, nmt.DefaultNamespaceIDLen, size) +// for _, msg := range randMsgs { +// copy(msg[:nmt.DefaultNamespaceIDLen], consts.TxNamespaceID) +// } +// return randMsgs +// } +// +// func toMessageSlice(msgs [][]byte) []*tmproto.Message { +// res := make([]*tmproto.Message, len(msgs)) +// for i := 0; i < len(msgs); i++ { +// res[i] = &tmproto.Message{ +// NamespaceId: msgs[i][:nmt.DefaultNamespaceIDLen], +// Data: msgs[i][nmt.DefaultNamespaceIDLen:], +// } +// } +// return res +// } +// +// func TestDataAvailabilityHeaderRewriteBug(t *testing.T) { +// ctx := context.Background() +// dag := mdutils.Mock() +// +// txs := types.Txs{} +// l := len(txs) +// bzs := make([][]byte, l) +// for i := 0; i < l; i++ { +// bzs[i] = txs[i] +// } +// app := &preprocessingApp{} +// +// // See state.CreateProposalBlock to understand why we do this here: +// processedBlockTxs := app.PreprocessTxs(abci.RequestPreprocessTxs{Txs: bzs}) +// ppt := processedBlockTxs.GetTxs() +// +// pbmessages := processedBlockTxs.GetMessages() +// +// lp := len(ppt) +// processedTxs := make(types.Txs, lp) +// if lp > 0 { +// for i := 0; i < l; i++ { +// processedTxs[i] = ppt[i] +// } +// } +// +// messages := types.MessagesFromProto(pbmessages) +// lastID := makeBlockIDRandom() +// h := int64(3) +// +// voteSet, _, vals := randVoteSet(h-1, 1, tmproto.PrecommitType, 10, 1) +// commit, err := types.MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now()) +// assert.NoError(t, err) +// block := types.MakeBlock(1, processedTxs, nil, nil, messages, commit) +// block.Hash() +// +// hash1 := block.DataAvailabilityHeader.Hash() +// +// _, dah, _, err := PutData(ctx, block, dag) +// if err != nil { +// t.Fatal(err) +// } +// +// block.Hash() +// hash2 := block.DataAvailabilityHeader.Hash() +// assert.Equal(t, hash1, hash2) +// } +// +// func makeBlockIDRandom() types.BlockID { +// var ( +// blockHash = make([]byte, tmhash.Size) +// partSetHash = make([]byte, tmhash.Size) +// ) +// mrand.Read(blockHash) +// mrand.Read(partSetHash) +// return types.BlockID{ +// Hash: blockHash, +// PartSetHeader: types.PartSetHeader{ +// Total: 123, +// Hash: partSetHash, +// }, +// } +// } +// +// func randVoteSet( +// height int64, +// round int32, +// signedMsgType tmproto.SignedMsgType, +// numValidators int, +// votingPower int64, +// ) (*types.VoteSet, *types.ValidatorSet, []types.PrivValidator) { +// valSet, privValidators := types.RandValidatorSet(numValidators, votingPower) +// return types.NewVoteSet("test_chain_id", height, round, signedMsgType, valSet), valSet, privValidators +// } From a1c6149e7ba8193f37539c62031143978bc0abe4 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Mon, 21 Jun 2021 14:45:17 +0300 Subject: [PATCH 06/25] refactor(types): Extract DAHeader and Shares --- types/block.go | 215 +++++---------------------------------- types/block_meta.go | 13 +-- types/block_test.go | 34 +++---- types/light.go | 3 +- types/proposal.go | 25 +++-- types/proposal_test.go | 11 +- types/share_splitting.go | 28 ++--- types/shares.go | 33 ------ types/shares_test.go | 50 ++++----- types/tx.go | 3 +- 10 files changed, 111 insertions(+), 304 deletions(-) diff --git a/types/block.go b/types/block.go index 99e8fcd729..4fa993aad2 100644 --- a/types/block.go +++ b/types/block.go @@ -11,7 +11,6 @@ import ( "github.com/gogo/protobuf/proto" gogotypes "github.com/gogo/protobuf/types" "github.com/lazyledger/nmt/namespace" - "github.com/lazyledger/rsmt2d" "github.com/lazyledger/lazyledger-core/crypto" "github.com/lazyledger/lazyledger-core/crypto/merkle" @@ -21,7 +20,7 @@ import ( tmmath "github.com/lazyledger/lazyledger-core/libs/math" "github.com/lazyledger/lazyledger-core/libs/protoio" tmsync "github.com/lazyledger/lazyledger-core/libs/sync" - "github.com/lazyledger/lazyledger-core/p2p/ipld/wrapper" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" tmversion "github.com/lazyledger/lazyledger-core/proto/tendermint/version" "github.com/lazyledger/lazyledger-core/types/consts" @@ -45,121 +44,14 @@ const ( MaxOverheadForBlock int64 = 11 ) -// DataAvailabilityHeader (DAHeader) contains the row and column roots of the erasure -// coded version of the data in Block.Data. -// Therefor the original Block.Data is arranged in a -// k × k matrix, which is then "extended" to a -// 2k × 2k matrix applying multiple times Reed-Solomon encoding. -// For details see Section 5.2: https://arxiv.org/abs/1809.09044 -// or the LazyLedger specification: -// https://github.com/lazyledger/lazyledger-specs/blob/master/specs/data_structures.md#availabledataheader -// Note that currently we list row and column roots in separate fields -// (different from the spec). -type DataAvailabilityHeader struct { - // RowRoot_j = root((M_{j,1} || M_{j,2} || ... || M_{j,2k} )) - RowsRoots NmtRoots `json:"row_roots"` - // ColumnRoot_j = root((M_{1,j} || M_{2,j} || ... || M_{2k,j} )) - ColumnRoots NmtRoots `json:"column_roots"` - // cached result of Hash() not to be recomputed - hash []byte -} - -type NmtRoots []namespace.IntervalDigest - -func (roots NmtRoots) Bytes() [][]byte { - res := make([][]byte, len(roots)) - for i := 0; i < len(roots); i++ { - res[i] = roots[i].Bytes() - } - return res -} - -func NmtRootsFromBytes(in [][]byte) (roots NmtRoots, err error) { - roots = make([]namespace.IntervalDigest, len(in)) - for i := 0; i < len(in); i++ { - roots[i], err = namespace.IntervalDigestFromBytes(consts.NamespaceSize, in[i]) - if err != nil { - return roots, err - } - } - return -} - -// String returns hex representation of merkle hash of the DAHeader. -func (dah *DataAvailabilityHeader) String() string { - if dah == nil { - return "" - } - return fmt.Sprintf("%X", dah.Hash()) -} - -// Equals checks equality of two DAHeaders. -func (dah *DataAvailabilityHeader) Equals(to *DataAvailabilityHeader) bool { - return bytes.Equal(dah.Hash(), to.Hash()) -} - -// Hash computes and caches the merkle root of the row and column roots. -func (dah *DataAvailabilityHeader) Hash() []byte { - if dah == nil { - return merkle.HashFromByteSlices(nil) - } - if len(dah.hash) != 0 { - return dah.hash - } - - colsCount := len(dah.ColumnRoots) - rowsCount := len(dah.RowsRoots) - slices := make([][]byte, colsCount+rowsCount) - for i, rowRoot := range dah.RowsRoots { - slices[i] = rowRoot.Bytes() - } - for i, colRoot := range dah.ColumnRoots { - slices[i+colsCount] = colRoot.Bytes() - } - // The single data root is computed using a simple binary merkle tree. - // Effectively being root(rowRoots || columnRoots): - dah.hash = merkle.HashFromByteSlices(slices) - return dah.hash -} - -func (dah *DataAvailabilityHeader) ToProto() (*tmproto.DataAvailabilityHeader, error) { - if dah == nil { - return nil, errors.New("nil DataAvailabilityHeader") - } - - dahp := new(tmproto.DataAvailabilityHeader) - dahp.RowRoots = dah.RowsRoots.Bytes() - dahp.ColumnRoots = dah.ColumnRoots.Bytes() - return dahp, nil -} - -func DataAvailabilityHeaderFromProto(dahp *tmproto.DataAvailabilityHeader) (dah *DataAvailabilityHeader, err error) { - if dahp == nil { - return nil, errors.New("nil DataAvailabilityHeader") - } - - dah = new(DataAvailabilityHeader) - dah.RowsRoots, err = NmtRootsFromBytes(dahp.RowRoots) - if err != nil { - return - } - - dah.ColumnRoots, err = NmtRootsFromBytes(dahp.ColumnRoots) - if err != nil { - return - } - - return -} - // Block defines the atomic unit of a Tendermint blockchain. type Block struct { mtx tmsync.Mutex Header `json:"header"` Data `json:"data"` - DataAvailabilityHeader DataAvailabilityHeader `json:"availability_header"` - LastCommit *Commit `json:"last_commit"` + DataAvailabilityHeader ipld.DataAvailabilityHeader `json:"availability_header"` + LastCommit *Commit `json:"last_commit"` } // ValidateBasic performs basic validation that doesn't involve state data. @@ -189,11 +81,6 @@ func (b *Block) ValidateBasic() error { return fmt.Errorf("wrong Header.LastCommitHash. Expected %X, got %X", w, g) } - // NOTE: b.Data.Txs may be nil, but b.Data.Hash() still works fine. - if w, g := b.DataAvailabilityHeader.Hash(), b.DataHash; !bytes.Equal(w, g) { - return fmt.Errorf("wrong Header.DataHash. Expected %X, got %X", w, g) - } - // NOTE: b.Evidence.Evidence may be nil, but we're just looping. for i, ev := range b.Evidence.Evidence { if err := ev.ValidateBasic(); err != nil { @@ -208,66 +95,6 @@ func (b *Block) ValidateBasic() error { return nil } -// fillHeader fills in any remaining header fields that are a function of the block data -func (b *Block) fillHeader() { - if b.LastCommitHash == nil { - b.LastCommitHash = b.LastCommit.Hash() - } - if b.DataHash == nil || b.DataAvailabilityHeader.hash == nil { - b.fillDataAvailabilityHeader() - } - if b.EvidenceHash == nil { - b.EvidenceHash = b.Evidence.Hash() - } -} - -// TODO: Move out from 'types' package -// fillDataAvailabilityHeader fills in any remaining DataAvailabilityHeader fields -// that are a function of the block data. -func (b *Block) fillDataAvailabilityHeader() { - namespacedShares, dataSharesLen := b.Data.ComputeShares() - shares := namespacedShares.RawShares() - - // create the nmt wrapper to generate row and col commitments - squareSize := uint32(math.Sqrt(float64(len(shares)))) - tree := wrapper.NewErasuredNamespacedMerkleTree(uint64(squareSize)) - - // TODO(ismail): for better efficiency and a larger number shares - // we should switch to the rsmt2d.LeopardFF16 codec: - extendedDataSquare, err := rsmt2d.ComputeExtendedDataSquare(shares, rsmt2d.NewRSGF8Codec(), tree.Constructor) - if err != nil { - panic(fmt.Sprintf("unexpected error: %v", err)) - } - - // generate the row and col roots using the EDS and nmt wrapper - rowRoots := extendedDataSquare.RowRoots() - colRoots := extendedDataSquare.ColumnRoots() - - b.DataAvailabilityHeader = DataAvailabilityHeader{ - RowsRoots: make([]namespace.IntervalDigest, extendedDataSquare.Width()), - ColumnRoots: make([]namespace.IntervalDigest, extendedDataSquare.Width()), - } - - // todo(evan): remove interval digests - // convert the roots to interval digests - for i := 0; i < len(rowRoots); i++ { - rowRoot, err := namespace.IntervalDigestFromBytes(consts.NamespaceSize, rowRoots[i]) - if err != nil { - panic(err) - } - colRoot, err := namespace.IntervalDigestFromBytes(consts.NamespaceSize, colRoots[i]) - if err != nil { - panic(err) - } - b.DataAvailabilityHeader.RowsRoots[i] = rowRoot - b.DataAvailabilityHeader.ColumnRoots[i] = colRoot - } - - // return the root hash of DA Header - b.DataHash = b.DataAvailabilityHeader.Hash() - b.NumOriginalDataShares = uint64(dataSharesLen) -} - // Hash computes and returns the block hash. // If the block is incomplete, block hash is nil for safety. func (b *Block) Hash() tmbytes.HexBytes { @@ -276,11 +103,17 @@ func (b *Block) Hash() tmbytes.HexBytes { } b.mtx.Lock() defer b.mtx.Unlock() - - if b.LastCommit == nil { + // short circuit if block is incomplete + if b.LastCommit == nil || b.DataHash == nil { return nil } - b.fillHeader() + // fill remaining fields + if b.Header.LastCommitHash == nil { + b.Header.LastCommitHash = b.LastCommit.Hash() + } + if b.Header.EvidenceHash == nil { + b.Header.EvidenceHash = b.Evidence.Hash() + } return b.Header.Hash() } @@ -413,7 +246,7 @@ func BlockFromProto(bp *tmproto.Block) (*Block, error) { return nil, err } - dah, err := DataAvailabilityHeaderFromProto(bp.DataAvailabilityHeader) + dah, err := ipld.DataAvailabilityHeaderFromProto(bp.DataAvailabilityHeader) if err != nil { return nil, err } @@ -479,22 +312,24 @@ func MaxDataBytesNoEvidence(maxBytes int64, valsCount int) int64 { // It populates the same set of fields validated by ValidateBasic. func MakeBlock( height int64, - txs []Tx, evidence []Evidence, intermediateStateRoots []tmbytes.HexBytes, messages Messages, + txs []Tx, evidences []Evidence, intermediateStateRoots []tmbytes.HexBytes, messages Messages, lastCommit *Commit) *Block { + evidence := EvidenceData{Evidence: evidences} block := &Block{ Header: Header{ - Version: tmversion.Consensus{Block: version.BlockProtocol, App: 0}, - Height: height, + Version: tmversion.Consensus{Block: version.BlockProtocol, App: 0}, + Height: height, + LastCommitHash: lastCommit.Hash(), + EvidenceHash: evidence.Hash(), }, Data: Data{ Txs: txs, IntermediateStateRoots: IntermediateStateRoots{RawRootsList: intermediateStateRoots}, - Evidence: EvidenceData{Evidence: evidence}, + Evidence: evidence, Messages: messages, }, LastCommit: lastCommit, } - block.fillHeader() return block } @@ -1219,7 +1054,7 @@ type IntermediateStateRoots struct { RawRootsList []tmbytes.HexBytes `json:"intermediate_roots"` } -func (roots IntermediateStateRoots) splitIntoShares() NamespacedShares { +func (roots IntermediateStateRoots) splitIntoShares() ipld.NamespacedShares { rawDatas := make([][]byte, 0, len(roots.RawRootsList)) for _, root := range roots.RawRootsList { rawData, err := root.MarshalDelimited() @@ -1232,8 +1067,8 @@ func (roots IntermediateStateRoots) splitIntoShares() NamespacedShares { return shares } -func (msgs Messages) splitIntoShares() NamespacedShares { - shares := make([]NamespacedShare, 0) +func (msgs Messages) splitIntoShares() ipld.NamespacedShares { + shares := make([]ipld.NamespacedShare, 0) for _, m := range msgs.MessagesList { rawData, err := m.MarshalDelimited() if err != nil { @@ -1246,7 +1081,7 @@ func (msgs Messages) splitIntoShares() NamespacedShares { // ComputeShares splits block data into shares of an original data square and // returns them along with an amount of non-redundant shares. -func (data *Data) ComputeShares() (NamespacedShares, int) { +func (data *Data) ComputeShares() (ipld.NamespacedShares, int) { // TODO(ismail): splitting into shares should depend on the block size and layout // see: https://github.com/lazyledger/lazyledger-specs/blob/master/specs/block_proposer.md#laying-out-transactions-and-messages @@ -1525,7 +1360,7 @@ func (data *EvidenceData) FromProto(eviData *tmproto.EvidenceList) error { return nil } -func (data *EvidenceData) splitIntoShares() NamespacedShares { +func (data *EvidenceData) splitIntoShares() ipld.NamespacedShares { rawDatas := make([][]byte, 0, len(data.Evidence)) for _, ev := range data.Evidence { pev, err := EvidenceToProto(ev) diff --git a/types/block_meta.go b/types/block_meta.go index 0926fa91a9..371d228fbf 100644 --- a/types/block_meta.go +++ b/types/block_meta.go @@ -5,16 +5,17 @@ import ( "errors" "fmt" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" ) // BlockMeta contains meta information. type BlockMeta struct { - BlockID BlockID `json:"block_id"` - BlockSize int `json:"block_size"` - Header Header `json:"header"` - NumTxs int `json:"num_txs"` - DAHeader DataAvailabilityHeader `json:"da_header"` + BlockID BlockID `json:"block_id"` + BlockSize int `json:"block_size"` + Header Header `json:"header"` + NumTxs int `json:"num_txs"` + DAHeader ipld.DataAvailabilityHeader `json:"da_header"` } // NewBlockMeta returns a new BlockMeta. @@ -65,7 +66,7 @@ func BlockMetaFromProto(pb *tmproto.BlockMeta) (*BlockMeta, error) { return nil, err } - dah, err := DataAvailabilityHeaderFromProto(pb.DaHeader) + dah, err := ipld.DataAvailabilityHeaderFromProto(pb.DaHeader) if err != nil { return nil, err } diff --git a/types/block_test.go b/types/block_test.go index 31f81f8632..53e98d77e0 100644 --- a/types/block_test.go +++ b/types/block_test.go @@ -4,6 +4,7 @@ import ( // it is ok to use math/rand here: we do not need a cryptographically secure random // number generator here and we can run the tests a bit faster stdbytes "bytes" + "context" "encoding/hex" "math" mrand "math/rand" @@ -14,6 +15,7 @@ import ( "time" gogotypes "github.com/gogo/protobuf/types" + mdutils "github.com/ipfs/go-merkledag/test" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -23,6 +25,7 @@ import ( "github.com/lazyledger/lazyledger-core/libs/bits" "github.com/lazyledger/lazyledger-core/libs/bytes" tmrand "github.com/lazyledger/lazyledger-core/libs/rand" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" tmversion "github.com/lazyledger/lazyledger-core/proto/tendermint/version" "github.com/lazyledger/lazyledger-core/types/consts" @@ -80,13 +83,6 @@ func TestBlockValidateBasic(t *testing.T) { blk.LastCommit.hash = nil // clear hash or change wont be noticed }, true}, {"Remove LastCommitHash", func(blk *Block) { blk.LastCommitHash = []byte("something else") }, true}, - {"Tampered Data", func(blk *Block) { - blk.Data.Txs[0] = Tx("something else") - blk.DataHash = nil // clear hash or change wont be noticed - }, true}, - {"Tampered DataHash", func(blk *Block) { - blk.DataHash = tmrand.Bytes(len(blk.DataHash)) - }, true}, {"Tampered EvidenceHash", func(blk *Block) { blk.EvidenceHash = tmrand.Bytes(len(blk.EvidenceHash)) }, true}, @@ -109,6 +105,8 @@ func TestBlockValidateBasic(t *testing.T) { i := i t.Run(tc.testName, func(t *testing.T) { block := MakeBlock(h, txs, evList, nil, Messages{}, commit) + _, err = block.RowSet(context.TODO(), mdutils.Mock()) + require.NoError(t, err) block.ProposerAddress = valSet.GetProposer().Address tc.malleateBlock(block) err = block.ValidateBasic() @@ -146,7 +144,7 @@ func TestBlockMakePartSetWithEvidence(t *testing.T) { partSet := MakeBlock(h, []Tx{Tx("Hello World")}, evList, nil, Messages{}, commit).MakePartSet(512) assert.NotNil(t, partSet) - assert.EqualValues(t, 5, partSet.Total()) + assert.EqualValues(t, 4, partSet.Total()) } func TestBlockHashesTo(t *testing.T) { @@ -163,6 +161,8 @@ func TestBlockHashesTo(t *testing.T) { block := MakeBlock(h, []Tx{Tx("Hello World")}, evList, nil, Messages{}, commit) block.ValidatorsHash = valSet.Hash() + _, err = block.RowSet(context.TODO(), mdutils.Mock()) + require.NoError(t, err) assert.False(t, block.HashesTo([]byte{})) assert.False(t, block.HashesTo([]byte("something else"))) assert.True(t, block.HashesTo(block.Hash())) @@ -212,10 +212,10 @@ func makeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) BlockID { } } -func makeDAHeaderRandom() *DataAvailabilityHeader { - rows, _ := NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)}) - clns, _ := NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)}) - return &DataAvailabilityHeader{ +func makeDAHeaderRandom() *ipld.DataAvailabilityHeader { + rows, _ := ipld.NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)}) + clns, _ := ipld.NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)}) + return &ipld.DataAvailabilityHeader{ RowsRoots: rows, ColumnRoots: clns, } @@ -223,21 +223,11 @@ func makeDAHeaderRandom() *DataAvailabilityHeader { var nilBytes []byte -// This follows RFC-6962, i.e. `echo -n '' | sha256sum` -var emptyBytes = []byte{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, - 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, - 0x78, 0x52, 0xb8, 0x55} - func TestNilHeaderHashDoesntCrash(t *testing.T) { assert.Equal(t, nilBytes, []byte((*Header)(nil).Hash())) assert.Equal(t, nilBytes, []byte((new(Header)).Hash())) } -func TestNilDataAvailabilityHeaderHashDoesntCrash(t *testing.T) { - assert.Equal(t, emptyBytes, (*DataAvailabilityHeader)(nil).Hash()) - assert.Equal(t, emptyBytes, new(DataAvailabilityHeader).Hash()) -} - func TestEmptyBlockData(t *testing.T) { blockData := Data{} shares, _ := blockData.ComputeShares() diff --git a/types/light.go b/types/light.go index 7c7bff681f..b696b46e32 100644 --- a/types/light.go +++ b/types/light.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" ) @@ -16,7 +17,7 @@ type LightBlock struct { ValidatorSet *ValidatorSet `json:"validator_set"` // DataAvailabilityHeader is only populated for DAS light clients for others it can be nil. - DataAvailabilityHeader *DataAvailabilityHeader `json:"data_availability_header"` + DataAvailabilityHeader *ipld.DataAvailabilityHeader `json:"data_availability_header"` } // ValidateBasic checks that the data is correct and consistent diff --git a/types/proposal.go b/types/proposal.go index 32740b4363..2cebb25afe 100644 --- a/types/proposal.go +++ b/types/proposal.go @@ -7,6 +7,7 @@ import ( tmbytes "github.com/lazyledger/lazyledger-core/libs/bytes" "github.com/lazyledger/lazyledger-core/libs/protoio" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" tmtime "github.com/lazyledger/lazyledger-core/types/time" ) @@ -24,18 +25,24 @@ var ( // If POLRound >= 0, then BlockID corresponds to the block that is locked in POLRound. type Proposal struct { Type tmproto.SignedMsgType - Height int64 `json:"height"` - Round int32 `json:"round"` // there can not be greater than 2_147_483_647 rounds - POLRound int32 `json:"pol_round"` // -1 if null. - BlockID BlockID `json:"block_id"` - Timestamp time.Time `json:"timestamp"` - Signature []byte `json:"signature"` - DAHeader *DataAvailabilityHeader `json:"da_header"` + Height int64 `json:"height"` + Round int32 `json:"round"` // there can not be greater than 2_147_483_647 rounds + POLRound int32 `json:"pol_round"` // -1 if null. + BlockID BlockID `json:"block_id"` + Timestamp time.Time `json:"timestamp"` + Signature []byte `json:"signature"` + DAHeader *ipld.DataAvailabilityHeader `json:"da_header"` } // NewProposal returns a new Proposal. // If there is no POLRound, polRound should be -1. -func NewProposal(height int64, round int32, polRound int32, blockID BlockID, daH *DataAvailabilityHeader) *Proposal { +func NewProposal( + height int64, + round int32, + polRound int32, + blockID BlockID, + daH *ipld.DataAvailabilityHeader, +) *Proposal { return &Proposal{ Type: tmproto.ProposalType, Height: height, @@ -157,7 +164,7 @@ func ProposalFromProto(pp *tmproto.Proposal) (*Proposal, error) { return nil, err } - dah, err := DataAvailabilityHeaderFromProto(pp.DAHeader) + dah, err := ipld.DataAvailabilityHeaderFromProto(pp.DAHeader) if err != nil { return nil, err } diff --git a/types/proposal_test.go b/types/proposal_test.go index e4939775bc..dbec4c3d26 100644 --- a/types/proposal_test.go +++ b/types/proposal_test.go @@ -12,6 +12,7 @@ import ( "github.com/lazyledger/lazyledger-core/crypto/tmhash" "github.com/lazyledger/lazyledger-core/libs/protoio" tmrand "github.com/lazyledger/lazyledger-core/libs/rand" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" ) @@ -21,8 +22,8 @@ var ( ) func init() { - rows, _ := NmtRootsFromBytes([][]byte{[]byte("HeHasBeenElected--June_15_2020_amino_was_removed")}) - clmns, _ := NmtRootsFromBytes([][]byte{[]byte("HeHasBeenElected--June_15_2020_amino_was_removed")}) + rows, _ := ipld.NmtRootsFromBytes([][]byte{[]byte("HeHasBeenElected--June_15_2020_amino_was_removed")}) + clmns, _ := ipld.NmtRootsFromBytes([][]byte{[]byte("HeHasBeenElected--June_15_2020_amino_was_removed")}) var stamp, err = time.Parse(TimeFormat, "2018-02-11T07:09:22.765Z") if err != nil { @@ -35,7 +36,7 @@ func init() { PartSetHeader: PartSetHeader{Total: 111, Hash: []byte("--June_15_2020_amino_was_removed")}}, POLRound: -1, Timestamp: stamp, - DAHeader: &DataAvailabilityHeader{ + DAHeader: &ipld.DataAvailabilityHeader{ RowsRoots: rows, ColumnRoots: clmns, }, @@ -185,7 +186,7 @@ func TestProposalProtoBuf(t *testing.T) { makeDAHeaderRandom(), ) proposal.Signature = []byte("sig") - proposal2 := NewProposal(1, 2, 3, BlockID{}, &DataAvailabilityHeader{}) + proposal2 := NewProposal(1, 2, 3, BlockID{}, &ipld.DataAvailabilityHeader{}) testCases := []struct { msg string @@ -194,7 +195,7 @@ func TestProposalProtoBuf(t *testing.T) { }{ {"success", proposal, true}, {"success", proposal2, false}, // blockID cannot be empty - {"empty proposal failure validatebasic", &Proposal{DAHeader: &DataAvailabilityHeader{}}, false}, + {"empty proposal failure validatebasic", &Proposal{DAHeader: &ipld.DataAvailabilityHeader{}}, false}, {"nil proposal", nil, false}, } for _, tc := range testCases { diff --git a/types/share_splitting.go b/types/share_splitting.go index 49a326690c..090f1e31fc 100644 --- a/types/share_splitting.go +++ b/types/share_splitting.go @@ -3,13 +3,15 @@ package types import ( "bytes" - "github.com/lazyledger/lazyledger-core/types/consts" "github.com/lazyledger/nmt/namespace" + + "github.com/lazyledger/lazyledger-core/p2p/ipld" + "github.com/lazyledger/lazyledger-core/types/consts" ) // appendToShares appends raw data as shares. // Used for messages. -func appendToShares(shares []NamespacedShare, nid namespace.ID, rawData []byte) []NamespacedShare { +func appendToShares(shares []ipld.NamespacedShare, nid namespace.ID, rawData []byte) []ipld.NamespacedShare { if len(rawData) <= consts.MsgShareSize { rawShare := append(append( make([]byte, 0, len(nid)+len(rawData)), @@ -17,7 +19,7 @@ func appendToShares(shares []NamespacedShare, nid namespace.ID, rawData []byte) rawData..., ) paddedShare := zeroPadIfNecessary(rawShare, consts.ShareSize) - share := NamespacedShare{paddedShare, nid} + share := ipld.NamespacedShare{Share: paddedShare, ID: nid} shares = append(shares, share) } else { // len(rawData) > MsgShareSize shares = append(shares, splitMessage(rawData, nid)...) @@ -27,14 +29,14 @@ func appendToShares(shares []NamespacedShare, nid namespace.ID, rawData []byte) // splitMessage breaks the data in a message into the minimum number of // namespaced shares -func splitMessage(rawData []byte, nid namespace.ID) []NamespacedShare { - shares := make([]NamespacedShare, 0) +func splitMessage(rawData []byte, nid namespace.ID) []ipld.NamespacedShare { + shares := make([]ipld.NamespacedShare, 0) firstRawShare := append(append( make([]byte, 0, consts.ShareSize), nid...), rawData[:consts.MsgShareSize]..., ) - shares = append(shares, NamespacedShare{firstRawShare, nid}) + shares = append(shares, ipld.NamespacedShare{Share: firstRawShare, ID: nid}) rawData = rawData[consts.MsgShareSize:] for len(rawData) > 0 { shareSizeOrLen := min(consts.MsgShareSize, len(rawData)) @@ -44,7 +46,7 @@ func splitMessage(rawData []byte, nid namespace.ID) []NamespacedShare { rawData[:shareSizeOrLen]..., ) paddedShare := zeroPadIfNecessary(rawShare, consts.ShareSize) - share := NamespacedShare{paddedShare, nid} + share := ipld.NamespacedShare{Share: paddedShare, ID: nid} shares = append(shares, share) rawData = rawData[shareSizeOrLen:] } @@ -53,8 +55,8 @@ func splitMessage(rawData []byte, nid namespace.ID) []NamespacedShare { // splitContiguous splits multiple raw data contiguously as shares. // Used for transactions, intermediate state roots, and evidence. -func splitContiguous(nid namespace.ID, rawDatas [][]byte) []NamespacedShare { - shares := make([]NamespacedShare, 0) +func splitContiguous(nid namespace.ID, rawDatas [][]byte) []ipld.NamespacedShare { + shares := make([]ipld.NamespacedShare, 0) // Index into the outer slice of rawDatas outerIndex := 0 // Index into the inner slice of rawDatas @@ -69,7 +71,7 @@ func splitContiguous(nid namespace.ID, rawDatas [][]byte) []NamespacedShare { byte(startIndex)), rawData...) paddedShare := zeroPadIfNecessary(rawShare, consts.ShareSize) - share := NamespacedShare{paddedShare, nid} + share := ipld.NamespacedShare{Share: paddedShare, ID: nid} shares = append(shares, share) } return shares @@ -110,10 +112,10 @@ func getNextChunk(rawDatas [][]byte, outerIndex int, innerIndex int, width int) return rawData, outerIndex, innerIndex, startIndex } -func GenerateTailPaddingShares(n int, shareWidth int) NamespacedShares { - shares := make([]NamespacedShare, n) +func GenerateTailPaddingShares(n int, shareWidth int) ipld.NamespacedShares { + shares := make([]ipld.NamespacedShare, n) for i := 0; i < n; i++ { - shares[i] = NamespacedShare{bytes.Repeat([]byte{0}, shareWidth), consts.TailPaddingNamespaceID} + shares[i] = ipld.NamespacedShare{Share: bytes.Repeat([]byte{0}, shareWidth), ID: consts.TailPaddingNamespaceID} } return shares } diff --git a/types/shares.go b/types/shares.go index b96a83e96a..0f75b58116 100644 --- a/types/shares.go +++ b/types/shares.go @@ -2,41 +2,8 @@ package types import ( "encoding/binary" - - "github.com/lazyledger/nmt/namespace" ) -// Share contains the raw share data without the corresponding namespace. -type Share []byte - -// NamespacedShare extends a Share with the corresponding namespace. -type NamespacedShare struct { - Share - ID namespace.ID -} - -func (n NamespacedShare) NamespaceID() namespace.ID { - return n.ID -} - -func (n NamespacedShare) Data() []byte { - return n.Share -} - -// NamespacedShares is just a list of NamespacedShare elements. -// It can be used to extract the raw raw shares. -type NamespacedShares []NamespacedShare - -// RawShares returns the raw shares that can be fed into the erasure coding -// library (e.g. rsmt2d). -func (ns NamespacedShares) RawShares() [][]byte { - res := make([][]byte, len(ns)) - for i, nsh := range ns { - res[i] = nsh.Share - } - return res -} - func (tx Tx) MarshalDelimited() ([]byte, error) { lenBuf := make([]byte, binary.MaxVarintLen64) length := uint64(len(tx)) diff --git a/types/shares_test.go b/types/shares_test.go index 8bcd23f842..1152027622 100644 --- a/types/shares_test.go +++ b/types/shares_test.go @@ -10,16 +10,18 @@ import ( "testing" "time" - tmbytes "github.com/lazyledger/lazyledger-core/libs/bytes" - "github.com/lazyledger/lazyledger-core/libs/protoio" - "github.com/lazyledger/lazyledger-core/types/consts" "github.com/lazyledger/nmt/namespace" "github.com/lazyledger/rsmt2d" "github.com/stretchr/testify/assert" + + tmbytes "github.com/lazyledger/lazyledger-core/libs/bytes" + "github.com/lazyledger/lazyledger-core/libs/protoio" + "github.com/lazyledger/lazyledger-core/p2p/ipld" + "github.com/lazyledger/lazyledger-core/types/consts" ) type splitter interface { - splitIntoShares() NamespacedShares + splitIntoShares() ipld.NamespacedShares } func TestMakeShares(t *testing.T) { @@ -58,20 +60,20 @@ func TestMakeShares(t *testing.T) { tests := []struct { name string args args - want NamespacedShares + want ipld.NamespacedShares }{ {"evidence", args{ data: &EvidenceData{ Evidence: []Evidence{testEvidence}, }, - }, NamespacedShares{NamespacedShare{ + }, ipld.NamespacedShares{ipld.NamespacedShare{ Share: append( append(reservedEvidenceNamespaceID, byte(0)), testEvidenceBytes[:consts.TxShareSize]..., ), ID: reservedEvidenceNamespaceID, - }, NamespacedShare{ + }, ipld.NamespacedShare{ Share: append( append(reservedEvidenceNamespaceID, byte(0)), zeroPadIfNecessary(testEvidenceBytes[consts.TxShareSize:], consts.TxShareSize)..., @@ -83,8 +85,8 @@ func TestMakeShares(t *testing.T) { args{ data: Txs{smolTx}, }, - NamespacedShares{ - NamespacedShare{ + ipld.NamespacedShares{ + ipld.NamespacedShare{ Share: append( append(reservedTxNamespaceID, byte(0)), zeroPadIfNecessary(smolTxLenDelimited, consts.TxShareSize)..., @@ -97,15 +99,15 @@ func TestMakeShares(t *testing.T) { args{ data: Txs{largeTx}, }, - NamespacedShares{ - NamespacedShare{ + ipld.NamespacedShares{ + ipld.NamespacedShare{ Share: append( append(reservedTxNamespaceID, byte(0)), largeTxLenDelimited[:consts.TxShareSize]..., ), ID: reservedTxNamespaceID, }, - NamespacedShare{ + ipld.NamespacedShare{ Share: append( append(reservedTxNamespaceID, byte(0)), zeroPadIfNecessary(largeTxLenDelimited[consts.TxShareSize:], consts.TxShareSize)..., @@ -118,15 +120,15 @@ func TestMakeShares(t *testing.T) { args{ data: Txs{largeTx, smolTx}, }, - NamespacedShares{ - NamespacedShare{ + ipld.NamespacedShares{ + ipld.NamespacedShare{ Share: append( append(reservedTxNamespaceID, byte(0)), largeTxLenDelimited[:consts.TxShareSize]..., ), ID: reservedTxNamespaceID, }, - NamespacedShare{ + ipld.NamespacedShare{ Share: append( append( reservedTxNamespaceID, @@ -145,8 +147,8 @@ func TestMakeShares(t *testing.T) { args{ data: Messages{[]Message{msg1}}, }, - NamespacedShares{ - NamespacedShare{ + ipld.NamespacedShares{ + ipld.NamespacedShare{ Share: append( []byte(msg1.NamespaceID), zeroPadIfNecessary(msg1Marshaled, consts.MsgShareSize)..., @@ -193,7 +195,7 @@ func Test_zeroPadIfNecessary(t *testing.T) { } func Test_appendToSharesOverwrite(t *testing.T) { - var shares NamespacedShares + var shares ipld.NamespacedShares // generate some arbitrary namespaced shares first share that must be split newShare := generateRandomNamespacedShares(1, consts.MsgShareSize+1)[0] @@ -245,7 +247,7 @@ func TestDataFromSquare(t *testing.T) { ) shares, _ := data.ComputeShares() - rawShares := shares.RawShares() + rawShares := shares.Raw() eds, err := rsmt2d.ComputeExtendedDataSquare(rawShares, rsmt2d.NewRSGF8Codec(), rsmt2d.NewDefaultTree) if err != nil { @@ -322,7 +324,7 @@ func Test_processContiguousShares(t *testing.T) { shares := txs.splitIntoShares() - parsedTxs, err := processContiguousShares(shares.RawShares()) + parsedTxs, err := processContiguousShares(shares.Raw()) if err != nil { t.Error(err) } @@ -339,7 +341,7 @@ func Test_processContiguousShares(t *testing.T) { shares := txs.splitIntoShares() - parsedTxs, err := processContiguousShares(shares.RawShares()) + parsedTxs, err := processContiguousShares(shares.Raw()) if err != nil { t.Error(err) } @@ -403,7 +405,7 @@ func Test_parseMsgShares(t *testing.T) { shares := msgs.splitIntoShares() - parsedMsgs, err := parseMsgShares(shares.RawShares()) + parsedMsgs, err := parseMsgShares(shares.Raw()) if err != nil { t.Error(err) } @@ -420,7 +422,7 @@ func Test_parseMsgShares(t *testing.T) { msgs := generateRandomlySizedMessages(tc.msgCount, tc.msgSize) shares := msgs.splitIntoShares() - parsedMsgs, err := parseMsgShares(shares.RawShares()) + parsedMsgs, err := parseMsgShares(shares.Raw()) if err != nil { t.Error(err) } @@ -525,7 +527,7 @@ func generateRandomMessage(size int) Message { return msg } -func generateRandomNamespacedShares(count, msgSize int) NamespacedShares { +func generateRandomNamespacedShares(count, msgSize int) ipld.NamespacedShares { shares := generateRandNamespacedRawData(count, consts.NamespaceSize, msgSize) msgs := make([]Message, count) for i, s := range shares { diff --git a/types/tx.go b/types/tx.go index bbd4ce18c5..f446436625 100644 --- a/types/tx.go +++ b/types/tx.go @@ -8,6 +8,7 @@ import ( "github.com/lazyledger/lazyledger-core/crypto/merkle" "github.com/lazyledger/lazyledger-core/crypto/tmhash" tmbytes "github.com/lazyledger/lazyledger-core/libs/bytes" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" "github.com/lazyledger/lazyledger-core/types/consts" ) @@ -80,7 +81,7 @@ func (txs Txs) Proof(i int) TxProof { } } -func (txs Txs) splitIntoShares() NamespacedShares { +func (txs Txs) splitIntoShares() ipld.NamespacedShares { rawDatas := make([][]byte, len(txs)) for i, tx := range txs { rawData, err := tx.MarshalDelimited() From 236145f1737274ff9bb656f8263659bc795d5663 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Mon, 21 Jun 2021 14:49:46 +0300 Subject: [PATCH 07/25] feat(types): introduce RowSet --- types/block.go | 19 +++++++++++++++++++ types/part_set.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/types/block.go b/types/block.go index 4fa993aad2..dd274a6e24 100644 --- a/types/block.go +++ b/types/block.go @@ -2,6 +2,7 @@ package types import ( "bytes" + "context" "errors" "fmt" "math" @@ -10,6 +11,7 @@ import ( "github.com/gogo/protobuf/proto" gogotypes "github.com/gogo/protobuf/types" + format "github.com/ipfs/go-ipld-format" "github.com/lazyledger/nmt/namespace" "github.com/lazyledger/lazyledger-core/crypto" @@ -138,6 +140,23 @@ func (b *Block) MakePartSet(partSize uint32) *PartSet { return NewPartSetFromData(bz, partSize) } +// TODO(Wondertan): Aim for Block to be complete without calling RowSet +func (b *Block) RowSet(ctx context.Context, adder format.NodeAdder) (*RowSet, error) { + shares, dataLen := b.ComputeShares() + eds, err := ipld.PutData(ctx, shares, adder) + if err != nil { + return nil, fmt.Errorf("failed to put Block into DAG: %w", err) + } + + // TODO(Wondertan): Finish DAHeader removal from Block + // Currently needed for StoreTests + b.DataAvailabilityHeader = *ipld.MakeDataHeader(eds) + + b.Header.NumOriginalDataShares = uint64(dataLen) + b.Header.DataHash = b.DataAvailabilityHeader.Hash() + return NewRowSet(eds), nil +} + // HashesTo is a convenience function that checks if a block hashes to the given argument. // Returns false if the block is nil or the hash is empty. func (b *Block) HashesTo(hash []byte) bool { diff --git a/types/part_set.go b/types/part_set.go index 59f02cbc97..dc63697f89 100644 --- a/types/part_set.go +++ b/types/part_set.go @@ -6,13 +6,17 @@ import ( "fmt" "io" + "github.com/lazyledger/rsmt2d" + "github.com/lazyledger/lazyledger-core/crypto/merkle" "github.com/lazyledger/lazyledger-core/libs/bits" tmbytes "github.com/lazyledger/lazyledger-core/libs/bytes" tmjson "github.com/lazyledger/lazyledger-core/libs/json" tmmath "github.com/lazyledger/lazyledger-core/libs/math" tmsync "github.com/lazyledger/lazyledger-core/libs/sync" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" + "github.com/lazyledger/lazyledger-core/types/consts" ) var ( @@ -373,3 +377,28 @@ func (ps *PartSet) MarshalJSON() ([]byte, error) { ps.partsBitArray, }) } + +type RowSet struct { + DAHeader *ipld.DataAvailabilityHeader + + rows [][]byte + rowsHave *bits.BitArray +} + +func NewRowSet(eds *rsmt2d.ExtendedDataSquare) *RowSet { + width := int(eds.Width() / 2) + rows := make([][]byte, width) + for i := 0; i < width; i++ { + row := eds.Row(uint(i)) + rows[i] = make([]byte, 0, consts.ShareSize*width) + for j := 0; j < width; j++ { + rows[i] = append(rows[i], row[j]...) + } + } + + return &RowSet{ + DAHeader: ipld.MakeDataHeader(eds), + rows: rows, + rowsHave: bits.NewBitArray(width), + } +} From b1d0b0f85993eb365ce40fb3b9e0c4fe0583e403 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Mon, 21 Jun 2021 14:52:34 +0300 Subject: [PATCH 08/25] feat: rely on new RowSet method and new API in p2p/ipld in consensus --- consensus/state.go | 49 ++++++++++++++++++++++------------ consensus/types/round_state.go | 7 +++-- go.mod | 3 +-- node/node.go | 1 + state/execution.go | 27 ++++++++++++++++--- state/state.go | 4 +-- 6 files changed, 65 insertions(+), 26 deletions(-) diff --git a/consensus/state.go b/consensus/state.go index 90112e15a7..c7c443f0fe 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -156,8 +156,8 @@ type State struct { metrics *Metrics // context of the recent proposed block - proposalCtx context.Context - proposalCancel context.CancelFunc + provideCtx context.Context + provideCancel context.CancelFunc } // StateOption sets an optional parameter on the State. @@ -658,12 +658,15 @@ func (cs *State) updateToState(state sm.State) { cs.Proposal = nil cs.ProposalBlock = nil cs.ProposalBlockParts = nil + cs.ProposalBlockRows = nil cs.LockedRound = -1 cs.LockedBlock = nil cs.LockedBlockParts = nil + cs.LockedBlockRows = nil cs.ValidRound = -1 cs.ValidBlock = nil cs.ValidBlockParts = nil + cs.ValidBlockRows = nil cs.Votes = cstypes.NewHeightVoteSet(state.ChainID, height, validators) cs.CommitRound = -1 cs.LastValidators = state.LastValidators @@ -962,6 +965,7 @@ func (cs *State) enterNewRound(height int64, round int32) { cs.Proposal = nil cs.ProposalBlock = nil cs.ProposalBlockParts = nil + cs.ProposalBlockRows = nil } cs.Votes.SetRound(tmmath.SafeAddInt32(round, 1)) // also track next round (round+1) to allow round-skipping cs.TriggeredTimeoutPrecommit = false @@ -1078,14 +1082,15 @@ func (cs *State) isProposer(address []byte) bool { func (cs *State) defaultDecideProposal(height int64, round int32) { var block *types.Block var blockParts *types.PartSet + var blockRows *types.RowSet // Decide on block if cs.ValidBlock != nil { // If there is valid block, choose that. - block, blockParts = cs.ValidBlock, cs.ValidBlockParts + block, blockParts, blockRows = cs.ValidBlock, cs.ValidBlockParts, cs.ValidBlockRows } else { // Create a new proposal block from state/txs from the mempool. - block, blockParts = cs.createProposalBlock() + block, blockParts, blockRows = cs.createProposalBlock() if block == nil { return } @@ -1121,9 +1126,9 @@ func (cs *State) defaultDecideProposal(height int64, round int32) { cs.Logger.Error("enterPropose: Error signing proposal", "height", height, "round", round, "err", err) } - // cancel ctx for previous proposal block to ensure block putting/providing does not queues up - if cs.proposalCancel != nil { - // FIXME(ismail): below commented out cancel tries to prevent block putting + // cancel ctx for previous proposal block to ensure block providing does not queues up + if cs.provideCancel != nil { //nolint:staticcheck + // FIXME(ismail): below commented out cancel tries to prevent block providing // and providing no to queue up endlessly. // But in a real network proposers should have enough time in between. // And even if not, queuing up to a problematic extent will take a lot of time: @@ -1139,22 +1144,20 @@ func (cs *State) defaultDecideProposal(height int64, round int32) { // the provide timeout could still be larger than just the time between // two consecutive proposals. // - cs.proposalCancel() + cs.provideCancel() } - cs.proposalCtx, cs.proposalCancel = context.WithCancel(context.TODO()) - go func(ctx context.Context) { - cs.Logger.Info("Putting Block to IPFS", "height", block.Height) - err = ipld.PutBlock(ctx, cs.dag, block, cs.croute, cs.Logger) + cs.provideCtx, cs.provideCancel = context.WithCancel(context.TODO()) + go func(ctx context.Context, dah *ipld.DataAvailabilityHeader) { + err = ipld.ProvideData(ctx, dah, cs.croute, cs.Logger.With("height", block.Height)) if err != nil { if errors.Is(err, context.Canceled) { - cs.Logger.Error("Putting Block didn't finish in time and was terminated", "height", block.Height) + cs.Logger.Error("Providing Block didn't finish in time and was terminated", "height", block.Height) return } - cs.Logger.Error("Failed to put Block to IPFS", "err", err, "height", block.Height) + cs.Logger.Error("Failed to provide Block to DHT", "err", err, "height", block.Height) return } - cs.Logger.Info("Finished putting block to IPFS", "height", block.Height) - }(cs.proposalCtx) + }(cs.provideCtx, blockRows.DAHeader) } // Returns true if the proposal block is complete && @@ -1180,7 +1183,7 @@ func (cs *State) isProposalComplete() bool { // // NOTE: keep it side-effect free for clarity. // CONTRACT: cs.privValidator is not nil. -func (cs *State) createProposalBlock() (block *types.Block, blockParts *types.PartSet) { +func (cs *State) createProposalBlock() (block *types.Block, blockParts *types.PartSet, blockRows *types.RowSet) { if cs.privValidator == nil { panic("entered createProposalBlock with privValidator being nil") } @@ -1365,6 +1368,7 @@ func (cs *State) enterPrecommit(height int64, round int32) { cs.LockedRound = -1 cs.LockedBlock = nil cs.LockedBlockParts = nil + cs.LockedBlockRows = nil if err := cs.eventBus.PublishEventUnlock(cs.RoundStateEvent()); err != nil { cs.Logger.Error("Error publishing event unlock", "err", err) } @@ -1413,6 +1417,7 @@ func (cs *State) enterPrecommit(height int64, round int32) { if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) { cs.ProposalBlock = nil cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader) + cs.ProposalBlockRows = nil } if err := cs.eventBus.PublishEventUnlock(cs.RoundStateEvent()); err != nil { cs.Logger.Error("Error publishing event unlock", "err", err) @@ -1487,6 +1492,7 @@ func (cs *State) enterCommit(height int64, commitRound int32) { logger.Info("Commit is for locked block. Set ProposalBlock=LockedBlock", "blockHash", blockID.Hash) cs.ProposalBlock = cs.LockedBlock cs.ProposalBlockParts = cs.LockedBlockParts + cs.ProposalBlockRows = cs.LockedBlockRows } // If we don't have the block being committed, set up to get it. @@ -1502,6 +1508,7 @@ func (cs *State) enterCommit(height int64, commitRound int32) { // Set up ProposalBlockParts and keep waiting. cs.ProposalBlock = nil cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader) + cs.ProposalBlockRows = nil if err := cs.eventBus.PublishEventValidBlock(cs.RoundStateEvent()); err != nil { cs.Logger.Error("Error publishing valid block", "err", err) } @@ -1864,6 +1871,10 @@ func (cs *State) addProposalBlockPart(msg *BlockPartMessage, peerID p2p.ID) (add } cs.ProposalBlock = block + cs.ProposalBlockRows, err = block.RowSet(context.TODO(), cs.dag) + if err != nil { + return false, err + } // NOTE: it's possible to receive complete proposal blocks for future rounds without having the proposal cs.Logger.Info("Received complete proposal block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash()) if err := cs.eventBus.PublishEventCompleteProposal(cs.CompleteProposalEvent()); err != nil { @@ -1880,6 +1891,7 @@ func (cs *State) addProposalBlockPart(msg *BlockPartMessage, peerID p2p.ID) (add cs.ValidRound = cs.Round cs.ValidBlock = cs.ProposalBlock cs.ValidBlockParts = cs.ProposalBlockParts + cs.ValidBlockRows = cs.ProposalBlockRows } // TODO: In case there is +2/3 majority in Prevotes set for some // block and cs.ProposalBlock contains different block, either @@ -2046,6 +2058,7 @@ func (cs *State) addVote( cs.LockedRound = -1 cs.LockedBlock = nil cs.LockedBlockParts = nil + cs.LockedBlockRows = nil if err := cs.eventBus.PublishEventUnlock(cs.RoundStateEvent()); err != nil { return added, err } @@ -2061,12 +2074,14 @@ func (cs *State) addVote( cs.ValidRound = vote.Round cs.ValidBlock = cs.ProposalBlock cs.ValidBlockParts = cs.ProposalBlockParts + cs.ValidBlockRows = cs.ProposalBlockRows } else { cs.Logger.Info( "Valid block we don't know about. Set ProposalBlock=nil", "proposal", cs.ProposalBlock.Hash(), "blockID", blockID.Hash) // We're getting the wrong block. cs.ProposalBlock = nil + cs.ProposalBlockRows = nil } if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) { cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader) diff --git a/consensus/types/round_state.go b/consensus/types/round_state.go index 8c76019a44..b305565769 100644 --- a/consensus/types/round_state.go +++ b/consensus/types/round_state.go @@ -76,13 +76,16 @@ type RoundState struct { Proposal *types.Proposal `json:"proposal"` ProposalBlock *types.Block `json:"proposal_block"` ProposalBlockParts *types.PartSet `json:"proposal_block_parts"` + ProposalBlockRows *types.RowSet `json:"proposal_block_rows"` LockedRound int32 `json:"locked_round"` LockedBlock *types.Block `json:"locked_block"` LockedBlockParts *types.PartSet `json:"locked_block_parts"` + LockedBlockRows *types.RowSet `json:"locked_block_rows"` // Last known round with POL for non-nil valid block. - ValidRound int32 `json:"valid_round"` - ValidBlock *types.Block `json:"valid_block"` // Last known block of POL mentioned above. + ValidRound int32 `json:"valid_round"` + ValidBlock *types.Block `json:"valid_block"` // Last known block of POL mentioned above. + ValidBlockRows *types.RowSet `json:"valid_block_rows"` // Last known block parts of POL mentioned above. ValidBlockParts *types.PartSet `json:"valid_block_parts"` diff --git a/go.mod b/go.mod index 596d3c66f3..5a35a2de3d 100644 --- a/go.mod +++ b/go.mod @@ -56,8 +56,7 @@ require ( github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 - golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect - google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4 // indirect + golang.org/x/sync v0.0.0-20210220032951-036812b2e83c google.golang.org/grpc v1.38.0 ) diff --git a/node/node.go b/node/node.go index 72b5d64aa4..c221f2f173 100644 --- a/node/node.go +++ b/node/node.go @@ -734,6 +734,7 @@ func NewNode(config *cfg.Config, mempool, evidencePool, sm.BlockExecutorWithMetrics(smMetrics), + sm.BlockExecutorWithDAG(ipfsNode.DAG), ) // Make BlockchainReactor. Don't start fast sync if we're doing a state sync first. diff --git a/state/execution.go b/state/execution.go index 2666b3f9c0..41ca3ab18c 100644 --- a/state/execution.go +++ b/state/execution.go @@ -6,6 +6,9 @@ import ( "fmt" "time" + format "github.com/ipfs/go-ipld-format" + mdutils "github.com/ipfs/go-merkledag/test" + abci "github.com/lazyledger/lazyledger-core/abci/types" cryptoenc "github.com/lazyledger/lazyledger-core/crypto/encoding" "github.com/lazyledger/lazyledger-core/libs/fail" @@ -24,6 +27,9 @@ import ( // BlockExecutor provides the context and accessories for properly executing a block. type BlockExecutor struct { + // DAG Store + adder format.NodeAdder + // save state, validators, consensus params, abci responses here store Store @@ -51,6 +57,12 @@ func BlockExecutorWithMetrics(metrics *Metrics) BlockExecutorOption { } } +func BlockExecutorWithDAG(adder format.NodeAdder) BlockExecutorOption { + return func(blockExec *BlockExecutor) { + blockExec.adder = adder + } +} + // NewBlockExecutor returns a new BlockExecutor with a NopEventBus. // Call SetEventBus to provide one. func NewBlockExecutor( @@ -74,7 +86,9 @@ func NewBlockExecutor( for _, option := range options { option(res) } - + if res.adder == nil { + res.adder = mdutils.Mock() + } return res } @@ -96,7 +110,7 @@ func (blockExec *BlockExecutor) CreateProposalBlock( height int64, state State, commit *types.Commit, proposerAddr []byte, -) (*types.Block, *types.PartSet) { +) (*types.Block, *types.PartSet, *types.RowSet) { maxBytes := state.ConsensusParams.Block.MaxBytes maxGas := state.ConsensusParams.Block.MaxGas @@ -155,7 +169,14 @@ func (blockExec *BlockExecutor) CreateProposalBlock( messages := types.MessagesFromProto(pbmessages) - return state.MakeBlock(height, processedTxs, evidence, nil, messages, commit, proposerAddr) + block := state.MakeBlock(height, processedTxs, evidence, nil, messages, commit, proposerAddr) + rows, err := block.RowSet(context.TODO(), blockExec.adder) + if err != nil { + blockExec.logger.Error("Can't make RowSet", "err", err) + return nil, nil, nil + } + + return block, block.MakePartSet(types.BlockPartSizeBytes), rows } // ValidateBlock validates the given block against the given state. diff --git a/state/state.go b/state/state.go index b3c4858b05..2c33977a2f 100644 --- a/state/state.go +++ b/state/state.go @@ -241,7 +241,7 @@ func (state State) MakeBlock( messages types.Messages, commit *types.Commit, proposerAddress []byte, -) (*types.Block, *types.PartSet) { +) *types.Block { // Build base block with block data. block := types.MakeBlock(height, txs, evidence, intermediateStateRoots, messages, commit) @@ -263,7 +263,7 @@ func (state State) MakeBlock( proposerAddress, ) - return block, block.MakePartSet(types.BlockPartSizeBytes) + return block } // MedianTime computes a median time for a given Commit (based on Timestamp field of votes messages) and the From 613d803b71a8814d12d709b758ce46a58058e775 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Mon, 21 Jun 2021 14:53:25 +0300 Subject: [PATCH 09/25] fix: tests and build everywhere --- blockchain/msgs_test.go | 5 +++++ blockchain/v0/reactor_test.go | 8 ++++++-- consensus/byzantine_test.go | 4 ++-- consensus/common_test.go | 2 +- consensus/msgs_test.go | 7 ++++--- consensus/replay_test.go | 16 ++++++++++------ consensus/state_test.go | 4 ++-- evidence/pool_test.go | 9 +++++++-- light/client.go | 3 +-- light/provider/http/http.go | 3 ++- node/node_test.go | 6 +++--- privval/file_test.go | 3 ++- privval/msgs_test.go | 3 ++- privval/signer_client_test.go | 7 ++++--- rpc/core/types/responses.go | 3 ++- state/execution_test.go | 2 +- state/helpers_test.go | 13 ++++++++++--- state/validation_test.go | 12 +++++------- store/store_test.go | 8 ++++++-- tools/tm-signer-harness/internal/test_harness.go | 3 ++- 20 files changed, 77 insertions(+), 44 deletions(-) diff --git a/blockchain/msgs_test.go b/blockchain/msgs_test.go index 3a608430e8..8c83d0ce01 100644 --- a/blockchain/msgs_test.go +++ b/blockchain/msgs_test.go @@ -1,11 +1,13 @@ package blockchain import ( + "context" "encoding/hex" "math" "testing" "github.com/gogo/protobuf/proto" + mdutils "github.com/ipfs/go-merkledag/test" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -83,6 +85,9 @@ func TestBlockchainMessageVectors(t *testing.T) { block := types.MakeBlock(int64(3), []types.Tx{types.Tx("Hello World")}, nil, nil, types.Messages{}, nil) block.Version.Block = 11 // overwrite updated protocol version + _, err := block.RowSet(context.TODO(), mdutils.Mock()) + require.NoError(t, err) + bpb, err := block.ToProto() require.NoError(t, err) diff --git a/blockchain/v0/reactor_test.go b/blockchain/v0/reactor_test.go index b87e2853fe..bc8c2313c0 100644 --- a/blockchain/v0/reactor_test.go +++ b/blockchain/v0/reactor_test.go @@ -302,9 +302,13 @@ func makeTxs(height int64) (txs []types.Tx) { } func makeBlock(height int64, state sm.State, lastCommit *types.Commit) *types.Block { - block, _ := state.MakeBlock(height, makeTxs(height), nil, + b := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, lastCommit, state.Validators.GetProposer().Address) - return block + _, err := b.RowSet(context.TODO(), mdutils.Mock()) + if err != nil { + panic(err) + } + return b } type testApp struct { diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index 821467b98c..1448e2a759 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -384,7 +384,7 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St // Avoid sending on internalMsgQueue and running consensus state. // Create a new proposal block from state/txs from the mempool. - block1, blockParts1 := cs.createProposalBlock() + block1, blockParts1, _ := cs.createProposalBlock() polRound, propBlockID := cs.ValidRound, types.BlockID{Hash: block1.Hash(), PartSetHeader: blockParts1.Header()} proposal1 := types.NewProposal(height, round, polRound, propBlockID, &block1.DataAvailabilityHeader) p1, err := proposal1.ToProto() @@ -399,7 +399,7 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St deliverTxsRange(cs, 0, 1) // Create a new proposal block from state/txs from the mempool. - block2, blockParts2 := cs.createProposalBlock() + block2, blockParts2, _ := cs.createProposalBlock() polRound, propBlockID = cs.ValidRound, types.BlockID{Hash: block2.Hash(), PartSetHeader: blockParts2.Header()} proposal2 := types.NewProposal(height, round, polRound, propBlockID, &block2.DataAvailabilityHeader) p2, err := proposal2.ToProto() diff --git a/consensus/common_test.go b/consensus/common_test.go index 2f41c2eb4e..589e2f26f8 100644 --- a/consensus/common_test.go +++ b/consensus/common_test.go @@ -196,7 +196,7 @@ func decideProposal( round int32, ) (proposal *types.Proposal, block *types.Block) { cs1.mtx.Lock() - block, blockParts := cs1.createProposalBlock() + block, blockParts, _ := cs1.createProposalBlock() validRound := cs1.ValidRound chainID := cs1.state.ChainID cs1.mtx.Unlock() diff --git a/consensus/msgs_test.go b/consensus/msgs_test.go index 1ca5c30b62..83a404b53e 100644 --- a/consensus/msgs_test.go +++ b/consensus/msgs_test.go @@ -15,6 +15,7 @@ import ( "github.com/lazyledger/lazyledger-core/libs/bits" tmrand "github.com/lazyledger/lazyledger-core/libs/rand" "github.com/lazyledger/lazyledger-core/p2p" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmcons "github.com/lazyledger/lazyledger-core/proto/tendermint/consensus" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" "github.com/lazyledger/lazyledger-core/types" @@ -48,7 +49,7 @@ func TestMsgToProto(t *testing.T) { pbParts, err := parts.ToProto() require.NoError(t, err) - roots, err := types.NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)}) + roots, err := ipld.NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)}) require.NoError(t, err) proposal := types.Proposal{ Type: tmproto.ProposalType, @@ -58,7 +59,7 @@ func TestMsgToProto(t *testing.T) { BlockID: bi, Timestamp: time.Now(), Signature: tmrand.Bytes(20), - DAHeader: &types.DataAvailabilityHeader{ + DAHeader: &ipld.DataAvailabilityHeader{ RowsRoots: roots, ColumnRoots: roots, }, @@ -361,7 +362,7 @@ func TestConsMsgsVectors(t *testing.T) { BlockID: bi, Timestamp: date, Signature: []byte("add_more_exclamation"), - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } pbProposal, err := proposal.ToProto() require.NoError(t, err) diff --git a/consensus/replay_test.go b/consensus/replay_test.go index 8b367ae961..75ddc6cd66 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -368,7 +368,7 @@ func TestSimulateValidatorsChange(t *testing.T) { newValidatorTx1 := kvstore.MakeValSetChangeTx(valPubKey1ABCI, testMinPower) err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx1, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ := css[0].createProposalBlock() // changeProposer(t, cs1, vs2) + propBlock, _, _ := css[0].createProposalBlock() // changeProposer(t, cs1, vs2) propBlockParts := propBlock.MakePartSet(partSize) blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} @@ -399,7 +399,7 @@ func TestSimulateValidatorsChange(t *testing.T) { updateValidatorTx1 := kvstore.MakeValSetChangeTx(updatePubKey1ABCI, 25) err = assertMempool(css[0].txNotifier).CheckTx(updateValidatorTx1, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) + propBlock, _, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) propBlockParts = propBlock.MakePartSet(partSize) blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} @@ -437,7 +437,7 @@ func TestSimulateValidatorsChange(t *testing.T) { newValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, testMinPower) err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx3, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) + propBlock, _, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) propBlockParts = propBlock.MakePartSet(partSize) blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} newVss := make([]*validatorStub, nVals+1) @@ -513,7 +513,7 @@ func TestSimulateValidatorsChange(t *testing.T) { removeValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, 0) err = assertMempool(css[0].txNotifier).CheckTx(removeValidatorTx3, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) + propBlock, _, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) propBlockParts = propBlock.MakePartSet(partSize) blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} newVss = make([]*validatorStub, nVals+3) @@ -1001,8 +1001,7 @@ func makeBlock(state sm.State, lastBlock *types.Block, lastBlockMeta *types.Bloc lastCommit = types.NewCommit(vote.Height, vote.Round, lastBlockMeta.BlockID, []types.CommitSig{vote.CommitSig()}) } - - return state.MakeBlock( + block := state.MakeBlock( height, []types.Tx{}, nil, @@ -1011,6 +1010,11 @@ func makeBlock(state sm.State, lastBlock *types.Block, lastBlockMeta *types.Bloc lastCommit, state.Validators.GetProposer().Address, ) + _, err := block.RowSet(context.TODO(), mdutils.Mock()) + if err != nil { + panic(err) + } + return block, block.MakePartSet(types.BlockPartSizeBytes) } type badApp struct { diff --git a/consensus/state_test.go b/consensus/state_test.go index e713917dd5..cd47dc1fc9 100644 --- a/consensus/state_test.go +++ b/consensus/state_test.go @@ -194,7 +194,7 @@ func TestStateBadProposal(t *testing.T) { proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) voteCh := subscribe(cs1.eventBus, types.EventQueryVote) - propBlock, _ := cs1.createProposalBlock() // changeProposer(t, cs1, vs2) + propBlock, _, _ := cs1.createProposalBlock() // changeProposer(t, cs1, vs2) // make the second validator the proposer by incrementing round round++ @@ -255,7 +255,7 @@ func TestStateOversizedBlock(t *testing.T) { timeoutProposeCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose) voteCh := subscribe(cs1.eventBus, types.EventQueryVote) - propBlock, _ := cs1.createProposalBlock() + propBlock, _, _ := cs1.createProposalBlock() propBlock.Data.Txs = []types.Tx{tmrand.Bytes(2001)} propBlock.Header.DataHash = propBlock.DataAvailabilityHeader.Hash() diff --git a/evidence/pool_test.go b/evidence/pool_test.go index 8fb837afde..d4e26f850e 100644 --- a/evidence/pool_test.go +++ b/evidence/pool_test.go @@ -175,6 +175,8 @@ func TestEvidencePoolUpdate(t *testing.T) { val, evidenceChainID) lastCommit := makeCommit(height, val.PrivKey.PubKey().Address()) block := types.MakeBlock(height+1, []types.Tx{}, []types.Evidence{ev}, nil, types.Messages{}, lastCommit) + _, err = block.RowSet(context.TODO(), mdutils.Mock()) + require.NoError(t, err) // update state (partially) state.LastBlockHeight = height + 1 state.LastBlockTime = defaultEvidenceTime.Add(22 * time.Minute) @@ -400,13 +402,16 @@ func initializeBlockStore(db dbm.DB, state sm.State, valAddr []byte) *store.Bloc for i := int64(1); i <= state.LastBlockHeight; i++ { lastCommit := makeCommit(i-1, valAddr) - block, _ := state.MakeBlock(i, []types.Tx{}, nil, nil, + block := state.MakeBlock(i, []types.Tx{}, nil, nil, types.Messages{}, lastCommit, state.Validators.GetProposer().Address) block.Header.Time = defaultEvidenceTime.Add(time.Duration(i) * time.Minute) block.Header.Version = tmversion.Consensus{Block: version.BlockProtocol, App: 1} const parts = 1 partSet := block.MakePartSet(parts) - + _, err := block.RowSet(context.TODO(), mdutils.Mock()) + if err != nil { + panic(err) + } seenCommit := makeCommit(i, valAddr) err := blockStore.SaveBlock(context.TODO(), block, partSet, seenCommit) if err != nil { diff --git a/light/client.go b/light/client.go index fca018058a..cecfc429fa 100644 --- a/light/client.go +++ b/light/client.go @@ -9,7 +9,6 @@ import ( format "github.com/ipfs/go-ipld-format" "github.com/ipfs/go-merkledag" - "github.com/lazyledger/nmt/namespace" "github.com/lazyledger/lazyledger-core/libs/log" tmmath "github.com/lazyledger/lazyledger-core/libs/math" @@ -700,7 +699,7 @@ func (c *Client) verifySequential( c.dag, interimBlock.DataAvailabilityHeader, numSamples, - func(data namespace.PrefixedData8) {}, // noop + func(ipld.NamespacedShare) {}, // noop ) if err != nil { return fmt.Errorf("data availability sampling failed; ipld.ValidateAvailability: %w", err) diff --git a/light/provider/http/http.go b/light/provider/http/http.go index 566f4f85a6..c52e0db37c 100644 --- a/light/provider/http/http.go +++ b/light/provider/http/http.go @@ -10,6 +10,7 @@ import ( "time" "github.com/lazyledger/lazyledger-core/light/provider" + "github.com/lazyledger/lazyledger-core/p2p/ipld" rpcclient "github.com/lazyledger/lazyledger-core/rpc/client" rpchttp "github.com/lazyledger/lazyledger-core/rpc/client/http" "github.com/lazyledger/lazyledger-core/types" @@ -181,7 +182,7 @@ func (p *http) signedHeader(ctx context.Context, height *int64) (*types.SignedHe return nil, provider.ErrNoResponse } -func (p *http) daHeader(ctx context.Context, height *int64) (*types.DataAvailabilityHeader, error) { +func (p *http) daHeader(ctx context.Context, height *int64) (*ipld.DataAvailabilityHeader, error) { for attempt := 1; attempt <= maxRetryAttempts; attempt++ { daHeaderRes, err := p.client.DataAvailabilityHeader(ctx, height) if err != nil { diff --git a/node/node_test.go b/node/node_test.go index 92b00fd3f3..4ef0fdf1a7 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -321,7 +321,7 @@ func TestCreateProposalBlock(t *testing.T) { ) commit := types.NewCommit(height-1, 0, types.BlockID{}, nil) - block, _ := blockExec.CreateProposalBlock( + block, _, _ := blockExec.CreateProposalBlock( height, state, commit, proposerAddr, @@ -390,7 +390,7 @@ func TestMaxTxsProposalBlockSize(t *testing.T) { ) commit := types.NewCommit(height-1, 0, types.BlockID{}, nil) - block, _ := blockExec.CreateProposalBlock( + block, _, _ := blockExec.CreateProposalBlock( height, state, commit, proposerAddr, @@ -497,7 +497,7 @@ func TestMaxProposalBlockSize(t *testing.T) { commit.Signatures = append(commit.Signatures, cs) } - block, partSet := blockExec.CreateProposalBlock( + block, partSet, _ := blockExec.CreateProposalBlock( math.MaxInt64, state, commit, proposerAddr, diff --git a/privval/file_test.go b/privval/file_test.go index 9ddde34c84..ebaa56bfb9 100644 --- a/privval/file_test.go +++ b/privval/file_test.go @@ -15,6 +15,7 @@ import ( "github.com/lazyledger/lazyledger-core/crypto/tmhash" tmjson "github.com/lazyledger/lazyledger-core/libs/json" tmrand "github.com/lazyledger/lazyledger-core/libs/rand" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" "github.com/lazyledger/lazyledger-core/types" tmtime "github.com/lazyledger/lazyledger-core/types/time" @@ -350,6 +351,6 @@ func newProposal(height int64, round int32, blockID types.BlockID) *types.Propos Round: round, BlockID: blockID, Timestamp: tmtime.Now(), - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } } diff --git a/privval/msgs_test.go b/privval/msgs_test.go index a11e4221df..35eca0d725 100644 --- a/privval/msgs_test.go +++ b/privval/msgs_test.go @@ -12,6 +12,7 @@ import ( "github.com/lazyledger/lazyledger-core/crypto/ed25519" cryptoenc "github.com/lazyledger/lazyledger-core/crypto/encoding" "github.com/lazyledger/lazyledger-core/crypto/tmhash" + "github.com/lazyledger/lazyledger-core/p2p/ipld" cryptoproto "github.com/lazyledger/lazyledger-core/proto/tendermint/crypto" privproto "github.com/lazyledger/lazyledger-core/proto/tendermint/privval" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" @@ -54,7 +55,7 @@ func exampleProposal() *types.Proposal { Hash: tmhash.Sum([]byte("blockID_part_set_header_hash")), }, }, - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } } diff --git a/privval/signer_client_test.go b/privval/signer_client_test.go index 645e7ecb97..c51b483526 100644 --- a/privval/signer_client_test.go +++ b/privval/signer_client_test.go @@ -11,6 +11,7 @@ import ( "github.com/lazyledger/lazyledger-core/crypto" "github.com/lazyledger/lazyledger-core/crypto/tmhash" tmrand "github.com/lazyledger/lazyledger-core/libs/rand" + "github.com/lazyledger/lazyledger-core/p2p/ipld" cryptoproto "github.com/lazyledger/lazyledger-core/proto/tendermint/crypto" privvalproto "github.com/lazyledger/lazyledger-core/proto/tendermint/privval" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" @@ -125,7 +126,7 @@ func TestSignerProposal(t *testing.T) { POLRound: 2, BlockID: types.BlockID{Hash: hash, PartSetHeader: types.PartSetHeader{Hash: hash, Total: 2}}, Timestamp: ts, - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } want := &types.Proposal{ Type: tmproto.ProposalType, @@ -134,7 +135,7 @@ func TestSignerProposal(t *testing.T) { POLRound: 2, BlockID: types.BlockID{Hash: hash, PartSetHeader: types.PartSetHeader{Hash: hash, Total: 2}}, Timestamp: ts, - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } tc := tc @@ -342,7 +343,7 @@ func TestSignerSignProposalErrors(t *testing.T) { BlockID: types.BlockID{Hash: hash, PartSetHeader: types.PartSetHeader{Hash: hash, Total: 2}}, Timestamp: ts, Signature: []byte("signature"), - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } p, err := proposal.ToProto() diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index bb206333f2..a191079ae2 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -8,6 +8,7 @@ import ( "github.com/lazyledger/lazyledger-core/crypto" "github.com/lazyledger/lazyledger-core/libs/bytes" "github.com/lazyledger/lazyledger-core/p2p" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" "github.com/lazyledger/lazyledger-core/types" ) @@ -36,7 +37,7 @@ type ResultCommit struct { } type ResultDataAvailabilityHeader struct { - types.DataAvailabilityHeader `json:"data_availability_header"` + ipld.DataAvailabilityHeader `json:"data_availability_header"` } // ABCI results from a block diff --git a/state/execution_test.go b/state/execution_test.go index b6ea333d14..5c393746fd 100644 --- a/state/execution_test.go +++ b/state/execution_test.go @@ -100,7 +100,7 @@ func TestBeginBlockValidators(t *testing.T) { lastCommit := types.NewCommit(1, 0, prevBlockID, tc.lastCommitSigs) // block for height 2 - block, _ := state.MakeBlock(2, makeTxs(2), nil, nil, + block := state.MakeBlock(2, makeTxs(2), nil, nil, types.Messages{}, lastCommit, state.Validators.GetProposer().Address) _, err = sm.ExecCommitBlock(proxyApp.Consensus(), block, log.TestingLogger(), stateStore, 1) diff --git a/state/helpers_test.go b/state/helpers_test.go index 32a3c78cf8..5a713244ea 100644 --- a/state/helpers_test.go +++ b/state/helpers_test.go @@ -2,9 +2,12 @@ package state_test import ( "bytes" + "context" "fmt" "time" + mdutils "github.com/ipfs/go-merkledag/test" + abci "github.com/lazyledger/lazyledger-core/abci/types" "github.com/lazyledger/lazyledger-core/crypto" "github.com/lazyledger/lazyledger-core/crypto/ed25519" @@ -54,7 +57,7 @@ func makeAndCommitGoodBlock( func makeAndApplyGoodBlock(state sm.State, height int64, lastCommit *types.Commit, proposerAddr []byte, blockExec *sm.BlockExecutor, evidence []types.Evidence) (sm.State, types.BlockID, error) { - block, _ := state.MakeBlock( + block := state.MakeBlock( height, makeTxs(height), evidence, @@ -63,12 +66,16 @@ func makeAndApplyGoodBlock(state sm.State, height int64, lastCommit *types.Commi lastCommit, proposerAddr, ) + _, err := block.RowSet(context.TODO(), mdutils.Mock()) + if err != nil { + return sm.State{}, types.BlockID{}, err + } if err := blockExec.ValidateBlock(state, block); err != nil { return state, types.BlockID{}, err } blockID := types.BlockID{Hash: block.Hash(), PartSetHeader: types.PartSetHeader{Total: 3, Hash: tmrand.Bytes(32)}} - state, _, err := blockExec.ApplyBlock(state, blockID, block) + state, _, err = blockExec.ApplyBlock(state, blockID, block) if err != nil { return state, types.BlockID{}, err } @@ -140,7 +147,7 @@ func makeState(nVals, height int) (sm.State, dbm.DB, map[string]types.PrivValida } func makeBlock(state sm.State, height int64) *types.Block { - block, _ := state.MakeBlock( + block := state.MakeBlock( height, makeTxs(state.LastBlockHeight), nil, diff --git a/state/validation_test.go b/state/validation_test.go index 1aa1853d60..cd2e9f5a04 100644 --- a/state/validation_test.go +++ b/state/validation_test.go @@ -59,8 +59,6 @@ func TestValidateBlockHeader(t *testing.T) { {"LastBlockID wrong", func(block *types.Block) { block.LastBlockID.PartSetHeader.Total += 10 }}, {"LastCommitHash wrong", func(block *types.Block) { block.LastCommitHash = wrongHash }}, - {"DataHash wrong", func(block *types.Block) { block.DataHash = wrongHash }}, - {"ValidatorsHash wrong", func(block *types.Block) { block.ValidatorsHash = wrongHash }}, {"NextValidatorsHash wrong", func(block *types.Block) { block.NextValidatorsHash = wrongHash }}, {"ConsensusHash wrong", func(block *types.Block) { block.ConsensusHash = wrongHash }}, @@ -84,7 +82,7 @@ func TestValidateBlockHeader(t *testing.T) { Invalid blocks don't pass */ for _, tc := range testCases { - block, _ := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, lastCommit, proposerAddr) + block := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, lastCommit, proposerAddr) tc.malleateBlock(block) err := blockExec.ValidateBlock(state, block) t.Logf("%s: %v", tc.name, err) @@ -101,7 +99,7 @@ func TestValidateBlockHeader(t *testing.T) { } nextHeight := validationTestsStopHeight - block, _ := state.MakeBlock( + block := state.MakeBlock( nextHeight, makeTxs(nextHeight), nil, nil, types.Messages{}, lastCommit, @@ -153,7 +151,7 @@ func TestValidateBlockCommit(t *testing.T) { state.LastBlockID, []types.CommitSig{wrongHeightVote.CommitSig()}, ) - block, _ := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, wrongHeightCommit, proposerAddr) + block := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, wrongHeightCommit, proposerAddr) err = blockExec.ValidateBlock(state, block) _, isErrInvalidCommitHeight := err.(types.ErrInvalidCommitHeight) require.True(t, isErrInvalidCommitHeight, "expected ErrInvalidCommitHeight at height %d but got: %v", height, err) @@ -161,7 +159,7 @@ func TestValidateBlockCommit(t *testing.T) { /* #2589: test len(block.LastCommit.Signatures) == state.LastValidators.Size() */ - block, _ = state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, wrongSigsCommit, proposerAddr) + block = state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, wrongSigsCommit, proposerAddr) err = blockExec.ValidateBlock(state, block) _, isErrInvalidCommitSignatures := err.(types.ErrInvalidCommitSignatures) require.True(t, isErrInvalidCommitSignatures, @@ -270,7 +268,7 @@ func TestValidateBlockEvidence(t *testing.T) { evidence = append(evidence, newEv) currentBytes += int64(len(newEv.Bytes())) } - block, _ := state.MakeBlock(height, makeTxs(height), evidence, nil, types.Messages{}, lastCommit, proposerAddr) + block := state.MakeBlock(height, makeTxs(height), evidence, nil, types.Messages{}, lastCommit, proposerAddr) err := blockExec.ValidateBlock(state, block) if assert.Error(t, err) { _, ok := err.(*types.ErrEvidenceOverflow) diff --git a/store/store_test.go b/store/store_test.go index c54b78937b..518256bf93 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -58,9 +58,13 @@ func makeTxs(height int64) (txs []types.Tx) { } func makeBlock(height int64, state sm.State, lastCommit *types.Commit) *types.Block { - block, _ := state.MakeBlock(height, makeTxs(height), nil, + b := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, lastCommit, state.Validators.GetProposer().Address) - return block + _, err := b.RowSet(context.TODO(), mdutils.Mock()) + if err != nil { + panic(err) + } + return b } func makeStateAndBlockStore(logger log.Logger) (sm.State, *BlockStore, cleanupFunc) { diff --git a/tools/tm-signer-harness/internal/test_harness.go b/tools/tm-signer-harness/internal/test_harness.go index e2a4d01532..b7656d38ab 100644 --- a/tools/tm-signer-harness/internal/test_harness.go +++ b/tools/tm-signer-harness/internal/test_harness.go @@ -9,6 +9,7 @@ import ( "time" "github.com/lazyledger/lazyledger-core/crypto/tmhash" + "github.com/lazyledger/lazyledger-core/p2p/ipld" "github.com/lazyledger/lazyledger-core/crypto/ed25519" "github.com/lazyledger/lazyledger-core/privval" @@ -228,7 +229,7 @@ func (th *TestHarness) TestSignProposal() error { }, }, Timestamp: time.Now(), - DAHeader: &types.DataAvailabilityHeader{}, + DAHeader: &ipld.DataAvailabilityHeader{}, } p, err := prop.ToProto() if err != nil { From 9174d8b12d2d6dafd096aec46ff9810a58473a0d Mon Sep 17 00:00:00 2001 From: Wondertan Date: Sun, 27 Jun 2021 22:47:21 +0300 Subject: [PATCH 10/25] fix(state): update to new p2p/ipld API --- blockchain/v0/reactor_test.go | 1 + consensus/state.go | 2 +- evidence/pool_test.go | 3 ++- rpc/core/blocks.go | 3 ++- store/store.go | 20 +++++++++++++------- store/store_test.go | 1 + 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/blockchain/v0/reactor_test.go b/blockchain/v0/reactor_test.go index bc8c2313c0..c2ff57aaf9 100644 --- a/blockchain/v0/reactor_test.go +++ b/blockchain/v0/reactor_test.go @@ -9,6 +9,7 @@ import ( "testing" "time" + mdutils "github.com/ipfs/go-merkledag/test" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/consensus/state.go b/consensus/state.go index c7c443f0fe..02a7e9fb7e 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -1127,7 +1127,7 @@ func (cs *State) defaultDecideProposal(height int64, round int32) { } // cancel ctx for previous proposal block to ensure block providing does not queues up - if cs.provideCancel != nil { //nolint:staticcheck + if cs.provideCancel != nil { // FIXME(ismail): below commented out cancel tries to prevent block providing // and providing no to queue up endlessly. // But in a real network proposers should have enough time in between. diff --git a/evidence/pool_test.go b/evidence/pool_test.go index d4e26f850e..7c3b161e1a 100644 --- a/evidence/pool_test.go +++ b/evidence/pool_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + mdutils "github.com/ipfs/go-merkledag/test" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -413,7 +414,7 @@ func initializeBlockStore(db dbm.DB, state sm.State, valAddr []byte) *store.Bloc panic(err) } seenCommit := makeCommit(i, valAddr) - err := blockStore.SaveBlock(context.TODO(), block, partSet, seenCommit) + err = blockStore.SaveBlock(context.TODO(), block, partSet, seenCommit) if err != nil { panic(err) } diff --git a/rpc/core/blocks.go b/rpc/core/blocks.go index 06d411a6a3..a98f8adb15 100644 --- a/rpc/core/blocks.go +++ b/rpc/core/blocks.go @@ -4,6 +4,7 @@ import ( "fmt" tmmath "github.com/lazyledger/lazyledger-core/libs/math" + "github.com/lazyledger/lazyledger-core/p2p/ipld" ctypes "github.com/lazyledger/lazyledger-core/rpc/core/types" rpctypes "github.com/lazyledger/lazyledger-core/rpc/jsonrpc/types" "github.com/lazyledger/lazyledger-core/types" @@ -156,7 +157,7 @@ func DataAvailabilityHeader(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.Re block, err := env.BlockStore.LoadBlock(ctx.Context(), height) if err != nil { return &ctypes.ResultDataAvailabilityHeader{ - DataAvailabilityHeader: types.DataAvailabilityHeader{}, + DataAvailabilityHeader: ipld.DataAvailabilityHeader{}, }, err } _ = block.Hash() diff --git a/store/store.go b/store/store.go index 2e6c684695..109a64b196 100644 --- a/store/store.go +++ b/store/store.go @@ -3,9 +3,8 @@ package store import ( "context" "fmt" - "strings" - "strconv" + "strings" "github.com/gogo/protobuf/proto" "github.com/ipfs/go-blockservice" @@ -14,7 +13,8 @@ import ( format "github.com/ipfs/go-ipld-format" "github.com/ipfs/go-merkledag" - "github.com/lazyledger/lazyledger-core/ipfs" + "github.com/lazyledger/rsmt2d" + dbm "github.com/lazyledger/lazyledger-core/libs/db" "github.com/lazyledger/lazyledger-core/libs/log" tmsync "github.com/lazyledger/lazyledger-core/libs/sync" @@ -22,7 +22,6 @@ import ( tmstore "github.com/lazyledger/lazyledger-core/proto/tendermint/store" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" "github.com/lazyledger/lazyledger-core/types" - "github.com/lazyledger/rsmt2d" ) /* @@ -115,7 +114,7 @@ func (bs *BlockStore) LoadBlock(ctx context.Context, height int64) (*types.Block lastCommit := bs.LoadBlockCommit(height - 1) - data, err := ipld.RetrieveBlockData(ctx, &blockMeta.DAHeader, bs.dag, rsmt2d.NewRSGF8Codec()) + data, err := ipld.RetrieveData(ctx, &blockMeta.DAHeader, bs.dag, rsmt2d.NewRSGF8Codec()) if err != nil { if strings.Contains(err.Error(), format.ErrNotFound.Error()) { return nil, fmt.Errorf("failure to retrieve block data from local ipfs store: %w", err) @@ -124,9 +123,14 @@ func (bs *BlockStore) LoadBlock(ctx context.Context, height int64) (*types.Block return nil, err } + bdata, err := types.DataFromSquare(data) + if err != nil { + return nil, err + } + block := types.Block{ Header: blockMeta.Header, - Data: data, + Data: bdata, DataAvailabilityHeader: blockMeta.DAHeader, LastCommit: lastCommit, } @@ -369,13 +373,15 @@ func (bs *BlockStore) SaveBlock( bs.saveBlockPart(height, i, part) } - err := ipld.PutBlock(ctx, bs.dag, block, ipfs.MockRouting(), bs.logger) + shares, _ := block.ComputeShares() + eds, err := ipld.PutData(ctx, shares, bs.dag) if err != nil { return err } // Save block meta blockMeta := types.NewBlockMeta(block, blockParts) + blockMeta.DAHeader = *ipld.MakeDataHeader(eds) pbm, err := blockMeta.ToProto() if err != nil { panic(fmt.Errorf("failed to marshal block meta while saving: %w", err)) diff --git a/store/store_test.go b/store/store_test.go index 518256bf93..185ec46c47 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -12,6 +12,7 @@ import ( "time" "github.com/gogo/protobuf/proto" + mdutils "github.com/ipfs/go-merkledag/test" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" From a1e21c46ac205bf46859b2833510e97f8d177792 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 23 Jun 2021 21:09:14 +0300 Subject: [PATCH 11/25] feat(libs/bits): ADd new Ones method to BitArray --- libs/bits/bit_array.go | 10 ++++++++++ libs/bits/bit_array_test.go | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/libs/bits/bit_array.go b/libs/bits/bit_array.go index 99a19ff561..08ca9c41a4 100644 --- a/libs/bits/bit_array.go +++ b/libs/bits/bit_array.go @@ -222,6 +222,16 @@ func (bA *BitArray) IsEmpty() bool { return true } +// Ones returns amount of 1 bits in the array. +func (bA *BitArray) Ones() int { + if bA == nil { + return 0 + } + bA.mtx.Lock() + defer bA.mtx.Unlock() + return len(bA.getTrueIndices()) +} + // IsFull returns true iff all bits in the bit array are 1. func (bA *BitArray) IsFull() bool { if bA == nil { diff --git a/libs/bits/bit_array_test.go b/libs/bits/bit_array_test.go index 4035fcca00..fd9875f11c 100644 --- a/libs/bits/bit_array_test.go +++ b/libs/bits/bit_array_test.go @@ -174,6 +174,15 @@ func TestBytes(t *testing.T) { check(bA, []byte{0x80, 0x03}) } +func TestBitArrayOnes(t *testing.T) { + ba := NewBitArray(5) + ba.SetIndex(0, true) + ba.SetIndex(2, true) + ba.SetIndex(4, true) + assert.Equal(t, 3, ba.Ones()) +} + + func TestEmptyFull(t *testing.T) { ns := []int{47, 123} for _, n := range ns { From 04533f10b11867312e0f8241bdec7b3926e5525a Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 23 Jun 2021 21:12:38 +0300 Subject: [PATCH 12/25] feat(types): finish RowSet implementation --- types/row_set.go | 130 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 types/row_set.go diff --git a/types/row_set.go b/types/row_set.go new file mode 100644 index 0000000000..c0350b78c0 --- /dev/null +++ b/types/row_set.go @@ -0,0 +1,130 @@ +package types + +import ( + "fmt" + "sync" + + "github.com/lazyledger/nmt/namespace" + "github.com/lazyledger/rsmt2d" + + "github.com/lazyledger/lazyledger-core/libs/bits" + "github.com/lazyledger/lazyledger-core/p2p/ipld" + "github.com/lazyledger/lazyledger-core/p2p/ipld/wrapper" + "github.com/lazyledger/lazyledger-core/types/consts" +) + +type Row []byte + +func NewRow(row [][]byte) Row { + r := make([]byte, 0, len(row[0])*len(row)) + for j := 0; j < len(row); j++ { + r = append(r, row[j]...) + } + return r +} + +type RowSet struct { + DAHeader *ipld.DataAvailabilityHeader + rowsHave *bits.BitArray + rows [][]byte + l sync.RWMutex +} + +func NewRowSet(eds *rsmt2d.ExtendedDataSquare) *RowSet { + width := int(eds.Width()) + rowsHave := bits.NewBitArray(width) + rows := make([][]byte, width) + for i := 0; i < width; i++ { + rowsHave.SetIndex(i, true) + rows[i] = NewRow(eds.Row(uint(i))) + } + + return &RowSet{ + DAHeader: ipld.MakeDataHeader(eds), + rowsHave: rowsHave, + rows: rows, + } +} + +func NewRowSetFromHeader(dah *ipld.DataAvailabilityHeader) *RowSet { + return &RowSet{ + DAHeader: dah, + rowsHave: bits.NewBitArray(len(dah.RowsRoots)), + rows: make([][]byte, len(dah.RowsRoots)), + } +} + +func (rs *RowSet) Count() int { + return rs.rowsHave.Ones() +} + +func (rs *RowSet) Total() int { + return rs.rowsHave.Size() +} + +func (rs *RowSet) IsComplete() bool { + return rs.rowsHave.IsFull() +} + +func (rs *RowSet) BitArray() *bits.BitArray { + return rs.rowsHave.Copy() +} + +func (rs *RowSet) Square() (*rsmt2d.ExtendedDataSquare, error) { + if !rs.IsComplete() { + return nil, fmt.Errorf("square is not complete") + } + return rsmt2d.ImportExtendedDataSquare( + rs.rows, + rsmt2d.NewRSGF8Codec(), + wrapper.NewErasuredNamespacedMerkleTree(uint64(len(rs.rows))).Constructor, + ) +} + +func (rs *RowSet) HasHeader(dah *ipld.DataAvailabilityHeader) bool { + return rs.DAHeader.Equals(dah) +} + +func (rs *RowSet) GetRow(i int) Row { + if i > len(rs.rows) { + return nil + } + rs.l.RLock() + defer rs.l.RUnlock() + return rs.rows[i] +} + +func (rs *RowSet) AddRow(row Row) (bool, error) { + rs.l.Lock() + defer rs.l.Unlock() + + ss := consts.ShareSize + tree := wrapper.NewErasuredNamespacedMerkleTree(uint64(len(rs.rows))) + for i := 0; i < len(row)/ss; i++ { + tree.Push(row[i*ss:(i+1)*ss], rsmt2d.SquareIndex{Cell: uint(i)}) + } + + root, err := namespace.IntervalDigestFromBytes(ipld.NamespaceSize, tree.Root()) + if err != nil { + return false, err + } + + idx, isFound := findRoot(rs.DAHeader, &root) + if !isFound { + return false, fmt.Errorf("invalid row") + } + + rs.rows[idx] = row + rs.rowsHave.SetIndex(idx, true) + return true, nil +} + +func findRoot(dah *ipld.DataAvailabilityHeader, root *namespace.IntervalDigest) (int, bool) { + for i, rr := range dah.RowsRoots { + if rr.Equal(root) { + return i, true + } + } + + return 0, false +} From 11f450f309046758c22ae618c22435650f54b455 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 30 Jun 2021 12:58:02 +0300 Subject: [PATCH 13/25] feat(types): update row set implementation with more tests --- types/part_set.go | 29 ------- types/row_set.go | 170 ++++++++++++++++++++++++++++++++---------- types/row_set_test.go | 60 +++++++++++++++ 3 files changed, 192 insertions(+), 67 deletions(-) create mode 100644 types/row_set_test.go diff --git a/types/part_set.go b/types/part_set.go index dc63697f89..59f02cbc97 100644 --- a/types/part_set.go +++ b/types/part_set.go @@ -6,17 +6,13 @@ import ( "fmt" "io" - "github.com/lazyledger/rsmt2d" - "github.com/lazyledger/lazyledger-core/crypto/merkle" "github.com/lazyledger/lazyledger-core/libs/bits" tmbytes "github.com/lazyledger/lazyledger-core/libs/bytes" tmjson "github.com/lazyledger/lazyledger-core/libs/json" tmmath "github.com/lazyledger/lazyledger-core/libs/math" tmsync "github.com/lazyledger/lazyledger-core/libs/sync" - "github.com/lazyledger/lazyledger-core/p2p/ipld" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" - "github.com/lazyledger/lazyledger-core/types/consts" ) var ( @@ -377,28 +373,3 @@ func (ps *PartSet) MarshalJSON() ([]byte, error) { ps.partsBitArray, }) } - -type RowSet struct { - DAHeader *ipld.DataAvailabilityHeader - - rows [][]byte - rowsHave *bits.BitArray -} - -func NewRowSet(eds *rsmt2d.ExtendedDataSquare) *RowSet { - width := int(eds.Width() / 2) - rows := make([][]byte, width) - for i := 0; i < width; i++ { - row := eds.Row(uint(i)) - rows[i] = make([]byte, 0, consts.ShareSize*width) - for j := 0; j < width; j++ { - rows[i] = append(rows[i], row[j]...) - } - } - - return &RowSet{ - DAHeader: ipld.MakeDataHeader(eds), - rows: rows, - rowsHave: bits.NewBitArray(width), - } -} diff --git a/types/row_set.go b/types/row_set.go index c0350b78c0..8357750ca9 100644 --- a/types/row_set.go +++ b/types/row_set.go @@ -1,6 +1,7 @@ package types import ( + "errors" "fmt" "sync" @@ -10,63 +11,142 @@ import ( "github.com/lazyledger/lazyledger-core/libs/bits" "github.com/lazyledger/lazyledger-core/p2p/ipld" "github.com/lazyledger/lazyledger-core/p2p/ipld/wrapper" + tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" "github.com/lazyledger/lazyledger-core/types/consts" ) -type Row []byte +var ErrInvalidRow = errors.New("invalid row") -func NewRow(row [][]byte) Row { - r := make([]byte, 0, len(row[0])*len(row)) - for j := 0; j < len(row); j++ { - r = append(r, row[j]...) +type Row struct { + Index int + Data []byte +} + +func NewRow(idx int, row [][]byte) *Row { + data := make([]byte, len(row)*ipld.ShareSize) + for i := 0; i < len(row); i++ { + copy(data[i*ipld.ShareSize:(i+1)*ipld.ShareSize], row[i]) + } + return &Row{Index: idx, Data: data} +} + +func (r *Row) ForEachShare(f func(int, []byte)) { + for i := 0; i < r.Shares(); i++ { + f(i, r.Data[i*ipld.ShareSize:(i+1)*ipld.ShareSize]) + } +} + +func (r *Row) Shares() int { + return len(r.Data) / ipld.ShareSize +} + +// TODO(Wondertan): Ideally, it would be nice to check that Row corresponds to DAHeader here(on Row message is received) +// but: +// * Then we would need to calculate Tree for Row twice or more +// * Violate ValidateBasic pattern by passing header there are reworking reactor logic. +// This way we can also sending Row Index and only rely on Hash. +func (r *Row) ValidateBasic() error { + if len(r.Data)%ipld.ShareSize != 0 { + return fmt.Errorf("row's data must be multople of share size(%d)", ipld.ShareSize) + } + return nil +} + +func (r *Row) ToProto() (*tmproto.Row, error) { + if r == nil { + return nil, errors.New("nil part") + } + pb := new(tmproto.Row) + pb.Index = uint32(r.Index) + pb.Data = r.Data + return pb, nil +} + +func RowFromProto(pb *tmproto.Row) (*Row, error) { + if pb == nil { + return nil, errors.New("nil part") } - return r + + part := new(Row) + part.Index = int(pb.Index) + part.Data = pb.Data + return part, part.ValidateBasic() } type RowSet struct { DAHeader *ipld.DataAvailabilityHeader + rowsHave *bits.BitArray - rows [][]byte - l sync.RWMutex + rows []*Row + l sync.RWMutex } func NewRowSet(eds *rsmt2d.ExtendedDataSquare) *RowSet { width := int(eds.Width()) rowsHave := bits.NewBitArray(width) - rows := make([][]byte, width) + rows := make([]*Row, width) for i := 0; i < width; i++ { rowsHave.SetIndex(i, true) - rows[i] = NewRow(eds.Row(uint(i))) + rows[i] = NewRow(i, eds.Row(uint(i))) } + dah := ipld.MakeDataHeader(eds) + dah.Hash() // cache hash earlier to avoid races return &RowSet{ - DAHeader: ipld.MakeDataHeader(eds), + DAHeader: dah, rowsHave: rowsHave, rows: rows, } } func NewRowSetFromHeader(dah *ipld.DataAvailabilityHeader) *RowSet { + dah.Hash() // ensure hash is cached to avoid races return &RowSet{ DAHeader: dah, rowsHave: bits.NewBitArray(len(dah.RowsRoots)), - rows: make([][]byte, len(dah.RowsRoots)), + rows: make([]*Row, len(dah.RowsRoots)), + } +} + +func (rs *RowSet) StringShort() string { + if rs == nil { + return "nil-RowSet" } + return fmt.Sprintf("(%v of %v)", rs.Count(), rs.Total()) } func (rs *RowSet) Count() int { + if rs == nil { + return 0 + } return rs.rowsHave.Ones() } func (rs *RowSet) Total() int { + if rs == nil { + return 0 + } return rs.rowsHave.Size() } +func (rs *RowSet) TotalSize() int { + if rs == nil { + return 0 + } + return rs.Total() * rs.SquareSize() * consts.ShareSize +} + func (rs *RowSet) IsComplete() bool { + if rs == nil { + return false + } return rs.rowsHave.IsFull() } func (rs *RowSet) BitArray() *bits.BitArray { + if rs == nil { + return bits.NewBitArray(0) + } return rs.rowsHave.Copy() } @@ -74,18 +154,35 @@ func (rs *RowSet) Square() (*rsmt2d.ExtendedDataSquare, error) { if !rs.IsComplete() { return nil, fmt.Errorf("square is not complete") } + size := rs.SquareSize() + shares := make([][]byte, size*size) + for i, r := range rs.rows { + r.ForEachShare(func(j int, share []byte) { + shares[(i*size)+j] = share + }) + } return rsmt2d.ImportExtendedDataSquare( - rs.rows, + shares, rsmt2d.NewRSGF8Codec(), - wrapper.NewErasuredNamespacedMerkleTree(uint64(len(rs.rows))).Constructor, + wrapper.NewErasuredNamespacedMerkleTree(uint64(size/2)).Constructor, ) } +func (rs *RowSet) SquareSize() int { + if rs == nil { + return 0 + } + return len(rs.DAHeader.RowsRoots) +} + func (rs *RowSet) HasHeader(dah *ipld.DataAvailabilityHeader) bool { + if rs == nil { + return false + } return rs.DAHeader.Equals(dah) } -func (rs *RowSet) GetRow(i int) Row { +func (rs *RowSet) GetRow(i int) *Row { if i > len(rs.rows) { return nil } @@ -94,37 +191,34 @@ func (rs *RowSet) GetRow(i int) Row { return rs.rows[i] } -func (rs *RowSet) AddRow(row Row) (bool, error) { - rs.l.Lock() - defer rs.l.Unlock() - - ss := consts.ShareSize - tree := wrapper.NewErasuredNamespacedMerkleTree(uint64(len(rs.rows))) - for i := 0; i < len(row)/ss; i++ { - tree.Push(row[i*ss:(i+1)*ss], rsmt2d.SquareIndex{Cell: uint(i)}) +func (rs *RowSet) AddRow(row *Row) (bool, error) { + if rs == nil { + return false, nil } + if rs.rowsHave.GetIndex(row.Index) { + return false, nil + } + if row.Shares() != rs.SquareSize() { + return false, ErrInvalidRow + } + + tree := wrapper.NewErasuredNamespacedMerkleTree(uint64(rs.SquareSize() / 2)) + row.ForEachShare(func(i int, data []byte) { + tree.Push(data, rsmt2d.SquareIndex{Axis: uint(row.Index), Cell: uint(i)}) + }) root, err := namespace.IntervalDigestFromBytes(ipld.NamespaceSize, tree.Root()) if err != nil { return false, err } - idx, isFound := findRoot(rs.DAHeader, &root) - if !isFound { - return false, fmt.Errorf("invalid row") + if !rs.DAHeader.RowsRoots[row.Index].Equal(&root) { + return false, ErrInvalidRow } - rs.rows[idx] = row - rs.rowsHave.SetIndex(idx, true) + rs.l.Lock() + rs.rows[row.Index] = row + rs.l.Unlock() + rs.rowsHave.SetIndex(row.Index, true) return true, nil } - -func findRoot(dah *ipld.DataAvailabilityHeader, root *namespace.IntervalDigest) (int, bool) { - for i, rr := range dah.RowsRoots { - if rr.Equal(root) { - return i, true - } - } - - return 0, false -} diff --git a/types/row_set_test.go b/types/row_set_test.go new file mode 100644 index 0000000000..9983602ebf --- /dev/null +++ b/types/row_set_test.go @@ -0,0 +1,60 @@ +package types + +import ( + "context" + "testing" + + mdutils "github.com/ipfs/go-merkledag/test" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/lazyledger/lazyledger-core/p2p/ipld" +) + +func TestRowSet(t *testing.T) { + edsIn := ipld.RandEDS(t, 32) + + rsIn := NewRowSet(edsIn) + assert.True(t, rsIn.Count() == rsIn.Total()) + assert.True(t, rsIn.IsComplete()) + + edsOut, err := rsIn.Square() + require.NoError(t, err) + assert.True(t, rsIn.HasHeader(ipld.MakeDataHeader(edsOut))) + assert.True(t, ipld.EqualEDS(edsIn, edsOut)) + + rsOut := NewRowSetFromHeader(rsIn.DAHeader) + for i := 0; i < rsIn.Total(); i++ { + added, err := rsOut.AddRow(rsIn.GetRow(i)) + require.NoError(t, err) + assert.True(t, added) + } + + edsOut, err = rsOut.Square() + require.NoError(t, err) + assert.True(t, rsIn.HasHeader(ipld.MakeDataHeader(edsOut))) + assert.True(t, ipld.EqualEDS(edsIn, edsOut)) +} + +func TestRowSetEmptyBlock(t *testing.T) { + shares, _ := (&Data{}).ComputeShares() + + edsIn, err := ipld.PutData(context.TODO(), shares, mdutils.Mock()) + require.NoError(t, err) + + rsIn := NewRowSet(edsIn) + assert.True(t, rsIn.Count() == rsIn.Total()) + assert.True(t, rsIn.IsComplete()) + + rsOut := NewRowSetFromHeader(rsIn.DAHeader) + for i := 0; i < rsIn.Total(); i++ { + added, err := rsOut.AddRow(rsIn.GetRow(i)) + require.NoError(t, err) + assert.True(t, added) + } + + edsOut, err := rsOut.Square() + require.NoError(t, err) + assert.True(t, rsIn.HasHeader(ipld.MakeDataHeader(edsOut))) + assert.True(t, ipld.EqualEDS(edsIn, edsOut)) +} From 35c52b4b0c164fb7bffe011515dae86f1371e2fc Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 30 Jun 2021 13:00:43 +0300 Subject: [PATCH 14/25] feat(p2p/ipld): add helper methods to DAHeader to show amount of Rows and Col --- p2p/ipld/header.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/p2p/ipld/header.go b/p2p/ipld/header.go index 67f4530a33..53e1a0d782 100644 --- a/p2p/ipld/header.go +++ b/p2p/ipld/header.go @@ -57,6 +57,16 @@ func MakeDataHeader(eds *rsmt2d.ExtendedDataSquare) *DataAvailabilityHeader { return dah } +// Rows tells amount of rows committed to the DAHeader +func (dah *DataAvailabilityHeader) Rows() int { + return len(dah.RowsRoots) +} + +// Cols tells amount of columns committed to the DAHeader +func (dah *DataAvailabilityHeader) Cols() int { + return len(dah.ColumnRoots) +} + type NmtRoots []namespace.IntervalDigest func (roots NmtRoots) Bytes() [][]byte { @@ -88,6 +98,9 @@ func (dah *DataAvailabilityHeader) String() string { // Equals checks equality of two DAHeaders. func (dah *DataAvailabilityHeader) Equals(to *DataAvailabilityHeader) bool { + if dah == nil || to == nil { + return false + } return bytes.Equal(dah.Hash(), to.Hash()) } From 7e011b6426c19443c95904d41f03ca1943797374 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 30 Jun 2021 13:01:22 +0300 Subject: [PATCH 15/25] fix(p2p/ipld): fix testing utilities bugs --- p2p/ipld/testing.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/p2p/ipld/testing.go b/p2p/ipld/testing.go index 7a864fc5e7..dd19c16dc2 100644 --- a/p2p/ipld/testing.go +++ b/p2p/ipld/testing.go @@ -3,7 +3,6 @@ package ipld import ( "bytes" "crypto/sha256" - "math" mrand "math/rand" "sort" "testing" @@ -48,11 +47,11 @@ func RandNamespacedCID(t *testing.T) cid.Cid { func RandEDS(t *testing.T, size int) *rsmt2d.ExtendedDataSquare { shares := RandNamespacedShares(t, size*size) // create the nmt wrapper to generate row and col commitments - squareSize := uint32(math.Sqrt(float64(len(shares)))) - tree := wrapper.NewErasuredNamespacedMerkleTree(uint64(squareSize)) + tree := wrapper.NewErasuredNamespacedMerkleTree(uint64(size)) // recompute the eds eds, err := rsmt2d.ComputeExtendedDataSquare(shares.Raw(), rsmt2d.NewRSGF8Codec(), tree.Constructor) require.NoError(t, err, "failure to recompute the extended data square") + eds.RowRoots() return eds } @@ -73,7 +72,7 @@ func RandNamespacedShares(t *testing.T, total int) NamespacedShares { shares := make(NamespacedShares, total) for i := 0; i < total; i++ { shares[i].ID = data[i] - shares[i].Share = make([]byte, NamespaceSize+ShareSize) + shares[i].Share = make([]byte, ShareSize) copy(shares[i].Share[:NamespaceSize], data[i]) _, err := mrand.Read(shares[i].Share[NamespaceSize:]) // nolint:gosec // G404: Use of weak random number generator require.NoError(t, err) From c27591b3b1bd258b0068af22b3449eb360a45eb4 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 30 Jun 2021 13:03:50 +0300 Subject: [PATCH 16/25] fix(state): block exec: don't return PartSet on CreateProposalBlock --- state/execution.go | 6 +++--- state/state.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/state/execution.go b/state/execution.go index 41ca3ab18c..72ac06b36d 100644 --- a/state/execution.go +++ b/state/execution.go @@ -110,7 +110,7 @@ func (blockExec *BlockExecutor) CreateProposalBlock( height int64, state State, commit *types.Commit, proposerAddr []byte, -) (*types.Block, *types.PartSet, *types.RowSet) { +) (*types.Block, *types.RowSet) { maxBytes := state.ConsensusParams.Block.MaxBytes maxGas := state.ConsensusParams.Block.MaxGas @@ -173,10 +173,10 @@ func (blockExec *BlockExecutor) CreateProposalBlock( rows, err := block.RowSet(context.TODO(), blockExec.adder) if err != nil { blockExec.logger.Error("Can't make RowSet", "err", err) - return nil, nil, nil + return nil, nil } - return block, block.MakePartSet(types.BlockPartSizeBytes), rows + return block, rows } // ValidateBlock validates the given block against the given state. diff --git a/state/state.go b/state/state.go index 2c33977a2f..64a6f8a88a 100644 --- a/state/state.go +++ b/state/state.go @@ -8,8 +8,8 @@ import ( "time" "github.com/gogo/protobuf/proto" - tmbytes "github.com/lazyledger/lazyledger-core/libs/bytes" + tmbytes "github.com/lazyledger/lazyledger-core/libs/bytes" tmstate "github.com/lazyledger/lazyledger-core/proto/tendermint/state" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" tmversion "github.com/lazyledger/lazyledger-core/proto/tendermint/version" From d2bf230ec3c62eeefad2f3ee1ce404d128cefd1c Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 30 Jun 2021 13:11:18 +0300 Subject: [PATCH 17/25] faet(consesnsus): implemenent row gossiping in consensus reactor --- consensus/msgs.go | 55 +++++---- consensus/reactor.go | 176 +++++++++++++--------------- consensus/replay.go | 4 +- consensus/types/peer_round_state.go | 10 +- 4 files changed, 119 insertions(+), 126 deletions(-) diff --git a/consensus/msgs.go b/consensus/msgs.go index 98093be00f..0afebba8df 100644 --- a/consensus/msgs.go +++ b/consensus/msgs.go @@ -10,6 +10,7 @@ import ( "github.com/lazyledger/lazyledger-core/libs/bits" tmmath "github.com/lazyledger/lazyledger-core/libs/math" "github.com/lazyledger/lazyledger-core/p2p" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmcons "github.com/lazyledger/lazyledger-core/proto/tendermint/consensus" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" "github.com/lazyledger/lazyledger-core/types" @@ -36,16 +37,20 @@ func MsgToProto(msg Message) (*tmcons.Message, error) { }, } case *NewValidBlockMessage: - pbPartSetHeader := msg.BlockPartSetHeader.ToProto() - pbBits := msg.BlockParts.ToProto() + dah, err := msg.BlockDAHeader.ToProto() + if err != nil { + return nil, err + } + + pbBits := msg.BlockRows.ToProto() pb = tmcons.Message{ Sum: &tmcons.Message_NewValidBlock{ NewValidBlock: &tmcons.NewValidBlock{ - Height: msg.Height, - Round: msg.Round, - BlockPartSetHeader: pbPartSetHeader, - BlockParts: pbBits, - IsCommit: msg.IsCommit, + Height: msg.Height, + Round: msg.Round, + DaHeader: dah, + BlockParts: pbBits, + IsCommit: msg.IsCommit, }, }, } @@ -73,17 +78,17 @@ func MsgToProto(msg Message) (*tmcons.Message, error) { }, }, } - case *BlockPartMessage: - parts, err := msg.Part.ToProto() + case *BlockRowMessage: + row, err := msg.Row.ToProto() if err != nil { return nil, fmt.Errorf("msg to proto error: %w", err) } pb = tmcons.Message{ - Sum: &tmcons.Message_BlockPart{ - BlockPart: &tmcons.BlockPart{ + Sum: &tmcons.Message_BlockRow{ + BlockRow: &tmcons.BlockRow{ Height: msg.Height, Round: msg.Round, - Part: *parts, + Row: row, }, }, } @@ -169,7 +174,7 @@ func MsgFromProto(msg *tmcons.Message) (Message, error) { LastCommitRound: msg.NewRoundStep.LastCommitRound, } case *tmcons.Message_NewValidBlock: - pbPartSetHeader, err := types.PartSetHeaderFromProto(&msg.NewValidBlock.BlockPartSetHeader) + dah, err := ipld.DataAvailabilityHeaderFromProto(msg.NewValidBlock.DaHeader) if err != nil { return nil, fmt.Errorf("parts header to proto error: %w", err) } @@ -181,11 +186,11 @@ func MsgFromProto(msg *tmcons.Message) (Message, error) { } pb = &NewValidBlockMessage{ - Height: msg.NewValidBlock.Height, - Round: msg.NewValidBlock.Round, - BlockPartSetHeader: *pbPartSetHeader, - BlockParts: pbBits, - IsCommit: msg.NewValidBlock.IsCommit, + Height: msg.NewValidBlock.Height, + Round: msg.NewValidBlock.Round, + BlockDAHeader: dah, + BlockRows: pbBits, + IsCommit: msg.NewValidBlock.IsCommit, } case *tmcons.Message_Proposal: pbP, err := types.ProposalFromProto(&msg.Proposal.Proposal) @@ -207,15 +212,15 @@ func MsgFromProto(msg *tmcons.Message) (Message, error) { ProposalPOLRound: msg.ProposalPol.ProposalPolRound, ProposalPOL: pbBits, } - case *tmcons.Message_BlockPart: - parts, err := types.PartFromProto(&msg.BlockPart.Part) + case *tmcons.Message_BlockRow: + row, err := types.RowFromProto(msg.BlockRow.Row) if err != nil { - return nil, fmt.Errorf("blockpart msg to proto error: %w", err) + return nil, fmt.Errorf("block row msg to proto error: %w", err) } - pb = &BlockPartMessage{ - Height: msg.BlockPart.Height, - Round: msg.BlockPart.Round, - Part: parts, + pb = &BlockRowMessage{ + Height: msg.BlockRow.Height, + Round: msg.BlockRow.Round, + Row: row, } case *tmcons.Message_Vote: vote, err := types.VoteFromProto(msg.Vote.Vote) diff --git a/consensus/reactor.go b/consensus/reactor.go index 09871e7652..5a513eeea8 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -1,6 +1,7 @@ package consensus import ( + "context" "errors" "fmt" "reflect" @@ -8,6 +9,7 @@ import ( "time" "github.com/gogo/protobuf/proto" + mdutils "github.com/ipfs/go-merkledag/test" cstypes "github.com/lazyledger/lazyledger-core/consensus/types" "github.com/lazyledger/lazyledger-core/libs/bits" @@ -16,10 +18,12 @@ import ( "github.com/lazyledger/lazyledger-core/libs/log" tmsync "github.com/lazyledger/lazyledger-core/libs/sync" "github.com/lazyledger/lazyledger-core/p2p" + "github.com/lazyledger/lazyledger-core/p2p/ipld" tmcons "github.com/lazyledger/lazyledger-core/proto/tendermint/consensus" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" sm "github.com/lazyledger/lazyledger-core/state" "github.com/lazyledger/lazyledger-core/types" + "github.com/lazyledger/lazyledger-core/types/consts" tmtime "github.com/lazyledger/lazyledger-core/types/time" ) @@ -313,8 +317,8 @@ func (conR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { conR.conS.peerMsgQueue <- msgInfo{msg, src.ID()} case *ProposalPOLMessage: ps.ApplyProposalPOLMessage(msg) - case *BlockPartMessage: - ps.SetHasProposalBlockPart(msg.Height, msg.Round, int(msg.Part.Index)) + case *BlockRowMessage: + ps.SetHasProposalBlockRow(msg.Height, msg.Round, msg.Row.Index) conR.Metrics.BlockParts.With("peer_id", string(src.ID())).Add(1) conR.conS.peerMsgQueue <- msgInfo{msg, src.ID()} default: @@ -434,11 +438,11 @@ func (conR *Reactor) broadcastNewRoundStepMessage(rs *cstypes.RoundState) { func (conR *Reactor) broadcastNewValidBlockMessage(rs *cstypes.RoundState) { csMsg := &NewValidBlockMessage{ - Height: rs.Height, - Round: rs.Round, - BlockPartSetHeader: rs.ProposalBlockParts.Header(), - BlockParts: rs.ProposalBlockParts.BitArray(), - IsCommit: rs.Step == cstypes.RoundStepCommit, + Height: rs.Height, + Round: rs.Round, + BlockDAHeader: rs.ProposalBlockRows.DAHeader, + BlockRows: rs.ProposalBlockRows.BitArray(), + IsCommit: rs.Step == cstypes.RoundStepCommit, } conR.Switch.Broadcast(StateChannel, MustEncode(csMsg)) } @@ -503,17 +507,16 @@ OUTER_LOOP: prs := ps.GetRoundState() // Send proposal Block parts? - if rs.ProposalBlockParts.HasHeader(prs.ProposalBlockPartSetHeader) { - if index, ok := rs.ProposalBlockParts.BitArray().Sub(prs.ProposalBlockParts.Copy()).PickRandom(); ok { - part := rs.ProposalBlockParts.GetPart(index) - msg := &BlockPartMessage{ + if rs.ProposalBlockRows.HasHeader(prs.ProposalBlockDAHeader) { + if index, ok := rs.ProposalBlockRows.BitArray().Sub(prs.ProposalBlockRows.Copy()).PickRandom(); ok { + msg := &BlockRowMessage{ Height: rs.Height, // This tells peer that this part applies to us. Round: rs.Round, // This tells peer that this part applies to us. - Part: part, + Row: rs.ProposalBlockRows.GetRow(index), } - logger.Debug("Sending block part", "height", prs.Height, "round", prs.Round) + logger.Debug("Sending block row", "height", prs.Height, "round", prs.Round) if peer.Send(DataChannel, MustEncode(msg)) { - ps.SetHasProposalBlockPart(prs.Height, prs.Round, index) + ps.SetHasProposalBlockRow(prs.Height, prs.Round, index) } continue OUTER_LOOP } @@ -524,14 +527,14 @@ OUTER_LOOP: heightLogger := logger.With("height", prs.Height) // if we never received the commit message from the peer, the block parts wont be initialized - if prs.ProposalBlockParts == nil { + if prs.ProposalBlockRows == nil { blockMeta := conR.conS.blockStore.LoadBlockMeta(prs.Height) if blockMeta == nil { heightLogger.Error("Failed to load block meta", "blockstoreBase", conR.conS.blockStore.Base(), "blockstoreHeight", conR.conS.blockStore.Height()) time.Sleep(conR.conS.config.PeerGossipSleepDuration) } else { - ps.InitProposalBlockParts(blockMeta.BlockID.PartSetHeader) + ps.InitProposalBlockRows(&blockMeta.DAHeader) } // continue the loop since prs is a copy and not effected by this initialization continue OUTER_LOOP @@ -589,39 +592,26 @@ OUTER_LOOP: func (conR *Reactor) gossipDataForCatchup(logger log.Logger, rs *cstypes.RoundState, prs *cstypes.PeerRoundState, ps *PeerState, peer p2p.Peer) { - if index, ok := prs.ProposalBlockParts.Not().PickRandom(); ok { - // Ensure that the peer's PartSetHeader is correct - blockMeta := conR.conS.blockStore.LoadBlockMeta(prs.Height) - if blockMeta == nil { - logger.Error("Failed to load block meta", "ourHeight", rs.Height, - "blockstoreBase", conR.conS.blockStore.Base(), "blockstoreHeight", conR.conS.blockStore.Height()) - time.Sleep(conR.conS.config.PeerGossipSleepDuration) - return - } else if !blockMeta.BlockID.PartSetHeader.Equals(prs.ProposalBlockPartSetHeader) { - logger.Info("Peer ProposalBlockPartSetHeader mismatch, sleeping", - "blockPartSetHeader", blockMeta.BlockID.PartSetHeader, "peerBlockPartSetHeader", prs.ProposalBlockPartSetHeader) - time.Sleep(conR.conS.config.PeerGossipSleepDuration) - return - } - // Load the part - part := conR.conS.blockStore.LoadBlockPart(prs.Height, index) - if part == nil { - logger.Error("Could not load part", "index", index, - "blockPartSetHeader", blockMeta.BlockID.PartSetHeader, "peerBlockPartSetHeader", prs.ProposalBlockPartSetHeader) + if index, ok := prs.ProposalBlockRows.Not().PickRandom(); ok { + // TODO(Wondertan): Surely loading block from store every time can be optimized + b := conR.conS.blockStore.LoadBlock(prs.Height) + rs, err := b.RowSet(context.TODO(), mdutils.Mock()) + if err != nil { + conR.Logger.Error("can't make RowSet", "err", err) time.Sleep(conR.conS.config.PeerGossipSleepDuration) return } // Send the part - msg := &BlockPartMessage{ + msg := &BlockRowMessage{ Height: prs.Height, // Not our height, so it doesn't matter. Round: prs.Round, // Not our height, so it doesn't matter. - Part: part, + Row: rs.GetRow(index), } - logger.Debug("Sending block part for catchup", "round", prs.Round, "index", index) + logger.Debug("Sending block row for catchup", "round", prs.Round, "index", index) if peer.Send(DataChannel, MustEncode(msg)) { - ps.SetHasProposalBlockPart(prs.Height, prs.Round, index) + ps.SetHasProposalBlockRow(prs.Height, prs.Round, index) } else { - logger.Debug("Sending block part for catchup failed") + logger.Debug("Sending block row for catchup failed") } return } @@ -876,8 +866,8 @@ func (conR *Reactor) peerStatsRoutine() { if numVotes := ps.RecordVote(); numVotes%votesToContributeToBecomeGoodPeer == 0 { conR.Switch.MarkPeerAsGood(peer) } - case *BlockPartMessage: - if numParts := ps.RecordBlockPart(); numParts%blocksToContributeToBecomeGoodPeer == 0 { + case *BlockRowMessage: + if numParts := ps.RecordBlockRow(); numParts%blocksToContributeToBecomeGoodPeer == 0 { conR.Switch.MarkPeerAsGood(peer) } } @@ -940,13 +930,13 @@ type PeerState struct { // peerStateStats holds internal statistics for a peer. type peerStateStats struct { - Votes int `json:"votes"` - BlockParts int `json:"block_parts"` + Votes int `json:"votes"` + BlockRows int `json:"block_rows"` } func (pss peerStateStats) String() string { - return fmt.Sprintf("peerStateStats{votes: %d, blockParts: %d}", - pss.Votes, pss.BlockParts) + return fmt.Sprintf("peerStateStats{votes: %d, blockRows: %d}", + pss.Votes, pss.BlockRows) } // NewPeerState returns a new PeerState for the given Peer @@ -1012,32 +1002,32 @@ func (ps *PeerState) SetHasProposal(proposal *types.Proposal) { ps.PRS.Proposal = true - // ps.PRS.ProposalBlockParts is set due to NewValidBlockMessage - if ps.PRS.ProposalBlockParts != nil { + // ps.PRS.ProposalBlockRows is set due to NewValidBlockMessage + if ps.PRS.ProposalBlockRows != nil { return } - ps.PRS.ProposalBlockPartSetHeader = proposal.BlockID.PartSetHeader - ps.PRS.ProposalBlockParts = bits.NewBitArray(int(proposal.BlockID.PartSetHeader.Total)) + ps.PRS.ProposalBlockDAHeader = proposal.DAHeader + ps.PRS.ProposalBlockRows = bits.NewBitArray(proposal.DAHeader.Rows()) ps.PRS.ProposalPOLRound = proposal.POLRound ps.PRS.ProposalPOL = nil // Nil until ProposalPOLMessage received. } -// InitProposalBlockParts initializes the peer's proposal block parts header and bit array. -func (ps *PeerState) InitProposalBlockParts(partSetHeader types.PartSetHeader) { +// InitProposalBlockRows initializes the peer's proposal block parts header and bit array. +func (ps *PeerState) InitProposalBlockRows(dah *ipld.DataAvailabilityHeader) { ps.mtx.Lock() defer ps.mtx.Unlock() - if ps.PRS.ProposalBlockParts != nil { + if ps.PRS.ProposalBlockRows != nil { return } - ps.PRS.ProposalBlockPartSetHeader = partSetHeader - ps.PRS.ProposalBlockParts = bits.NewBitArray(int(partSetHeader.Total)) + ps.PRS.ProposalBlockDAHeader = dah + ps.PRS.ProposalBlockRows = bits.NewBitArray(dah.Rows()) } -// SetHasProposalBlockPart sets the given block part index as known for the peer. -func (ps *PeerState) SetHasProposalBlockPart(height int64, round int32, index int) { +// SetHasProposalBlockRow sets the given block part index as known for the peer. +func (ps *PeerState) SetHasProposalBlockRow(height int64, round int32, index int) { ps.mtx.Lock() defer ps.mtx.Unlock() @@ -1045,7 +1035,7 @@ func (ps *PeerState) SetHasProposalBlockPart(height int64, round int32, index in return } - ps.PRS.ProposalBlockParts.SetIndex(index, true) + ps.PRS.ProposalBlockRows.SetIndex(index, true) } // PickSendVote picks a vote and sends it to the peer. @@ -1219,14 +1209,14 @@ func (ps *PeerState) VotesSent() int { return ps.Stats.Votes } -// RecordBlockPart increments internal block part related statistics for this peer. +// RecordBlockRow increments internal block part related statistics for this peer. // It returns the total number of added block parts. -func (ps *PeerState) RecordBlockPart() int { +func (ps *PeerState) RecordBlockRow() int { ps.mtx.Lock() defer ps.mtx.Unlock() - ps.Stats.BlockParts++ - return ps.Stats.BlockParts + ps.Stats.BlockRows++ + return ps.Stats.BlockRows } // BlockPartsSent returns the number of useful block parts the peer has sent us. @@ -1234,7 +1224,7 @@ func (ps *PeerState) BlockPartsSent() int { ps.mtx.Lock() defer ps.mtx.Unlock() - return ps.Stats.BlockParts + return ps.Stats.BlockRows } // SetHasVote sets the given vote as known by the peer @@ -1283,8 +1273,8 @@ func (ps *PeerState) ApplyNewRoundStepMessage(msg *NewRoundStepMessage) { ps.PRS.StartTime = startTime if psHeight != msg.Height || psRound != msg.Round { ps.PRS.Proposal = false - ps.PRS.ProposalBlockPartSetHeader = types.PartSetHeader{} - ps.PRS.ProposalBlockParts = nil + ps.PRS.ProposalBlockDAHeader = nil + ps.PRS.ProposalBlockRows = nil ps.PRS.ProposalPOLRound = -1 ps.PRS.ProposalPOL = nil // We'll update the BitArray capacity later. @@ -1326,8 +1316,8 @@ func (ps *PeerState) ApplyNewValidBlockMessage(msg *NewValidBlockMessage) { return } - ps.PRS.ProposalBlockPartSetHeader = msg.BlockPartSetHeader - ps.PRS.ProposalBlockParts = msg.BlockParts + ps.PRS.ProposalBlockDAHeader = msg.BlockDAHeader + ps.PRS.ProposalBlockRows = msg.BlockRows } // ApplyProposalPOLMessage updates the peer state for the new proposal POL. @@ -1413,7 +1403,7 @@ func init() { tmjson.RegisterType(&NewValidBlockMessage{}, "tendermint/NewValidBlockMessage") tmjson.RegisterType(&ProposalMessage{}, "tendermint/Proposal") tmjson.RegisterType(&ProposalPOLMessage{}, "tendermint/ProposalPOL") - tmjson.RegisterType(&BlockPartMessage{}, "tendermint/BlockPart") + tmjson.RegisterType(&BlockRowMessage{}, "tendermint/BlockRow") tmjson.RegisterType(&VoteMessage{}, "tendermint/Vote") tmjson.RegisterType(&HasVoteMessage{}, "tendermint/HasVote") tmjson.RegisterType(&VoteSetMaj23Message{}, "tendermint/VoteSetMaj23") @@ -1494,11 +1484,11 @@ func (m *NewRoundStepMessage) String() string { // i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r. // In case the block is also committed, then IsCommit flag is set to true. type NewValidBlockMessage struct { - Height int64 - Round int32 - BlockPartSetHeader types.PartSetHeader - BlockParts *bits.BitArray - IsCommit bool + Height int64 + Round int32 + BlockDAHeader *ipld.DataAvailabilityHeader + BlockRows *bits.BitArray + IsCommit bool } // ValidateBasic performs basic validation. @@ -1509,27 +1499,25 @@ func (m *NewValidBlockMessage) ValidateBasic() error { if m.Round < 0 { return errors.New("negative Round") } - if err := m.BlockPartSetHeader.ValidateBasic(); err != nil { - return fmt.Errorf("wrong BlockPartSetHeader: %v", err) - } - if m.BlockParts.Size() == 0 { - return errors.New("empty blockParts") + if m.BlockRows.Size() == 0 { + return errors.New("empty BlockRows") } - if m.BlockParts.Size() != int(m.BlockPartSetHeader.Total) { - return fmt.Errorf("blockParts bit array size %d not equal to BlockPartSetHeader.Total %d", - m.BlockParts.Size(), - m.BlockPartSetHeader.Total) + if m.BlockRows.Size() != m.BlockDAHeader.Rows() { + return fmt.Errorf("block rows bit array size %d not equal to BlockDAHeader.Rows %d", + m.BlockRows.Size(), + m.BlockDAHeader.Rows(), + ) } - if m.BlockParts.Size() > int(types.MaxBlockPartsCount) { - return fmt.Errorf("blockParts bit array is too big: %d, max: %d", m.BlockParts.Size(), types.MaxBlockPartsCount) + if m.BlockRows.Size() > consts.MaxSquareSize { + return fmt.Errorf("block rows bit array is too big: %d, max: %d", m.BlockRows.Size(), consts.MaxSquareSize) } return nil } // String returns a string representation. func (m *NewValidBlockMessage) String() string { - return fmt.Sprintf("[ValidBlockMessage H:%v R:%v BP:%v BA:%v IsCommit:%v]", - m.Height, m.Round, m.BlockPartSetHeader, m.BlockParts, m.IsCommit) + return fmt.Sprintf("[ValidBlockMessage H:%v R:%v BR:%v BA:%v IsCommit:%v]", + m.Height, m.Round, m.BlockDAHeader, m.BlockRows, m.IsCommit) } //------------------------------------- @@ -1582,30 +1570,30 @@ func (m *ProposalPOLMessage) String() string { //------------------------------------- -// BlockPartMessage is sent when gossipping a piece of the proposed block. -type BlockPartMessage struct { +// BlockRowMessage is sent when gossipping a piece of the proposed block. +type BlockRowMessage struct { Height int64 Round int32 - Part *types.Part + Row *types.Row } // ValidateBasic performs basic validation. -func (m *BlockPartMessage) ValidateBasic() error { +func (m *BlockRowMessage) ValidateBasic() error { if m.Height < 0 { return errors.New("negative Height") } if m.Round < 0 { return errors.New("negative Round") } - if err := m.Part.ValidateBasic(); err != nil { - return fmt.Errorf("wrong Part: %v", err) + if err := m.Row.ValidateBasic(); err != nil { + return fmt.Errorf("wrong Row: %v", err) } return nil } // String returns a string representation. -func (m *BlockPartMessage) String() string { - return fmt.Sprintf("[BlockPart H:%v R:%v P:%v]", m.Height, m.Round, m.Part) +func (m *BlockRowMessage) String() string { + return fmt.Sprintf("[BlockRow H:%v R:%v P:%v]", m.Height, m.Round, m.Row) } //------------------------------------- diff --git a/consensus/replay.go b/consensus/replay.go index 7eca15b7e5..aa6ccd91c7 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -71,8 +71,8 @@ func (cs *State) readReplayMessage(msg *TimedWALMessage, newStepSub types.Subscr p := msg.Proposal cs.Logger.Info("Replay: Proposal", "height", p.Height, "round", p.Round, "header", p.BlockID.PartSetHeader, "pol", p.POLRound, "peer", peerID) - case *BlockPartMessage: - cs.Logger.Info("Replay: BlockPart", "height", msg.Height, "round", msg.Round, "peer", peerID) + case *BlockRowMessage: + cs.Logger.Info("Replay: BlockRow", "height", msg.Height, "round", msg.Round, "peer", peerID) case *VoteMessage: v := msg.Vote cs.Logger.Info("Replay: Vote", "height", v.Height, "round", v.Round, "type", v.Type, diff --git a/consensus/types/peer_round_state.go b/consensus/types/peer_round_state.go index 6a1447eec0..b281cd51af 100644 --- a/consensus/types/peer_round_state.go +++ b/consensus/types/peer_round_state.go @@ -5,7 +5,7 @@ import ( "time" "github.com/lazyledger/lazyledger-core/libs/bits" - "github.com/lazyledger/lazyledger-core/types" + "github.com/lazyledger/lazyledger-core/p2p/ipld" ) //----------------------------------------------------------------------------- @@ -21,9 +21,9 @@ type PeerRoundState struct { StartTime time.Time `json:"start_time"` // True if peer has proposal for this round - Proposal bool `json:"proposal"` - ProposalBlockPartSetHeader types.PartSetHeader `json:"proposal_block_part_set_header"` - ProposalBlockParts *bits.BitArray `json:"proposal_block_parts"` + Proposal bool `json:"proposal"` + ProposalBlockDAHeader *ipld.DataAvailabilityHeader `json:"proposal_block_part_set_header"` + ProposalBlockRows *bits.BitArray `json:"proposal_block_parts"` // Proposal's POL round. -1 if none. ProposalPOLRound int32 `json:"proposal_pol_round"` @@ -58,7 +58,7 @@ func (prs PeerRoundState) StringIndented(indent string) string { %s Catchup %v (round %v) %s}`, indent, prs.Height, prs.Round, prs.Step, prs.StartTime, - indent, prs.ProposalBlockPartSetHeader, prs.ProposalBlockParts, + indent, prs.ProposalBlockDAHeader, prs.ProposalBlockRows, indent, prs.ProposalPOL, prs.ProposalPOLRound, indent, prs.Prevotes, indent, prs.Precommits, From bad2b9f21ca00478e17e3cb45de7e327192ca8b5 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 30 Jun 2021 13:13:57 +0300 Subject: [PATCH 18/25] feat(proto): update protos for row block gossiping --- abci/types/types.pb.go | 220 ++------- proto/tendermint/blockchain/types.pb.go | 30 +- proto/tendermint/consensus/types.pb.go | 333 +++++++------- proto/tendermint/consensus/types.proto | 10 +- proto/tendermint/consensus/wal.pb.go | 25 +- proto/tendermint/crypto/keys.pb.go | 5 +- proto/tendermint/crypto/proof.pb.go | 25 +- proto/tendermint/libs/bits/types.pb.go | 5 +- proto/tendermint/mempool/types.pb.go | 10 +- proto/tendermint/p2p/conn.pb.go | 25 +- proto/tendermint/p2p/pex.pb.go | 15 +- proto/tendermint/p2p/types.pb.go | 20 +- proto/tendermint/privval/types.pb.go | 55 +-- proto/tendermint/state/types.pb.go | 25 +- proto/tendermint/statesync/types.pb.go | 25 +- proto/tendermint/store/types.pb.go | 5 +- proto/tendermint/types/block.pb.go | 5 +- proto/tendermint/types/canonical.pb.go | 20 +- proto/tendermint/types/events.pb.go | 5 +- proto/tendermint/types/params.pb.go | 30 +- proto/tendermint/types/types.pb.go | 583 +++++++++++++++--------- proto/tendermint/types/types.proto | 5 + proto/tendermint/types/validator.pb.go | 15 +- proto/tendermint/version/types.pb.go | 5 +- rpc/grpc/types.pb.go | 20 +- 25 files changed, 651 insertions(+), 870 deletions(-) diff --git a/abci/types/types.pb.go b/abci/types/types.pb.go index ca723b42e0..c274f8a6bb 100644 --- a/abci/types/types.pb.go +++ b/abci/types/types.pb.go @@ -8313,10 +8313,7 @@ func (m *Request) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -8398,10 +8395,7 @@ func (m *RequestEcho) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -8451,10 +8445,7 @@ func (m *RequestFlush) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -8606,10 +8597,7 @@ func (m *RequestInfo) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -8847,10 +8835,7 @@ func (m *RequestInitChain) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -9005,10 +8990,7 @@ func (m *RequestQuery) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -9192,10 +9174,7 @@ func (m *RequestBeginBlock) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -9298,10 +9277,7 @@ func (m *RequestCheckTx) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -9385,10 +9361,7 @@ func (m *RequestDeliverTx) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -9457,10 +9430,7 @@ func (m *RequestEndBlock) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -9510,10 +9480,7 @@ func (m *RequestCommit) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -9563,10 +9530,7 @@ func (m *RequestListSnapshots) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -9686,10 +9650,7 @@ func (m *RequestOfferSnapshot) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -9796,10 +9757,7 @@ func (m *RequestLoadSnapshotChunk) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -9934,10 +9892,7 @@ func (m *RequestApplySnapshotChunk) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -10019,10 +9974,7 @@ func (m *RequestPreprocessTxs) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -10632,10 +10584,7 @@ func (m *Response) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -10717,10 +10666,7 @@ func (m *ResponseException) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -10802,10 +10748,7 @@ func (m *ResponseEcho) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -10855,10 +10798,7 @@ func (m *ResponseFlush) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -11044,10 +10984,7 @@ func (m *ResponseInfo) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -11201,10 +11138,7 @@ func (m *ResponseInitChain) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -11511,10 +11445,7 @@ func (m *ResponseQuery) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -11598,10 +11529,7 @@ func (m *ResponseBeginBlock) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -11872,10 +11800,7 @@ func (m *ResponseCheckTx) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -12146,10 +12071,7 @@ func (m *ResponseDeliverTx) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -12303,10 +12225,7 @@ func (m *ResponseEndBlock) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -12409,10 +12328,7 @@ func (m *ResponseCommit) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -12496,10 +12412,7 @@ func (m *ResponseListSnapshots) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -12568,10 +12481,7 @@ func (m *ResponseOfferSnapshot) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -12655,10 +12565,7 @@ func (m *ResponseLoadSnapshotChunk) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -12835,10 +12742,7 @@ func (m *ResponseApplySnapshotChunk) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -12956,10 +12860,7 @@ func (m *ResponsePreprocessTxs) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -13153,10 +13054,7 @@ func (m *ConsensusParams) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -13244,10 +13142,7 @@ func (m *BlockParams) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -13350,10 +13245,7 @@ func (m *LastCommitInfo) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -13469,10 +13361,7 @@ func (m *Event) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -13610,10 +13499,7 @@ func (m *EventAttribute) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -13768,10 +13654,7 @@ func (m *TxResult) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -13874,10 +13757,7 @@ func (m *Validator) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -13979,10 +13859,7 @@ func (m *ValidatorUpdate) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -14085,10 +13962,7 @@ func (m *VoteInfo) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -14261,10 +14135,7 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -14439,10 +14310,7 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/blockchain/types.pb.go b/proto/tendermint/blockchain/types.pb.go index 16e70d09e7..2ec783ed7f 100644 --- a/proto/tendermint/blockchain/types.pb.go +++ b/proto/tendermint/blockchain/types.pb.go @@ -900,10 +900,7 @@ func (m *BlockRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -972,10 +969,7 @@ func (m *NoBlockResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1061,10 +1055,7 @@ func (m *BlockResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1114,10 +1105,7 @@ func (m *StatusRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1205,10 +1193,7 @@ func (m *StatusResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1433,10 +1418,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/consensus/types.pb.go b/proto/tendermint/consensus/types.pb.go index c2a820ee2b..178735fdf0 100644 --- a/proto/tendermint/consensus/types.pb.go +++ b/proto/tendermint/consensus/types.pb.go @@ -107,11 +107,11 @@ func (m *NewRoundStep) GetLastCommitRound() int32 { //i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r. // In case the block is also committed, then IsCommit flag is set to true. type NewValidBlock struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` - BlockPartSetHeader types.PartSetHeader `protobuf:"bytes,3,opt,name=block_part_set_header,json=blockPartSetHeader,proto3" json:"block_part_set_header"` - BlockParts *bits.BitArray `protobuf:"bytes,4,opt,name=block_parts,json=blockParts,proto3" json:"block_parts,omitempty"` - IsCommit bool `protobuf:"varint,5,opt,name=is_commit,json=isCommit,proto3" json:"is_commit,omitempty"` + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` + DaHeader *types.DataAvailabilityHeader `protobuf:"bytes,3,opt,name=da_header,json=daHeader,proto3" json:"da_header,omitempty"` + BlockParts *bits.BitArray `protobuf:"bytes,4,opt,name=block_parts,json=blockParts,proto3" json:"block_parts,omitempty"` + IsCommit bool `protobuf:"varint,5,opt,name=is_commit,json=isCommit,proto3" json:"is_commit,omitempty"` } func (m *NewValidBlock) Reset() { *m = NewValidBlock{} } @@ -161,11 +161,11 @@ func (m *NewValidBlock) GetRound() int32 { return 0 } -func (m *NewValidBlock) GetBlockPartSetHeader() types.PartSetHeader { +func (m *NewValidBlock) GetDaHeader() *types.DataAvailabilityHeader { if m != nil { - return m.BlockPartSetHeader + return m.DaHeader } - return types.PartSetHeader{} + return nil } func (m *NewValidBlock) GetBlockParts() *bits.BitArray { @@ -288,25 +288,25 @@ func (m *ProposalPOL) GetProposalPol() bits.BitArray { return bits.BitArray{} } -// BlockPart is sent when gossipping a piece of the proposed block. -type BlockPart struct { +// BlockRow is sent when gossipping a piece of the proposed block. +type BlockRow struct { Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` - Part types.Part `protobuf:"bytes,3,opt,name=part,proto3" json:"part"` + Row *types.Row `protobuf:"bytes,3,opt,name=row,proto3" json:"row,omitempty"` } -func (m *BlockPart) Reset() { *m = BlockPart{} } -func (m *BlockPart) String() string { return proto.CompactTextString(m) } -func (*BlockPart) ProtoMessage() {} -func (*BlockPart) Descriptor() ([]byte, []int) { +func (m *BlockRow) Reset() { *m = BlockRow{} } +func (m *BlockRow) String() string { return proto.CompactTextString(m) } +func (*BlockRow) ProtoMessage() {} +func (*BlockRow) Descriptor() ([]byte, []int) { return fileDescriptor_81a22d2efc008981, []int{4} } -func (m *BlockPart) XXX_Unmarshal(b []byte) error { +func (m *BlockRow) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *BlockPart) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *BlockRow) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_BlockPart.Marshal(b, m, deterministic) + return xxx_messageInfo_BlockRow.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -316,37 +316,37 @@ func (m *BlockPart) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *BlockPart) XXX_Merge(src proto.Message) { - xxx_messageInfo_BlockPart.Merge(m, src) +func (m *BlockRow) XXX_Merge(src proto.Message) { + xxx_messageInfo_BlockRow.Merge(m, src) } -func (m *BlockPart) XXX_Size() int { +func (m *BlockRow) XXX_Size() int { return m.Size() } -func (m *BlockPart) XXX_DiscardUnknown() { - xxx_messageInfo_BlockPart.DiscardUnknown(m) +func (m *BlockRow) XXX_DiscardUnknown() { + xxx_messageInfo_BlockRow.DiscardUnknown(m) } -var xxx_messageInfo_BlockPart proto.InternalMessageInfo +var xxx_messageInfo_BlockRow proto.InternalMessageInfo -func (m *BlockPart) GetHeight() int64 { +func (m *BlockRow) GetHeight() int64 { if m != nil { return m.Height } return 0 } -func (m *BlockPart) GetRound() int32 { +func (m *BlockRow) GetRound() int32 { if m != nil { return m.Round } return 0 } -func (m *BlockPart) GetPart() types.Part { +func (m *BlockRow) GetRow() *types.Row { if m != nil { - return m.Part + return m.Row } - return types.Part{} + return nil } // Vote is sent when voting for a proposal (or lack thereof). @@ -615,7 +615,7 @@ type Message struct { // *Message_NewValidBlock // *Message_Proposal // *Message_ProposalPol - // *Message_BlockPart + // *Message_BlockRow // *Message_Vote // *Message_HasVote // *Message_VoteSetMaj23 @@ -674,8 +674,8 @@ type Message_Proposal struct { type Message_ProposalPol struct { ProposalPol *ProposalPOL `protobuf:"bytes,4,opt,name=proposal_pol,json=proposalPol,proto3,oneof" json:"proposal_pol,omitempty"` } -type Message_BlockPart struct { - BlockPart *BlockPart `protobuf:"bytes,5,opt,name=block_part,json=blockPart,proto3,oneof" json:"block_part,omitempty"` +type Message_BlockRow struct { + BlockRow *BlockRow `protobuf:"bytes,5,opt,name=block_row,json=blockRow,proto3,oneof" json:"block_row,omitempty"` } type Message_Vote struct { Vote *Vote `protobuf:"bytes,6,opt,name=vote,proto3,oneof" json:"vote,omitempty"` @@ -694,7 +694,7 @@ func (*Message_NewRoundStep) isMessage_Sum() {} func (*Message_NewValidBlock) isMessage_Sum() {} func (*Message_Proposal) isMessage_Sum() {} func (*Message_ProposalPol) isMessage_Sum() {} -func (*Message_BlockPart) isMessage_Sum() {} +func (*Message_BlockRow) isMessage_Sum() {} func (*Message_Vote) isMessage_Sum() {} func (*Message_HasVote) isMessage_Sum() {} func (*Message_VoteSetMaj23) isMessage_Sum() {} @@ -735,9 +735,9 @@ func (m *Message) GetProposalPol() *ProposalPOL { return nil } -func (m *Message) GetBlockPart() *BlockPart { - if x, ok := m.GetSum().(*Message_BlockPart); ok { - return x.BlockPart +func (m *Message) GetBlockRow() *BlockRow { + if x, ok := m.GetSum().(*Message_BlockRow); ok { + return x.BlockRow } return nil } @@ -777,7 +777,7 @@ func (*Message) XXX_OneofWrappers() []interface{} { (*Message_NewValidBlock)(nil), (*Message_Proposal)(nil), (*Message_ProposalPol)(nil), - (*Message_BlockPart)(nil), + (*Message_BlockRow)(nil), (*Message_Vote)(nil), (*Message_HasVote)(nil), (*Message_VoteSetMaj23)(nil), @@ -790,7 +790,7 @@ func init() { proto.RegisterType((*NewValidBlock)(nil), "tendermint.consensus.NewValidBlock") proto.RegisterType((*Proposal)(nil), "tendermint.consensus.Proposal") proto.RegisterType((*ProposalPOL)(nil), "tendermint.consensus.ProposalPOL") - proto.RegisterType((*BlockPart)(nil), "tendermint.consensus.BlockPart") + proto.RegisterType((*BlockRow)(nil), "tendermint.consensus.BlockRow") proto.RegisterType((*Vote)(nil), "tendermint.consensus.Vote") proto.RegisterType((*HasVote)(nil), "tendermint.consensus.HasVote") proto.RegisterType((*VoteSetMaj23)(nil), "tendermint.consensus.VoteSetMaj23") @@ -801,61 +801,62 @@ func init() { func init() { proto.RegisterFile("tendermint/consensus/types.proto", fileDescriptor_81a22d2efc008981) } var fileDescriptor_81a22d2efc008981 = []byte{ - // 863 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4f, 0x8f, 0xdb, 0x44, - 0x14, 0xb7, 0x59, 0x67, 0x93, 0x7d, 0xde, 0x3f, 0x30, 0xda, 0x56, 0x61, 0x81, 0x6c, 0x30, 0x97, - 0x15, 0x02, 0x07, 0x65, 0x0f, 0x48, 0x15, 0x12, 0xc5, 0xfc, 0xa9, 0x5b, 0x35, 0x6d, 0xe4, 0x54, - 0x15, 0xea, 0xc5, 0x72, 0xe2, 0x91, 0x33, 0xd4, 0xf6, 0x58, 0x9e, 0x49, 0x96, 0x70, 0xe4, 0x13, - 0xf0, 0x01, 0xf8, 0x1a, 0x48, 0x7c, 0x84, 0x1e, 0x7b, 0xe4, 0x54, 0xa1, 0xec, 0x47, 0x40, 0x70, - 0x46, 0x33, 0x9e, 0x24, 0x13, 0xea, 0x2e, 0xec, 0x05, 0xa9, 0xb7, 0x99, 0xbc, 0xf7, 0x7e, 0xf3, - 0xde, 0xef, 0xbd, 0xf7, 0x8b, 0xa1, 0xcb, 0x71, 0x1e, 0xe3, 0x32, 0x23, 0x39, 0xef, 0x4d, 0x68, - 0xce, 0x70, 0xce, 0x66, 0xac, 0xc7, 0x17, 0x05, 0x66, 0x6e, 0x51, 0x52, 0x4e, 0xd1, 0xf1, 0xc6, - 0xc3, 0x5d, 0x7b, 0x9c, 0x1c, 0x27, 0x34, 0xa1, 0xd2, 0xa1, 0x27, 0x4e, 0x95, 0xef, 0xc9, 0xbb, - 0x1a, 0x9a, 0xc4, 0xd0, 0x91, 0x4e, 0xf4, 0xb7, 0x52, 0x32, 0x66, 0xbd, 0x31, 0xe1, 0x5b, 0x1e, - 0xce, 0x2f, 0x26, 0xec, 0x3f, 0xc0, 0x17, 0x01, 0x9d, 0xe5, 0xf1, 0x88, 0xe3, 0x02, 0xdd, 0x84, - 0xdd, 0x29, 0x26, 0xc9, 0x94, 0xb7, 0xcd, 0xae, 0x79, 0xb6, 0x13, 0x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, 0x3e, - 0x4a, 0xed, 0xbe, 0x6f, 0x04, 0xcd, 0xa9, 0x92, 0x81, 0x7b, 0x70, 0x28, 0xe2, 0xe4, 0xdf, 0x49, - 0x26, 0xd6, 0xb1, 0xdd, 0xba, 0xaa, 0xa1, 0xfa, 0xe2, 0x8a, 0x86, 0xce, 0xf5, 0x45, 0xbe, 0x03, - 0x07, 0x6b, 0x2c, 0x31, 0x4f, 0xed, 0xbd, 0xab, 0x48, 0xd4, 0x16, 0x49, 0x90, 0x38, 0xdf, 0x5c, - 0xbd, 0x06, 0xec, 0xb0, 0x59, 0xe6, 0x3d, 0x79, 0xb6, 0xec, 0x98, 0xcf, 0x97, 0x1d, 0xf3, 0xf7, - 0x65, 0xc7, 0xfc, 0xe9, 0xb2, 0x63, 0x3c, 0xbf, 0xec, 0x18, 0xbf, 0x5d, 0x76, 0x8c, 0x27, 0xb7, - 0x13, 0xc2, 0xa7, 0xb3, 0xb1, 0x3b, 0xa1, 0x59, 0x2f, 0x8d, 0x7e, 0x58, 0xa4, 0x38, 0x4e, 0x70, - 0xa9, 0x1d, 0x3f, 0x9e, 0xd0, 0x12, 0xf7, 0xaa, 0x4f, 0x8f, 0xba, 0x8f, 0x97, 0xf1, 0xae, 0xb4, - 0x9d, 0xff, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x08, 0xab, 0x10, 0x2c, 0xdb, 0x08, 0x00, 0x00, + // 871 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xdd, 0x8e, 0xdb, 0x44, + 0x14, 0xb6, 0xd9, 0x64, 0xe3, 0x3d, 0xde, 0x1f, 0x18, 0x6d, 0xab, 0xb0, 0x40, 0x76, 0x31, 0x17, + 0xac, 0x10, 0x38, 0x28, 0x7b, 0x81, 0x54, 0x81, 0xa0, 0xa1, 0xa5, 0x6e, 0xd5, 0x6d, 0xa3, 0x49, + 0xd5, 0x8b, 0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0xa5, 0x86, 0xa9, 0xb9, 0xb3, 0xa9, + 0x82, 0x86, 0x8a, 0x54, 0x05, 0x27, 0xcb, 0x6d, 0xb7, 0x0e, 0x5b, 0x62, 0x9c, 0x76, 0x5f, 0xbc, + 0x9c, 0xb7, 0xec, 0x57, 0xf3, 0x96, 0xfd, 0xe7, 0xbc, 0x65, 0xff, 0x72, 0xd1, 0xb2, 0x5e, 0x5d, + 0xb4, 0xac, 0x3f, 0x2e, 0x5a, 0xd6, 0x8b, 0x6f, 0x62, 0x26, 0x47, 0xe3, 0x81, 0x3f, 0xe4, 0x69, + 0x3b, 0x21, 0x3f, 0xcd, 0x12, 0x1a, 0xc5, 0xb4, 0x30, 0x96, 0x9f, 0x0d, 0x79, 0x41, 0xdb, 0xe5, + 0xaf, 0xc5, 0xba, 0x9f, 0x93, 0xc1, 0xb6, 0x3e, 0x3b, 0xfb, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xa9, + 0xe2, 0xd7, 0xc3, 0xbb, 0x08, 0x00, 0x00, } func (m *NewRoundStep) Marshal() (dAtA []byte, err error) { @@ -948,16 +949,18 @@ func (m *NewValidBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - { - size, err := m.BlockPartSetHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.DaHeader != nil { + { + size, err := m.DaHeader.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a } - i-- - dAtA[i] = 0x1a if m.Round != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.Round)) i-- @@ -1047,7 +1050,7 @@ func (m *ProposalPOL) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *BlockPart) Marshal() (dAtA []byte, err error) { +func (m *BlockRow) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1057,26 +1060,28 @@ func (m *BlockPart) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *BlockPart) MarshalTo(dAtA []byte) (int, error) { +func (m *BlockRow) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *BlockPart) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *BlockRow) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size, err := m.Part.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.Row != nil { + { + size, err := m.Row.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a } - i-- - dAtA[i] = 0x1a if m.Round != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.Round)) i-- @@ -1390,16 +1395,16 @@ func (m *Message_ProposalPol) MarshalToSizedBuffer(dAtA []byte) (int, error) { } return len(dAtA) - i, nil } -func (m *Message_BlockPart) MarshalTo(dAtA []byte) (int, error) { +func (m *Message_BlockRow) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Message_BlockPart) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Message_BlockRow) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) - if m.BlockPart != nil { + if m.BlockRow != nil { { - size, err := m.BlockPart.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.BlockRow.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1542,8 +1547,10 @@ func (m *NewValidBlock) Size() (n int) { if m.Round != 0 { n += 1 + sovTypes(uint64(m.Round)) } - l = m.BlockPartSetHeader.Size() - n += 1 + l + sovTypes(uint64(l)) + if m.DaHeader != nil { + l = m.DaHeader.Size() + n += 1 + l + sovTypes(uint64(l)) + } if m.BlockParts != nil { l = m.BlockParts.Size() n += 1 + l + sovTypes(uint64(l)) @@ -1582,7 +1589,7 @@ func (m *ProposalPOL) Size() (n int) { return n } -func (m *BlockPart) Size() (n int) { +func (m *BlockRow) Size() (n int) { if m == nil { return 0 } @@ -1594,8 +1601,10 @@ func (m *BlockPart) Size() (n int) { if m.Round != 0 { n += 1 + sovTypes(uint64(m.Round)) } - l = m.Part.Size() - n += 1 + l + sovTypes(uint64(l)) + if m.Row != nil { + l = m.Row.Size() + n += 1 + l + sovTypes(uint64(l)) + } return n } @@ -1735,14 +1744,14 @@ func (m *Message_ProposalPol) Size() (n int) { } return n } -func (m *Message_BlockPart) Size() (n int) { +func (m *Message_BlockRow) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.BlockPart != nil { - l = m.BlockPart.Size() + if m.BlockRow != nil { + l = m.BlockRow.Size() n += 1 + l + sovTypes(uint64(l)) } return n @@ -1932,10 +1941,7 @@ func (m *NewRoundStep) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2019,7 +2025,7 @@ func (m *NewValidBlock) Unmarshal(dAtA []byte) error { } case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockPartSetHeader", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DaHeader", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2046,7 +2052,10 @@ func (m *NewValidBlock) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.BlockPartSetHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.DaHeader == nil { + m.DaHeader = &types.DataAvailabilityHeader{} + } + if err := m.DaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2112,10 +2121,7 @@ func (m *NewValidBlock) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2198,10 +2204,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2322,10 +2325,7 @@ func (m *ProposalPOL) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2340,7 +2340,7 @@ func (m *ProposalPOL) Unmarshal(dAtA []byte) error { } return nil } -func (m *BlockPart) Unmarshal(dAtA []byte) error { +func (m *BlockRow) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2363,10 +2363,10 @@ func (m *BlockPart) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: BlockPart: wiretype end group for non-group") + return fmt.Errorf("proto: BlockRow: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: BlockPart: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: BlockRow: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2409,7 +2409,7 @@ func (m *BlockPart) Unmarshal(dAtA []byte) error { } case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Part", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Row", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2436,7 +2436,10 @@ func (m *BlockPart) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Part.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Row == nil { + m.Row = &types.Row{} + } + if err := m.Row.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2446,10 +2449,7 @@ func (m *BlockPart) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2535,10 +2535,7 @@ func (m *Vote) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2664,10 +2661,7 @@ func (m *HasVote) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2807,10 +2801,7 @@ func (m *VoteSetMaj23) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2983,10 +2974,7 @@ func (m *VoteSetBits) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -3172,7 +3160,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockPart", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BlockRow", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3199,11 +3187,11 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &BlockPart{} + v := &BlockRow{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Sum = &Message_BlockPart{v} + m.Sum = &Message_BlockRow{v} iNdEx = postIndex case 6: if wireType != 2 { @@ -3351,10 +3339,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/consensus/types.proto b/proto/tendermint/consensus/types.proto index 36bf40b27a..52b9721a51 100644 --- a/proto/tendermint/consensus/types.proto +++ b/proto/tendermint/consensus/types.proto @@ -23,7 +23,7 @@ message NewRoundStep { message NewValidBlock { int64 height = 1; int32 round = 2; - tendermint.types.PartSetHeader block_part_set_header = 3 [(gogoproto.nullable) = false]; + tendermint.types.DataAvailabilityHeader da_header = 3; tendermint.libs.bits.BitArray block_parts = 4; bool is_commit = 5; } @@ -40,11 +40,11 @@ message ProposalPOL { tendermint.libs.bits.BitArray proposal_pol = 3 [(gogoproto.nullable) = false]; } -// BlockPart is sent when gossipping a piece of the proposed block. -message BlockPart { +// BlockRow is sent when gossipping a piece of the proposed block. +message BlockRow { int64 height = 1; int32 round = 2; - tendermint.types.Part part = 3 [(gogoproto.nullable) = false]; + tendermint.types.Row row = 3; } // Vote is sent when voting for a proposal (or lack thereof). @@ -83,7 +83,7 @@ message Message { NewValidBlock new_valid_block = 2; Proposal proposal = 3; ProposalPOL proposal_pol = 4; - BlockPart block_part = 5; + BlockRow block_row = 5; Vote vote = 6; HasVote has_vote = 7; VoteSetMaj23 vote_set_maj23 = 8; diff --git a/proto/tendermint/consensus/wal.pb.go b/proto/tendermint/consensus/wal.pb.go index bda46d050a..a014e78fe8 100644 --- a/proto/tendermint/consensus/wal.pb.go +++ b/proto/tendermint/consensus/wal.pb.go @@ -922,10 +922,7 @@ func (m *MsgInfo) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthWal - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthWal } if (iNdEx + skippy) > l { @@ -1065,10 +1062,7 @@ func (m *TimeoutInfo) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthWal - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthWal } if (iNdEx + skippy) > l { @@ -1137,10 +1131,7 @@ func (m *EndHeight) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthWal - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthWal } if (iNdEx + skippy) > l { @@ -1330,10 +1321,7 @@ func (m *WALMessage) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthWal - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthWal } if (iNdEx + skippy) > l { @@ -1452,10 +1440,7 @@ func (m *TimedWALMessage) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthWal - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthWal } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/crypto/keys.pb.go b/proto/tendermint/crypto/keys.pb.go index cbf9d0bc34..b9e751f10b 100644 --- a/proto/tendermint/crypto/keys.pb.go +++ b/proto/tendermint/crypto/keys.pb.go @@ -555,10 +555,7 @@ func (m *PublicKey) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthKeys - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthKeys } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/crypto/proof.pb.go b/proto/tendermint/crypto/proof.pb.go index 565af0b65d..48a2eb1832 100644 --- a/proto/tendermint/crypto/proof.pb.go +++ b/proto/tendermint/crypto/proof.pb.go @@ -821,10 +821,7 @@ func (m *Proof) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthProof - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthProof } if (iNdEx + skippy) > l { @@ -944,10 +941,7 @@ func (m *ValueOp) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthProof - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthProof } if (iNdEx + skippy) > l { @@ -1093,10 +1087,7 @@ func (m *DominoOp) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthProof - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthProof } if (iNdEx + skippy) > l { @@ -1246,10 +1237,7 @@ func (m *ProofOp) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthProof - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthProof } if (iNdEx + skippy) > l { @@ -1333,10 +1321,7 @@ func (m *ProofOps) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthProof - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthProof } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/libs/bits/types.pb.go b/proto/tendermint/libs/bits/types.pb.go index 65212b2286..c164664aee 100644 --- a/proto/tendermint/libs/bits/types.pb.go +++ b/proto/tendermint/libs/bits/types.pb.go @@ -308,10 +308,7 @@ func (m *BitArray) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/mempool/types.pb.go b/proto/tendermint/mempool/types.pb.go index 059b691675..1e0dabe982 100644 --- a/proto/tendermint/mempool/types.pb.go +++ b/proto/tendermint/mempool/types.pb.go @@ -371,10 +371,7 @@ func (m *Txs) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -459,10 +456,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/p2p/conn.pb.go b/proto/tendermint/p2p/conn.pb.go index 56a0e548f0..5420bac511 100644 --- a/proto/tendermint/p2p/conn.pb.go +++ b/proto/tendermint/p2p/conn.pb.go @@ -724,10 +724,7 @@ func (m *PacketPing) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthConn - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthConn } if (iNdEx + skippy) > l { @@ -777,10 +774,7 @@ func (m *PacketPong) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthConn - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthConn } if (iNdEx + skippy) > l { @@ -903,10 +897,7 @@ func (m *PacketMsg) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthConn - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthConn } if (iNdEx + skippy) > l { @@ -1061,10 +1052,7 @@ func (m *Packet) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthConn - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthConn } if (iNdEx + skippy) > l { @@ -1181,10 +1169,7 @@ func (m *AuthSigMessage) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthConn - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthConn } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/p2p/pex.pb.go b/proto/tendermint/p2p/pex.pb.go index 86557cab1e..17ccaf3487 100644 --- a/proto/tendermint/p2p/pex.pb.go +++ b/proto/tendermint/p2p/pex.pb.go @@ -465,10 +465,7 @@ func (m *PexRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthPex - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthPex } if (iNdEx + skippy) > l { @@ -552,10 +549,7 @@ func (m *PexAddrs) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthPex - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthPex } if (iNdEx + skippy) > l { @@ -675,10 +669,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthPex - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthPex } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/p2p/types.pb.go b/proto/tendermint/p2p/types.pb.go index 1f116152a1..ddc7e0d49e 100644 --- a/proto/tendermint/p2p/types.pb.go +++ b/proto/tendermint/p2p/types.pb.go @@ -768,10 +768,7 @@ func (m *NetAddress) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -878,10 +875,7 @@ func (m *ProtocolVersion) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1191,10 +1185,7 @@ func (m *DefaultNodeInfo) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1308,10 +1299,7 @@ func (m *DefaultNodeInfoOther) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/privval/types.pb.go b/proto/tendermint/privval/types.pb.go index 61077b77de..f878935276 100644 --- a/proto/tendermint/privval/types.pb.go +++ b/proto/tendermint/privval/types.pb.go @@ -1709,10 +1709,7 @@ func (m *RemoteSignerError) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1794,10 +1791,7 @@ func (m *PubKeyRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1916,10 +1910,7 @@ func (m *PubKeyResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2037,10 +2028,7 @@ func (m *SignVoteRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2159,10 +2147,7 @@ func (m *SignedVoteResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2280,10 +2265,7 @@ func (m *SignProposalRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2402,10 +2384,7 @@ func (m *SignedProposalResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2455,10 +2434,7 @@ func (m *PingRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2508,10 +2484,7 @@ func (m *PingResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2841,10 +2814,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2961,10 +2931,7 @@ func (m *AuthSigMessage) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/state/types.pb.go b/proto/tendermint/state/types.pb.go index b6e34cf5bd..12f6c57e8f 100644 --- a/proto/tendermint/state/types.pb.go +++ b/proto/tendermint/state/types.pb.go @@ -1070,10 +1070,7 @@ func (m *ABCIResponses) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1178,10 +1175,7 @@ func (m *ValidatorsInfo) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1283,10 +1277,7 @@ func (m *ConsensusParamsInfo) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1401,10 +1392,7 @@ func (m *Version) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1870,10 +1858,7 @@ func (m *State) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/statesync/types.pb.go b/proto/tendermint/statesync/types.pb.go index 0dacb6872f..fb44a7e836 100644 --- a/proto/tendermint/statesync/types.pb.go +++ b/proto/tendermint/statesync/types.pb.go @@ -1035,10 +1035,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1088,10 +1085,7 @@ func (m *SnapshotsRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1266,10 +1260,7 @@ func (m *SnapshotsResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1376,10 +1367,7 @@ func (m *ChunkRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1540,10 +1528,7 @@ func (m *ChunkResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/store/types.pb.go b/proto/tendermint/store/types.pb.go index d68fe18710..ffa4a146d2 100644 --- a/proto/tendermint/store/types.pb.go +++ b/proto/tendermint/store/types.pb.go @@ -234,10 +234,7 @@ func (m *BlockStoreState) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/types/block.pb.go b/proto/tendermint/types/block.pb.go index 778dd3f52e..832cf23fe7 100644 --- a/proto/tendermint/types/block.pb.go +++ b/proto/tendermint/types/block.pb.go @@ -397,10 +397,7 @@ func (m *Block) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthBlock - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthBlock } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/types/canonical.pb.go b/proto/tendermint/types/canonical.pb.go index dfeb236a7a..9c9dfb7953 100644 --- a/proto/tendermint/types/canonical.pb.go +++ b/proto/tendermint/types/canonical.pb.go @@ -802,10 +802,7 @@ func (m *CanonicalBlockID) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthCanonical - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthCanonical } if (iNdEx + skippy) > l { @@ -908,10 +905,7 @@ func (m *CanonicalPartSetHeader) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthCanonical - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthCanonical } if (iNdEx + skippy) > l { @@ -1156,10 +1150,7 @@ func (m *CanonicalProposal) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthCanonical - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthCanonical } if (iNdEx + skippy) > l { @@ -1349,10 +1340,7 @@ func (m *CanonicalVote) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthCanonical - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthCanonical } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/types/events.pb.go b/proto/tendermint/types/events.pb.go index cafc33f3ad..158d17bb44 100644 --- a/proto/tendermint/types/events.pb.go +++ b/proto/tendermint/types/events.pb.go @@ -286,10 +286,7 @@ func (m *EventDataRoundState) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthEvents } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/types/params.pb.go b/proto/tendermint/types/params.pb.go index 53b993b34b..482765df1d 100644 --- a/proto/tendermint/types/params.pb.go +++ b/proto/tendermint/types/params.pb.go @@ -1213,10 +1213,7 @@ func (m *ConsensusParams) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthParams } if (iNdEx + skippy) > l { @@ -1323,10 +1320,7 @@ func (m *BlockParams) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthParams } if (iNdEx + skippy) > l { @@ -1447,10 +1441,7 @@ func (m *EvidenceParams) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthParams } if (iNdEx + skippy) > l { @@ -1532,10 +1523,7 @@ func (m *ValidatorParams) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthParams } if (iNdEx + skippy) > l { @@ -1604,10 +1592,7 @@ func (m *VersionParams) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthParams } if (iNdEx + skippy) > l { @@ -1695,10 +1680,7 @@ func (m *HashedParams) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthParams } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/types/types.pb.go b/proto/tendermint/types/types.pb.go index 69288929f2..7307d0263b 100644 --- a/proto/tendermint/types/types.pb.go +++ b/proto/tendermint/types/types.pb.go @@ -208,6 +208,58 @@ func (m *Part) GetProof() crypto.Proof { return crypto.Proof{} } +type Row struct { + Index uint32 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *Row) Reset() { *m = Row{} } +func (m *Row) String() string { return proto.CompactTextString(m) } +func (*Row) ProtoMessage() {} +func (*Row) Descriptor() ([]byte, []int) { + return fileDescriptor_d3a6e55e2345de56, []int{2} +} +func (m *Row) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Row) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Row.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Row) XXX_Merge(src proto.Message) { + xxx_messageInfo_Row.Merge(m, src) +} +func (m *Row) XXX_Size() int { + return m.Size() +} +func (m *Row) XXX_DiscardUnknown() { + xxx_messageInfo_Row.DiscardUnknown(m) +} + +var xxx_messageInfo_Row proto.InternalMessageInfo + +func (m *Row) GetIndex() uint32 { + if m != nil { + return m.Index + } + return 0 +} + +func (m *Row) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + // BlockID type BlockID struct { Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` @@ -218,7 +270,7 @@ func (m *BlockID) Reset() { *m = BlockID{} } func (m *BlockID) String() string { return proto.CompactTextString(m) } func (*BlockID) ProtoMessage() {} func (*BlockID) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{2} + return fileDescriptor_d3a6e55e2345de56, []int{3} } func (m *BlockID) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -289,7 +341,7 @@ func (m *Header) Reset() { *m = Header{} } func (m *Header) String() string { return proto.CompactTextString(m) } func (*Header) ProtoMessage() {} func (*Header) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{3} + return fileDescriptor_d3a6e55e2345de56, []int{4} } func (m *Header) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -438,7 +490,7 @@ func (m *Data) Reset() { *m = Data{} } func (m *Data) String() string { return proto.CompactTextString(m) } func (*Data) ProtoMessage() {} func (*Data) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{4} + return fileDescriptor_d3a6e55e2345de56, []int{5} } func (m *Data) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -506,7 +558,7 @@ func (m *Evidence) Reset() { *m = Evidence{} } func (m *Evidence) String() string { return proto.CompactTextString(m) } func (*Evidence) ProtoMessage() {} func (*Evidence) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{5} + return fileDescriptor_d3a6e55e2345de56, []int{6} } func (m *Evidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -593,7 +645,7 @@ func (m *DuplicateVoteEvidence) Reset() { *m = DuplicateVoteEvidence{} } func (m *DuplicateVoteEvidence) String() string { return proto.CompactTextString(m) } func (*DuplicateVoteEvidence) ProtoMessage() {} func (*DuplicateVoteEvidence) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{6} + return fileDescriptor_d3a6e55e2345de56, []int{7} } func (m *DuplicateVoteEvidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -670,7 +722,7 @@ func (m *LightClientAttackEvidence) Reset() { *m = LightClientAttackEvid func (m *LightClientAttackEvidence) String() string { return proto.CompactTextString(m) } func (*LightClientAttackEvidence) ProtoMessage() {} func (*LightClientAttackEvidence) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{7} + return fileDescriptor_d3a6e55e2345de56, []int{8} } func (m *LightClientAttackEvidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -742,7 +794,7 @@ func (m *EvidenceList) Reset() { *m = EvidenceList{} } func (m *EvidenceList) String() string { return proto.CompactTextString(m) } func (*EvidenceList) ProtoMessage() {} func (*EvidenceList) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{8} + return fileDescriptor_d3a6e55e2345de56, []int{9} } func (m *EvidenceList) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -786,7 +838,7 @@ func (m *IntermediateStateRoots) Reset() { *m = IntermediateStateRoots{} func (m *IntermediateStateRoots) String() string { return proto.CompactTextString(m) } func (*IntermediateStateRoots) ProtoMessage() {} func (*IntermediateStateRoots) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{9} + return fileDescriptor_d3a6e55e2345de56, []int{10} } func (m *IntermediateStateRoots) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -830,7 +882,7 @@ func (m *Messages) Reset() { *m = Messages{} } func (m *Messages) String() string { return proto.CompactTextString(m) } func (*Messages) ProtoMessage() {} func (*Messages) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{10} + return fileDescriptor_d3a6e55e2345de56, []int{11} } func (m *Messages) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -875,7 +927,7 @@ func (m *Message) Reset() { *m = Message{} } func (m *Message) String() string { return proto.CompactTextString(m) } func (*Message) ProtoMessage() {} func (*Message) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{11} + return fileDescriptor_d3a6e55e2345de56, []int{12} } func (m *Message) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -939,7 +991,7 @@ func (m *DataAvailabilityHeader) Reset() { *m = DataAvailabilityHeader{} func (m *DataAvailabilityHeader) String() string { return proto.CompactTextString(m) } func (*DataAvailabilityHeader) ProtoMessage() {} func (*DataAvailabilityHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{12} + return fileDescriptor_d3a6e55e2345de56, []int{13} } func (m *DataAvailabilityHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -999,7 +1051,7 @@ func (m *Vote) Reset() { *m = Vote{} } func (m *Vote) String() string { return proto.CompactTextString(m) } func (*Vote) ProtoMessage() {} func (*Vote) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{13} + return fileDescriptor_d3a6e55e2345de56, []int{14} } func (m *Vote) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1097,7 +1149,7 @@ func (m *Commit) Reset() { *m = Commit{} } func (m *Commit) String() string { return proto.CompactTextString(m) } func (*Commit) ProtoMessage() {} func (*Commit) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{14} + return fileDescriptor_d3a6e55e2345de56, []int{15} } func (m *Commit) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1173,7 +1225,7 @@ func (m *CommitSig) Reset() { *m = CommitSig{} } func (m *CommitSig) String() string { return proto.CompactTextString(m) } func (*CommitSig) ProtoMessage() {} func (*CommitSig) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{15} + return fileDescriptor_d3a6e55e2345de56, []int{16} } func (m *CommitSig) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1245,7 +1297,7 @@ func (m *Proposal) Reset() { *m = Proposal{} } func (m *Proposal) String() string { return proto.CompactTextString(m) } func (*Proposal) ProtoMessage() {} func (*Proposal) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{16} + return fileDescriptor_d3a6e55e2345de56, []int{17} } func (m *Proposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1339,7 +1391,7 @@ func (m *SignedHeader) Reset() { *m = SignedHeader{} } func (m *SignedHeader) String() string { return proto.CompactTextString(m) } func (*SignedHeader) ProtoMessage() {} func (*SignedHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{17} + return fileDescriptor_d3a6e55e2345de56, []int{18} } func (m *SignedHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1392,7 +1444,7 @@ func (m *LightBlock) Reset() { *m = LightBlock{} } func (m *LightBlock) String() string { return proto.CompactTextString(m) } func (*LightBlock) ProtoMessage() {} func (*LightBlock) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{18} + return fileDescriptor_d3a6e55e2345de56, []int{19} } func (m *LightBlock) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1454,7 +1506,7 @@ func (m *BlockMeta) Reset() { *m = BlockMeta{} } func (m *BlockMeta) String() string { return proto.CompactTextString(m) } func (*BlockMeta) ProtoMessage() {} func (*BlockMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{19} + return fileDescriptor_d3a6e55e2345de56, []int{20} } func (m *BlockMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1529,7 +1581,7 @@ func (m *TxProof) Reset() { *m = TxProof{} } func (m *TxProof) String() string { return proto.CompactTextString(m) } func (*TxProof) ProtoMessage() {} func (*TxProof) Descriptor() ([]byte, []int) { - return fileDescriptor_d3a6e55e2345de56, []int{20} + return fileDescriptor_d3a6e55e2345de56, []int{21} } func (m *TxProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1584,6 +1636,7 @@ func init() { proto.RegisterEnum("tendermint.types.SignedMsgType", SignedMsgType_name, SignedMsgType_value) proto.RegisterType((*PartSetHeader)(nil), "tendermint.types.PartSetHeader") proto.RegisterType((*Part)(nil), "tendermint.types.Part") + proto.RegisterType((*Row)(nil), "tendermint.types.Row") proto.RegisterType((*BlockID)(nil), "tendermint.types.BlockID") proto.RegisterType((*Header)(nil), "tendermint.types.Header") proto.RegisterType((*Data)(nil), "tendermint.types.Data") @@ -1608,125 +1661,126 @@ func init() { func init() { proto.RegisterFile("tendermint/types/types.proto", fileDescriptor_d3a6e55e2345de56) } var fileDescriptor_d3a6e55e2345de56 = []byte{ - // 1879 bytes of a gzipped FileDescriptorProto + // 1889 bytes of a gzipped FileDescriptorProto 0x1f,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d, 0x1f, 0xb2, - 0xbd, 0x01, 0x76, 0x3c, 0xcb, 0xb1, 0xa5, 0x45, 0xb9, 0x66, 0xfe, 0xfa, 0xe5, 0x56, 0x66, 0x57, - 0xd0, 0x5a, 0x7b, 0x66, 0x46, 0x32, 0x5b, 0x36, 0x5a, 0x87, 0xc5, 0x01, 0x71, 0xfa, 0x03, 0x2e, - 0xc3, 0x92, 0x34, 0xf5, 0x0a, 0xfd, 0x04, 0x52, 0x22, 0x21, 0xca, 0x29, 0xb9, 0xf7, 0x66, 0x5d, - 0x65, 0x4b, 0x3d, 0xcc, 0x96, 0xfa, 0x49, 0x98, 0x2d, 0xcd, 0xac, 0xd8, 0xf8, 0xc5, 0xdf, 0xb7, - 0x0c, 0x53, 0x4a, 0xa0, 0x5d, 0x28, 0xba, 0x98, 0x71, 0xab, 0x2b, 0xc2, 0x26, 0xb6, 0x4f, 0x4b, - 0x15, 0x1b, 0xd3, 0x01, 0xd1, 0x81, 0xd5, 0xa6, 0xe7, 0x85, 0x94, 0x22, 0xd9, 0x68, 0x1b, 0x4a, - 0x52, 0x49, 0x8f, 0x0e, 0x87, 0x0e, 0xb7, 0x64, 0xdc, 0x17, 0x65, 0xdc, 0x97, 0x04, 0x7d, 0x57, - 0x92, 0x1f, 0x8b, 0x13, 0xf8, 0x31, 0x94, 0xbd, 0xd1, 0xd0, 0xa2, 0x81, 0xd3, 0x77, 0x3c, 0xec, - 0x5a, 0x36, 0xe6, 0xd8, 0x62, 0x03, 0x1c, 0x10, 0x56, 0xce, 0x54, 0x8d, 0xed, 0x94, 0xb9, 0xe6, - 0x8d, 0x86, 0xc7, 0x9a, 0xbd, 0x87, 0x39, 0xee, 0x48, 0x26, 0xba, 0x0b, 0x39, 0x89, 0x95, 0xba, - 0xb3, 0x52, 0x77, 0x56, 0x10, 0xa4, 0xd6, 0x77, 0x60, 0x39, 0x4a, 0x57, 0xa6, 0x20, 0x39, 0xb5, - 0xfd, 0x98, 0x2c, 0x81, 0x0f, 0x60, 0xd5, 0x23, 0xe7, 0xdc, 0xba, 0x89, 0x06, 0x89, 0x46, 0x82, - 0x77, 0x3a, 0x29, 0xf1, 0x3d, 0x58, 0xea, 0x85, 0xa7, 0xa6, 0xb0, 0x79, 0x89, 0x2d, 0x46, 0x54, - 0x09, 0xdb, 0x80, 0x2c, 0xf6, 0x7d, 0x05, 0x28, 0x48, 0x40, 0x06, 0xfb, 0xbe, 0x64, 0xbd, 0x07, - 0x2b, 0x32, 0x38, 0x01, 0x61, 0x23, 0x97, 0x6b, 0x25, 0x45, 0x89, 0x59, 0x16, 0x0c, 0x53, 0xd1, - 0x25, 0xf6, 0x3b, 0x50, 0x24, 0x67, 0x8e, 0x4d, 0xbc, 0x1e, 0x51, 0xb8, 0x25, 0x89, 0x2b, 0x84, - 0x44, 0x09, 0x7a, 0x17, 0x4a, 0x7e, 0x40, 0x7d, 0xca, 0x48, 0x60, 0x61, 0xdb, 0x0e, 0x08, 0x63, - 0xe5, 0x65, 0xa5, 0x2f, 0xa4, 0x37, 0x14, 0xb9, 0xf6, 0xdb, 0x04, 0xa4, 0x44, 0x10, 0x51, 0x09, - 0x92, 0xfc, 0x9c, 0x95, 0x8d, 0x6a, 0x72, 0xbb, 0x60, 0x8a, 0xbf, 0x68, 0x00, 0x65, 0xc7, 0xe3, - 0x24, 0x18, 0x12, 0xdb, 0xc1, 0x9c, 0x58, 0x8c, 0x8b, 0xdf, 0x80, 0x52, 0xce, 0x74, 0x51, 0x6c, - 0x4f, 0xe7, 0x40, 0x2b, 0x26, 0xd1, 0x11, 0x02, 0xa6, 0xc0, 0xeb, 0x94, 0x58, 0x77, 0x66, 0x72, - 0xd1, 0xa7, 0x90, 0x0d, 0xed, 0xd7, 0xd5, 0x5c, 0x99, 0xd6, 0xbc, 0xaf, 0x11, 0x07, 0x0e, 0xe3, - 0x5a, 0x5f, 0x24, 0x85, 0x3e, 0x86, 0xec, 0x90, 0x30, 0x86, 0xfb, 0x84, 0x45, 0x29, 0x3e, 0xa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b0, 0x6b, 0x89, 0x53, 0xb3, 0xd8, 0x00, 0x07, 0x84, 0x95, 0x33, 0x55, 0x63, 0x3b, 0x65, 0xae, + 0x79, 0xa3, 0xe1, 0xb1, 0x66, 0xef, 0x61, 0x8e, 0x3b, 0x92, 0x89, 0xee, 0x43, 0x4e, 0x62, 0xa5, + 0xee, 0xac, 0xd4, 0x9d, 0x15, 0x04, 0xa9, 0xf5, 0x1d, 0x58, 0x8e, 0xf2, 0x9b, 0x29, 0x48, 0x4e, + 0x6d, 0x3f, 0x26, 0x4b, 0xe0, 0x23, 0x58, 0xf5, 0xc8, 0x05, 0xb7, 0x6e, 0xa3, 0x41, 0xa2, 0x91, + 0xe0, 0x9d, 0x4e, 0x4a, 0x7c, 0x07, 0x96, 0x7a, 0xe1, 0xa9, 0x29, 0x6c, 0x5e, 0x62, 0x8b, 0x11, + 0x55, 0xc2, 0x36, 0x20, 0x8b, 0x7d, 0x5f, 0x01, 0x0a, 0x12, 0x90, 0xc1, 0xbe, 0x2f, 0x59, 0xef, + 0xc1, 0x8a, 0x0c, 0x4e, 0x40, 0xd8, 0xc8, 0xe5, 0x5a, 0x49, 0x51, 0x62, 0x96, 0x05, 0xc3, 0x54, + 0x74, 0x89, 0xfd, 0x16, 0x14, 0xc9, 0x99, 0x63, 0x13, 0xaf, 0x47, 0x14, 0x6e, 0x49, 0xe2, 0x0a, + 0x21, 0x51, 0x82, 0xde, 0x85, 0x92, 0x1f, 0x50, 0x9f, 0x32, 0x12, 0x58, 0xd8, 0xb6, 0x03, 0xc2, + 0x58, 0x79, 0x59, 0xe9, 0x0b, 0xe9, 0x0d, 0x45, 0xae, 0xfd, 0x3a, 0x01, 0x29, 0x11, 0x44, 0x54, + 0x82, 0x24, 0xbf, 0x60, 0x65, 0xa3, 0x9a, 0xdc, 0x2e, 0x98, 0xe2, 0x2f, 0x1a, 0x40, 0xd9, 0xf1, + 0x38, 0x09, 0x86, 0xc4, 0x76, 0x30, 0x27, 0x16, 0xe3, 0x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87, 0xf2, 0xb4, + 0xc4, 0x71, 0xfb, 0xb8, 0xd3, 0x38, 0x28, 0x55, 0x37, 0x4b, 0x57, 0xd7, 0xd5, 0x42, 0xd8, 0xfd, + 0x05, 0x7e, 0xec, 0x59, 0xf3, 0xf4, 0xab, 0x9b, 0x8a, 0xf1, 0xf5, 0x4d, 0xc5, 0xf8, 0xdb, 0x4d, + 0xc5, 0x78, 0xf9, 0xba, 0xb2, 0xf0, 0xf5, 0xeb, 0xca, 0xc2, 0x9f, 0x5f, 0x57, 0x16, 0x7e, 0xf9, + 0x71, 0xdf, 0xe1, 0x83, 0x51, 0xb7, 0xde, 0xa3, 0xc3, 0x1d, 0x17, 0xbf, 0xb8, 0x74, 0x89, 0xdd, + 0x27, 0x41, 0xec, 0xef, 0x87, 0x3d, 0x1a, 0xe8, 0xaf, 0x75, 0x3b, 0xb7, 0x3f, 0xad, 0x75, 0x17, + 0x25, 0xfd, 0xa3, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xcd, 0x08, 0x41, 0x5f, 0x1b, 0x14, 0x00, + 0x00, } func (m *PartSetHeader) Marshal() (dAtA []byte, err error) { @@ -1809,6 +1863,41 @@ func (m *Part) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Row) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Row) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Row) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if m.Index != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Index)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *BlockID) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2966,6 +3055,22 @@ func (m *Part) Size() (n int) { return n } +func (m *Row) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Index != 0 { + n += 1 + sovTypes(uint64(m.Index)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + func (m *BlockID) Size() (n int) { if m == nil { return 0 @@ -3525,10 +3630,7 @@ func (m *PartSetHeader) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -3664,10 +3766,110 @@ func (m *Part) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } - if (iNdEx + skippy) < 0 { + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Row) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Row: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Row: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -3784,10 +3986,7 @@ func (m *BlockID) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -4312,10 +4511,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -4496,10 +4692,7 @@ func (m *Data) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -4619,10 +4812,7 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -4815,10 +5005,7 @@ func (m *DuplicateVoteEvidence) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -5009,10 +5196,7 @@ func (m *LightClientAttackEvidence) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -5096,10 +5280,7 @@ func (m *EvidenceList) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -5181,10 +5362,7 @@ func (m *IntermediateStateRoots) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -5268,10 +5446,7 @@ func (m *Messages) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -5389,10 +5564,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -5506,10 +5678,7 @@ func (m *DataAvailabilityHeader) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -5769,10 +5938,7 @@ func (m *Vote) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -5961,10 +6127,7 @@ func (m *Commit) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -6134,10 +6297,7 @@ func (m *CommitSig) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -6399,10 +6559,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -6524,10 +6681,7 @@ func (m *SignedHeader) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -6685,10 +6839,7 @@ func (m *LightBlock) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -6878,10 +7029,7 @@ func (m *BlockMeta) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -7035,10 +7183,7 @@ func (m *TxProof) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/types/types.proto b/proto/tendermint/types/types.proto index 21a825dc23..903dd9a1b2 100644 --- a/proto/tendermint/types/types.proto +++ b/proto/tendermint/types/types.proto @@ -46,6 +46,11 @@ message Part { tendermint.crypto.Proof proof = 3 [(gogoproto.nullable) = false]; } +message Row { + uint32 index = 1; + bytes data = 2; +} + // BlockID message BlockID { bytes hash = 1; diff --git a/proto/tendermint/types/validator.pb.go b/proto/tendermint/types/validator.pb.go index baf5216d71..7f3006110d 100644 --- a/proto/tendermint/types/validator.pb.go +++ b/proto/tendermint/types/validator.pb.go @@ -584,10 +584,7 @@ func (m *ValidatorSet) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthValidator - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthValidator } if (iNdEx + skippy) > l { @@ -742,10 +739,7 @@ func (m *Validator) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthValidator - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthValidator } if (iNdEx + skippy) > l { @@ -850,10 +844,7 @@ func (m *SimpleValidator) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthValidator - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthValidator } if (iNdEx + skippy) > l { diff --git a/proto/tendermint/version/types.pb.go b/proto/tendermint/version/types.pb.go index 5017f5bd7a..53ca4300ec 100644 --- a/proto/tendermint/version/types.pb.go +++ b/proto/tendermint/version/types.pb.go @@ -266,10 +266,7 @@ func (m *Consensus) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { diff --git a/rpc/grpc/types.pb.go b/rpc/grpc/types.pb.go index fbaab961d0..2acbd1d5eb 100644 --- a/rpc/grpc/types.pb.go +++ b/rpc/grpc/types.pb.go @@ -568,10 +568,7 @@ func (m *RequestPing) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -655,10 +652,7 @@ func (m *RequestBroadcastTx) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -708,10 +702,7 @@ func (m *ResponsePing) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -833,10 +824,7 @@ func (m *ResponseBroadcastTx) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { From a034eebb8dd6c076254d3053acc28574be878f2b Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 30 Jun 2021 13:14:53 +0300 Subject: [PATCH 19/25] feat(consensus): implement row gossiping for consensus state --- consensus/state.go | 126 ++++++++++++++++++++++++++++----------------- 1 file changed, 80 insertions(+), 46 deletions(-) diff --git a/consensus/state.go b/consensus/state.go index 02a7e9fb7e..4e64dd5742 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -5,14 +5,13 @@ import ( "context" "errors" "fmt" - "io/ioutil" "os" "reflect" "runtime/debug" "time" - "github.com/gogo/protobuf/proto" format "github.com/ipfs/go-ipld-format" + mdutils "github.com/ipfs/go-merkledag/test" "github.com/libp2p/go-libp2p-core/routing" cfg "github.com/lazyledger/lazyledger-core/config" @@ -488,13 +487,13 @@ func (cs *State) SetProposal(proposal *types.Proposal, peerID p2p.ID) error { return nil } -// AddProposalBlockPart inputs a part of the proposal block. -func (cs *State) AddProposalBlockPart(height int64, round int32, part *types.Part, peerID p2p.ID) error { +// AddProposalBlockRow inputs a part of the proposal block. +func (cs *State) AddProposalBlockRow(height int64, round int32, part *types.Row, peerID p2p.ID) error { if peerID == "" { - cs.internalMsgQueue <- msgInfo{&BlockPartMessage{height, round, part}, ""} + cs.internalMsgQueue <- msgInfo{&BlockRowMessage{height, round, part}, ""} } else { - cs.peerMsgQueue <- msgInfo{&BlockPartMessage{height, round, part}, peerID} + cs.peerMsgQueue <- msgInfo{&BlockRowMessage{height, round, part}, peerID} } // TODO: wait for event?! @@ -505,15 +504,15 @@ func (cs *State) AddProposalBlockPart(height int64, round int32, part *types.Par func (cs *State) SetProposalAndBlock( proposal *types.Proposal, block *types.Block, - parts *types.PartSet, + parts *types.RowSet, peerID p2p.ID, ) error { if err := cs.SetProposal(proposal, peerID); err != nil { return err } - for i := 0; i < int(parts.Total()); i++ { - part := parts.GetPart(i) - if err := cs.AddProposalBlockPart(proposal.Height, proposal.Round, part, peerID); err != nil { + for i := 0; i < parts.Total(); i++ { + part := parts.GetRow(i) + if err := cs.AddProposalBlockRow(proposal.Height, proposal.Round, part, peerID); err != nil { return err } } @@ -797,9 +796,9 @@ func (cs *State) handleMsg(mi msgInfo) { // will not cause transition. // once proposal is set, we can receive block parts err = cs.setProposal(msg.Proposal) - case *BlockPartMessage: + case *BlockRowMessage: // if the proposal is complete, we'll enterPrevote or tryFinalizeCommit - added, err = cs.addProposalBlockPart(msg, peerID) + added, err = cs.addProposalBlockRow(msg, peerID) if added { cs.statsMsgQueue <- mi } @@ -1028,7 +1027,7 @@ func (cs *State) enterPropose(height int64, round int32) { cs.newStep() // If we have the whole proposal + POL, then goto Prevote now. - // else, we'll enterPrevote when the rest of the proposal is received (in AddProposalBlockPart), + // else, we'll enterPrevote when the rest of the proposal is received (in AddProposalBlockRow), // or else after timeoutPropose if cs.isProposalComplete() { cs.enterPrevote(height, cs.Round) @@ -1090,7 +1089,7 @@ func (cs *State) defaultDecideProposal(height int64, round int32) { block, blockParts, blockRows = cs.ValidBlock, cs.ValidBlockParts, cs.ValidBlockRows } else { // Create a new proposal block from state/txs from the mempool. - block, blockParts, blockRows = cs.createProposalBlock() + block, blockParts, blockRows = cs.createProposalBlock(cs.privValidatorPubKey.Address()) if block == nil { return } @@ -1104,7 +1103,7 @@ func (cs *State) defaultDecideProposal(height int64, round int32) { // Make proposal propBlockID := types.BlockID{Hash: block.Hash(), PartSetHeader: blockParts.Header()} - proposal := types.NewProposal(height, round, cs.ValidRound, propBlockID, &block.DataAvailabilityHeader) + proposal := types.NewProposal(height, round, cs.ValidRound, propBlockID, blockRows.DAHeader) p, err := proposal.ToProto() if err != nil { cs.Logger.Error(fmt.Sprintf("can't serialize proposal: %s", err.Error())) @@ -1116,9 +1115,12 @@ func (cs *State) defaultDecideProposal(height int64, round int32) { // send proposal and block parts on internal msg queue cs.sendInternalMessage(msgInfo{&ProposalMessage{proposal}, ""}) - for i := 0; i < int(blockParts.Total()); i++ { - part := blockParts.GetPart(i) - cs.sendInternalMessage(msgInfo{&BlockPartMessage{cs.Height, cs.Round, part}, ""}) + for i := 0; i < blockRows.Total(); i++ { + cs.sendInternalMessage(msgInfo{&BlockRowMessage{ + cs.Height, + cs.Round, + blockRows.GetRow(i), + }, ""}) } cs.Logger.Info("Signed proposal", "height", height, "round", round, "proposal", proposal) cs.Logger.Debug(fmt.Sprintf("Signed proposal block: %v", block)) @@ -1183,7 +1185,11 @@ func (cs *State) isProposalComplete() bool { // // NOTE: keep it side-effect free for clarity. // CONTRACT: cs.privValidator is not nil. -func (cs *State) createProposalBlock() (block *types.Block, blockParts *types.PartSet, blockRows *types.RowSet) { +func (cs *State) createProposalBlock(proposer crypto.Address) ( + block *types.Block, + blockParts *types.PartSet, + blockRows *types.RowSet, +) { if cs.privValidator == nil { panic("entered createProposalBlock with privValidator being nil") } @@ -1208,9 +1214,9 @@ func (cs *State) createProposalBlock() (block *types.Block, blockParts *types.Pa cs.Logger.Error(fmt.Sprintf("enterPropose: %v", errPubKeyIsNotSet)) return } - proposerAddr := cs.privValidatorPubKey.Address() - return cs.blockExec.CreateProposalBlock(cs.Height, cs.state, commit, proposerAddr) + b, rs := cs.blockExec.CreateProposalBlock(cs.Height, cs.state, commit, proposer) + return b, b.MakePartSet(types.BlockPartSizeBytes), rs } // Enter: `timeoutPropose` after entering Propose. @@ -1367,7 +1373,6 @@ func (cs *State) enterPrecommit(height int64, round int32) { logger.Info("enterPrecommit: +2/3 prevoted for nil. Unlocking") cs.LockedRound = -1 cs.LockedBlock = nil - cs.LockedBlockParts = nil cs.LockedBlockRows = nil if err := cs.eventBus.PublishEventUnlock(cs.RoundStateEvent()); err != nil { cs.Logger.Error("Error publishing event unlock", "err", err) @@ -1400,6 +1405,7 @@ func (cs *State) enterPrecommit(height int64, round int32) { cs.LockedRound = round cs.LockedBlock = cs.ProposalBlock cs.LockedBlockParts = cs.ProposalBlockParts + cs.LockedBlockRows = cs.ProposalBlockRows if err := cs.eventBus.PublishEventLock(cs.RoundStateEvent()); err != nil { cs.Logger.Error("Error publishing event lock", "err", err) } @@ -1413,11 +1419,10 @@ func (cs *State) enterPrecommit(height int64, round int32) { logger.Info("enterPrecommit: +2/3 prevotes for a block we don't have. Voting nil", "blockID", blockID) cs.LockedRound = -1 cs.LockedBlock = nil - cs.LockedBlockParts = nil - if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) { + // TODO(Wondertan): Add ProposalBlockRows initialization after adding DAHeader to Vote + if !cs.LockedBlockParts.HasHeader(blockID.PartSetHeader) { cs.ProposalBlock = nil cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader) - cs.ProposalBlockRows = nil } if err := cs.eventBus.PublishEventUnlock(cs.RoundStateEvent()); err != nil { cs.Logger.Error("Error publishing event unlock", "err", err) @@ -1819,6 +1824,15 @@ func (cs *State) defaultSetProposal(proposal *types.Proposal) error { if cs.ProposalBlockParts == nil { cs.ProposalBlockParts = types.NewPartSetFromHeader(proposal.BlockID.PartSetHeader) } + if cs.ProposalBlockRows == nil { + cs.ProposalBlockRows = types.NewRowSetFromHeader(proposal.DAHeader) + } + if cs.ProposalBlockRows.TotalSize() > int(cs.state.ConsensusParams.Block.MaxBytes) { + return fmt.Errorf("propasal for block exceeding maximum block size (%d > %d)", + cs.ProposalBlockRows.TotalSize(), cs.state.ConsensusParams.Block.MaxBytes, + ) + } + cs.Logger.Info("Received proposal", "proposal", proposal) return nil } @@ -1826,8 +1840,8 @@ func (cs *State) defaultSetProposal(proposal *types.Proposal) error { // NOTE: block is not necessarily valid. // Asynchronously triggers either enterPrevote (before we timeout of propose) or tryFinalizeCommit, // once we have the full block. -func (cs *State) addProposalBlockPart(msg *BlockPartMessage, peerID p2p.ID) (added bool, err error) { - height, round, part := msg.Height, msg.Round, msg.Part +func (cs *State) addProposalBlockRow(msg *BlockRowMessage, peerID p2p.ID) (added bool, err error) { + height, round, part := msg.Height, msg.Round, msg.Row // Blocks might be reused, so round mismatch is OK if cs.Height != height { @@ -1836,45 +1850,65 @@ func (cs *State) addProposalBlockPart(msg *BlockPartMessage, peerID p2p.ID) (add } // We're not expecting a block part. - if cs.ProposalBlockParts == nil { + if cs.ProposalBlockRows == nil { // NOTE: this can happen when we've gone to a higher round and // then receive parts from the previous round - not necessarily a bad peer. cs.Logger.Info("Received a block part when we're not expecting any", - "height", height, "round", round, "index", part.Index, "peer", peerID) + "height", height, "round", round, "index", "peer", peerID) return false, nil } + if cs.ProposalBlockRows.TotalSize() > int(cs.state.ConsensusParams.Block.MaxBytes) { + return false, fmt.Errorf("got row of a proposal block exceeding maximum block size (%d > %d)", + cs.ProposalBlockRows.TotalSize(), cs.state.ConsensusParams.Block.MaxBytes, + ) + } - added, err = cs.ProposalBlockParts.AddPart(part) + added, err = cs.ProposalBlockRows.AddRow(part) if err != nil { return added, err } - if cs.ProposalBlockParts.ByteSize() > cs.state.ConsensusParams.Block.MaxBytes { - return added, fmt.Errorf("total size of proposal block parts exceeds maximum block bytes (%d > %d)", - cs.ProposalBlockParts.ByteSize(), cs.state.ConsensusParams.Block.MaxBytes, - ) - } - if added && cs.ProposalBlockParts.IsComplete() { - bz, err := ioutil.ReadAll(cs.ProposalBlockParts.GetReader()) + if added && cs.ProposalBlockRows.IsComplete() { + square, err := cs.ProposalBlockRows.Square() if err != nil { return added, err } - var pbb = new(tmproto.Block) - err = proto.Unmarshal(bz, pbb) + data, err := types.DataFromSquare(square) if err != nil { return added, err } - block, err := types.BlockFromProto(pbb) - if err != nil { - return added, err + var commit *types.Commit + switch { + case cs.Height == cs.state.InitialHeight: + // We're creating a proposal for the first block. + // The commit is empty, but not nil. + commit = types.NewCommit(0, 0, types.BlockID{}, nil) + case cs.LastCommit.HasTwoThirdsMajority(): + // Make the commit from LastCommit + commit = cs.LastCommit.MakeCommit() + default: // This shouldn't happen. + return added, fmt.Errorf("no commit for the previous block") } - cs.ProposalBlock = block - cs.ProposalBlockRows, err = block.RowSet(context.TODO(), cs.dag) + cs.ProposalBlock = cs.state.MakeBlock( + cs.Proposal.Height, + data.Txs, + data.Evidence.Evidence, + data.IntermediateStateRoots.RawRootsList, + data.Messages, + commit, + cs.Validators.GetProposer().Address, + ) + + // TODO(Wondertan): This is unnecessary in general, but for now it writes needed fields + // and specifically NumOriginalDataShares, which likely should be par of the proposal + cs.ProposalBlockRows, err = cs.ProposalBlock.RowSet(context.TODO(), mdutils.Mock()) if err != nil { - return false, err + return added, err } + cs.ProposalBlockParts = cs.ProposalBlock.MakePartSet(types.BlockPartSizeBytes) + // NOTE: it's possible to receive complete proposal blocks for future rounds without having the proposal cs.Logger.Info("Received complete proposal block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash()) if err := cs.eventBus.PublishEventCompleteProposal(cs.CompleteProposalEvent()); err != nil { @@ -2081,8 +2115,8 @@ func (cs *State) addVote( "proposal", cs.ProposalBlock.Hash(), "blockID", blockID.Hash) // We're getting the wrong block. cs.ProposalBlock = nil - cs.ProposalBlockRows = nil } + // TODO(Wondertan): Add ProposalBlockRows initialization after adding DAHeader to Vote if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) { cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader) } From f33be9060488d8e6eac5f70800574629ca1520d0 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 30 Jun 2021 13:15:46 +0300 Subject: [PATCH 20/25] tests(consensus): fix state tests according to row gossiping --- consensus/common_test.go | 12 ++++- consensus/state_test.go | 102 ++++++++++++++++++--------------------- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/consensus/common_test.go b/consensus/common_test.go index 589e2f26f8..6b96ac0191 100644 --- a/consensus/common_test.go +++ b/consensus/common_test.go @@ -27,6 +27,7 @@ import ( abci "github.com/lazyledger/lazyledger-core/abci/types" cfg "github.com/lazyledger/lazyledger-core/config" cstypes "github.com/lazyledger/lazyledger-core/consensus/types" + "github.com/lazyledger/lazyledger-core/crypto" "github.com/lazyledger/lazyledger-core/ipfs" tmbytes "github.com/lazyledger/lazyledger-core/libs/bytes" dbm "github.com/lazyledger/lazyledger-core/libs/db" @@ -91,6 +92,11 @@ func newValidatorStub(privValidator types.PrivValidator, valIndex int32) *valida } } +func (vs *validatorStub) Address() crypto.Address { + pk, _ := vs.GetPubKey() + return pk.Address() +} + func (vs *validatorStub) signVote( voteType tmproto.SignedMsgType, hash []byte, @@ -194,9 +200,9 @@ func decideProposal( vs *validatorStub, height int64, round int32, -) (proposal *types.Proposal, block *types.Block) { +) (proposal *types.Proposal, block *types.Block, rows *types.RowSet) { cs1.mtx.Lock() - block, blockParts, _ := cs1.createProposalBlock() + block, blockParts, rows := cs1.createProposalBlock(vs.Address()) validRound := cs1.ValidRound chainID := cs1.state.ChainID cs1.mtx.Unlock() @@ -599,6 +605,7 @@ func ensureNewUnlock(unlockCh <-chan tmpubsub.Message, height int64, round int32 "Timeout expired while waiting for NewUnlock event") } +//nolint:unused func ensureProposal(proposalCh <-chan tmpubsub.Message, height int64, round int32, propID types.BlockID) { select { case <-time.After(ensureTimeout): @@ -785,6 +792,7 @@ func randConsensusNetWithPeers( } } +//nolint:unused func getSwitchIndex(switches []*p2p.Switch, peer p2p.Peer) int { for i, s := range switches { if peer.NodeInfo().ID() == s.NodeInfo().ID() { diff --git a/consensus/state_test.go b/consensus/state_test.go index cd47dc1fc9..584114889f 100644 --- a/consensus/state_test.go +++ b/consensus/state_test.go @@ -17,6 +17,7 @@ import ( "github.com/lazyledger/lazyledger-core/libs/log" tmpubsub "github.com/lazyledger/lazyledger-core/libs/pubsub" tmrand "github.com/lazyledger/lazyledger-core/libs/rand" + "github.com/lazyledger/lazyledger-core/p2p/ipld" p2pmock "github.com/lazyledger/lazyledger-core/p2p/mock" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" "github.com/lazyledger/lazyledger-core/types" @@ -183,7 +184,9 @@ func TestStateEnterProposeYesPrivValidator(t *testing.T) { ensureNoNewTimeout(timeoutCh, cs.config.TimeoutPropose.Nanoseconds()) } +// This test injects invalid field to block and checks if state discards it by voting nil func TestStateBadProposal(t *testing.T) { + t.Skip("Block Executor don't have any validation for types.Data fields and we can't inject bad data there") cs1, vss := randState(2) height, round := cs1.Height, cs1.Round @@ -194,12 +197,13 @@ func TestStateBadProposal(t *testing.T) { proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) voteCh := subscribe(cs1.eventBus, types.EventQueryVote) - propBlock, _, _ := cs1.createProposalBlock() // changeProposer(t, cs1, vs2) + propBlock, _, _ := cs1.createProposalBlock(vs2.Address()) // make the second validator the proposer by incrementing round round++ incrementRound(vss[1:]...) + // TODO(Wondertan): Inject invalid types.Data field to be discarded by Block Executor // make the block bad by tampering with statehash stateHash := propBlock.AppHash if len(stateHash) == 0 { @@ -207,9 +211,12 @@ func TestStateBadProposal(t *testing.T) { } stateHash[0] = (stateHash[0] + 1) % 255 propBlock.AppHash = stateHash + propBlockParts := propBlock.MakePartSet(partSize) + propBlockRows, err := propBlock.RowSet(context.TODO(), mdutils.Mock()) + require.NoError(t, err) blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} - proposal := types.NewProposal(vs2.Height, round, -1, blockID, &propBlock.DataAvailabilityHeader) + proposal := types.NewProposal(vs2.Height, round, -1, blockID, propBlockRows.DAHeader) p, err := proposal.ToProto() require.NoError(t, err) if err := vs2.SignProposal(config.ChainID(), p); err != nil { @@ -219,7 +226,7 @@ func TestStateBadProposal(t *testing.T) { proposal.Signature = p.Signature // set the proposal block - if err := cs1.SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(proposal, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } @@ -255,17 +262,17 @@ func TestStateOversizedBlock(t *testing.T) { timeoutProposeCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose) voteCh := subscribe(cs1.eventBus, types.EventQueryVote) - propBlock, _, _ := cs1.createProposalBlock() + propBlock, _, _ := cs1.createProposalBlock(vs2.Address()) propBlock.Data.Txs = []types.Tx{tmrand.Bytes(2001)} - propBlock.Header.DataHash = propBlock.DataAvailabilityHeader.Hash() // make the second validator the proposer by incrementing round round++ incrementRound(vss[1:]...) - propBlockParts := propBlock.MakePartSet(partSize) - blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} - proposal := types.NewProposal(height, round, -1, blockID, &propBlock.DataAvailabilityHeader) + propBlockRows, err := propBlock.RowSet(context.TODO(), mdutils.Mock()) + require.NoError(t, err) + blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlock.MakePartSet(partSize).Header()} + proposal := types.NewProposal(height, round, -1, blockID, propBlockRows.DAHeader) p, err := proposal.ToProto() require.NoError(t, err) if err := vs2.SignProposal(config.ChainID(), p); err != nil { @@ -273,21 +280,13 @@ func TestStateOversizedBlock(t *testing.T) { } proposal.Signature = p.Signature - totalBytes := 0 - for i := 0; i < int(propBlockParts.Total()); i++ { - part := propBlockParts.GetPart(i) - totalBytes += len(part.Bytes) - } - - if err := cs1.SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(proposal, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } // start the machine startTestRound(cs1, height, round) - t.Log("Block Sizes", "Limit", cs1.state.ConsensusParams.Block.MaxBytes, "Current", totalBytes) - // c1 should log an error with the block part message as it exceeds the consensus params. The // block is not added to cs.ProposalBlock so the node timeouts. ensureNewTimeout(timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds()) @@ -549,7 +548,7 @@ func TestStateLockNoPOL(t *testing.T) { cs2, _ := randState(2) // needed so generated block is different than locked block // before we time out into new round, set next proposal block - prop, propBlock := decideProposal(cs2, vs2, vs2.Height, vs2.Round+1) + prop, propBlock, propBlockRows := decideProposal(cs2, vs2, vs2.Height, vs2.Round+1) if prop == nil || propBlock == nil { t.Fatal("Failed to create proposal block with vs2") } @@ -565,7 +564,7 @@ func TestStateLockNoPOL(t *testing.T) { // now we're on a new round and not the proposer // so set the proposal block - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlock.MakePartSet(partSize), ""); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockRows, ""); err != nil { t.Fatal(err) } @@ -641,7 +640,7 @@ func TestStateLockPOLRelock(t *testing.T) { // before we timeout to the new round set the new proposal cs2 := newState(cs1.state, vs2, counter.NewApplication(true), mdutils.Mock()) - prop, propBlock := decideProposal(cs2, vs2, vs2.Height, vs2.Round+1) + prop, propBlock, propBlockRows := decideProposal(cs2, vs2, vs2.Height, vs2.Round+1) if prop == nil || propBlock == nil { t.Fatal("Failed to create proposal block with vs2") } @@ -656,7 +655,7 @@ func TestStateLockPOLRelock(t *testing.T) { round++ // moving to the next round //XXX: this isnt guaranteed to get there before the timeoutPropose ... - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } @@ -698,8 +697,6 @@ func TestStateLockPOLUnlock(t *testing.T) { vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, cs1.Round - partSize := types.BlockPartSizeBytes - proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) @@ -739,8 +736,7 @@ func TestStateLockPOLUnlock(t *testing.T) { signAddVotes(cs1, tmproto.PrecommitType, theBlockHash, theBlockParts, vs3) // before we time out into new round, set next proposal block - prop, propBlock := decideProposal(cs1, vs2, vs2.Height, vs2.Round+1) - propBlockParts := propBlock.MakePartSet(partSize) + prop, propBlock, propBlockRows := decideProposal(cs1, vs2, vs2.Height, vs2.Round+1) // timeout to new round ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds()) @@ -757,7 +753,7 @@ func TestStateLockPOLUnlock(t *testing.T) { cs1 unlocks! */ //XXX: this isnt guaranteed to get there before the timeoutPropose ... - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } @@ -827,7 +823,7 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { // before we timeout to the new round set the new proposal cs2 := newState(cs1.state, vs2, counter.NewApplication(true), mdutils.Mock()) - prop, propBlock := decideProposal(cs2, vs2, vs2.Height, vs2.Round+1) + prop, propBlock, propBlockRows := decideProposal(cs2, vs2, vs2.Height, vs2.Round+1) if prop == nil || propBlock == nil { t.Fatal("Failed to create proposal block with vs2") } @@ -862,7 +858,7 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { // we should have unlocked and locked on the new block, sending a precommit for this new block validatePrecommit(t, cs1, round, -1, vss[0], nil, nil) - if err := cs1.SetProposalAndBlock(prop, propBlock, secondBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } @@ -871,7 +867,7 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { // before we timeout to the new round set the new proposal cs3 := newState(cs1.state, vs3, counter.NewApplication(true), mdutils.Mock()) - prop, propBlock = decideProposal(cs3, vs3, vs3.Height, vs3.Round+1) + prop, propBlock, propBlockRows = decideProposal(cs3, vs3, vs3.Height, vs3.Round+1) if prop == nil || propBlock == nil { t.Fatal("Failed to create proposal block with vs2") } @@ -892,7 +888,7 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { Round2 (vs3, C) // C C C C // C nil nil nil) */ - if err := cs1.SetProposalAndBlock(prop, propBlock, thirdPropBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } @@ -953,7 +949,7 @@ func TestStateLockPOLSafety1(t *testing.T) { t.Log("### ONTO ROUND 1") - prop, propBlock := decideProposal(cs1, vs2, vs2.Height, vs2.Round+1) + prop, propBlock, propBlockRows := decideProposal(cs1, vs2, vs2.Height, vs2.Round+1) propBlockHash := propBlock.Hash() propBlockParts := propBlock.MakePartSet(partSize) @@ -963,7 +959,7 @@ func TestStateLockPOLSafety1(t *testing.T) { ensureNewRound(newRoundCh, height, round) //XXX: this isnt guaranteed to get there before the timeoutPropose ... - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } /*Round2 @@ -979,6 +975,7 @@ func TestStateLockPOLSafety1(t *testing.T) { panic("we should not be locked!") } t.Logf("new prop hash %v", fmt.Sprintf("%X", propBlockHash)) + t.Log(propBlock.String()) // go to prevote, prevote for proposal block ensurePrevote(voteCh, height, round) @@ -1050,7 +1047,7 @@ func TestStateLockPOLSafety2(t *testing.T) { // the block for R0: gets polkad but we miss it // (even though we signed it, shhh) - _, propBlock0 := decideProposal(cs1, vss[0], height, round) + _, propBlock0, propBlockRows0 := decideProposal(cs1, vss[0], height, round) propBlockHash0 := propBlock0.Hash() propBlockParts0 := propBlock0.MakePartSet(partSize) propBlockID0 := types.BlockID{Hash: propBlockHash0, PartSetHeader: propBlockParts0.Header()} @@ -1059,7 +1056,7 @@ func TestStateLockPOLSafety2(t *testing.T) { prevotes := signVotes(tmproto.PrevoteType, propBlockHash0, propBlockParts0.Header(), vs2, vs3, vs4) // the block for round 1 - prop1, propBlock1 := decideProposal(cs1, vs2, vs2.Height, vs2.Round+1) + prop1, propBlock1, propBlockRows1 := decideProposal(cs1, vs2, vs2.Height, vs2.Round+1) propBlockHash1 := propBlock1.Hash() propBlockParts1 := propBlock1.MakePartSet(partSize) @@ -1071,7 +1068,7 @@ func TestStateLockPOLSafety2(t *testing.T) { startTestRound(cs1, height, round) ensureNewRound(newRoundCh, height, round) - if err := cs1.SetProposalAndBlock(prop1, propBlock1, propBlockParts1, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop1, propBlock1, propBlockRows1, "some peer"); err != nil { t.Fatal(err) } ensureNewProposal(proposalCh, height, round) @@ -1105,7 +1102,7 @@ func TestStateLockPOLSafety2(t *testing.T) { newProp.Signature = p.Signature - if err := cs1.SetProposalAndBlock(newProp, propBlock0, propBlockParts0, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(newProp, propBlock0, propBlockRows0, "some peer"); err != nil { t.Fatal(err) } @@ -1285,7 +1282,7 @@ func TestSetValidBlockOnDelayedPrevote(t *testing.T) { // P0 miss to lock B as Proposal Block is missing, but set valid block to B after // receiving delayed Block Proposal. func TestSetValidBlockOnDelayedProposal(t *testing.T) { - + t.Skip("This requires DAHeader in Vote") cs1, vss := randState(4) vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, cs1.Round @@ -1313,7 +1310,7 @@ func TestSetValidBlockOnDelayedProposal(t *testing.T) { ensurePrevote(voteCh, height, round) validatePrevote(t, cs1, round, vss[0], nil) - prop, propBlock := decideProposal(cs1, vs2, vs2.Height, vs2.Round+1) + prop, propBlock, propBlockRows := decideProposal(cs1, vs2, vs2.Height, vs2.Round+1) propBlockHash := propBlock.Hash() propBlockParts := propBlock.MakePartSet(partSize) @@ -1326,7 +1323,7 @@ func TestSetValidBlockOnDelayedProposal(t *testing.T) { ensurePrecommit(voteCh, height, round) validatePrecommit(t, cs1, round, -1, vss[0], nil, nil) - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } @@ -1478,7 +1475,7 @@ func TestEmitNewValidBlockEventOnCommitWithoutBlock(t *testing.T) { newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) validBlockCh := subscribe(cs1.eventBus, types.EventQueryValidBlock) - _, propBlock := decideProposal(cs1, vs2, vs2.Height, vs2.Round) + _, propBlock, _ := decideProposal(cs1, vs2, vs2.Height, vs2.Round) propBlockHash := propBlock.Hash() propBlockParts := propBlock.MakePartSet(partSize) @@ -1501,7 +1498,7 @@ func TestEmitNewValidBlockEventOnCommitWithoutBlock(t *testing.T) { // P0 receives 2/3+ Precommit for B for round 0, while being in round 1. It emits NewValidBlock event. // After receiving block, it executes block and moves to the next height. func TestCommitFromPreviousRound(t *testing.T) { - + t.Skip("This requires DAHeader in Vote") cs1, vss := randState(4) vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, int32(1) @@ -1512,7 +1509,7 @@ func TestCommitFromPreviousRound(t *testing.T) { validBlockCh := subscribe(cs1.eventBus, types.EventQueryValidBlock) proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) - prop, propBlock := decideProposal(cs1, vs2, vs2.Height, vs2.Round) + prop, propBlock, propBlockRows := decideProposal(cs1, vs2, vs2.Height, vs2.Round) propBlockHash := propBlock.Hash() propBlockParts := propBlock.MakePartSet(partSize) @@ -1530,8 +1527,9 @@ func TestCommitFromPreviousRound(t *testing.T) { assert.True(t, rs.CommitRound == vs2.Round) assert.True(t, rs.ProposalBlock == nil) assert.True(t, rs.ProposalBlockParts.Header().Equals(propBlockParts.Header())) + assert.True(t, rs.ProposalBlockRows.DAHeader.Equals(propBlockRows.DAHeader)) - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } @@ -1624,8 +1622,6 @@ func TestResetTimeoutPrecommitUponNewHeight(t *testing.T) { vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, cs1.Round - partSize := types.BlockPartSizeBytes - proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) @@ -1659,10 +1655,8 @@ func TestResetTimeoutPrecommitUponNewHeight(t *testing.T) { ensureNewBlockHeader(newBlockHeader, height, theBlockHash) - prop, propBlock := decideProposal(cs1, vs2, height+1, 0) - propBlockParts := propBlock.MakePartSet(partSize) - - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil { + prop, propBlock, propBlockRows := decideProposal(cs1, vs2, height+1, 0) + if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } ensureNewProposal(proposalCh, height+1, 0) @@ -1828,20 +1822,18 @@ func TestStateHalt1(t *testing.T) { } func TestStateOutputsBlockPartsStats(t *testing.T) { - // create dummy peer cs, _ := randState(1) peer := p2pmock.NewPeer(nil) - // 1) new block part - parts := types.NewPartSetFromData(tmrand.Bytes(100), 10) - msg := &BlockPartMessage{ + rs := types.NewRowSet(ipld.RandEDS(t, 4)) + msg := &BlockRowMessage{ Height: 1, Round: 0, - Part: parts.GetPart(0), + Row: rs.GetRow(0), } - cs.ProposalBlockParts = types.NewPartSetFromHeader(parts.Header()) + cs.ProposalBlockRows = types.NewRowSetFromHeader(rs.DAHeader) cs.handleMsg(msgInfo{msg, peer.ID()}) statsMessage := <-cs.statsMsgQueue From e64dee7c1428d3bfb54c719dd2ff03e183c5c211 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 30 Jun 2021 13:17:53 +0300 Subject: [PATCH 21/25] tests(consensus): fix byzantine tests --- consensus/byzantine_test.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index 1448e2a759..96a8a19427 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -218,6 +218,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) { // B sees a commit, A doesn't. // Heal partition and ensure A sees the commit func TestByzantineConflictingProposalsWithPartition(t *testing.T) { + t.Skip("This requires DAHeader in Vote") N := 4 logger := consensusLogger().With("test", "byzantine") app := newCounter @@ -384,7 +385,7 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St // Avoid sending on internalMsgQueue and running consensus state. // Create a new proposal block from state/txs from the mempool. - block1, blockParts1, _ := cs.createProposalBlock() + block1, blockParts1, blockRows1 := cs.createProposalBlock(cs.privValidatorPubKey.Address()) polRound, propBlockID := cs.ValidRound, types.BlockID{Hash: block1.Hash(), PartSetHeader: blockParts1.Header()} proposal1 := types.NewProposal(height, round, polRound, propBlockID, &block1.DataAvailabilityHeader) p1, err := proposal1.ToProto() @@ -399,7 +400,7 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St deliverTxsRange(cs, 0, 1) // Create a new proposal block from state/txs from the mempool. - block2, blockParts2, _ := cs.createProposalBlock() + block2, blockParts2, blockRows2 := cs.createProposalBlock(cs.privValidatorPubKey.Address()) polRound, propBlockID = cs.ValidRound, types.BlockID{Hash: block2.Hash(), PartSetHeader: blockParts2.Header()} proposal2 := types.NewProposal(height, round, polRound, propBlockID, &block2.DataAvailabilityHeader) p2, err := proposal2.ToProto() @@ -418,9 +419,9 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St t.Logf("Byzantine: broadcasting conflicting proposals to %d peers", len(peers)) for i, peer := range peers { if i < len(peers)/2 { - go sendProposalAndParts(height, round, cs, peer, proposal1, block1Hash, blockParts1) + go sendProposalAndParts(height, round, cs, peer, proposal1, block1Hash, blockParts1, blockRows1) } else { - go sendProposalAndParts(height, round, cs, peer, proposal2, block2Hash, blockParts2) + go sendProposalAndParts(height, round, cs, peer, proposal2, block2Hash, blockParts2, blockRows2) } } } @@ -433,18 +434,19 @@ func sendProposalAndParts( proposal *types.Proposal, blockHash []byte, parts *types.PartSet, + rows *types.RowSet, ) { // proposal msg := &ProposalMessage{Proposal: proposal} peer.Send(DataChannel, MustEncode(msg)) // parts - for i := 0; i < int(parts.Total()); i++ { - part := parts.GetPart(i) - msg := &BlockPartMessage{ + for i := 0; i < rows.Total(); i++ { + row := rows.GetRow(i) + msg := &BlockRowMessage{ Height: height, // This tells peer that this part applies to us. Round: round, // This tells peer that this part applies to us. - Part: part, + Row: row, } peer.Send(DataChannel, MustEncode(msg)) } From 9f04c1767f2eaa7850506f75d7c48de289692c17 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 30 Jun 2021 13:18:18 +0300 Subject: [PATCH 22/25] tests(consensus): fix reactor tests --- consensus/msgs_test.go | 107 +++++++++++++++++--------------------- consensus/reactor_test.go | 49 +++++++++-------- 2 files changed, 73 insertions(+), 83 deletions(-) diff --git a/consensus/msgs_test.go b/consensus/msgs_test.go index 83a404b53e..965557a585 100644 --- a/consensus/msgs_test.go +++ b/consensus/msgs_test.go @@ -1,16 +1,17 @@ package consensus import ( + "context" "encoding/hex" "math" "testing" "time" "github.com/gogo/protobuf/proto" + mdutils "github.com/ipfs/go-merkledag/test" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/lazyledger/lazyledger-core/crypto/merkle" "github.com/lazyledger/lazyledger-core/crypto/tmhash" "github.com/lazyledger/lazyledger-core/libs/bits" tmrand "github.com/lazyledger/lazyledger-core/libs/rand" @@ -23,11 +24,17 @@ import ( ) func TestMsgToProto(t *testing.T) { + rows, _ := ipld.NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)}) + clns, _ := ipld.NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)}) + dah := &ipld.DataAvailabilityHeader{ + RowsRoots: rows, + ColumnRoots: clns, + } + pbDah, _ := dah.ToProto() psh := types.PartSetHeader{ Total: 1, Hash: tmrand.Bytes(32), } - pbPsh := psh.ToProto() bi := types.BlockID{ Hash: tmrand.Bytes(32), PartSetHeader: psh, @@ -36,17 +43,11 @@ func TestMsgToProto(t *testing.T) { bits := bits.NewBitArray(1) pbBits := bits.ToProto() - parts := types.Part{ + row := types.Row{ Index: 1, - Bytes: []byte("test"), - Proof: merkle.Proof{ - Total: 1, - Index: 1, - LeafHash: tmrand.Bytes(32), - Aunts: [][]byte{}, - }, + Data: tmrand.Bytes(consts.ShareSize), } - pbParts, err := parts.ToProto() + pbRow, err := row.ToProto() require.NoError(t, err) roots, err := ipld.NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)}) @@ -103,32 +104,32 @@ func TestMsgToProto(t *testing.T) { }, false}, {"successful NewValidBlockMessage", &NewValidBlockMessage{ - Height: 1, - Round: 1, - BlockPartSetHeader: psh, - BlockParts: bits, - IsCommit: false, + Height: 1, + Round: 1, + BlockDAHeader: dah, + BlockRows: bits, + IsCommit: false, }, &tmcons.Message{ Sum: &tmcons.Message_NewValidBlock{ NewValidBlock: &tmcons.NewValidBlock{ - Height: 1, - Round: 1, - BlockPartSetHeader: pbPsh, - BlockParts: pbBits, - IsCommit: false, + Height: 1, + Round: 1, + DaHeader: pbDah, + BlockParts: pbBits, + IsCommit: false, }, }, }, false}, - {"successful BlockPartMessage", &BlockPartMessage{ + {"successful BlockRowMessage", &BlockRowMessage{ Height: 100, Round: 1, - Part: &parts, + Row: &row, }, &tmcons.Message{ - Sum: &tmcons.Message_BlockPart{ - BlockPart: &tmcons.BlockPart{ + Sum: &tmcons.Message_BlockRow{ + BlockRow: &tmcons.BlockRow{ Height: 100, Round: 1, - Part: *pbParts, + Row: pbRow, }, }, }, false}, @@ -220,18 +221,11 @@ func TestMsgToProto(t *testing.T) { } func TestWALMsgProto(t *testing.T) { - - parts := types.Part{ + row := types.Row{ Index: 1, - Bytes: []byte("test"), - Proof: merkle.Proof{ - Total: 1, - Index: 1, - LeafHash: tmrand.Bytes(32), - Aunts: [][]byte{}, - }, + Data: tmrand.Bytes(consts.ShareSize), } - pbParts, err := parts.ToProto() + pbRow, err := row.ToProto() require.NoError(t, err) testsCases := []struct { @@ -254,21 +248,21 @@ func TestWALMsgProto(t *testing.T) { }, }, false}, {"successful msgInfo", msgInfo{ - Msg: &BlockPartMessage{ + Msg: &BlockRowMessage{ Height: 100, Round: 1, - Part: &parts, + Row: &row, }, PeerID: p2p.ID("string"), }, &tmcons.WALMessage{ Sum: &tmcons.WALMessage_MsgInfo{ MsgInfo: &tmcons.MsgInfo{ Msg: tmcons.Message{ - Sum: &tmcons.Message_BlockPart{ - BlockPart: &tmcons.BlockPart{ + Sum: &tmcons.Message_BlockRow{ + BlockRow: &tmcons.BlockRow{ Height: 100, Round: 1, - Part: *pbParts, + Row: pbRow, }, }, }, @@ -326,12 +320,18 @@ func TestWALMsgProto(t *testing.T) { // nolint:lll //ignore line length for tests func TestConsMsgsVectors(t *testing.T) { + rs, _ := (&types.Block{}).RowSet(context.TODO(), mdutils.Mock()) + pbDah, _ := rs.DAHeader.ToProto() + + row := rs.GetRow(0) + pbRow, err := row.ToProto() + require.NoError(t, err) + date := time.Date(2018, 8, 30, 12, 0, 0, 0, time.UTC) psh := types.PartSetHeader{ Total: 1, Hash: []byte("add_more_exclamation_marks_code-"), } - pbPsh := psh.ToProto() bi := types.BlockID{ Hash: []byte("add_more_exclamation_marks_code-"), @@ -341,19 +341,6 @@ func TestConsMsgsVectors(t *testing.T) { bits := bits.NewBitArray(1) pbBits := bits.ToProto() - parts := types.Part{ - Index: 1, - Bytes: []byte("test"), - Proof: merkle.Proof{ - Total: 1, - Index: 1, - LeafHash: []byte("add_more_exclamation_marks_code-"), - Aunts: [][]byte{}, - }, - } - pbParts, err := parts.ToProto() - require.NoError(t, err) - proposal := types.Proposal{ Type: tmproto.ProposalType, Height: 1, @@ -399,16 +386,16 @@ func TestConsMsgsVectors(t *testing.T) { }}}, "0a2608ffffffffffffffff7f10ffffffff0718ffffffff0f20ffffffffffffffff7f28ffffffff07"}, {"NewValidBlock", &tmcons.Message{Sum: &tmcons.Message_NewValidBlock{ NewValidBlock: &tmcons.NewValidBlock{ - Height: 1, Round: 1, BlockPartSetHeader: pbPsh, BlockParts: pbBits, IsCommit: false}}}, - "1231080110011a24080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d22050801120100"}, + Height: 1, Round: 1, DaHeader: pbDah, BlockParts: pbBits, IsCommit: false}}}, + "12d601080110011ac8010a30fffffffffffffffefffffffffffffffe669aa8f0d85221a05b6f0917884d30616a6c7d5330a5640a08a04dcc5b092f4f0a30ffffffffffffffffffffffffffffffff293437f3b6a5611e25c90d5a44b84cc4b3720cdba68553defe8b719af1f5c3951230fffffffffffffffefffffffffffffffe669aa8f0d85221a05b6f0917884d30616a6c7d5330a5640a08a04dcc5b092f4f1230ffffffffffffffffffffffffffffffff293437f3b6a5611e25c90d5a44b84cc4b3720cdba68553defe8b719af1f5c39522050801120100"}, {"Proposal", &tmcons.Message{Sum: &tmcons.Message_Proposal{Proposal: &tmcons.Proposal{Proposal: *pbProposal}}}, "1a740a7208201001180120012a480a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d1224080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d320608c0b89fdc053a146164645f6d6f72655f6578636c616d6174696f6e4200"}, {"ProposalPol", &tmcons.Message{Sum: &tmcons.Message_ProposalPol{ ProposalPol: &tmcons.ProposalPOL{Height: 1, ProposalPolRound: 1}}}, "2206080110011a00"}, - {"BlockPart", &tmcons.Message{Sum: &tmcons.Message_BlockPart{ - BlockPart: &tmcons.BlockPart{Height: 1, Round: 1, Part: *pbParts}}}, - "2a36080110011a3008011204746573741a26080110011a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d"}, + {"BlockPart", &tmcons.Message{Sum: &tmcons.Message_BlockRow{ + BlockRow: &tmcons.BlockRow{Height: 1, Round: 1, Row: pbRow}}}, + "2a8a04080110011a83041280040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}, {"Vote", &tmcons.Message{Sum: &tmcons.Message_Vote{ Vote: &tmcons.Vote{Vote: vpb}}}, "32700a6e0802100122480a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d1224080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d2a0608c0b89fdc0532146164645f6d6f72655f6578636c616d6174696f6e3801"}, diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index 0ed1251ea7..b4eb4072ca 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -28,15 +28,18 @@ import ( "github.com/lazyledger/lazyledger-core/libs/bytes" "github.com/lazyledger/lazyledger-core/libs/db/memdb" "github.com/lazyledger/lazyledger-core/libs/log" + tmrand "github.com/lazyledger/lazyledger-core/libs/rand" tmsync "github.com/lazyledger/lazyledger-core/libs/sync" mempl "github.com/lazyledger/lazyledger-core/mempool" "github.com/lazyledger/lazyledger-core/p2p" + "github.com/lazyledger/lazyledger-core/p2p/ipld" p2pmock "github.com/lazyledger/lazyledger-core/p2p/mock" tmproto "github.com/lazyledger/lazyledger-core/proto/tendermint/types" sm "github.com/lazyledger/lazyledger-core/state" statemocks "github.com/lazyledger/lazyledger-core/state/mocks" "github.com/lazyledger/lazyledger-core/store" "github.com/lazyledger/lazyledger-core/types" + "github.com/lazyledger/lazyledger-core/types/consts" ) //---------------------------------------------- @@ -781,32 +784,35 @@ func TestNewValidBlockMessageValidateBasic(t *testing.T) { {func(msg *NewValidBlockMessage) { msg.Height = -1 }, "negative Height"}, {func(msg *NewValidBlockMessage) { msg.Round = -1 }, "negative Round"}, { - func(msg *NewValidBlockMessage) { msg.BlockPartSetHeader.Total = 2 }, - "blockParts bit array size 1 not equal to BlockPartSetHeader.Total 2", + func(msg *NewValidBlockMessage) { msg.BlockDAHeader.RowsRoots = nil }, + "block rows bit array size 1 not equal to BlockDAHeader.Rows 0", }, { func(msg *NewValidBlockMessage) { - msg.BlockPartSetHeader.Total = 0 - msg.BlockParts = bits.NewBitArray(0) + msg.BlockDAHeader.RowsRoots = nil + msg.BlockRows = bits.NewBitArray(0) }, - "empty blockParts", + "empty BlockRows", }, { - func(msg *NewValidBlockMessage) { msg.BlockParts = bits.NewBitArray(int(types.MaxBlockPartsCount) + 1) }, - "blockParts bit array size 1602 not equal to BlockPartSetHeader.Total 1", + func(msg *NewValidBlockMessage) { msg.BlockRows = bits.NewBitArray(int(types.MaxBlockPartsCount) + 1) }, + "block rows bit array size 1602 not equal to BlockDAHeader.Rows 1", }, } for i, tc := range testCases { tc := tc t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) { + rows, _ := ipld.NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)}) + clns, _ := ipld.NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)}) msg := &NewValidBlockMessage{ Height: 1, Round: 0, - BlockPartSetHeader: types.PartSetHeader{ - Total: 1, + BlockDAHeader: &ipld.DataAvailabilityHeader{ + RowsRoots: rows, + ColumnRoots: clns, }, - BlockParts: bits.NewBitArray(1), + BlockRows: bits.NewBitArray(1), } tc.malleateFn(msg) @@ -850,37 +856,34 @@ func TestProposalPOLMessageValidateBasic(t *testing.T) { } func TestBlockPartMessageValidateBasic(t *testing.T) { - testPart := new(types.Part) - testPart.Proof.LeafHash = tmhash.Sum([]byte("leaf")) + testRow := &types.Row{ + Data: tmrand.Bytes(consts.ShareSize), + } + testCases := []struct { testName string messageHeight int64 messageRound int32 - messagePart *types.Part + messagePart *types.Row expectErr bool }{ - {"Valid Message", 0, 0, testPart, false}, - {"Invalid Message", -1, 0, testPart, true}, - {"Invalid Message", 0, -1, testPart, true}, + {"Valid Message", 0, 0, testRow, false}, + {"Invalid Message", -1, 0, testRow, true}, + {"Invalid Message", 0, -1, testRow, true}, } for _, tc := range testCases { tc := tc t.Run(tc.testName, func(t *testing.T) { - message := BlockPartMessage{ + message := BlockRowMessage{ Height: tc.messageHeight, Round: tc.messageRound, - Part: tc.messagePart, + Row: tc.messagePart, } assert.Equal(t, tc.expectErr, message.ValidateBasic() != nil, "Validate Basic had an unexpected result") }) } - - message := BlockPartMessage{Height: 0, Round: 0, Part: new(types.Part)} - message.Part.Index = 1 - - assert.Equal(t, true, message.ValidateBasic() != nil, "Validate Basic had an unexpected result") } func TestHasVoteMessageValidateBasic(t *testing.T) { From 1b8c45ba75d13b3cd0e63657c72dee4cb33f0ddb Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 30 Jun 2021 13:19:12 +0300 Subject: [PATCH 23/25] tests(consensus): fix replay and wal tests --- consensus/replay_test.go | 177 ++++++++++++++++++++++----------------- consensus/wal_test.go | 50 ++++++----- 2 files changed, 126 insertions(+), 101 deletions(-) diff --git a/consensus/replay_test.go b/consensus/replay_test.go index 75ddc6cd66..87e8124d7d 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -338,8 +338,6 @@ func TestSimulateValidatorsChange(t *testing.T) { sim.GenesisState, _ = sm.MakeGenesisState(genDoc) sim.CleanupFunc = cleanup - partSize := types.BlockPartSizeBytes - newRoundCh := subscribe(css[0].eventBus, types.EventQueryNewRound) proposalCh := subscribe(css[0].eventBus, types.EventQueryCompleteProposal) @@ -368,8 +366,7 @@ func TestSimulateValidatorsChange(t *testing.T) { newValidatorTx1 := kvstore.MakeValSetChangeTx(valPubKey1ABCI, testMinPower) err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx1, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _, _ := css[0].createProposalBlock() // changeProposer(t, cs1, vs2) - propBlockParts := propBlock.MakePartSet(partSize) + propBlock, propBlockParts, propBlockRows := css[0].createProposalBlock(vss[1].Address()) blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} proposal := types.NewProposal(vss[1].Height, round, -1, blockID, &propBlock.DataAvailabilityHeader) @@ -381,7 +378,7 @@ func TestSimulateValidatorsChange(t *testing.T) { proposal.Signature = p.Signature // set the proposal block - if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil { + if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } ensureNewProposal(proposalCh, height, round) @@ -399,8 +396,7 @@ func TestSimulateValidatorsChange(t *testing.T) { updateValidatorTx1 := kvstore.MakeValSetChangeTx(updatePubKey1ABCI, 25) err = assertMempool(css[0].txNotifier).CheckTx(updateValidatorTx1, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) - propBlockParts = propBlock.MakePartSet(partSize) + propBlock, propBlockParts, propBlockRows = css[0].createProposalBlock(vss[2].Address()) blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} proposal = types.NewProposal(vss[2].Height, round, -1, blockID, &propBlock.DataAvailabilityHeader) @@ -412,7 +408,7 @@ func TestSimulateValidatorsChange(t *testing.T) { proposal.Signature = p.Signature // set the proposal block - if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil { + if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } ensureNewProposal(proposalCh, height, round) @@ -437,8 +433,7 @@ func TestSimulateValidatorsChange(t *testing.T) { newValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, testMinPower) err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx3, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) - propBlockParts = propBlock.MakePartSet(partSize) + propBlock, propBlockParts, propBlockRows = css[0].createProposalBlock(vss[3].Address()) blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} newVss := make([]*validatorStub, nVals+1) copy(newVss, vss[:nVals+1]) @@ -470,7 +465,7 @@ func TestSimulateValidatorsChange(t *testing.T) { proposal.Signature = p.Signature // set the proposal block - if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil { + if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } ensureNewProposal(proposalCh, height, round) @@ -513,8 +508,7 @@ func TestSimulateValidatorsChange(t *testing.T) { removeValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, 0) err = assertMempool(css[0].txNotifier).CheckTx(removeValidatorTx3, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) - propBlockParts = propBlock.MakePartSet(partSize) + propBlock, propBlockParts, propBlockRows = css[0].createProposalBlock(vss[1].Address()) blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} newVss = make([]*validatorStub, nVals+3) copy(newVss, vss[:nVals+3]) @@ -530,7 +524,7 @@ func TestSimulateValidatorsChange(t *testing.T) { proposal.Signature = p.Signature // set the proposal block - if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil { + if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockRows, "some peer"); err != nil { t.Fatal(err) } ensureNewProposal(proposalCh, height, round) @@ -681,7 +675,7 @@ func testHandshakeReplay(t *testing.T, config *cfg.Config, nBlocks int, mode uin } else { // test single node testConfig := ResetConfig(fmt.Sprintf("%s_%v_s", t.Name(), mode)) defer func() { _ = os.RemoveAll(testConfig.RootDir) }() - walBody, err := walWithNBlocks(t, numBlocks) + walBody, gen, err := walWithNBlocks(t, numBlocks) require.NoError(t, err) walFile := tempWALWithData(walBody) config.Consensus.SetWalFile(walFile) @@ -698,7 +692,7 @@ func testHandshakeReplay(t *testing.T, config *cfg.Config, nBlocks int, mode uin t.Error(err) } }) - chain, commits, err = makeBlockchainFromWAL(wal) + chain, commits, err = makeBlockchainFromWAL(wal, gen) require.NoError(t, err) pubKey, err := privVal.GetPubKey() require.NoError(t, err) @@ -1042,7 +1036,7 @@ func (app *badApp) Commit() abci.ResponseCommit { //-------------------------- // utils for making blocks -func makeBlockchainFromWAL(wal WAL) ([]*types.Block, []*types.Commit, error) { +func makeBlockchainFromWAL(wal WAL, gen sm.State) ([]*types.Block, []*types.Commit, error) { var height int64 // Search for height marker @@ -1056,14 +1050,88 @@ func makeBlockchainFromWAL(wal WAL) ([]*types.Block, []*types.Commit, error) { defer gr.Close() // log.Notice("Build a blockchain by reading from the WAL") + blockStoreDB := memdb.NewDB() + stateDB := blockStoreDB + stateStore := sm.NewStore(stateDB) + err = stateStore.Save(gen) + if err != nil { + return nil, nil, err + } + proxy := proxy.NewAppConns(proxy.DefaultClientCreator("kvstore", "")) + err = proxy.Start() + if err != nil { + return nil, nil, err + } + exec := sm.NewBlockExecutor( + stateStore, + log.TestingLogger(), + proxy.Consensus(), + emptyMempool{}, + sm.EmptyEvidencePool{}, + ) var ( - blocks []*types.Block - commits []*types.Commit - thisBlockParts *types.PartSet - thisBlockCommit *types.Commit + blocks []*types.Block + commits []*types.Commit + thisBlockProposal *types.Proposal + thisBlockRows *types.RowSet + thisBlockCommit *types.Commit + thisVote *types.Vote + thisState = gen ) + processBlock := func() error { + square, err := thisBlockRows.Square() + if err != nil { + return err + } + + data, err := types.DataFromSquare(square) + if err != nil { + return err + } + + var lastCommit *types.Commit + if thisState.InitialHeight == height+1 { + lastCommit = types.NewCommit(0, 0, types.BlockID{}, nil) + } else { + lastCommit = commits[len(commits)-1] + } + + block := thisState.MakeBlock( + thisBlockProposal.Height, + data.Txs, + data.Evidence.Evidence, + data.IntermediateStateRoots.RawRootsList, + data.Messages, + lastCommit, + thisVote.ValidatorAddress, + ) + + // TODO(Wondertan): Rework this + _, err = block.RowSet(context.TODO(), mdutils.Mock()) + if err != nil { + return err + } + + thisState, _, err = exec.ApplyBlock( + thisState, + types.BlockID{ + Hash: block.Hash(), + PartSetHeader: block.MakePartSet(types.BlockPartSizeBytes).Header(), + }, + block, + ) + if err != nil { + return err + } + + blocks = append(blocks, block) + commits = append(commits, thisBlockCommit) + height++ + return nil + } + dec := NewWALDecoder(gr) for { msg, err := dec.Decode() @@ -1081,70 +1149,29 @@ func makeBlockchainFromWAL(wal WAL) ([]*types.Block, []*types.Commit, error) { switch p := piece.(type) { case EndHeightMessage: // if its not the first one, we have a full block - if thisBlockParts != nil { - var pbb = new(tmproto.Block) - bz, err := ioutil.ReadAll(thisBlockParts.GetReader()) - if err != nil { - panic(err) - } - err = proto.Unmarshal(bz, pbb) + if thisBlockRows != nil { + err := processBlock() if err != nil { - panic(err) - } - block, err := types.BlockFromProto(pbb) - if err != nil { - panic(err) - } - - if block.Height != height+1 { - panic(fmt.Sprintf("read bad block from wal. got height %d, expected %d", block.Height, height+1)) - } - commitHeight := thisBlockCommit.Height - if commitHeight != height+1 { - panic(fmt.Sprintf("commit doesnt match. got height %d, expected %d", commitHeight, height+1)) + return nil, nil, err } - blocks = append(blocks, block) - commits = append(commits, thisBlockCommit) - height++ } - case *types.PartSetHeader: - thisBlockParts = types.NewPartSetFromHeader(*p) - case *types.Part: - _, err := thisBlockParts.AddPart(p) + case *types.Proposal: + thisBlockProposal = p + thisBlockRows = types.NewRowSetFromHeader(p.DAHeader) + case *types.Row: + _, err := thisBlockRows.AddRow(p) if err != nil { return nil, nil, err } case *types.Vote: if p.Type == tmproto.PrecommitType { + thisVote = p thisBlockCommit = types.NewCommit(p.Height, p.Round, p.BlockID, []types.CommitSig{p.CommitSig()}) } } } - // grab the last block too - bz, err := ioutil.ReadAll(thisBlockParts.GetReader()) - if err != nil { - panic(err) - } - var pbb = new(tmproto.Block) - err = proto.Unmarshal(bz, pbb) - if err != nil { - panic(err) - } - block, err := types.BlockFromProto(pbb) - if err != nil { - panic(err) - } - if block.Height != height+1 { - panic(fmt.Sprintf("read bad block from wal. got height %d, expected %d", block.Height, height+1)) - } - commitHeight := thisBlockCommit.Height - if commitHeight != height+1 { - panic(fmt.Sprintf("commit doesnt match. got height %d, expected %d", commitHeight, height+1)) - } - blocks = append(blocks, block) - commits = append(commits, thisBlockCommit) - return blocks, commits, nil + return blocks, commits, processBlock() } func readPieceFromWAL(msg *TimedWALMessage) interface{} { @@ -1153,9 +1180,9 @@ func readPieceFromWAL(msg *TimedWALMessage) interface{} { case msgInfo: switch msg := m.Msg.(type) { case *ProposalMessage: - return &msg.Proposal.BlockID.PartSetHeader - case *BlockPartMessage: - return msg.Part + return msg.Proposal + case *BlockRowMessage: + return msg.Row case *VoteMessage: return msg.Vote } diff --git a/consensus/wal_test.go b/consensus/wal_test.go index 65fdaf7a7b..8fd24ae5a7 100644 --- a/consensus/wal_test.go +++ b/consensus/wal_test.go @@ -18,7 +18,6 @@ import ( "github.com/lazyledger/lazyledger-core/abci/example/kvstore" cfg "github.com/lazyledger/lazyledger-core/config" "github.com/lazyledger/lazyledger-core/consensus/types" - "github.com/lazyledger/lazyledger-core/crypto/merkle" "github.com/lazyledger/lazyledger-core/ipfs" "github.com/lazyledger/lazyledger-core/libs/autofile" "github.com/lazyledger/lazyledger-core/libs/db/memdb" @@ -63,7 +62,7 @@ func TestWALTruncate(t *testing.T) { // 60 block's size nearly 70K, greater than group's headBuf size(4096 * 10), // when headBuf is full, truncate content will Flush to the file. at this // time, RotateFile is called, truncate content exist in each file. - err = walGenerateNBlocks(t, wal.Group(), 60) + _, err = walGenerateNBlocks(t, wal.Group(), 60) require.NoError(t, err) time.Sleep(5 * time.Millisecond) // wait groupCheckDuration, make sure RotateFile run @@ -132,17 +131,12 @@ func TestWALWrite(t *testing.T) { }) // 1) Write returns an error if msg is too big - msg := &BlockPartMessage{ + msg := &BlockRowMessage{ Height: 1, Round: 1, - Part: &tmtypes.Part{ + Row: &tmtypes.Row{ Index: 1, - Bytes: make([]byte, 1), - Proof: merkle.Proof{ - Total: 1, - Index: 1, - LeafHash: make([]byte, maxMsgSizeBytes-30), - }, + Data: make([]byte, maxMsgSizeBytes), }, } @@ -155,7 +149,7 @@ func TestWALWrite(t *testing.T) { } func TestWALSearchForEndHeight(t *testing.T) { - walBody, err := walWithNBlocks(t, 6) + walBody, _, err := walWithNBlocks(t, 6) if err != nil { t.Fatal(err) } @@ -191,7 +185,7 @@ func TestWALPeriodicSync(t *testing.T) { wal.SetLogger(log.TestingLogger()) // Generate some data - err = walGenerateNBlocks(t, wal.Group(), 5) + _, err = walGenerateNBlocks(t, wal.Group(), 5) require.NoError(t, err) // We should have data in the buffer now @@ -278,7 +272,7 @@ func BenchmarkWalDecode1GB(b *testing.B) { // persistent kvstore application and special consensus wal instance // (byteBufferWAL) and waits until numBlocks are created. // If the node fails to produce given numBlocks, it returns an error. -func walGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { +func walGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (gen sm.State, err error) { config := getConfig(t) app := kvstore.NewPersistentKVStoreApplication(filepath.Join(config.DBDir(), "wal_generator")) @@ -293,30 +287,31 @@ func walGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { privValidatorStateFile := config.PrivValidatorStateFile() privValidator, err := privval.LoadOrGenFilePV(privValidatorKeyFile, privValidatorStateFile) if err != nil { - return err + return sm.State{}, err } genDoc, err := tmtypes.GenesisDocFromFile(config.GenesisFile()) if err != nil { - return fmt.Errorf("failed to read genesis file: %w", err) + return sm.State{}, fmt.Errorf("failed to read genesis file: %w", err) } blockStoreDB := memdb.NewDB() stateDB := blockStoreDB stateStore := sm.NewStore(stateDB) state, err := sm.MakeGenesisState(genDoc) if err != nil { - return fmt.Errorf("failed to make genesis state: %w", err) + return sm.State{}, fmt.Errorf("failed to make genesis state: %w", err) } state.Version.Consensus.App = kvstore.ProtocolVersion if err = stateStore.Save(state); err != nil { t.Error(err) } + gen = state.Copy() dag := mdutils.Mock() blockStore := store.MockBlockStore(blockStoreDB) proxyApp := proxy.NewAppConns(proxy.NewLocalClientCreator(app)) proxyApp.SetLogger(logger.With("module", "proxy")) if err := proxyApp.Start(); err != nil { - return fmt.Errorf("failed to start proxy app connections: %w", err) + return sm.State{}, fmt.Errorf("failed to start proxy app connections: %w", err) } t.Cleanup(func() { if err := proxyApp.Stop(); err != nil { @@ -327,7 +322,7 @@ func walGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { eventBus := tmtypes.NewEventBus() eventBus.SetLogger(logger.With("module", "events")) if err := eventBus.Start(); err != nil { - return fmt.Errorf("failed to start event bus: %w", err) + return sm.State{}, fmt.Errorf("failed to start event bus: %w", err) } t.Cleanup(func() { if err := eventBus.Stop(); err != nil { @@ -337,7 +332,6 @@ func walGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { mempool := emptyMempool{} evpool := sm.EmptyEvidencePool{} blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(), mempool, evpool) - require.NoError(t, err) consensusState := NewState(config.Consensus, state.Copy(), blockExec, blockStore, mempool, dag, ipfs.MockRouting(), evpool) consensusState.SetLogger(logger) @@ -358,7 +352,7 @@ func walGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { consensusState.wal = wal if err := consensusState.Start(); err != nil { - return fmt.Errorf("failed to start consensus state: %w", err) + return sm.State{}, fmt.Errorf("failed to start consensus state: %w", err) } select { @@ -366,26 +360,30 @@ func walGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { if err := consensusState.Stop(); err != nil { t.Error(err) } - return nil + return case <-time.After(1 * time.Minute): if err := consensusState.Stop(); err != nil { t.Error(err) } - return fmt.Errorf("waited too long for tendermint to produce %d blocks (grep logs for `wal_generator`)", numBlocks) + return sm.State{}, fmt.Errorf( + "waited too long for tendermint to produce %d blocks (grep logs for `wal_generator`)", + numBlocks, + ) } } // walWithNBlocks returns a WAL content with numBlocks. -func walWithNBlocks(t *testing.T, numBlocks int) (data []byte, err error) { +func walWithNBlocks(t *testing.T, numBlocks int) (data []byte, gen sm.State, err error) { var b bytes.Buffer wr := bufio.NewWriter(&b) - if err := walGenerateNBlocks(t, wr, numBlocks); err != nil { - return []byte{}, err + gen, err = walGenerateNBlocks(t, wr, numBlocks) + if err != nil { + return } wr.Flush() - return b.Bytes(), nil + return b.Bytes(), gen, nil } func randPort() int { From c1c884fa742c4fefe9a84dac224b4430a57dd98f Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 30 Jun 2021 13:20:20 +0300 Subject: [PATCH 24/25] tests(node): fix tests --- libs/bits/bit_array_test.go | 1 - node/node_test.go | 10 +++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/libs/bits/bit_array_test.go b/libs/bits/bit_array_test.go index fd9875f11c..53e62dd4af 100644 --- a/libs/bits/bit_array_test.go +++ b/libs/bits/bit_array_test.go @@ -182,7 +182,6 @@ func TestBitArrayOnes(t *testing.T) { assert.Equal(t, 3, ba.Ones()) } - func TestEmptyFull(t *testing.T) { ns := []int{47, 123} for _, n := range ns { diff --git a/node/node_test.go b/node/node_test.go index 4ef0fdf1a7..99c3b8236b 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -321,7 +321,7 @@ func TestCreateProposalBlock(t *testing.T) { ) commit := types.NewCommit(height-1, 0, types.BlockID{}, nil) - block, _, _ := blockExec.CreateProposalBlock( + block, _ := blockExec.CreateProposalBlock( height, state, commit, proposerAddr, @@ -390,7 +390,7 @@ func TestMaxTxsProposalBlockSize(t *testing.T) { ) commit := types.NewCommit(height-1, 0, types.BlockID{}, nil) - block, _, _ := blockExec.CreateProposalBlock( + block, _ := blockExec.CreateProposalBlock( height, state, commit, proposerAddr, @@ -497,7 +497,7 @@ func TestMaxProposalBlockSize(t *testing.T) { commit.Signatures = append(commit.Signatures, cs) } - block, partSet, _ := blockExec.CreateProposalBlock( + block, _ := blockExec.CreateProposalBlock( math.MaxInt64, state, commit, proposerAddr, @@ -515,10 +515,6 @@ func TestMaxProposalBlockSize(t *testing.T) { require.Equal(t, int64(pb.LastCommit.Size()), types.MaxCommitBytes(types.MaxVotesCount)) // make sure that the block is less than the max possible size assert.LessOrEqual(t, maxBytes, int64(pb.Size())) - // because of the proto overhead we expect the part set bytes to be equal or - // less than the pb block size - assert.LessOrEqual(t, partSet.ByteSize(), int64(pb.Size())) - } func TestNodeNewNodeCustomReactors(t *testing.T) { From bb13617ea28353190dbc6a968bdfa343610f0334 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 30 Jun 2021 14:00:16 +0300 Subject: [PATCH 25/25] fix(consensus): fix reactor block loading in catchup logic broken after rebasing --- consensus/reactor.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/consensus/reactor.go b/consensus/reactor.go index 5a513eeea8..345ca95a35 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -594,7 +594,12 @@ func (conR *Reactor) gossipDataForCatchup(logger log.Logger, rs *cstypes.RoundSt if index, ok := prs.ProposalBlockRows.Not().PickRandom(); ok { // TODO(Wondertan): Surely loading block from store every time can be optimized - b := conR.conS.blockStore.LoadBlock(prs.Height) + b, err := conR.conS.blockStore.LoadBlock(context.TODO(), prs.Height) + if err != nil { + conR.Logger.Error("can't load block", "err", err) + time.Sleep(conR.conS.config.PeerGossipSleepDuration) + return + } rs, err := b.RowSet(context.TODO(), mdutils.Mock()) if err != nil { conR.Logger.Error("can't make RowSet", "err", err)