fix (#348)
This commit is contained in:
parent
47fc466129
commit
a135d8f89d
@ -780,7 +780,7 @@ func (s *ProposalsTestSuite) TestProcessProposal() {
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{})
|
||||
|
||||
proposalHandler := s.setUpProposalHandlers([]block.Lane{mevLane, freeLane, defaultLane}).ProcessProposalHandler()
|
||||
proposal := [][]byte{}
|
||||
var proposal [][]byte
|
||||
|
||||
resp, err := proposalHandler(s.ctx, &cometabci.RequestProcessProposal{Txs: proposal, Height: 2})
|
||||
s.Require().NoError(err)
|
||||
@ -816,11 +816,10 @@ func (s *ProposalsTestSuite) TestProcessProposal() {
|
||||
tx2: true,
|
||||
})
|
||||
|
||||
defaultLane.Insert(sdk.Context{}, tx1)
|
||||
defaultLane.Insert(sdk.Context{}, tx2)
|
||||
|
||||
txs := [][]sdk.Tx{}
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx1))
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx2))
|
||||
|
||||
var txs [][]sdk.Tx
|
||||
for iterator := defaultLane.Select(context.Background(), nil); iterator != nil; iterator = iterator.Next() {
|
||||
txs = append(txs, []sdk.Tx{iterator.Tx()})
|
||||
}
|
||||
@ -1099,7 +1098,7 @@ func (s *ProposalsTestSuite) TestProcessProposal() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Mev lane
|
||||
mevLane := s.setUpTOBLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{})
|
||||
mevLane := s.setUpTOBLane(math.LegacyMustNewDecFromStr("0.3"), map[sdk.Tx]bool{})
|
||||
|
||||
// Set up the default lane
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{tx2: true, tx1: true})
|
||||
@ -1371,13 +1370,13 @@ func (s *ProposalsTestSuite) TestPrepareProcessParity() {
|
||||
}
|
||||
|
||||
// Set up the default lane with the transactions
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.0"), validationMap)
|
||||
defaultLane := s.setUpStandardLane(math.LegacyZeroDec(), validationMap)
|
||||
for _, tx := range txsToInsert {
|
||||
s.Require().NoError(defaultLane.Insert(s.ctx, tx))
|
||||
}
|
||||
|
||||
// Create a bunch of transactions to insert into the free lane
|
||||
freeTxsToInsert := []sdk.Tx{}
|
||||
var freeTxsToInsert []sdk.Tx
|
||||
freeValidationMap := make(map[sdk.Tx]bool)
|
||||
for _, account := range accounts {
|
||||
for nonce := uint64(0); nonce < numTxsPerAccount; nonce++ {
|
||||
@ -1399,20 +1398,20 @@ func (s *ProposalsTestSuite) TestPrepareProcessParity() {
|
||||
}
|
||||
}
|
||||
|
||||
freelane := s.setUpFreeLane(math.LegacyMustNewDecFromStr("0.0"), freeValidationMap)
|
||||
freelane := s.setUpFreeLane(math.LegacyMustNewDecFromStr("0.25"), freeValidationMap)
|
||||
for _, tx := range freeTxsToInsert {
|
||||
s.Require().NoError(freelane.Insert(s.ctx, tx))
|
||||
}
|
||||
|
||||
// Retrieve the transactions from the default lane in the same way the prepare function would.
|
||||
retrievedTxs := []sdk.Tx{}
|
||||
var retrievedTxs []sdk.Tx
|
||||
for iterator := defaultLane.Select(context.Background(), nil); iterator != nil; iterator = iterator.Next() {
|
||||
retrievedTxs = append(retrievedTxs, iterator.Tx())
|
||||
}
|
||||
s.Require().Equal(len(txsToInsert), len(retrievedTxs))
|
||||
|
||||
// Retrieve the transactions from the free lane in the same way the prepare function would.
|
||||
freeRetrievedTxs := []sdk.Tx{}
|
||||
var freeRetrievedTxs []sdk.Tx
|
||||
for iterator := freelane.Select(context.Background(), nil); iterator != nil; iterator = iterator.Next() {
|
||||
freeRetrievedTxs = append(freeRetrievedTxs, iterator.Tx())
|
||||
}
|
||||
@ -1489,13 +1488,13 @@ func (s *ProposalsTestSuite) TestIterateMempoolAndProcessProposalParity() {
|
||||
}
|
||||
|
||||
// Set up the default lane with the transactions
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.0"), validationMap)
|
||||
defaultLane := s.setUpStandardLane(math.LegacyZeroDec(), validationMap)
|
||||
for _, tx := range txsToInsert {
|
||||
s.Require().NoError(defaultLane.Insert(s.ctx, tx))
|
||||
}
|
||||
|
||||
// Create a bunch of transactions to insert into the free lane
|
||||
freeTxsToInsert := []sdk.Tx{}
|
||||
var freeTxsToInsert []sdk.Tx
|
||||
freeValidationMap := make(map[sdk.Tx]bool)
|
||||
for _, account := range accounts {
|
||||
for nonce := uint64(0); nonce < numTxsPerAccount; nonce++ {
|
||||
@ -1517,7 +1516,7 @@ func (s *ProposalsTestSuite) TestIterateMempoolAndProcessProposalParity() {
|
||||
}
|
||||
}
|
||||
|
||||
freelane := s.setUpFreeLane(math.LegacyMustNewDecFromStr("0.0"), freeValidationMap)
|
||||
freelane := s.setUpFreeLane(math.LegacyMustNewDecFromStr("0.3"), freeValidationMap)
|
||||
for _, tx := range freeTxsToInsert {
|
||||
s.Require().NoError(freelane.Insert(s.ctx, tx))
|
||||
}
|
||||
|
||||
@ -224,7 +224,9 @@ func (m *LanedMempool) ValidateBasic() error {
|
||||
}
|
||||
|
||||
maxBlockSpace := lane.GetMaxBlockSpace()
|
||||
if maxBlockSpace.IsZero() {
|
||||
if seenZeroMaxBlockSpace && maxBlockSpace.IsZero() {
|
||||
return fmt.Errorf("only one lane can have unlimited max block space")
|
||||
} else if maxBlockSpace.IsZero() {
|
||||
seenZeroMaxBlockSpace = true
|
||||
}
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ func (suite *BlockBusterTestSuite) SetupTest() {
|
||||
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
|
||||
SignerExtractor: signer_extraction.NewDefaultAdapter(),
|
||||
AnteHandler: nil,
|
||||
MaxBlockSpace: math.LegacyZeroDec(),
|
||||
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.3"),
|
||||
}
|
||||
factory := mev.NewDefaultAuctionFactory(suite.encodingConfig.TxConfig.TxDecoder(), signer_extraction.NewDefaultAdapter())
|
||||
suite.mevLane = mev.NewMEVLane(
|
||||
@ -98,7 +98,7 @@ func (suite *BlockBusterTestSuite) SetupTest() {
|
||||
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
|
||||
SignerExtractor: signer_extraction.NewDefaultAdapter(),
|
||||
AnteHandler: nil,
|
||||
MaxBlockSpace: math.LegacyZeroDec(),
|
||||
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.3"),
|
||||
}
|
||||
suite.freeLane = free.NewFreeLane(
|
||||
freeConfig,
|
||||
@ -163,7 +163,7 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
return nil
|
||||
})
|
||||
|
||||
baseConfig := base.LaneConfig{
|
||||
defaultConfig := base.LaneConfig{
|
||||
Logger: log.NewNopLogger(),
|
||||
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
|
||||
@ -172,7 +172,16 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
MaxBlockSpace: math.LegacyZeroDec(),
|
||||
}
|
||||
|
||||
defaultLane := defaultlane.NewDefaultLane(baseConfig, base.DefaultMatchHandler())
|
||||
baseConfig := base.LaneConfig{
|
||||
Logger: log.NewNopLogger(),
|
||||
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
|
||||
SignerExtractor: signer_extraction.NewDefaultAdapter(),
|
||||
AnteHandler: nil,
|
||||
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.3"),
|
||||
}
|
||||
|
||||
defaultLane := defaultlane.NewDefaultLane(defaultConfig, base.DefaultMatchHandler())
|
||||
factory := mev.NewDefaultAuctionFactory(suite.encodingConfig.TxConfig.TxDecoder(), signer_extraction.NewDefaultAdapter())
|
||||
mevLane := mev.NewMEVLane(
|
||||
baseConfig,
|
||||
@ -185,6 +194,12 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
free.DefaultMatchHandler(),
|
||||
)
|
||||
|
||||
invalidFreeLane := free.NewFreeLane(
|
||||
defaultConfig,
|
||||
base.DefaultTxPriority(),
|
||||
free.DefaultMatchHandler(),
|
||||
)
|
||||
|
||||
suite.Run("works with a single lane", func() {
|
||||
lanes := []block.Lane{defaultLane}
|
||||
|
||||
@ -262,7 +277,7 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
suite.Require().NoError(err)
|
||||
})
|
||||
|
||||
suite.Run("default lane not included", func() {
|
||||
suite.Run("default lane not included - invalid total space", func() {
|
||||
lanes := []block.Lane{mevLane, freeLane}
|
||||
|
||||
_, err := block.NewLanedMempool(
|
||||
@ -270,7 +285,18 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
lanes,
|
||||
fetcher,
|
||||
)
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().Error(err)
|
||||
})
|
||||
|
||||
suite.Run("two lanes with unlimited blockspace", func() {
|
||||
lanes := []block.Lane{defaultLane, invalidFreeLane}
|
||||
|
||||
_, err := block.NewLanedMempool(
|
||||
log.NewNopLogger(),
|
||||
lanes,
|
||||
fetcher,
|
||||
)
|
||||
suite.Require().Error(err)
|
||||
})
|
||||
|
||||
suite.Run("duplicate lanes", func() {
|
||||
|
||||
@ -65,7 +65,7 @@ func CreateMempool() *block.LanedMempool {
|
||||
TxEncoder: encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: encodingConfig.TxConfig.TxDecoder(),
|
||||
AnteHandler: nil,
|
||||
MaxBlockSpace: math.LegacyZeroDec(),
|
||||
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.3"),
|
||||
MaxTxs: 0, // unlimited
|
||||
}
|
||||
factory := mev.NewDefaultAuctionFactory(encodingConfig.TxConfig.TxDecoder(), signerExtractor)
|
||||
@ -77,7 +77,7 @@ func CreateMempool() *block.LanedMempool {
|
||||
TxEncoder: encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: encodingConfig.TxConfig.TxDecoder(),
|
||||
AnteHandler: nil,
|
||||
MaxBlockSpace: math.LegacyZeroDec(),
|
||||
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.3"),
|
||||
MaxTxs: 0, // unlimited
|
||||
}
|
||||
freeLane := free.NewFreeLane[string](freeConfig, base.DefaultTxPriority(), free.DefaultMatchHandler())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user