moving lanes to their own directory
This commit is contained in:
parent
b2daf5acbb
commit
9d349910d1
@ -7,8 +7,8 @@ import (
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/terminator"
|
||||
"github.com/skip-mev/pob/blockbuster/utils"
|
||||
"github.com/skip-mev/pob/lanes/terminator"
|
||||
)
|
||||
|
||||
type (
|
||||
@ -13,11 +13,12 @@ import (
|
||||
cometabci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/abci"
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
"github.com/skip-mev/pob/blockbuster/abci"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/base"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/free"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/mev"
|
||||
"github.com/skip-mev/pob/blockbuster/constructor"
|
||||
"github.com/skip-mev/pob/lanes/base"
|
||||
"github.com/skip-mev/pob/lanes/free"
|
||||
"github.com/skip-mev/pob/lanes/mev"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
@ -756,10 +757,10 @@ func (s *ProposalsTestSuite) setUpFreeLane(maxBlockSpace math.LegacyDec, expecte
|
||||
MaxBlockSpace: maxBlockSpace,
|
||||
}
|
||||
|
||||
return free.NewFreeLane(cfg, blockbuster.DefaultTxPriority(), free.DefaultMatchHandler())
|
||||
return free.NewFreeLane(cfg, constructor.DefaultTxPriority(), free.DefaultMatchHandler())
|
||||
}
|
||||
|
||||
func (s *ProposalsTestSuite) setUpPanicLane(maxBlockSpace math.LegacyDec) *blockbuster.LaneConstructor[string] {
|
||||
func (s *ProposalsTestSuite) setUpPanicLane(maxBlockSpace math.LegacyDec) *constructor.LaneConstructor[string] {
|
||||
cfg := blockbuster.LaneConfig{
|
||||
Logger: log.NewTestLogger(s.T()),
|
||||
TxEncoder: s.encodingConfig.TxConfig.TxEncoder(),
|
||||
@ -767,11 +768,11 @@ func (s *ProposalsTestSuite) setUpPanicLane(maxBlockSpace math.LegacyDec) *block
|
||||
MaxBlockSpace: maxBlockSpace,
|
||||
}
|
||||
|
||||
lane := blockbuster.NewLaneConstructor[string](
|
||||
lane := constructor.NewLaneConstructor[string](
|
||||
cfg,
|
||||
"panic",
|
||||
blockbuster.NewConstructorMempool[string](blockbuster.DefaultTxPriority(), cfg.TxEncoder, 0),
|
||||
blockbuster.DefaultMatchHandler(),
|
||||
constructor.NewConstructorMempool[string](constructor.DefaultTxPriority(), cfg.TxEncoder, 0),
|
||||
constructor.DefaultMatchHandler(),
|
||||
)
|
||||
|
||||
lane.SetPrepareLaneHandler(blockbuster.PanicPrepareLaneHandler())
|
||||
@ -781,7 +782,7 @@ func (s *ProposalsTestSuite) setUpPanicLane(maxBlockSpace math.LegacyDec) *block
|
||||
}
|
||||
|
||||
func (s *ProposalsTestSuite) setUpProposalHandlers(lanes []blockbuster.Lane) *abci.ProposalHandler {
|
||||
mempool := blockbuster.NewMempool(log.NewTestLogger(s.T()), true, lanes...)
|
||||
mempool := blockbuster.NewLanedMempool(log.NewTestLogger(s.T()), true, lanes...)
|
||||
|
||||
return abci.NewProposalHandler(
|
||||
log.NewTestLogger(s.T()),
|
||||
@ -1,7 +1,8 @@
|
||||
package blockbuster
|
||||
package constructor
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
"github.com/skip-mev/pob/blockbuster/utils"
|
||||
)
|
||||
|
||||
@ -11,10 +12,10 @@ import (
|
||||
// error. The proposal will only be modified if it passes all of the invarient checks.
|
||||
func (l *LaneConstructor[C]) PrepareLane(
|
||||
ctx sdk.Context,
|
||||
proposal BlockProposal,
|
||||
proposal blockbuster.BlockProposal,
|
||||
maxTxBytes int64,
|
||||
next PrepareLanesHandler,
|
||||
) (BlockProposal, error) {
|
||||
next blockbuster.PrepareLanesHandler,
|
||||
) (blockbuster.BlockProposal, error) {
|
||||
txs, txsToRemove, err := l.prepareLaneHandler(ctx, proposal, maxTxBytes)
|
||||
if err != nil {
|
||||
return proposal, err
|
||||
@ -47,7 +48,7 @@ func (l *LaneConstructor[C]) CheckOrder(ctx sdk.Context, txs []sdk.Tx) error {
|
||||
// the verification logic of the lane (processLaneHandler). If the transactions are valid, we
|
||||
// return the transactions that do not belong to this lane to the next lane. If the transactions
|
||||
// are invalid, we return an error.
|
||||
func (l *LaneConstructor[C]) ProcessLane(ctx sdk.Context, txs []sdk.Tx, next ProcessLanesHandler) (sdk.Context, error) {
|
||||
func (l *LaneConstructor[C]) ProcessLane(ctx sdk.Context, txs []sdk.Tx, next blockbuster.ProcessLanesHandler) (sdk.Context, error) {
|
||||
remainingTxs, err := l.processLaneHandler(ctx, txs)
|
||||
if err != nil {
|
||||
return ctx, err
|
||||
@ -1,9 +1,10 @@
|
||||
package blockbuster
|
||||
package constructor
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
"github.com/skip-mev/pob/blockbuster/utils"
|
||||
)
|
||||
|
||||
@ -11,8 +12,8 @@ import (
|
||||
// selects all transactions in the mempool that are valid and not already in the partial
|
||||
// proposal. It will continue to reap transactions until the maximum block space for this
|
||||
// lane has been reached. Additionally, any transactions that are invalid will be returned.
|
||||
func (l *LaneConstructor[C]) DefaultPrepareLaneHandler() PrepareLaneHandler {
|
||||
return func(ctx sdk.Context, proposal BlockProposal, maxTxBytes int64) ([][]byte, []sdk.Tx, error) {
|
||||
func (l *LaneConstructor[C]) DefaultPrepareLaneHandler() blockbuster.PrepareLaneHandler {
|
||||
return func(ctx sdk.Context, proposal blockbuster.BlockProposal, maxTxBytes int64) ([][]byte, []sdk.Tx, error) {
|
||||
var (
|
||||
totalSize int64
|
||||
txs [][]byte
|
||||
@ -95,7 +96,7 @@ func (l *LaneConstructor[C]) DefaultPrepareLaneHandler() PrepareLaneHandler {
|
||||
// fails to verify, the entire proposal is rejected. If the handler comes across a transaction
|
||||
// that does not match the lane's matcher, it will return the remaining transactions in the
|
||||
// proposal.
|
||||
func (l *LaneConstructor[C]) DefaultProcessLaneHandler() ProcessLaneHandler {
|
||||
func (l *LaneConstructor[C]) DefaultProcessLaneHandler() blockbuster.ProcessLaneHandler {
|
||||
return func(ctx sdk.Context, txs []sdk.Tx) ([]sdk.Tx, error) {
|
||||
var err error
|
||||
|
||||
@ -122,7 +123,7 @@ func (l *LaneConstructor[C]) DefaultProcessLaneHandler() ProcessLaneHandler {
|
||||
// lane.
|
||||
// 2. Transactions that belong to other lanes cannot be interleaved with transactions that
|
||||
// belong to this lane.
|
||||
func (l *LaneConstructor[C]) DefaultCheckOrderHandler() CheckOrderHandler {
|
||||
func (l *LaneConstructor[C]) DefaultCheckOrderHandler() blockbuster.CheckOrderHandler {
|
||||
return func(ctx sdk.Context, txs []sdk.Tx) error {
|
||||
seenOtherLaneTx := false
|
||||
|
||||
@ -148,7 +149,7 @@ func (l *LaneConstructor[C]) DefaultCheckOrderHandler() CheckOrderHandler {
|
||||
|
||||
// DefaultMatchHandler returns a default implementation of the MatchHandler. It matches all
|
||||
// transactions.
|
||||
func DefaultMatchHandler() MatchHandler {
|
||||
func DefaultMatchHandler() blockbuster.MatchHandler {
|
||||
return func(ctx sdk.Context, tx sdk.Tx) bool {
|
||||
return true
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package blockbuster
|
||||
package constructor
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
)
|
||||
|
||||
// LaneConstructor is a generic implementation of a lane. It is meant to be used
|
||||
@ -17,42 +18,42 @@ type LaneConstructor[C comparable] struct {
|
||||
// cfg stores functionality required to encode/decode transactions, maintains how
|
||||
// many transactions are allowed in this lane's mempool, and the amount of block
|
||||
// space this lane is allowed to consume.
|
||||
cfg LaneConfig
|
||||
cfg blockbuster.LaneConfig
|
||||
|
||||
// laneName is the name of the lane.
|
||||
laneName string
|
||||
|
||||
// LaneMempool is the mempool that is responsible for storing transactions
|
||||
// that are waiting to be processed.
|
||||
LaneMempool
|
||||
blockbuster.LaneMempool
|
||||
|
||||
// matchHandler is the function that determines whether or not a transaction
|
||||
// should be processed by this lane.
|
||||
matchHandler MatchHandler
|
||||
matchHandler blockbuster.MatchHandler
|
||||
|
||||
// prepareLaneHandler is the function that is called when a new proposal is being
|
||||
// requested and the lane needs to submit transactions it wants included in the block.
|
||||
prepareLaneHandler PrepareLaneHandler
|
||||
prepareLaneHandler blockbuster.PrepareLaneHandler
|
||||
|
||||
// checkOrderHandler is the function that is called when a new proposal is being
|
||||
// verified and the lane needs to verify that the transactions included in the proposal
|
||||
// respect the ordering rules of the lane and does not interleave transactions from other lanes.
|
||||
checkOrderHandler CheckOrderHandler
|
||||
checkOrderHandler blockbuster.CheckOrderHandler
|
||||
|
||||
// processLaneHandler is the function that is called when a new proposal is being
|
||||
// verified and the lane needs to verify that the transactions included in the proposal
|
||||
// are valid respecting the verification logic of the lane.
|
||||
processLaneHandler ProcessLaneHandler
|
||||
processLaneHandler blockbuster.ProcessLaneHandler
|
||||
}
|
||||
|
||||
// NewLaneConstructor returns a new lane constructor. When creating this lane, the type
|
||||
// of the lane must be specified. The type of the lane is directly associated with the
|
||||
// type of the mempool that is used to store transactions that are waiting to be processed.
|
||||
func NewLaneConstructor[C comparable](
|
||||
cfg LaneConfig,
|
||||
cfg blockbuster.LaneConfig,
|
||||
laneName string,
|
||||
laneMempool LaneMempool,
|
||||
matchHandlerFn MatchHandler,
|
||||
laneMempool blockbuster.LaneMempool,
|
||||
matchHandlerFn blockbuster.MatchHandler,
|
||||
) *LaneConstructor[C] {
|
||||
lane := &LaneConstructor[C]{
|
||||
cfg: cfg,
|
||||
@ -105,7 +106,7 @@ func (l *LaneConstructor[C]) ValidateBasic() error {
|
||||
// SetPrepareLaneHandler sets the prepare lane handler for the lane. This handler
|
||||
// is called when a new proposal is being requested and the lane needs to submit
|
||||
// transactions it wants included in the block.
|
||||
func (l *LaneConstructor[C]) SetPrepareLaneHandler(prepareLaneHandler PrepareLaneHandler) {
|
||||
func (l *LaneConstructor[C]) SetPrepareLaneHandler(prepareLaneHandler blockbuster.PrepareLaneHandler) {
|
||||
if prepareLaneHandler == nil {
|
||||
panic("prepare lane handler cannot be nil")
|
||||
}
|
||||
@ -117,7 +118,7 @@ func (l *LaneConstructor[C]) SetPrepareLaneHandler(prepareLaneHandler PrepareLan
|
||||
// is called when a new proposal is being verified and the lane needs to verify
|
||||
// that the transactions included in the proposal are valid respecting the verification
|
||||
// logic of the lane.
|
||||
func (l *LaneConstructor[C]) SetProcessLaneHandler(processLaneHandler ProcessLaneHandler) {
|
||||
func (l *LaneConstructor[C]) SetProcessLaneHandler(processLaneHandler blockbuster.ProcessLaneHandler) {
|
||||
if processLaneHandler == nil {
|
||||
panic("process lane handler cannot be nil")
|
||||
}
|
||||
@ -129,7 +130,7 @@ func (l *LaneConstructor[C]) SetProcessLaneHandler(processLaneHandler ProcessLan
|
||||
// is called when a new proposal is being verified and the lane needs to verify
|
||||
// that the transactions included in the proposal respect the ordering rules of
|
||||
// the lane and does not include transactions from other lanes.
|
||||
func (l *LaneConstructor[C]) SetCheckOrderHandler(checkOrderHandler CheckOrderHandler) {
|
||||
func (l *LaneConstructor[C]) SetCheckOrderHandler(checkOrderHandler blockbuster.CheckOrderHandler) {
|
||||
if checkOrderHandler == nil {
|
||||
panic("check order handler cannot be nil")
|
||||
}
|
||||
@ -165,7 +166,7 @@ func (l *LaneConstructor[C]) Name() string {
|
||||
|
||||
// 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 *LaneConstructor[C]) SetIgnoreList(lanes []Lane) {
|
||||
func (l *LaneConstructor[C]) SetIgnoreList(lanes []blockbuster.Lane) {
|
||||
l.cfg.IgnoreList = lanes
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package blockbuster
|
||||
package constructor
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -7,6 +7,7 @@ import (
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkmempool "github.com/cosmos/cosmos-sdk/types/mempool"
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
"github.com/skip-mev/pob/blockbuster/utils"
|
||||
)
|
||||
|
||||
@ -24,7 +25,7 @@ type (
|
||||
// retrieve the priority of a given transaction and to compare the priority
|
||||
// of two transactions. The index utilizes this struct to order transactions
|
||||
// in the mempool.
|
||||
txPriority TxPriority[C]
|
||||
txPriority blockbuster.TxPriority[C]
|
||||
|
||||
// txEncoder defines the sdk.Tx encoder that allows us to encode transactions
|
||||
// to bytes.
|
||||
@ -38,8 +39,8 @@ type (
|
||||
|
||||
// DefaultTxPriority returns a default implementation of the TxPriority. It prioritizes
|
||||
// transactions by their fee.
|
||||
func DefaultTxPriority() TxPriority[string] {
|
||||
return TxPriority[string]{
|
||||
func DefaultTxPriority() blockbuster.TxPriority[string] {
|
||||
return blockbuster.TxPriority[string]{
|
||||
GetTxPriority: func(goCtx context.Context, tx sdk.Tx) string {
|
||||
feeTx, ok := tx.(sdk.FeeTx)
|
||||
if !ok {
|
||||
@ -80,10 +81,10 @@ func DefaultTxPriority() TxPriority[string] {
|
||||
}
|
||||
|
||||
// NewConstructorMempool returns a new ConstructorMempool.
|
||||
func NewConstructorMempool[C comparable](txPriority TxPriority[C], txEncoder sdk.TxEncoder, maxTx int) *ConstructorMempool[C] {
|
||||
func NewConstructorMempool[C comparable](txPriority blockbuster.TxPriority[C], txEncoder sdk.TxEncoder, maxTx int) *ConstructorMempool[C] {
|
||||
return &ConstructorMempool[C]{
|
||||
index: NewPriorityMempool(
|
||||
PriorityNonceMempoolConfig[C]{
|
||||
index: blockbuster.NewPriorityMempool(
|
||||
blockbuster.PriorityNonceMempoolConfig[C]{
|
||||
TxPriority: txPriority,
|
||||
MaxTx: maxTx,
|
||||
},
|
||||
@ -11,10 +11,10 @@ import (
|
||||
sdkmempool "github.com/cosmos/cosmos-sdk/types/mempool"
|
||||
)
|
||||
|
||||
var _ Mempool = (*BBMempool)(nil)
|
||||
var _ Mempool = (*LanedMempool)(nil)
|
||||
|
||||
type (
|
||||
// Mempool defines the Blockbuster mempool interface.
|
||||
// LanedMempool defines the Block SDK mempool interface.
|
||||
Mempool interface {
|
||||
sdkmempool.Mempool
|
||||
|
||||
@ -26,14 +26,11 @@ type (
|
||||
|
||||
// GetTxDistribution returns the number of transactions in each lane.
|
||||
GetTxDistribution() map[string]int
|
||||
|
||||
// GetLane returns the lane with the given name.
|
||||
GetLane(name string) (Lane, error)
|
||||
}
|
||||
|
||||
// BBMempool defines the Blockbuster mempool implementation. It contains a registry
|
||||
// LanedMempool defines the Block SDK mempool implementation. It contains a registry
|
||||
// of lanes, which allows for customizable block proposal construction.
|
||||
BBMempool struct {
|
||||
LanedMempool struct {
|
||||
logger log.Logger
|
||||
|
||||
// registry contains the lanes in the mempool. The lanes are ordered
|
||||
@ -43,7 +40,7 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// NewMempool returns a new Blockbuster mempool. The blockbuster mempool is
|
||||
// NewLanedMempool returns a new Blockbuster mempool. The blockbuster mempool is
|
||||
// comprised of a registry of lanes. Each lane is responsible for selecting
|
||||
// transactions according to its own selection logic. The lanes are ordered
|
||||
// according to their priority. The first lane in the registry has the highest
|
||||
@ -54,8 +51,8 @@ type (
|
||||
// attempt to insert, remove transactions from all lanes it belongs to. It is recommended,
|
||||
// that mutex is set to true when creating the mempool. This will ensure that each
|
||||
// transaction cannot be inserted into the lanes before it.
|
||||
func NewMempool(logger log.Logger, mutex bool, lanes ...Lane) *BBMempool {
|
||||
mempool := &BBMempool{
|
||||
func NewLanedMempool(logger log.Logger, mutex bool, lanes ...Lane) *LanedMempool {
|
||||
mempool := &LanedMempool{
|
||||
logger: logger,
|
||||
registry: lanes,
|
||||
}
|
||||
@ -79,7 +76,7 @@ func NewMempool(logger log.Logger, mutex bool, lanes ...Lane) *BBMempool {
|
||||
|
||||
// CountTx returns the total number of transactions in the mempool. This will
|
||||
// be the sum of the number of transactions in each lane.
|
||||
func (m *BBMempool) CountTx() int {
|
||||
func (m *LanedMempool) CountTx() int {
|
||||
var total int
|
||||
for _, lane := range m.registry {
|
||||
total += lane.CountTx()
|
||||
@ -89,7 +86,7 @@ func (m *BBMempool) CountTx() int {
|
||||
}
|
||||
|
||||
// GetTxDistribution returns the number of transactions in each lane.
|
||||
func (m *BBMempool) GetTxDistribution() map[string]int {
|
||||
func (m *LanedMempool) GetTxDistribution() map[string]int {
|
||||
counts := make(map[string]int, len(m.registry))
|
||||
|
||||
for _, lane := range m.registry {
|
||||
@ -101,7 +98,7 @@ func (m *BBMempool) GetTxDistribution() map[string]int {
|
||||
|
||||
// Insert will insert a transaction into the mempool. It inserts the transaction
|
||||
// into the first lane that it matches.
|
||||
func (m *BBMempool) Insert(ctx context.Context, tx sdk.Tx) (err error) {
|
||||
func (m *LanedMempool) Insert(ctx context.Context, tx sdk.Tx) (err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
m.logger.Error("panic in Insert", "err", r)
|
||||
@ -136,12 +133,12 @@ func (m *BBMempool) Insert(ctx context.Context, tx sdk.Tx) (err error) {
|
||||
// - Determine if it even makes sense to return an iterator. What does that even
|
||||
// mean in the context where you have multiple lanes?
|
||||
// - Perhaps consider implementing and returning a no-op iterator?
|
||||
func (m *BBMempool) Select(_ context.Context, _ [][]byte) sdkmempool.Iterator {
|
||||
func (m *LanedMempool) Select(_ context.Context, _ [][]byte) sdkmempool.Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Remove removes a transaction from all of the lanes it is currently in.
|
||||
func (m *BBMempool) Remove(tx sdk.Tx) (err error) {
|
||||
func (m *LanedMempool) Remove(tx sdk.Tx) (err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
m.logger.Error("panic in Remove", "err", r)
|
||||
@ -179,7 +176,7 @@ func (m *BBMempool) Remove(tx sdk.Tx) (err error) {
|
||||
}
|
||||
|
||||
// Contains returns true if the transaction is contained in any of the lanes.
|
||||
func (m *BBMempool) Contains(tx sdk.Tx) (contains bool) {
|
||||
func (m *LanedMempool) Contains(tx sdk.Tx) (contains bool) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
m.logger.Error("panic in Contains", "err", r)
|
||||
@ -197,7 +194,7 @@ func (m *BBMempool) Contains(tx sdk.Tx) (contains bool) {
|
||||
}
|
||||
|
||||
// Registry returns the mempool's lane registry.
|
||||
func (m *BBMempool) Registry() []Lane {
|
||||
func (m *LanedMempool) Registry() []Lane {
|
||||
return m.registry
|
||||
}
|
||||
|
||||
@ -205,7 +202,7 @@ func (m *BBMempool) Registry() []Lane {
|
||||
// the following:
|
||||
// - The sum of the lane max block space percentages is less than or equal to 1.
|
||||
// - There is no unused block space.
|
||||
func (m *BBMempool) ValidateBasic() error {
|
||||
func (m *LanedMempool) ValidateBasic() error {
|
||||
sum := math.LegacyZeroDec()
|
||||
seenZeroMaxBlockSpace := false
|
||||
|
||||
@ -230,14 +227,3 @@ func (m *BBMempool) ValidateBasic() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetLane returns the lane with the given name.
|
||||
func (m *BBMempool) GetLane(name string) (Lane, error) {
|
||||
for _, lane := range m.registry {
|
||||
if lane.Name() == name {
|
||||
return lane, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("lane %s not found", name)
|
||||
}
|
||||
|
||||
@ -11,9 +11,10 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/base"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/free"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/mev"
|
||||
"github.com/skip-mev/pob/blockbuster/constructor"
|
||||
"github.com/skip-mev/pob/lanes/base"
|
||||
"github.com/skip-mev/pob/lanes/free"
|
||||
"github.com/skip-mev/pob/lanes/mev"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
buildertypes "github.com/skip-mev/pob/x/builder/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
@ -79,7 +80,7 @@ func (suite *BlockBusterTestSuite) SetupTest() {
|
||||
}
|
||||
suite.freeLane = free.NewFreeLane(
|
||||
freeConfig,
|
||||
blockbuster.DefaultTxPriority(),
|
||||
constructor.DefaultTxPriority(),
|
||||
free.DefaultMatchHandler(),
|
||||
)
|
||||
|
||||
@ -97,7 +98,7 @@ func (suite *BlockBusterTestSuite) SetupTest() {
|
||||
|
||||
// Mempool set up
|
||||
suite.lanes = []blockbuster.Lane{suite.mevLane, suite.freeLane, suite.baseLane}
|
||||
suite.mempool = blockbuster.NewMempool(log.NewTestLogger(suite.T()), true, suite.lanes...)
|
||||
suite.mempool = blockbuster.NewLanedMempool(log.NewTestLogger(suite.T()), true, suite.lanes...)
|
||||
|
||||
// Accounts set up
|
||||
suite.accounts = testutils.RandomAccounts(suite.random, 10)
|
||||
|
||||
@ -9,8 +9,8 @@ import (
|
||||
"cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/base"
|
||||
"github.com/skip-mev/pob/blockbuster/utils/mocks"
|
||||
"github.com/skip-mev/pob/lanes/base"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
)
|
||||
|
||||
@ -2,6 +2,7 @@ package base
|
||||
|
||||
import (
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
"github.com/skip-mev/pob/blockbuster/constructor"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -18,20 +19,20 @@ var _ blockbuster.Lane = (*DefaultLane)(nil)
|
||||
// CometBFT/Tendermint consensus engine builds and verifies blocks pre SDK version
|
||||
// 0.47.0.
|
||||
type DefaultLane struct {
|
||||
*blockbuster.LaneConstructor[string]
|
||||
*constructor.LaneConstructor[string]
|
||||
}
|
||||
|
||||
// NewDefaultLane returns a new default lane.
|
||||
func NewDefaultLane(cfg blockbuster.LaneConfig) *DefaultLane {
|
||||
lane := blockbuster.NewLaneConstructor[string](
|
||||
lane := constructor.NewLaneConstructor[string](
|
||||
cfg,
|
||||
LaneName,
|
||||
blockbuster.NewConstructorMempool[string](
|
||||
blockbuster.DefaultTxPriority(),
|
||||
constructor.NewConstructorMempool[string](
|
||||
constructor.DefaultTxPriority(),
|
||||
cfg.TxEncoder,
|
||||
cfg.MaxTxs,
|
||||
),
|
||||
blockbuster.DefaultMatchHandler(),
|
||||
constructor.DefaultMatchHandler(),
|
||||
)
|
||||
|
||||
return &DefaultLane{
|
||||
@ -3,12 +3,12 @@ package base_test
|
||||
import (
|
||||
"cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
"github.com/skip-mev/pob/blockbuster/constructor"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
)
|
||||
|
||||
func (s *BaseTestSuite) TestGetTxPriority() {
|
||||
txPriority := blockbuster.DefaultTxPriority()
|
||||
txPriority := constructor.DefaultTxPriority()
|
||||
|
||||
s.Run("should be able to get the priority off a normal transaction with fees", func() {
|
||||
tx, err := testutils.CreateRandomTx(
|
||||
@ -56,7 +56,7 @@ func (s *BaseTestSuite) TestGetTxPriority() {
|
||||
}
|
||||
|
||||
func (s *BaseTestSuite) TestCompareTxPriority() {
|
||||
txPriority := blockbuster.DefaultTxPriority()
|
||||
txPriority := constructor.DefaultTxPriority()
|
||||
|
||||
s.Run("should return 0 when both priorities are nil", func() {
|
||||
a := sdk.NewCoin(s.gasTokenDenom, math.NewInt(0)).String()
|
||||
@ -84,7 +84,7 @@ func (s *BaseTestSuite) TestCompareTxPriority() {
|
||||
}
|
||||
|
||||
func (s *BaseTestSuite) TestInsert() {
|
||||
mempool := blockbuster.NewConstructorMempool[string](blockbuster.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
|
||||
mempool := constructor.NewConstructorMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
|
||||
|
||||
s.Run("should be able to insert a transaction", func() {
|
||||
tx, err := testutils.CreateRandomTx(
|
||||
@ -136,7 +136,7 @@ func (s *BaseTestSuite) TestInsert() {
|
||||
}
|
||||
|
||||
func (s *BaseTestSuite) TestRemove() {
|
||||
mempool := blockbuster.NewConstructorMempool[string](blockbuster.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
|
||||
mempool := constructor.NewConstructorMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
|
||||
|
||||
s.Run("should be able to remove a transaction", func() {
|
||||
tx, err := testutils.CreateRandomTx(
|
||||
@ -174,7 +174,7 @@ func (s *BaseTestSuite) TestRemove() {
|
||||
|
||||
func (s *BaseTestSuite) TestSelect() {
|
||||
s.Run("should be able to select transactions in the correct order", func() {
|
||||
mempool := blockbuster.NewConstructorMempool[string](blockbuster.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
|
||||
mempool := constructor.NewConstructorMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
|
||||
|
||||
tx1, err := testutils.CreateRandomTx(
|
||||
s.encodingConfig.TxConfig,
|
||||
@ -213,7 +213,7 @@ func (s *BaseTestSuite) TestSelect() {
|
||||
})
|
||||
|
||||
s.Run("should be able to select a single transaction", func() {
|
||||
mempool := blockbuster.NewConstructorMempool[string](blockbuster.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
|
||||
mempool := constructor.NewConstructorMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
|
||||
|
||||
tx1, err := testutils.CreateRandomTx(
|
||||
s.encodingConfig.TxConfig,
|
||||
@ -4,6 +4,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
"github.com/skip-mev/pob/blockbuster/constructor"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -16,7 +17,7 @@ var _ blockbuster.Lane = (*FreeLane)(nil)
|
||||
// FreeLane defines the lane that is responsible for processing free transactions.
|
||||
// By default, transactions that are staking related are considered free.
|
||||
type FreeLane struct {
|
||||
*blockbuster.LaneConstructor[string]
|
||||
*constructor.LaneConstructor[string]
|
||||
}
|
||||
|
||||
// NewFreeLane returns a new free lane.
|
||||
@ -25,10 +26,10 @@ func NewFreeLane(
|
||||
txPriority blockbuster.TxPriority[string],
|
||||
matchFn blockbuster.MatchHandler,
|
||||
) *FreeLane {
|
||||
lane := blockbuster.NewLaneConstructor[string](
|
||||
lane := constructor.NewLaneConstructor[string](
|
||||
cfg,
|
||||
LaneName,
|
||||
blockbuster.NewConstructorMempool[string](
|
||||
constructor.NewConstructorMempool[string](
|
||||
txPriority,
|
||||
cfg.TxEncoder,
|
||||
cfg.MaxTxs,
|
||||
@ -5,6 +5,7 @@ import (
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
"github.com/skip-mev/pob/blockbuster/constructor"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -33,7 +34,7 @@ type (
|
||||
|
||||
MEVLane struct {
|
||||
// LaneConfig defines the base lane configuration.
|
||||
*blockbuster.LaneConstructor[string]
|
||||
*constructor.LaneConstructor[string]
|
||||
|
||||
// Factory defines the API/functionality which is responsible for determining
|
||||
// if a transaction is a bid transaction and how to extract relevant
|
||||
@ -48,10 +49,10 @@ func NewMEVLane(
|
||||
factory Factory,
|
||||
) *MEVLane {
|
||||
lane := &MEVLane{
|
||||
LaneConstructor: blockbuster.NewLaneConstructor[string](
|
||||
LaneConstructor: constructor.NewLaneConstructor[string](
|
||||
cfg,
|
||||
LaneName,
|
||||
blockbuster.NewConstructorMempool[string](
|
||||
constructor.NewConstructorMempool[string](
|
||||
TxPriority(factory),
|
||||
cfg.TxEncoder,
|
||||
cfg.MaxTxs,
|
||||
@ -8,7 +8,7 @@ import (
|
||||
"cosmossdk.io/log"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/mev"
|
||||
"github.com/skip-mev/pob/lanes/mev"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/mev"
|
||||
"github.com/skip-mev/pob/lanes/mev"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
buildertypes "github.com/skip-mev/pob/x/builder/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -61,11 +61,12 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
|
||||
"github.com/skip-mev/pob/abci"
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
"github.com/skip-mev/pob/blockbuster/abci"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/base"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/free"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/mev"
|
||||
"github.com/skip-mev/pob/blockbuster/constructor"
|
||||
"github.com/skip-mev/pob/lanes/base"
|
||||
"github.com/skip-mev/pob/lanes/free"
|
||||
"github.com/skip-mev/pob/lanes/mev"
|
||||
buildermodule "github.com/skip-mev/pob/x/builder"
|
||||
builderkeeper "github.com/skip-mev/pob/x/builder/keeper"
|
||||
)
|
||||
@ -284,7 +285,7 @@ func New(
|
||||
}
|
||||
freeLane := free.NewFreeLane(
|
||||
freeConfig,
|
||||
blockbuster.DefaultTxPriority(),
|
||||
constructor.DefaultTxPriority(),
|
||||
free.DefaultMatchHandler(),
|
||||
)
|
||||
|
||||
@ -304,7 +305,7 @@ func New(
|
||||
freeLane,
|
||||
defaultLane,
|
||||
}
|
||||
mempool := blockbuster.NewMempool(app.Logger(), true, lanes...)
|
||||
mempool := blockbuster.NewLanedMempool(app.Logger(), true, lanes...)
|
||||
app.App.SetMempool(mempool)
|
||||
|
||||
// Create a global ante handler that will be called on each transaction when
|
||||
|
||||
@ -12,8 +12,8 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/skip-mev/pob/blockbuster"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/base"
|
||||
"github.com/skip-mev/pob/blockbuster/lanes/mev"
|
||||
"github.com/skip-mev/pob/lanes/base"
|
||||
"github.com/skip-mev/pob/lanes/mev"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
"github.com/skip-mev/pob/x/builder/ante"
|
||||
"github.com/skip-mev/pob/x/builder/keeper"
|
||||
@ -108,7 +108,7 @@ func (suite *AnteTestSuite) SetupTest() {
|
||||
|
||||
// Mempool set up
|
||||
suite.lanes = []blockbuster.Lane{suite.mevLane, suite.baseLane}
|
||||
suite.mempool = blockbuster.NewMempool(log.NewTestLogger(suite.T()), true, suite.lanes...)
|
||||
suite.mempool = blockbuster.NewLanedMempool(log.NewTestLogger(suite.T()), true, suite.lanes...)
|
||||
}
|
||||
|
||||
func (suite *AnteTestSuite) anteHandler(ctx sdk.Context, tx sdk.Tx, _ bool) (sdk.Context, error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user