feat(MEV): Updating MEV Lane with Testing + Cleaner Implementation (#134)
* updating mev lane with cleaner impl * nit * lint
This commit is contained in:
+17
-1
@@ -17,12 +17,19 @@ func (l *BaseLane) PrepareLane(
|
||||
proposal proposals.Proposal,
|
||||
next block.PrepareLanesHandler,
|
||||
) (proposals.Proposal, error) {
|
||||
limit := proposal.GetLaneLimits(l.cfg.MaxBlockSpace)
|
||||
l.Logger().Info("preparing lane", "lane", l.Name())
|
||||
|
||||
// Select transactions from the lane respecting the selection logic of the lane and the
|
||||
// max block space for the lane.
|
||||
limit := proposal.GetLaneLimits(l.cfg.MaxBlockSpace)
|
||||
txsToInclude, txsToRemove, err := l.prepareLaneHandler(ctx, proposal, limit)
|
||||
if err != nil {
|
||||
l.Logger().Error(
|
||||
"failed to prepare lane",
|
||||
"lane", l.Name(),
|
||||
"err", err,
|
||||
)
|
||||
|
||||
return proposal, err
|
||||
}
|
||||
|
||||
@@ -68,6 +75,8 @@ func (l *BaseLane) ProcessLane(
|
||||
txs [][]byte,
|
||||
next block.ProcessLanesHandler,
|
||||
) (proposals.Proposal, error) {
|
||||
l.Logger().Info("processing lane", "lane", l.Name(), "num_txs_to_verify", len(txs))
|
||||
|
||||
// Assume that this lane is processing sdk.Tx's and decode the transactions.
|
||||
decodedTxs, err := utils.GetDecodedTxs(l.TxDecoder(), txs)
|
||||
if err != nil {
|
||||
@@ -82,6 +91,13 @@ func (l *BaseLane) ProcessLane(
|
||||
|
||||
// Verify the transactions that belong to this lane according to the verification logic of the lane.
|
||||
if err := l.processLaneHandler(ctx, decodedTxs); err != nil {
|
||||
l.Logger().Error(
|
||||
"failed to process lane",
|
||||
"lane", l.Name(),
|
||||
"err", err,
|
||||
"num_txs_to_verify", len(decodedTxs),
|
||||
)
|
||||
|
||||
return proposal, err
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package block
|
||||
|
||||
import (
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkmempool "github.com/cosmos/cosmos-sdk/types/mempool"
|
||||
@@ -57,9 +56,6 @@ type Lane interface {
|
||||
// GetMaxBlockSpace returns the max block space for the lane as a relative percentage.
|
||||
GetMaxBlockSpace() math.LegacyDec
|
||||
|
||||
// Logger returns the lane's logger.
|
||||
Logger() log.Logger
|
||||
|
||||
// Name returns the name of the lane.
|
||||
Name() string
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@ import (
|
||||
|
||||
block "github.com/skip-mev/block-sdk/block"
|
||||
|
||||
log "cosmossdk.io/log"
|
||||
|
||||
math "cosmossdk.io/math"
|
||||
|
||||
mempool "github.com/cosmos/cosmos-sdk/types/mempool"
|
||||
@@ -95,22 +93,6 @@ func (_m *Lane) Insert(_a0 context.Context, _a1 types.Tx) error {
|
||||
return r0
|
||||
}
|
||||
|
||||
// Logger provides a mock function with given fields:
|
||||
func (_m *Lane) Logger() log.Logger {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 log.Logger
|
||||
if rf, ok := ret.Get(0).(func() log.Logger); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(log.Logger)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Match provides a mock function with given fields: ctx, tx
|
||||
func (_m *Lane) Match(ctx types.Context, tx types.Tx) bool {
|
||||
ret := _m.Called(ctx, tx)
|
||||
|
||||
Reference in New Issue
Block a user