Skip to content

Commit

Permalink
fix!: Share splitting bug v0.11.0 (#1109)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
evan-forbes committed Dec 13, 2022
1 parent 1e782f8 commit 281a352
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 deletions.
52 changes: 30 additions & 22 deletions app/test/fuzz_abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}
}
}
6 changes: 6 additions & 0 deletions pkg/shares/share_splitting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 281a352

Please sign in to comment.