-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: Add a block validity rule that all PFB transactions must have valid signatures #1300
Changes from 23 commits
fe08277
f14f1c7
799a065
b8b5235
53b0bd2
827faa3
7c1fafe
7eae040
520faf7
28cb6fa
8c8239e
697bdd5
4db2681
3af3536
9999b61
539f384
2db0ee9
8192fc0
f45d4a9
47b36a8
d508e9e
c50e7b8
b40bb7a
7f157b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,9 @@ import ( | |
"github.com/celestiaorg/celestia-app/app" | ||
"github.com/celestiaorg/celestia-app/app/encoding" | ||
"github.com/celestiaorg/celestia-app/testutil" | ||
"github.com/celestiaorg/celestia-app/testutil/blobfactory" | ||
"github.com/stretchr/testify/require" | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
tmrand "github.com/tendermint/tendermint/libs/rand" | ||
core "github.com/tendermint/tendermint/proto/tendermint/types" | ||
coretypes "github.com/tendermint/tendermint/types" | ||
) | ||
|
@@ -25,54 +25,68 @@ func TestPrepareProposalConsistency(t *testing.T) { | |
t.Skip("skipping TestPrepareProposalConsistency in short mode.") | ||
} | ||
encConf := encoding.MakeConfig(app.ModuleEncodingRegisters...) | ||
testApp, _ := testutil.SetupTestAppWithGenesisValSet() | ||
accounts := make([]string, 1100) // 1000 for creating blob txs, 100 for creating send txs | ||
for i := range accounts { | ||
accounts[i] = tmrand.Str(20) | ||
} | ||
|
||
testApp, kr := testutil.SetupTestAppWithGenesisValSet(accounts...) | ||
|
||
type test struct { | ||
name string | ||
count, blobCount, size int | ||
} | ||
tests := []test{ | ||
{"many small single share single blob transactions", 10000, 1, 400}, | ||
{"many small single share single blob transactions", 1000, 1, 400}, | ||
Comment on lines
-35
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reduced the length of this first test because it takes so long that sometimes we don't even run it once. changing this means that, at least in this test, are no longer testing for the weird things that can happen when using a bunch of small PFBs occasionally. We might still want to do that in the future, but I'm less worried now that we are limiting the number of txs to 5000. |
||
{"one hundred normal sized single blob transactions", 100, 1, 400000}, | ||
{"many single share multi-blob transactions", 1000, 100, 400}, | ||
{"one hundred normal sized multi-blob transactions", 100, 4, 400000}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
timer := time.After(time.Second * 30) | ||
timer := time.After(time.Second * 20) | ||
for { | ||
select { | ||
case <-timer: | ||
return | ||
default: | ||
ProcessRandomProposal(t, tt.count, tt.size, tt.blobCount, encConf, testApp) | ||
txs := testutil.RandBlobTxsWithAccounts( | ||
t, | ||
testApp, | ||
encConf.TxConfig.TxEncoder(), | ||
kr, | ||
tt.size, | ||
tt.count, | ||
true, | ||
"", | ||
accounts[:tt.count], | ||
) | ||
// create 100 send transactions | ||
sendTxs := testutil.SendTxsWithAccounts( | ||
t, | ||
testApp, | ||
encConf.TxConfig.TxEncoder(), | ||
kr, | ||
1000, | ||
accounts[0], | ||
accounts[len(accounts)-100:], | ||
"", | ||
) | ||
Comment on lines
+64
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this refactor was needed cause now we need access to state to query for account info before we can create the txs |
||
txs = append(txs, sendTxs...) | ||
resp := testApp.PrepareProposal(abci.RequestPrepareProposal{ | ||
BlockData: &core.Data{ | ||
Txs: coretypes.Txs(txs).ToSliceOfBytes(), | ||
}, | ||
}) | ||
res := testApp.ProcessProposal(abci.RequestProcessProposal{ | ||
BlockData: resp.BlockData, | ||
Header: core.Header{ | ||
DataHash: resp.BlockData.Hash, | ||
}, | ||
}) | ||
require.Equal(t, abci.ResponseProcessProposal_ACCEPT, res.Result) | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func ProcessRandomProposal( | ||
t *testing.T, | ||
count, | ||
maxSize int, | ||
maxBlobCount int, | ||
cfg encoding.Config, | ||
capp *app.App, | ||
) { | ||
txs := blobfactory.RandBlobTxsRandomlySized(cfg.TxConfig.TxEncoder(), count, maxSize, maxBlobCount) | ||
sendTxs := blobfactory.GenerateManyRawSendTxs(cfg.TxConfig, count) | ||
txs = append(txs, sendTxs...) | ||
resp := capp.PrepareProposal(abci.RequestPrepareProposal{ | ||
BlockData: &core.Data{ | ||
Txs: coretypes.Txs(txs).ToSliceOfBytes(), | ||
}, | ||
}) | ||
res := capp.ProcessProposal(abci.RequestProcessProposal{ | ||
BlockData: resp.BlockData, | ||
Header: core.Header{ | ||
DataHash: resp.BlockData.Hash, | ||
}, | ||
}) | ||
require.Equal(t, abci.ResponseProcessProposal_ACCEPT, res.Result) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add unit tests for these, since those tests are essentially identical to the
TestPrepareProposalFiltering
, in both what we test and structure of the test itself