fix: Removing IgnoreList from Lane Interface (#245)

* greedy approach to lane verification

* docs

* base lane testing

* mev lane testing nits

* abci top level testing done

* network spamming in E2E

* string rep of escrow address

* nit

* nit

* nit v1.0.1

* removing logs from testing

* query test

* logging with tx info

* nits

* nit

* nit

* testing nit

* adding readmes which i will fill out l8r

* removing ignore list from convo, ur done

* removing logs in testing

* nits

* eh ig we dont need it rn

* removing ignore list from config

* nit test

---------

Co-authored-by: Alex Johnson <alex@skip.money>
This commit is contained in:
David Terpay
2023-11-29 12:10:09 -05:00
committed by GitHub
co-authored by Alex Johnson
parent be4465ae95
commit b91cfb617c
17 changed files with 358 additions and 374 deletions
+51 -101
View File
@@ -10,7 +10,6 @@ import (
"cosmossdk.io/log"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/mock"
signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter"
"github.com/skip-mev/block-sdk/block"
@@ -539,23 +538,19 @@ func (s *BaseTestSuite) TestPrepareLane() {
)
s.Require().NoError(err)
mh := func(ctx sdk.Context, tx sdk.Tx) bool {
return true
}
// Create a lane with a max block space of 1 but a proposal that is smaller than the tx
expectedExecution := map[sdk.Tx]bool{
tx: true,
}
lane := s.initLane(math.LegacyOneDec(), expectedExecution)
lane := s.initLaneWithMatchHandlers(math.LegacyOneDec(), expectedExecution, []base.MatchHandler{mh})
// Insert the transaction into the lane
s.Require().NoError(lane.Insert(s.ctx, tx))
mockLane := mocks.NewLane(s.T())
mockLane.On(
"Match",
mock.Anything,
tx,
).Return(true, nil)
lane.SetIgnoreList([]block.Lane{mockLane})
txBz, err := s.encodingConfig.TxConfig.TxEncoder()(tx)
s.Require().NoError(err)
@@ -1060,27 +1055,18 @@ func (s *BaseTestSuite) TestProcessLane() {
s.Require().NoError(err)
// First lane matches this lane the other does not.
otherLane := mocks.NewLane(s.T())
otherLane.On(
"Match",
mock.Anything,
tx1,
).Return(true, nil)
mh := func(ctx sdk.Context, tx sdk.Tx) bool {
return tx == tx1
}
otherLane.On(
"Match",
mock.Anything,
tx2,
).Return(false, nil)
lane := s.initLane(
lane := s.initLaneWithMatchHandlers(
math.LegacyOneDec(),
map[sdk.Tx]bool{
tx1: true,
tx2: true,
},
[]base.MatchHandler{mh},
)
lane.SetIgnoreList([]block.Lane{otherLane})
proposal := []sdk.Tx{
tx1,
@@ -1332,39 +1318,22 @@ func (s *BaseTestSuite) TestProcessLane() {
tx4,
}
otherLane := mocks.NewLane(s.T())
otherLane.On(
"Match",
mock.Anything,
tx1,
).Return(false, nil)
mh := func(ctx sdk.Context, tx sdk.Tx) bool {
if tx == tx1 || tx == tx2 {
return false
}
otherLane.On(
"Match",
mock.Anything,
tx2,
).Return(false, nil)
return true
}
otherLane.On(
"Match",
mock.Anything,
tx3,
).Return(true, nil)
otherLane.On(
"Match",
mock.Anything,
tx4,
).Return(true, nil)
lane := s.initLane(
lane := s.initLaneWithMatchHandlers(
math.LegacyOneDec(),
map[sdk.Tx]bool{
tx1: true,
tx2: true,
},
[]base.MatchHandler{mh},
)
lane.SetIgnoreList([]block.Lane{otherLane})
txsFromLane, remainingTxs, err := lane.DefaultProcessLaneHandler()(s.ctx, proposal)
s.Require().NoError(err)
@@ -1436,36 +1405,15 @@ func (s *BaseTestSuite) TestProcessLane() {
tx4,
}
otherLane := mocks.NewLane(s.T())
otherLane.On(
"Match",
mock.Anything,
tx1,
).Return(true, nil)
mh := func(ctx sdk.Context, tx sdk.Tx) bool {
return true
}
otherLane.On(
"Match",
mock.Anything,
tx2,
).Return(true, nil)
otherLane.On(
"Match",
mock.Anything,
tx3,
).Return(true, nil)
otherLane.On(
"Match",
mock.Anything,
tx4,
).Return(true, nil)
lane := s.initLane(
lane := s.initLaneWithMatchHandlers(
math.LegacyOneDec(),
map[sdk.Tx]bool{},
[]base.MatchHandler{mh},
)
lane.SetIgnoreList([]block.Lane{otherLane})
txsFromLane, remainingTxs, err := lane.DefaultProcessLaneHandler()(s.ctx, proposal)
s.Require().NoError(err)
@@ -1533,32 +1481,15 @@ func (s *BaseTestSuite) TestProcessLane() {
tx4,
}
otherLane := mocks.NewLane(s.T())
otherLane.On(
"Match",
mock.Anything,
tx1,
).Return(false, nil)
mh := func(ctx sdk.Context, tx sdk.Tx) bool {
if tx == tx1 || tx == tx3 {
return false
}
otherLane.On(
"Match",
mock.Anything,
tx2,
).Return(true, nil)
return true
}
otherLane.On(
"Match",
mock.Anything,
tx3,
).Return(false, nil).Maybe()
otherLane.On(
"Match",
mock.Anything,
tx4,
).Return(true, nil).Maybe()
lane := s.initLane(
lane := s.initLaneWithMatchHandlers(
math.LegacyOneDec(),
map[sdk.Tx]bool{
tx1: true,
@@ -1566,8 +1497,8 @@ func (s *BaseTestSuite) TestProcessLane() {
tx3: true,
tx4: true,
},
[]base.MatchHandler{mh},
)
lane.SetIgnoreList([]block.Lane{otherLane})
txsFromLane, remainingTxs, err := lane.DefaultProcessLaneHandler()(s.ctx, proposal)
s.Require().Error(err)
@@ -1739,7 +1670,26 @@ func (s *BaseTestSuite) initLane(
maxBlockSpace,
)
return defaultlane.NewDefaultLane(config)
return defaultlane.NewDefaultLane(config, base.DefaultMatchHandler())
}
func (s *BaseTestSuite) initLaneWithMatchHandlers(
maxBlockSpace math.LegacyDec,
expectedExecution map[sdk.Tx]bool,
matchHandlers []base.MatchHandler,
) *defaultlane.DefaultLane {
config := base.NewLaneConfig(
log.NewNopLogger(),
s.encodingConfig.TxConfig.TxEncoder(),
s.encodingConfig.TxConfig.TxDecoder(),
s.setUpAnteHandler(expectedExecution),
signer_extraction.NewDefaultAdapter(),
maxBlockSpace,
)
mh := base.NewMatchHandler(base.DefaultMatchHandler(), matchHandlers...)
return defaultlane.NewDefaultLane(config, mh)
}
func (s *BaseTestSuite) setUpAnteHandler(expectedExecution map[sdk.Tx]bool) sdk.AnteHandler {
+3 -4
View File
@@ -13,8 +13,7 @@ const (
var _ block.Lane = (*DefaultLane)(nil)
// DefaultLane defines a default lane implementation. The default lane orders
// transactions by the transaction fees. The default lane accepts any transaction
// that should not be ignored (as defined by the IgnoreList in the LaneConfig).
// transactions by the transaction fees. The default lane accepts any transaction.
// The default lane builds and verifies blocks in a similar fashion to how the
// CometBFT/Tendermint consensus engine builds and verifies blocks pre SDK version
// 0.47.0.
@@ -23,7 +22,7 @@ type DefaultLane struct {
}
// NewDefaultLane returns a new default lane.
func NewDefaultLane(cfg base.LaneConfig) *DefaultLane {
func NewDefaultLane(cfg base.LaneConfig, matchHandler base.MatchHandler) *DefaultLane {
lane := base.NewBaseLane(
cfg,
LaneName,
@@ -33,7 +32,7 @@ func NewDefaultLane(cfg base.LaneConfig) *DefaultLane {
cfg.SignerExtractor,
cfg.MaxTxs,
),
base.DefaultMatchHandler(),
matchHandler,
)
if err := lane.ValidateBasic(); err != nil {
+2 -1
View File
@@ -45,6 +45,7 @@ type (
func NewMEVLane(
cfg base.LaneConfig,
factory Factory,
matchHandler base.MatchHandler,
) *MEVLane {
lane := &MEVLane{
BaseLane: base.NewBaseLane(
@@ -56,7 +57,7 @@ func NewMEVLane(
cfg.SignerExtractor,
cfg.MaxTxs,
),
factory.MatchHandler(),
matchHandler,
),
Factory: factory,
}
+1 -1
View File
@@ -64,7 +64,7 @@ func (s *MEVTestSuite) initLane(
)
factory := mev.NewDefaultAuctionFactory(s.encCfg.TxConfig.TxDecoder(), signer_extraction.NewDefaultAdapter())
return mev.NewMEVLane(config, factory)
return mev.NewMEVLane(config, factory, factory.MatchHandler())
}
func (s *MEVTestSuite) setUpAnteHandler(expectedExecution map[sdk.Tx]bool) sdk.AnteHandler {