fix: Remove Incorrect Ordering from DefaultTxPriority (#371)

* init

* replace existing tx_priorities with nop_tx_priority

* fix go.mod

---------

Co-authored-by: David Terpay <david.terpay@gmail.com>
This commit is contained in:
Nikhil Vasan
2024-01-18 12:51:58 -08:00
committed by GitHub
co-authored by David Terpay
parent d82fb33d1e
commit 234e2ff719
9 changed files with 127 additions and 421 deletions
+39 -20
View File
@@ -131,7 +131,7 @@ func (s *ProposalsTestSuite) TestPrepareProposal() {
tx1, err := testutils.CreateRandomTx(
s.encodingConfig.TxConfig,
s.accounts[0],
0,
1,
1,
0,
1,
@@ -142,8 +142,8 @@ func (s *ProposalsTestSuite) TestPrepareProposal() {
// Create a second random transaction that will be inserted into the default lane
tx2, err := testutils.CreateRandomTx(
s.encodingConfig.TxConfig,
s.accounts[1],
1,
s.accounts[0],
0,
1,
0,
1,
@@ -1346,27 +1346,46 @@ func (s *ProposalsTestSuite) TestPrepareProcessParity() {
numAccounts := 25
accounts := testutils.RandomAccounts(s.random, numAccounts)
feeDenoms := []string{
s.gasTokenDenom,
"eth",
"btc",
"usdt",
"usdc",
}
// Create a bunch of transactions to insert into the default lane
txsToInsert := []sdk.Tx{}
validationMap := make(map[sdk.Tx]bool)
for _, account := range accounts {
for nonce := uint64(0); nonce < numTxsPerAccount; nonce++ {
// create a random fee amount
feeAmount := math.NewInt(int64(rand.Intn(100000)))
tx, err := testutils.CreateRandomTx(
s.encodingConfig.TxConfig,
account,
nonce,
1,
0,
1,
sdk.NewCoin(s.gasTokenDenom, feeAmount),
)
s.Require().NoError(err)
txsToInsert = append(txsToInsert, tx)
validationMap[tx] = true
for nonce := uint64(0); nonce < numTxsPerAccount*uint64(numAccounts); nonce++ {
fees := []sdk.Coin{}
// choose a random set of fee denoms
perm := rand.Perm(len(feeDenoms))
for i := 0; i < 1+rand.Intn(len(feeDenoms)-1); i++ {
fees = append(fees, sdk.NewCoin(feeDenoms[perm[i]], math.NewInt(int64(rand.Intn(100000)))))
}
// choose a random set of accounts
perm = rand.Perm(len(accounts))
signers := []testutils.Account{}
for i := 0; i < 1+rand.Intn(len(accounts)-1); i++ {
signers = append(signers, accounts[perm[i]])
}
// create a random fee amount
tx, err := testutils.CreateRandomTxMultipleSigners(
s.encodingConfig.TxConfig,
signers,
nonce,
1,
0,
1,
fees...,
)
s.Require().NoError(err)
txsToInsert = append(txsToInsert, tx)
validationMap[tx] = true
}
// Set up the default lane with the transactions
+2 -2
View File
@@ -67,7 +67,7 @@ func (s *ProposalsTestSuite) setUpCustomMatchHandlerLane(maxBlockSpace math.Lega
options := []base.LaneOption{
base.WithMatchHandler(mh),
base.WithMempoolConfigs[string](cfg, base.DefaultTxPriority()),
base.WithMempoolConfigs(cfg, base.DefaultTxPriority()),
}
lane, err := base.NewBaseLane(
@@ -131,7 +131,7 @@ func (s *ProposalsTestSuite) setUpPanicLane(name string, maxBlockSpace math.Lega
options := []base.LaneOption{
base.WithMatchHandler(base.DefaultMatchHandler()),
base.WithMempoolConfigs[string](cfg, base.DefaultTxPriority()),
base.WithMempoolConfigs(cfg, base.DefaultTxPriority()),
base.WithPrepareLaneHandler(base.PanicPrepareLaneHandler()),
base.WithProcessLaneHandler(base.PanicProcessLaneHandler()),
}