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:
co-authored by
Alex Johnson
parent
be4465ae95
commit
b91cfb617c
@@ -8,7 +8,6 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter"
|
||||
"github.com/skip-mev/block-sdk/block"
|
||||
)
|
||||
|
||||
// LaneConfig defines the basic configurations needed for a lane.
|
||||
@@ -28,14 +27,6 @@ type LaneConfig struct {
|
||||
// lane (up to maxTxBytes as provided by the request). This is useful for the default lane.
|
||||
MaxBlockSpace math.LegacyDec
|
||||
|
||||
// IgnoreList defines the list of lanes to ignore when processing transactions. This
|
||||
// is useful for when you want lanes to exist after the default lane. For example,
|
||||
// say there are two lanes: default and free. The free lane should be processed after
|
||||
// the default lane. In this case, the free lane should be added to the ignore list
|
||||
// of the default lane. Otherwise, the transactions that belong to the free lane
|
||||
// will be processed by the default lane (which accepts all transactions by default).
|
||||
IgnoreList []block.Lane
|
||||
|
||||
// MaxTxs sets the maximum number of transactions allowed in the mempool with
|
||||
// the semantics:
|
||||
// - if MaxTx == 0, there is no cap on the number of transactions in the mempool
|
||||
|
||||
@@ -170,3 +170,19 @@ func DefaultMatchHandler() MatchHandler {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// NewMatchHandler returns a match handler that matches transactions
|
||||
// that match the lane and do not match with any of the provided match handlers.
|
||||
// In the context of building an application, you would want to use this to
|
||||
// ignore the match handlers of other lanes in the application.
|
||||
func NewMatchHandler(mh MatchHandler, ignoreMHs ...MatchHandler) MatchHandler {
|
||||
return func(ctx sdk.Context, tx sdk.Tx) bool {
|
||||
for _, ignoreMH := range ignoreMHs {
|
||||
if ignoreMH(ctx, tx) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return mh(ctx, tx)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-30
@@ -121,24 +121,7 @@ func (l *BaseLane) SetProcessLaneHandler(processLaneHandler ProcessLaneHandler)
|
||||
// if the transaction is on the ignore list. If the transaction is on the ignore
|
||||
// list, it returns false.
|
||||
func (l *BaseLane) Match(ctx sdk.Context, tx sdk.Tx) bool {
|
||||
return l.matchHandler(ctx, tx) && !l.CheckIgnoreList(ctx, tx)
|
||||
}
|
||||
|
||||
// CheckIgnoreList returns true if the transaction is on the ignore list. The ignore
|
||||
// list is utilized to prevent transactions that should be considered in other lanes
|
||||
// from being considered from this lane.
|
||||
func (l *BaseLane) CheckIgnoreList(ctx sdk.Context, tx sdk.Tx) bool {
|
||||
if l.cfg.IgnoreList == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, lane := range l.cfg.IgnoreList {
|
||||
if lane.Match(ctx, tx) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
return l.matchHandler(ctx, tx)
|
||||
}
|
||||
|
||||
// Name returns the name of the lane.
|
||||
@@ -146,18 +129,6 @@ func (l *BaseLane) Name() string {
|
||||
return l.laneName
|
||||
}
|
||||
|
||||
// SetIgnoreList sets the ignore list for the lane. The ignore list is a list
|
||||
// of lanes that the lane should ignore when processing transactions.
|
||||
func (l *BaseLane) SetIgnoreList(lanes []block.Lane) {
|
||||
l.cfg.IgnoreList = lanes
|
||||
}
|
||||
|
||||
// GetIgnoreList returns the ignore list for the lane. The ignore list is a list
|
||||
// of lanes that the lane should ignore when processing transactions.
|
||||
func (l *BaseLane) GetIgnoreList() []block.Lane {
|
||||
return l.cfg.IgnoreList
|
||||
}
|
||||
|
||||
// SetAnteHandler sets the ante handler for the lane.
|
||||
func (l *BaseLane) SetAnteHandler(anteHandler sdk.AnteHandler) {
|
||||
l.cfg.AnteHandler = anteHandler
|
||||
|
||||
Reference in New Issue
Block a user