rename of constructor to base
This commit is contained in:
parent
bf4e3b8af2
commit
af2b5226f3
@ -188,7 +188,7 @@ $ go install github.com/skip-mev/pob
|
||||
freeLane,
|
||||
},
|
||||
}
|
||||
defaultLane := base.NewDefaultLane(defaultConfig)
|
||||
defaultLane := base.NewStandardLane(defaultConfig)
|
||||
|
||||
// Set the lanes into the mempool.
|
||||
lanes := []block.Lane{
|
||||
|
||||
@ -133,7 +133,7 @@ proposals respectively.
|
||||
// transactions to bid for inclusion at the top of the next block.
|
||||
//
|
||||
// For more information on how to utilize the LaneConfig please
|
||||
// visit the README in block-sdk/block/constructor.
|
||||
// visit the README in block-sdk/block/base.
|
||||
//
|
||||
// MEV lane hosts an action at the top of the block.
|
||||
mevConfig := constructor.LaneConfig{
|
||||
@ -170,7 +170,7 @@ defaultConfig := constructor.LaneConfig{
|
||||
MaxBlockSpace: math.LegacyZeroDec(),
|
||||
MaxTxs: 0,
|
||||
}
|
||||
defaultLane := base.NewDefaultLane(defaultConfig)
|
||||
defaultLane := base.NewStandardLane(defaultConfig)
|
||||
|
||||
// Set the lanes into the mempool.
|
||||
lanes := []block.Lane{
|
||||
|
||||
@ -15,10 +15,10 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/abci"
|
||||
"github.com/skip-mev/pob/block"
|
||||
"github.com/skip-mev/pob/block/constructor"
|
||||
"github.com/skip-mev/pob/lanes/base"
|
||||
"github.com/skip-mev/pob/block/base"
|
||||
"github.com/skip-mev/pob/lanes/free"
|
||||
"github.com/skip-mev/pob/lanes/mev"
|
||||
"github.com/skip-mev/pob/lanes/standard"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
@ -55,7 +55,7 @@ func (s *ProposalsTestSuite) SetupTest() {
|
||||
func (s *ProposalsTestSuite) TestPrepareProposal() {
|
||||
s.Run("can prepare a proposal with no transactions", func() {
|
||||
// Set up the default lane with no transactions
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("1"), nil)
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("1"), nil)
|
||||
|
||||
proposalHandler := s.setUpProposalHandlers([]block.Lane{defaultLane}).PrepareProposalHandler()
|
||||
|
||||
@ -78,7 +78,7 @@ func (s *ProposalsTestSuite) TestPrepareProposal() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Set up the default lane
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("1"), map[sdk.Tx]bool{tx: true})
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("1"), map[sdk.Tx]bool{tx: true})
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx))
|
||||
|
||||
proposalHandler := s.setUpProposalHandlers([]block.Lane{defaultLane}).PrepareProposalHandler()
|
||||
@ -115,7 +115,7 @@ func (s *ProposalsTestSuite) TestPrepareProposal() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Set up the default lane with both transactions passing
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("1"), map[sdk.Tx]bool{tx1: true, tx2: true})
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("1"), map[sdk.Tx]bool{tx1: true, tx2: true})
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx1))
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx2))
|
||||
|
||||
@ -153,7 +153,7 @@ func (s *ProposalsTestSuite) TestPrepareProposal() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Set up the default lane with both transactions passing
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("1"), map[sdk.Tx]bool{tx1: true, tx2: false})
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("1"), map[sdk.Tx]bool{tx1: true, tx2: false})
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx1))
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx2))
|
||||
|
||||
@ -169,7 +169,7 @@ func (s *ProposalsTestSuite) TestPrepareProposal() {
|
||||
|
||||
s.Run("can build a proposal an empty proposal with multiple lanes", func() {
|
||||
mevLane := s.setUpTOBLane(math.LegacyMustNewDecFromStr("0.5"), nil)
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.5"), nil)
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.5"), nil)
|
||||
|
||||
proposalHandler := s.setUpProposalHandlers([]block.Lane{mevLane, defaultLane}).PrepareProposalHandler()
|
||||
|
||||
@ -199,7 +199,7 @@ func (s *ProposalsTestSuite) TestPrepareProposal() {
|
||||
})
|
||||
s.Require().NoError(mevLane.Insert(sdk.Context{}, tx))
|
||||
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.5"), nil)
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.5"), nil)
|
||||
|
||||
proposalHandler := s.setUpProposalHandlers([]block.Lane{mevLane, defaultLane}).PrepareProposalHandler()
|
||||
|
||||
@ -232,7 +232,7 @@ func (s *ProposalsTestSuite) TestPrepareProposal() {
|
||||
s.Require().NoError(mevLane.Insert(sdk.Context{}, tx))
|
||||
|
||||
// Set up the default lane with the bid tx and the bundled tx
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.5"), map[sdk.Tx]bool{
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.5"), map[sdk.Tx]bool{
|
||||
tx: true,
|
||||
bundleTxs[0]: true,
|
||||
})
|
||||
@ -270,7 +270,7 @@ func (s *ProposalsTestSuite) TestPrepareProposal() {
|
||||
s.Require().NoError(mevLane.Insert(sdk.Context{}, tx))
|
||||
|
||||
// Set up the default lane with the bid tx and the bundled tx
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.5"), map[sdk.Tx]bool{
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.5"), map[sdk.Tx]bool{
|
||||
// Even though this passes it should not include it in the proposal because it is in the ignore list
|
||||
tx: true,
|
||||
bundleTxs[0]: true,
|
||||
@ -309,7 +309,7 @@ func (s *ProposalsTestSuite) TestPrepareProposal() {
|
||||
s.Require().NoError(mevLane.Insert(sdk.Context{}, tx))
|
||||
|
||||
// Set up the default lane with the bid tx and the bundled tx
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
// Even though this passes it should not include it in the proposal because it is in the ignore list
|
||||
tx: true,
|
||||
bundleTxs[0]: true,
|
||||
@ -343,7 +343,7 @@ func (s *ProposalsTestSuite) TestPrepareProposal() {
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
freeTx: true,
|
||||
})
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, freeTx))
|
||||
@ -409,7 +409,7 @@ func (s *ProposalsTestSuite) TestPrepareProposal() {
|
||||
})
|
||||
mevLane.Insert(sdk.Context{}, tx)
|
||||
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
normalTx: true,
|
||||
})
|
||||
defaultLane.Insert(sdk.Context{}, normalTx)
|
||||
@ -445,7 +445,7 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() {
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
tx: true,
|
||||
})
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx))
|
||||
@ -478,7 +478,7 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() {
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
tx: true,
|
||||
})
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx))
|
||||
@ -512,7 +512,7 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() {
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
tx: true,
|
||||
})
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx))
|
||||
@ -546,7 +546,7 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() {
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{
|
||||
tx: true,
|
||||
})
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx))
|
||||
@ -571,7 +571,7 @@ func (s *ProposalsTestSuite) TestProcessProposal() {
|
||||
s.Run("can process a valid empty proposal", func() {
|
||||
mevLane := s.setUpTOBLane(math.LegacyMustNewDecFromStr("0.25"), map[sdk.Tx]bool{})
|
||||
freeLane := s.setUpFreeLane(math.LegacyMustNewDecFromStr("0.25"), map[sdk.Tx]bool{})
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{})
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{})
|
||||
|
||||
proposalHandler := s.setUpProposalHandlers([]block.Lane{mevLane, freeLane, defaultLane}).ProcessProposalHandler()
|
||||
|
||||
@ -584,7 +584,7 @@ func (s *ProposalsTestSuite) TestProcessProposal() {
|
||||
s.Run("rejects a proposal with bad txs", func() {
|
||||
mevLane := s.setUpTOBLane(math.LegacyMustNewDecFromStr("0.25"), map[sdk.Tx]bool{})
|
||||
freeLane := s.setUpFreeLane(math.LegacyMustNewDecFromStr("0.25"), map[sdk.Tx]bool{})
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{})
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.0"), map[sdk.Tx]bool{})
|
||||
|
||||
proposalHandler := s.setUpProposalHandlers([]block.Lane{mevLane, freeLane, defaultLane}).ProcessProposalHandler()
|
||||
|
||||
@ -636,7 +636,7 @@ func (s *ProposalsTestSuite) TestProcessProposal() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Set up the default lane
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("1"), map[sdk.Tx]bool{tx: true})
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("1"), map[sdk.Tx]bool{tx: true})
|
||||
s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx))
|
||||
|
||||
proposalHandler := s.setUpProposalHandlers([]block.Lane{defaultLane}).ProcessProposalHandler()
|
||||
@ -677,7 +677,7 @@ func (s *ProposalsTestSuite) TestProcessProposal() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Set up the default lane
|
||||
defaultLane := s.setUpDefaultLane(math.LegacyMustNewDecFromStr("0.5"), nil)
|
||||
defaultLane := s.setUpStandardLane(math.LegacyMustNewDecFromStr("0.5"), nil)
|
||||
defaultLane.SetProcessLaneHandler(block.NoOpProcessLaneHandler())
|
||||
|
||||
// Set up the TOB lane
|
||||
@ -724,8 +724,8 @@ func (s *ProposalsTestSuite) setUpAnteHandler(expectedExecution map[sdk.Tx]bool)
|
||||
return anteHandler
|
||||
}
|
||||
|
||||
func (s *ProposalsTestSuite) setUpDefaultLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *base.DefaultLane {
|
||||
cfg := constructor.LaneConfig{
|
||||
func (s *ProposalsTestSuite) setUpStandardLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *standard.StandardLane {
|
||||
cfg := base.LaneConfig{
|
||||
Logger: log.NewTestLogger(s.T()),
|
||||
TxEncoder: s.encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: s.encodingConfig.TxConfig.TxDecoder(),
|
||||
@ -733,11 +733,11 @@ func (s *ProposalsTestSuite) setUpDefaultLane(maxBlockSpace math.LegacyDec, expe
|
||||
MaxBlockSpace: maxBlockSpace,
|
||||
}
|
||||
|
||||
return base.NewDefaultLane(cfg)
|
||||
return standard.NewStandardLane(cfg)
|
||||
}
|
||||
|
||||
func (s *ProposalsTestSuite) setUpTOBLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *mev.MEVLane {
|
||||
cfg := constructor.LaneConfig{
|
||||
cfg := base.LaneConfig{
|
||||
Logger: log.NewTestLogger(s.T()),
|
||||
TxEncoder: s.encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: s.encodingConfig.TxConfig.TxDecoder(),
|
||||
@ -749,7 +749,7 @@ func (s *ProposalsTestSuite) setUpTOBLane(maxBlockSpace math.LegacyDec, expected
|
||||
}
|
||||
|
||||
func (s *ProposalsTestSuite) setUpFreeLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *free.FreeLane {
|
||||
cfg := constructor.LaneConfig{
|
||||
cfg := base.LaneConfig{
|
||||
Logger: log.NewTestLogger(s.T()),
|
||||
TxEncoder: s.encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: s.encodingConfig.TxConfig.TxDecoder(),
|
||||
@ -757,22 +757,22 @@ func (s *ProposalsTestSuite) setUpFreeLane(maxBlockSpace math.LegacyDec, expecte
|
||||
MaxBlockSpace: maxBlockSpace,
|
||||
}
|
||||
|
||||
return free.NewFreeLane(cfg, constructor.DefaultTxPriority(), free.DefaultMatchHandler())
|
||||
return free.NewFreeLane(cfg, base.DefaultTxPriority(), free.DefaultMatchHandler())
|
||||
}
|
||||
|
||||
func (s *ProposalsTestSuite) setUpPanicLane(maxBlockSpace math.LegacyDec) *constructor.LaneConstructor {
|
||||
cfg := constructor.LaneConfig{
|
||||
func (s *ProposalsTestSuite) setUpPanicLane(maxBlockSpace math.LegacyDec) *base.BaseLane {
|
||||
cfg := base.LaneConfig{
|
||||
Logger: log.NewTestLogger(s.T()),
|
||||
TxEncoder: s.encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: s.encodingConfig.TxConfig.TxDecoder(),
|
||||
MaxBlockSpace: maxBlockSpace,
|
||||
}
|
||||
|
||||
lane := constructor.NewLaneConstructor(
|
||||
lane := base.NewBaseLane(
|
||||
cfg,
|
||||
"panic",
|
||||
constructor.NewMempool[string](constructor.DefaultTxPriority(), cfg.TxEncoder, 0),
|
||||
constructor.DefaultMatchHandler(),
|
||||
base.NewMempool[string](base.DefaultTxPriority(), cfg.TxEncoder, 0),
|
||||
base.DefaultMatchHandler(),
|
||||
)
|
||||
|
||||
lane.SetPrepareLaneHandler(block.PanicPrepareLaneHandler())
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
# 🎨 Lane Constructor
|
||||
# 🎨 Base Lane
|
||||
|
||||
> 🏗️ Build your own lane in less than 10 minutes using the Lane Constructor
|
||||
> 🏗️ Build your own lane in less than 10 minutes using the Base Lane
|
||||
|
||||
## 💡 Overview
|
||||
|
||||
The Lane Constructor is a generic implementation of a lane. It comes out of the
|
||||
The Base Lane is a generic implementation of a lane. It comes out of the
|
||||
box with default implementations for all the required interfaces. It is meant to
|
||||
be used as a starting point for building your own lane.
|
||||
|
||||
@ -13,7 +13,7 @@ be used as a starting point for building your own lane.
|
||||
> **Default Implementations**
|
||||
>
|
||||
> There are default implementations for all of the below which can be found in
|
||||
> the `block/constructor` package. It is highly recommended that developers overview
|
||||
> the `block/base` package. It is highly recommended that developers overview
|
||||
> the default implementations before building their own lane.
|
||||
|
||||
There are **three** critical components to building a custom lane using the lane
|
||||
@ -128,7 +128,7 @@ transactions by default).
|
||||
### 2. 🗄️ LaneMempool
|
||||
|
||||
This is the data structure that is responsible for storing transactions
|
||||
as they are being verified and are waiting to be included in proposals. `block/constructor/mempool.go`
|
||||
as they are being verified and are waiting to be included in proposals. `block/base/mempool.go`
|
||||
provides an out-of-the-box implementation that should be used as a starting
|
||||
point for building out the mempool and should cover most use cases. To
|
||||
utilize the mempool, you must implement a `TxPriority[C]` struct that does the
|
||||
@ -143,7 +143,7 @@ should return 1, otherwise the method should return 0.
|
||||
* Implements a `MinValue` method that returns the minimum priority value
|
||||
that a transaction can have.
|
||||
|
||||
The default implementation can be found in `block/constructor/mempool.go`. What
|
||||
The default implementation can be found in `block/base/mempool.go`. What
|
||||
if we wanted to prioritize transactions by the amount they have staked on a chain?
|
||||
Well we could do something like the following:
|
||||
|
||||
@ -228,7 +228,7 @@ mempool := constructor.NewMempool[string](
|
||||
)
|
||||
|
||||
// Initialize your lane with the mempool
|
||||
lane := constructor.NewLaneConstructor(
|
||||
lane := constructor.NewBaseLane(
|
||||
laneCfg,
|
||||
LaneName,
|
||||
mempool,
|
||||
@ -240,7 +240,7 @@ lane := constructor.NewLaneConstructor(
|
||||
|
||||
`MatchHandler` is utilized to determine if a transaction should be included in
|
||||
the lane. This function can be a stateless or stateful check on the transaction.
|
||||
The default implementation can be found in `block/constructor/handlers.go`.
|
||||
The default implementation can be found in `block/base/handlers.go`.
|
||||
|
||||
The match handler can be as custom as desired. Following the example above, if
|
||||
we wanted to make a lane that only accepts transactions if they have a large
|
||||
@ -298,7 +298,7 @@ mempool := constructor.NewMempool[string](
|
||||
)
|
||||
|
||||
// Initialize your lane with the mempool
|
||||
lane := constructor.NewLaneConstructor(
|
||||
lane := constructor.NewBaseLane(
|
||||
cfg,
|
||||
LaneName,
|
||||
mempool,
|
||||
@ -319,7 +319,7 @@ have a custom lane that only accepts transactions that match a custom criteria.
|
||||
### [OPTIONAL] Steps 4-6
|
||||
|
||||
The remaining steps walk through the process of creating custom block
|
||||
building/verification logic. The default implementation found in `block/constructor/handlers.go`
|
||||
building/verification logic. The default implementation found in `block/base/handlers.go`
|
||||
should fit most use cases. Please reference that file for more details on
|
||||
the default implementation and whether it fits your use case.
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package constructor
|
||||
package base
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -10,7 +10,7 @@ import (
|
||||
// lane respecting the selection logic of the prepareLaneHandler. It will then update the partial
|
||||
// proposal with the selected transactions. If the proposal is unable to be updated, we return an
|
||||
// error. The proposal will only be modified if it passes all of the invarient checks.
|
||||
func (l *LaneConstructor) PrepareLane(
|
||||
func (l *BaseLane) PrepareLane(
|
||||
ctx sdk.Context,
|
||||
proposal block.BlockProposal,
|
||||
maxTxBytes int64,
|
||||
@ -40,7 +40,7 @@ func (l *LaneConstructor) PrepareLane(
|
||||
|
||||
// CheckOrder checks that the ordering logic of the lane is respected given the set of transactions
|
||||
// in the block proposal. If the ordering logic is not respected, we return an error.
|
||||
func (l *LaneConstructor) CheckOrder(ctx sdk.Context, txs []sdk.Tx) error {
|
||||
func (l *BaseLane) CheckOrder(ctx sdk.Context, txs []sdk.Tx) error {
|
||||
return l.checkOrderHandler(ctx, txs)
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ func (l *LaneConstructor) 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) ProcessLane(ctx sdk.Context, txs []sdk.Tx, next block.ProcessLanesHandler) (sdk.Context, error) {
|
||||
func (l *BaseLane) ProcessLane(ctx sdk.Context, txs []sdk.Tx, next block.ProcessLanesHandler) (sdk.Context, error) {
|
||||
remainingTxs, err := l.processLaneHandler(ctx, txs)
|
||||
if err != nil {
|
||||
return ctx, err
|
||||
@ -59,7 +59,7 @@ func (l *LaneConstructor) ProcessLane(ctx sdk.Context, txs []sdk.Tx, next block.
|
||||
|
||||
// AnteVerifyTx verifies that the transaction is valid respecting the ante verification logic of
|
||||
// of the antehandler chain.
|
||||
func (l *LaneConstructor) AnteVerifyTx(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) {
|
||||
func (l *BaseLane) AnteVerifyTx(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) {
|
||||
if l.cfg.AnteHandler != nil {
|
||||
return l.cfg.AnteHandler(ctx, tx, simulate)
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package constructor
|
||||
package base
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -1,4 +1,4 @@
|
||||
package constructor
|
||||
package base
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -12,7 +12,7 @@ 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) DefaultPrepareLaneHandler() block.PrepareLaneHandler {
|
||||
func (l *BaseLane) DefaultPrepareLaneHandler() block.PrepareLaneHandler {
|
||||
return func(ctx sdk.Context, proposal block.BlockProposal, maxTxBytes int64) ([][]byte, []sdk.Tx, error) {
|
||||
var (
|
||||
totalSize int64
|
||||
@ -96,7 +96,7 @@ func (l *LaneConstructor) DefaultPrepareLaneHandler() block.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) DefaultProcessLaneHandler() block.ProcessLaneHandler {
|
||||
func (l *BaseLane) DefaultProcessLaneHandler() block.ProcessLaneHandler {
|
||||
return func(ctx sdk.Context, txs []sdk.Tx) ([]sdk.Tx, error) {
|
||||
var err error
|
||||
|
||||
@ -123,7 +123,7 @@ func (l *LaneConstructor) DefaultProcessLaneHandler() block.ProcessLaneHandler {
|
||||
// lane.
|
||||
// 2. Transactions that belong to other lanes cannot be interleaved with transactions that
|
||||
// belong to this lane.
|
||||
func (l *LaneConstructor) DefaultCheckOrderHandler() block.CheckOrderHandler {
|
||||
func (l *BaseLane) DefaultCheckOrderHandler() block.CheckOrderHandler {
|
||||
return func(ctx sdk.Context, txs []sdk.Tx) error {
|
||||
seenOtherLaneTx := false
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package constructor
|
||||
package base
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -9,14 +9,14 @@ import (
|
||||
"github.com/skip-mev/pob/block"
|
||||
)
|
||||
|
||||
var _ block.Lane = (*LaneConstructor)(nil)
|
||||
var _ block.Lane = (*BaseLane)(nil)
|
||||
|
||||
// LaneConstructor is a generic implementation of a lane. It is meant to be used
|
||||
// BaseLane is a generic implementation of a lane. It is meant to be used
|
||||
// as a base for other lanes to be built on top of. It provides a default
|
||||
// implementation of the MatchHandler, PrepareLaneHandler, ProcessLaneHandler,
|
||||
// and CheckOrderHandler. To extend this lane, you must either utilize the default
|
||||
// handlers or construct your own that you pass into the constructor/setters.
|
||||
type LaneConstructor struct {
|
||||
// handlers or construct your own that you pass into the base/setters.
|
||||
type BaseLane 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.
|
||||
@ -48,16 +48,16 @@ type LaneConstructor struct {
|
||||
processLaneHandler block.ProcessLaneHandler
|
||||
}
|
||||
|
||||
// NewLaneConstructor returns a new lane constructor. When creating this lane, the type
|
||||
// NewBaseLane returns a new lane base. 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(
|
||||
func NewBaseLane(
|
||||
cfg LaneConfig,
|
||||
laneName string,
|
||||
laneMempool block.LaneMempool,
|
||||
matchHandlerFn block.MatchHandler,
|
||||
) *LaneConstructor {
|
||||
lane := &LaneConstructor{
|
||||
) *BaseLane {
|
||||
lane := &BaseLane{
|
||||
cfg: cfg,
|
||||
laneName: laneName,
|
||||
LaneMempool: laneMempool,
|
||||
@ -73,7 +73,7 @@ func NewLaneConstructor(
|
||||
|
||||
// ValidateBasic ensures that the lane was constructed properly. In the case that
|
||||
// the lane was not constructed with proper handlers, default handlers are set.
|
||||
func (l *LaneConstructor) ValidateBasic() error {
|
||||
func (l *BaseLane) ValidateBasic() error {
|
||||
if err := l.cfg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -108,7 +108,7 @@ func (l *LaneConstructor) 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) SetPrepareLaneHandler(prepareLaneHandler block.PrepareLaneHandler) {
|
||||
func (l *BaseLane) SetPrepareLaneHandler(prepareLaneHandler block.PrepareLaneHandler) {
|
||||
if prepareLaneHandler == nil {
|
||||
panic("prepare lane handler cannot be nil")
|
||||
}
|
||||
@ -120,7 +120,7 @@ func (l *LaneConstructor) SetPrepareLaneHandler(prepareLaneHandler block.Prepare
|
||||
// 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) SetProcessLaneHandler(processLaneHandler block.ProcessLaneHandler) {
|
||||
func (l *BaseLane) SetProcessLaneHandler(processLaneHandler block.ProcessLaneHandler) {
|
||||
if processLaneHandler == nil {
|
||||
panic("process lane handler cannot be nil")
|
||||
}
|
||||
@ -132,7 +132,7 @@ func (l *LaneConstructor) SetProcessLaneHandler(processLaneHandler block.Process
|
||||
// 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) SetCheckOrderHandler(checkOrderHandler block.CheckOrderHandler) {
|
||||
func (l *BaseLane) SetCheckOrderHandler(checkOrderHandler block.CheckOrderHandler) {
|
||||
if checkOrderHandler == nil {
|
||||
panic("check order handler cannot be nil")
|
||||
}
|
||||
@ -144,14 +144,14 @@ func (l *LaneConstructor) SetCheckOrderHandler(checkOrderHandler block.CheckOrde
|
||||
// function first determines if the transaction matches the lane and then checks
|
||||
// if the transaction is on the ignore list. If the transaction is on the ignore
|
||||
// list, it returns false.
|
||||
func (l *LaneConstructor) Match(ctx sdk.Context, tx sdk.Tx) bool {
|
||||
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 *LaneConstructor) CheckIgnoreList(ctx sdk.Context, tx sdk.Tx) bool {
|
||||
func (l *BaseLane) CheckIgnoreList(ctx sdk.Context, tx sdk.Tx) bool {
|
||||
for _, lane := range l.cfg.IgnoreList {
|
||||
if lane.Match(ctx, tx) {
|
||||
return true
|
||||
@ -162,38 +162,38 @@ func (l *LaneConstructor) CheckIgnoreList(ctx sdk.Context, tx sdk.Tx) bool {
|
||||
}
|
||||
|
||||
// Name returns the name of the lane.
|
||||
func (l *LaneConstructor) Name() string {
|
||||
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 *LaneConstructor) SetIgnoreList(lanes []block.Lane) {
|
||||
func (l *BaseLane) SetIgnoreList(lanes []block.Lane) {
|
||||
l.cfg.IgnoreList = lanes
|
||||
}
|
||||
|
||||
// SetAnteHandler sets the ante handler for the lane.
|
||||
func (l *LaneConstructor) SetAnteHandler(anteHandler sdk.AnteHandler) {
|
||||
func (l *BaseLane) SetAnteHandler(anteHandler sdk.AnteHandler) {
|
||||
l.cfg.AnteHandler = anteHandler
|
||||
}
|
||||
|
||||
// Logger returns the logger for the lane.
|
||||
func (l *LaneConstructor) Logger() log.Logger {
|
||||
func (l *BaseLane) Logger() log.Logger {
|
||||
return l.cfg.Logger
|
||||
}
|
||||
|
||||
// TxDecoder returns the tx decoder for the lane.
|
||||
func (l *LaneConstructor) TxDecoder() sdk.TxDecoder {
|
||||
func (l *BaseLane) TxDecoder() sdk.TxDecoder {
|
||||
return l.cfg.TxDecoder
|
||||
}
|
||||
|
||||
// TxEncoder returns the tx encoder for the lane.
|
||||
func (l *LaneConstructor) TxEncoder() sdk.TxEncoder {
|
||||
func (l *BaseLane) TxEncoder() sdk.TxEncoder {
|
||||
return l.cfg.TxEncoder
|
||||
}
|
||||
|
||||
// GetMaxBlockSpace returns the maximum amount of block space that the lane is
|
||||
// allowed to consume as a percentage of the total block space.
|
||||
func (l *LaneConstructor) GetMaxBlockSpace() math.LegacyDec {
|
||||
func (l *BaseLane) GetMaxBlockSpace() math.LegacyDec {
|
||||
return l.cfg.MaxBlockSpace
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package constructor
|
||||
package base
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -1,4 +1,4 @@
|
||||
package constructor
|
||||
package base
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// ------------------------------------------------------------------------------ //
|
||||
@ -11,10 +11,10 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/block"
|
||||
"github.com/skip-mev/pob/block/constructor"
|
||||
"github.com/skip-mev/pob/lanes/base"
|
||||
"github.com/skip-mev/pob/block/base"
|
||||
"github.com/skip-mev/pob/lanes/free"
|
||||
"github.com/skip-mev/pob/lanes/mev"
|
||||
"github.com/skip-mev/pob/lanes/standard"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
buildertypes "github.com/skip-mev/pob/x/builder/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
@ -29,7 +29,7 @@ type BlockBusterTestSuite struct {
|
||||
|
||||
// Define all of the lanes utilized in the test suite
|
||||
mevLane *mev.MEVLane
|
||||
baseLane *base.DefaultLane
|
||||
baseLane *standard.StandardLane
|
||||
freeLane *free.FreeLane
|
||||
gasTokenDenom string
|
||||
|
||||
@ -58,7 +58,7 @@ func (suite *BlockBusterTestSuite) SetupTest() {
|
||||
//
|
||||
// TOB lane set up
|
||||
suite.gasTokenDenom = "stake"
|
||||
mevConfig := constructor.LaneConfig{
|
||||
mevConfig := base.LaneConfig{
|
||||
Logger: log.NewNopLogger(),
|
||||
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
|
||||
@ -71,7 +71,7 @@ func (suite *BlockBusterTestSuite) SetupTest() {
|
||||
)
|
||||
|
||||
// Free lane set up
|
||||
freeConfig := constructor.LaneConfig{
|
||||
freeConfig := base.LaneConfig{
|
||||
Logger: log.NewNopLogger(),
|
||||
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
|
||||
@ -80,19 +80,19 @@ func (suite *BlockBusterTestSuite) SetupTest() {
|
||||
}
|
||||
suite.freeLane = free.NewFreeLane(
|
||||
freeConfig,
|
||||
constructor.DefaultTxPriority(),
|
||||
base.DefaultTxPriority(),
|
||||
free.DefaultMatchHandler(),
|
||||
)
|
||||
|
||||
// Base lane set up
|
||||
baseConfig := constructor.LaneConfig{
|
||||
baseConfig := base.LaneConfig{
|
||||
Logger: log.NewNopLogger(),
|
||||
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
|
||||
AnteHandler: nil,
|
||||
MaxBlockSpace: math.LegacyZeroDec(),
|
||||
}
|
||||
suite.baseLane = base.NewDefaultLane(
|
||||
suite.baseLane = standard.NewStandardLane(
|
||||
baseConfig,
|
||||
)
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"github.com/skip-mev/pob/block"
|
||||
"github.com/skip-mev/pob/block/constructor"
|
||||
"github.com/skip-mev/pob/block/base"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -17,19 +17,19 @@ var _ block.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 {
|
||||
*constructor.LaneConstructor
|
||||
*base.BaseLane
|
||||
}
|
||||
|
||||
// NewFreeLane returns a new free lane.
|
||||
func NewFreeLane(
|
||||
cfg constructor.LaneConfig,
|
||||
txPriority constructor.TxPriority[string],
|
||||
cfg base.LaneConfig,
|
||||
txPriority base.TxPriority[string],
|
||||
matchFn block.MatchHandler,
|
||||
) *FreeLane {
|
||||
lane := constructor.NewLaneConstructor(
|
||||
lane := base.NewBaseLane(
|
||||
cfg,
|
||||
LaneName,
|
||||
constructor.NewMempool[string](
|
||||
base.NewMempool[string](
|
||||
txPriority,
|
||||
cfg.TxEncoder,
|
||||
cfg.MaxTxs,
|
||||
@ -38,7 +38,7 @@ func NewFreeLane(
|
||||
)
|
||||
|
||||
return &FreeLane{
|
||||
LaneConstructor: lane,
|
||||
BaseLane: lane,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// NewCheckTxHandler is a constructor for CheckTxHandler.
|
||||
// NewCheckTxHandler is a base for CheckTxHandler.
|
||||
func NewCheckTxHandler(
|
||||
baseApp BaseApp,
|
||||
txDecoder sdk.TxDecoder,
|
||||
|
||||
@ -5,7 +5,7 @@ import (
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/block"
|
||||
"github.com/skip-mev/pob/block/constructor"
|
||||
"github.com/skip-mev/pob/block/base"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -34,7 +34,7 @@ type (
|
||||
|
||||
MEVLane struct {
|
||||
// LaneConfig defines the base lane configuration.
|
||||
*constructor.LaneConstructor
|
||||
*base.BaseLane
|
||||
|
||||
// Factory defines the API/functionality which is responsible for determining
|
||||
// if a transaction is a bid transaction and how to extract relevant
|
||||
@ -45,14 +45,14 @@ type (
|
||||
|
||||
// NewMEVLane returns a new TOB lane.
|
||||
func NewMEVLane(
|
||||
cfg constructor.LaneConfig,
|
||||
cfg base.LaneConfig,
|
||||
factory Factory,
|
||||
) *MEVLane {
|
||||
lane := &MEVLane{
|
||||
LaneConstructor: constructor.NewLaneConstructor(
|
||||
BaseLane: base.NewBaseLane(
|
||||
cfg,
|
||||
LaneName,
|
||||
constructor.NewMempool[string](
|
||||
base.NewMempool[string](
|
||||
TxPriority(factory),
|
||||
cfg.TxEncoder,
|
||||
cfg.MaxTxs,
|
||||
|
||||
@ -4,13 +4,13 @@ import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/block/constructor"
|
||||
"github.com/skip-mev/pob/block/base"
|
||||
)
|
||||
|
||||
// TxPriority returns a TxPriority over mev lane transactions only. It
|
||||
// is to be used in the mev index only.
|
||||
func TxPriority(config Factory) constructor.TxPriority[string] {
|
||||
return constructor.TxPriority[string]{
|
||||
func TxPriority(config Factory) base.TxPriority[string] {
|
||||
return base.TxPriority[string]{
|
||||
GetTxPriority: func(goCtx context.Context, tx sdk.Tx) string {
|
||||
bidInfo, err := config.GetAuctionBidInfo(tx)
|
||||
if err != nil {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package base_test
|
||||
package standard_test
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
@ -9,9 +9,9 @@ import (
|
||||
"cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/block"
|
||||
"github.com/skip-mev/pob/block/constructor"
|
||||
"github.com/skip-mev/pob/block/base"
|
||||
"github.com/skip-mev/pob/block/utils/mocks"
|
||||
"github.com/skip-mev/pob/lanes/base"
|
||||
"github.com/skip-mev/pob/lanes/standard"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
)
|
||||
|
||||
@ -502,8 +502,8 @@ func (s *BaseTestSuite) TestCheckOrder() {
|
||||
func (s *BaseTestSuite) initLane(
|
||||
maxBlockSpace math.LegacyDec,
|
||||
expectedExecution map[sdk.Tx]bool,
|
||||
) *base.DefaultLane {
|
||||
config := constructor.NewLaneConfig(
|
||||
) *standard.StandardLane {
|
||||
config := base.NewLaneConfig(
|
||||
log.NewTestLogger(s.T()),
|
||||
s.encodingConfig.TxConfig.TxEncoder(),
|
||||
s.encodingConfig.TxConfig.TxDecoder(),
|
||||
@ -511,7 +511,7 @@ func (s *BaseTestSuite) initLane(
|
||||
maxBlockSpace,
|
||||
)
|
||||
|
||||
return base.NewDefaultLane(config)
|
||||
return standard.NewStandardLane(config)
|
||||
}
|
||||
|
||||
func (s *BaseTestSuite) setUpAnteHandler(expectedExecution map[sdk.Tx]bool) sdk.AnteHandler {
|
||||
@ -1,4 +1,4 @@
|
||||
package base_test
|
||||
package standard_test
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
@ -1,8 +1,8 @@
|
||||
package base
|
||||
package standard
|
||||
|
||||
import (
|
||||
"github.com/skip-mev/pob/block"
|
||||
"github.com/skip-mev/pob/block/constructor"
|
||||
"github.com/skip-mev/pob/block/base"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -10,32 +10,32 @@ const (
|
||||
LaneName = "default"
|
||||
)
|
||||
|
||||
var _ block.Lane = (*DefaultLane)(nil)
|
||||
var _ block.Lane = (*StandardLane)(nil)
|
||||
|
||||
// DefaultLane defines a default lane implementation. The default lane orders
|
||||
// StandardLane defines a default lane implementation. The standard lane orders
|
||||
// transactions by the transaction fees. The default lane accepts any transaction
|
||||
// that is should not be ignored (as defined by the IgnoreList in the LaneConfig).
|
||||
// The default lane builds and verifies blocks in a similiar fashion to how the
|
||||
// CometBFT/Tendermint consensus engine builds and verifies blocks pre SDK version
|
||||
// 0.47.0.
|
||||
type DefaultLane struct {
|
||||
*constructor.LaneConstructor
|
||||
type StandardLane struct {
|
||||
*base.BaseLane
|
||||
}
|
||||
|
||||
// NewDefaultLane returns a new default lane.
|
||||
func NewDefaultLane(cfg constructor.LaneConfig) *DefaultLane {
|
||||
lane := constructor.NewLaneConstructor(
|
||||
// NewStandardLane returns a new default lane.
|
||||
func NewStandardLane(cfg base.LaneConfig) *StandardLane {
|
||||
lane := base.NewBaseLane(
|
||||
cfg,
|
||||
LaneName,
|
||||
constructor.NewMempool[string](
|
||||
constructor.DefaultTxPriority(),
|
||||
base.NewMempool[string](
|
||||
base.DefaultTxPriority(),
|
||||
cfg.TxEncoder,
|
||||
cfg.MaxTxs,
|
||||
),
|
||||
constructor.DefaultMatchHandler(),
|
||||
base.DefaultMatchHandler(),
|
||||
)
|
||||
|
||||
return &DefaultLane{
|
||||
LaneConstructor: lane,
|
||||
return &StandardLane{
|
||||
BaseLane: lane,
|
||||
}
|
||||
}
|
||||
@ -1,14 +1,14 @@
|
||||
package base_test
|
||||
package standard_test
|
||||
|
||||
import (
|
||||
"cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/block/constructor"
|
||||
"github.com/skip-mev/pob/block/base"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
)
|
||||
|
||||
func (s *BaseTestSuite) TestGetTxPriority() {
|
||||
txPriority := constructor.DefaultTxPriority()
|
||||
txPriority := base.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 := constructor.DefaultTxPriority()
|
||||
txPriority := base.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 := constructor.NewMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
|
||||
mempool := base.NewMempool[string](base.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 := constructor.NewMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
|
||||
mempool := base.NewMempool[string](base.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 := constructor.NewMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
|
||||
mempool := base.NewMempool[string](base.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 := constructor.NewMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
|
||||
mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
|
||||
|
||||
tx1, err := testutils.CreateRandomTx(
|
||||
s.encodingConfig.TxConfig,
|
||||
@ -63,10 +63,10 @@ import (
|
||||
|
||||
"github.com/skip-mev/pob/abci"
|
||||
"github.com/skip-mev/pob/block"
|
||||
"github.com/skip-mev/pob/block/constructor"
|
||||
"github.com/skip-mev/pob/lanes/base"
|
||||
"github.com/skip-mev/pob/block/base"
|
||||
"github.com/skip-mev/pob/lanes/free"
|
||||
"github.com/skip-mev/pob/lanes/mev"
|
||||
"github.com/skip-mev/pob/lanes/standard"
|
||||
buildermodule "github.com/skip-mev/pob/x/builder"
|
||||
builderkeeper "github.com/skip-mev/pob/x/builder/keeper"
|
||||
)
|
||||
@ -263,7 +263,7 @@ func New(
|
||||
// NOTE: The lanes are ordered by priority. The first lane is the highest priority
|
||||
// lane and the last lane is the lowest priority lane.
|
||||
// Top of block lane allows transactions to bid for inclusion at the top of the next block.
|
||||
mevConfig := constructor.LaneConfig{
|
||||
mevConfig := base.LaneConfig{
|
||||
Logger: app.Logger(),
|
||||
TxEncoder: app.txConfig.TxEncoder(),
|
||||
TxDecoder: app.txConfig.TxDecoder(),
|
||||
@ -276,7 +276,7 @@ func New(
|
||||
)
|
||||
|
||||
// Free lane allows transactions to be included in the next block for free.
|
||||
freeConfig := constructor.LaneConfig{
|
||||
freeConfig := base.LaneConfig{
|
||||
Logger: app.Logger(),
|
||||
TxEncoder: app.txConfig.TxEncoder(),
|
||||
TxDecoder: app.txConfig.TxDecoder(),
|
||||
@ -285,19 +285,19 @@ func New(
|
||||
}
|
||||
freeLane := free.NewFreeLane(
|
||||
freeConfig,
|
||||
constructor.DefaultTxPriority(),
|
||||
base.DefaultTxPriority(),
|
||||
free.DefaultMatchHandler(),
|
||||
)
|
||||
|
||||
// Default lane accepts all other transactions.
|
||||
defaultConfig := constructor.LaneConfig{
|
||||
defaultConfig := base.LaneConfig{
|
||||
Logger: app.Logger(),
|
||||
TxEncoder: app.txConfig.TxEncoder(),
|
||||
TxDecoder: app.txConfig.TxDecoder(),
|
||||
MaxBlockSpace: math.LegacyZeroDec(),
|
||||
MaxTxs: 0,
|
||||
}
|
||||
defaultLane := base.NewDefaultLane(defaultConfig)
|
||||
defaultLane := standard.NewStandardLane(defaultConfig)
|
||||
|
||||
// Set the lanes into the mempool.
|
||||
lanes := []block.Lane{
|
||||
|
||||
@ -12,9 +12,9 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/skip-mev/pob/block"
|
||||
"github.com/skip-mev/pob/block/constructor"
|
||||
"github.com/skip-mev/pob/lanes/base"
|
||||
"github.com/skip-mev/pob/block/base"
|
||||
"github.com/skip-mev/pob/lanes/mev"
|
||||
"github.com/skip-mev/pob/lanes/standard"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
"github.com/skip-mev/pob/x/builder/ante"
|
||||
"github.com/skip-mev/pob/x/builder/keeper"
|
||||
@ -42,7 +42,7 @@ type AnteTestSuite struct {
|
||||
// mempool and lane set up
|
||||
mempool block.Mempool
|
||||
mevLane *mev.MEVLane
|
||||
baseLane *base.DefaultLane
|
||||
baseLane *standard.StandardLane
|
||||
lanes []block.Lane
|
||||
|
||||
// Account set up
|
||||
@ -84,7 +84,7 @@ func (suite *AnteTestSuite) SetupTest() {
|
||||
// Lanes configuration
|
||||
//
|
||||
// TOB lane set up
|
||||
mevConfig := constructor.LaneConfig{
|
||||
mevConfig := base.LaneConfig{
|
||||
Logger: suite.ctx.Logger(),
|
||||
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
|
||||
@ -97,7 +97,7 @@ func (suite *AnteTestSuite) SetupTest() {
|
||||
)
|
||||
|
||||
// Base lane set up
|
||||
baseConfig := constructor.LaneConfig{
|
||||
baseConfig := base.LaneConfig{
|
||||
Logger: suite.ctx.Logger(),
|
||||
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
|
||||
@ -105,7 +105,7 @@ func (suite *AnteTestSuite) SetupTest() {
|
||||
MaxBlockSpace: math.LegacyZeroDec(),
|
||||
IgnoreList: []block.Lane{suite.mevLane},
|
||||
}
|
||||
suite.baseLane = base.NewDefaultLane(baseConfig)
|
||||
suite.baseLane = standard.NewStandardLane(baseConfig)
|
||||
|
||||
// Mempool set up
|
||||
suite.lanes = []block.Lane{suite.mevLane, suite.baseLane}
|
||||
@ -280,13 +280,13 @@ func (suite *AnteTestSuite) TestAnteHandler() {
|
||||
|
||||
distribution := suite.mempool.GetTxDistribution()
|
||||
suite.Require().Equal(0, distribution[mev.LaneName])
|
||||
suite.Require().Equal(0, distribution[base.LaneName])
|
||||
suite.Require().Equal(0, distribution[standard.LaneName])
|
||||
|
||||
suite.Require().NoError(suite.mempool.Insert(suite.ctx, topAuctionTx))
|
||||
|
||||
distribution = suite.mempool.GetTxDistribution()
|
||||
suite.Require().Equal(1, distribution[mev.LaneName])
|
||||
suite.Require().Equal(0, distribution[base.LaneName])
|
||||
suite.Require().Equal(0, distribution[standard.LaneName])
|
||||
}
|
||||
|
||||
// Create the actual mev tx and insert into the mempool
|
||||
|
||||
Loading…
Reference in New Issue
Block a user