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
+6 -6
View File
@@ -292,8 +292,8 @@ func (s *BaseTestSuite) TestPrepareLane() {
s.Run("should order transactions correctly in the proposal (with different insertion)", func() {
tx1, err := testutils.CreateRandomTx(
s.encodingConfig.TxConfig,
s.accounts[0],
0,
s.accounts[1],
1,
1,
0,
1,
@@ -961,7 +961,7 @@ func (s *BaseTestSuite) TestProcessLane() {
s.Require().Equal(encodedTxs, finalProposal.Txs)
})
s.Run("should not accept a proposal with transactions that are not in the correct order fee wise", func() {
s.Run("should accept a proposal with transactions that are in any order fee wise", func() {
tx1, err := testutils.CreateRandomTx(
s.encodingConfig.TxConfig,
s.accounts[0],
@@ -998,8 +998,8 @@ func (s *BaseTestSuite) TestProcessLane() {
)
txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal)
s.Require().Error(err)
s.Require().Len(txsFromLane, 0)
s.Require().NoError(err)
s.Require().Len(txsFromLane, 2)
s.Require().Len(remainingTxs, 0)
emptyProposal := proposals.NewProposal(
@@ -1009,7 +1009,7 @@ func (s *BaseTestSuite) TestProcessLane() {
)
_, err = lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler())
s.Require().Error(err)
s.Require().NoError(err)
})
s.Run("should not accept proposal where transactions from lane are not contiguous from the start", func() {
+10 -10
View File
@@ -95,7 +95,7 @@ func (s *BaseTestSuite) TestCompareTxPriority() {
s.Require().Error(err)
})
s.Run("should return 1 when the first tx has a higher priority", func() {
s.Run("should return 0 when the first tx has a higher fee", func() {
tx1, err := testutils.CreateRandomTx(
s.encodingConfig.TxConfig,
s.accounts[0],
@@ -120,12 +120,12 @@ func (s *BaseTestSuite) TestCompareTxPriority() {
cmp, err := lane.Compare(sdk.Context{}, tx1, tx2)
s.Require().NoError(err)
s.Require().Equal(1, cmp)
s.Require().Equal(0, cmp)
})
}
func (s *BaseTestSuite) TestInsert() {
mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3)
mempool := base.NewMempool(base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3)
s.Run("should be able to insert a transaction", func() {
tx, err := testutils.CreateRandomTx(
@@ -180,7 +180,7 @@ func (s *BaseTestSuite) TestInsert() {
}
func (s *BaseTestSuite) TestRemove() {
mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3)
mempool := base.NewMempool(base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3)
s.Run("should be able to remove a transaction", func() {
tx, err := testutils.CreateRandomTx(
@@ -220,11 +220,11 @@ func (s *BaseTestSuite) TestRemove() {
func (s *BaseTestSuite) TestSelect() {
s.Run("should be able to select transactions in the correct order", func() {
mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3)
mempool := base.NewMempool(base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3)
tx1, err := testutils.CreateRandomTx(
s.encodingConfig.TxConfig,
s.accounts[0],
s.accounts[1],
0,
0,
0,
@@ -236,7 +236,7 @@ func (s *BaseTestSuite) TestSelect() {
tx2, err := testutils.CreateRandomTx(
s.encodingConfig.TxConfig,
s.accounts[1],
0,
1,
0,
0,
0,
@@ -252,16 +252,16 @@ func (s *BaseTestSuite) TestSelect() {
// Check that the transactions are in the correct order
iterator := mempool.Select(sdk.Context{}, nil)
s.Require().NotNil(iterator)
s.Require().Equal(tx2, iterator.Tx())
s.Require().Equal(tx1, iterator.Tx())
// Check the second transaction
iterator = iterator.Next()
s.Require().NotNil(iterator)
s.Require().Equal(tx1, iterator.Tx())
s.Require().Equal(tx2, iterator.Tx())
})
s.Run("should be able to select a single transaction", func() {
mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3)
mempool := base.NewMempool(base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3)
tx1, err := testutils.CreateRandomTx(
s.encodingConfig.TxConfig,