From 281a352a03e23be27e7c0b9e2e40677d0cf90be5 Mon Sep 17 00:00:00 2001 From: Evan Forbes <42654277+evan-forbes@users.noreply.github.com> Date: Tue, 13 Dec 2022 08:36:48 -0600 Subject: [PATCH] fix!: Share splitting bug v0.11.0 (#1109) ## Overview fixes the bug described in #1108 the modified tests fails on v0.10.x ## Checklist - [x] New and updated code has appropriate documentation - [x] New and updated code has new and/or updated testing - [x] Required CI checks are passing - [x] Visual proof for any user facing features like CLI or documentation updates - [x] Linked issues closed with keywords --- app/test/fuzz_abci_test.go | 52 ++++++++++++++++++++--------------- pkg/shares/share_splitting.go | 6 ++++ 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/app/test/fuzz_abci_test.go b/app/test/fuzz_abci_test.go index 9c8587107c..ee9804b62a 100644 --- a/app/test/fuzz_abci_test.go +++ b/app/test/fuzz_abci_test.go @@ -25,29 +25,37 @@ func TestFuzzPrepareProcessProposal(t *testing.T) { encConf := encoding.MakeConfig(app.ModuleEncodingRegisters...) signer := testutil.GenerateKeyringSigner(t, testAccName) testApp := testutil.SetupTestAppWithGenesisValSet(t) - timer := time.After(time.Second * 30) - for { - select { - case <-timer: - return - default: - t.Run("randomized inputs to Prepare and Process Proposal", func(t *testing.T) { - pfdTxs := paytestutil.GenerateManyRawWirePFD(t, encConf.TxConfig, signer, tmrand.Intn(100), -1) - txs := paytestutil.GenerateManyRawSendTxs(t, encConf.TxConfig, signer, tmrand.Intn(20)) - txs = append(txs, pfdTxs...) - resp := testApp.PrepareProposal(abci.RequestPrepareProposal{ - BlockData: &core.Data{ - Txs: txs, - }, - }) - res := testApp.ProcessProposal(abci.RequestProcessProposal{ - BlockData: resp.BlockData, - Header: core.Header{ - DataHash: resp.BlockData.Hash, - }, + timer := time.After(time.Minute * 1) + + type test struct { + count, size int + } + tests := []test{{10000, 400}, {100, -1}} + + for _, tt := range tests { + for { + select { + case <-timer: + return + default: + t.Run("randomized inputs to Prepare and Process Proposal", func(t *testing.T) { + pfdTxs := paytestutil.GenerateManyRawWirePFD(t, encConf.TxConfig, signer, tmrand.Intn(tt.count), tt.size) + txs := paytestutil.GenerateManyRawSendTxs(t, encConf.TxConfig, signer, tmrand.Intn(20)) + txs = append(txs, pfdTxs...) + resp := testApp.PrepareProposal(abci.RequestPrepareProposal{ + BlockData: &core.Data{ + Txs: txs, + }, + }) + res := testApp.ProcessProposal(abci.RequestProcessProposal{ + BlockData: resp.BlockData, + Header: core.Header{ + DataHash: resp.BlockData.Hash, + }, + }) + require.Equal(t, abci.ResponseProcessProposal_ACCEPT, res.Result) }) - require.Equal(t, abci.ResponseProcessProposal_ACCEPT, res.Result) - }) + } } } } diff --git a/pkg/shares/share_splitting.go b/pkg/shares/share_splitting.go index 0a1a35e4c8..b7accb1467 100644 --- a/pkg/shares/share_splitting.go +++ b/pkg/shares/share_splitting.go @@ -51,6 +51,12 @@ func Split(data coretypes.Data, useShareIndexes bool) ([]Share, error) { MsgSharesUsed(len(data.Messages.MessagesList[0].Data)), int(data.OriginalSquareSize), ) + + // force msgIndexes to be the first share index + if len(msgIndexes) != 0 && useShareIndexes { + msgShareStart = int(msgIndexes[0]) + } + ns := appconsts.TxNamespaceID if len(evdShares) > 0 { ns = appconsts.EvidenceNamespaceID