feat: Lane Options (#272)
* init * lint * update mock * cr * readme nit
This commit is contained in:
@@ -71,9 +71,6 @@ type Lane interface {
|
||||
// Name returns the name of the lane.
|
||||
Name() string
|
||||
|
||||
// SetAnteHandler sets the lane's antehandler.
|
||||
SetAnteHandler(antehander sdk.AnteHandler)
|
||||
|
||||
// Match determines if a transaction belongs to this lane.
|
||||
Match(ctx sdk.Context, tx sdk.Tx) bool
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ func DefaultMatchHandler() base.MatchHandler {
|
||||
}
|
||||
```
|
||||
|
||||
The default `MatchHandler` is implemented in the [base lane](./handlers.go) and matches all transactions.
|
||||
The default `MatchHandler` is implemented in the [base lane](./match.go) and matches all transactions.
|
||||
|
||||
## PrepareLaneHandler
|
||||
|
||||
@@ -60,7 +60,7 @@ PrepareLaneHandler func(
|
||||
|
||||
To create a custom lane with a custom `PrepareLaneHandler`, you must implement this function and set it on the lane after it has been created. Please visit the [MEV lane's](../../lanes/mev/abci.go) `PrepareLaneHandler` for an example of how to implement this function.
|
||||
|
||||
The default `PrepareLaneHandler` is implemented in the [base lane](./handlers.go). It reaps transactions from the mempool, validates them, ensures that the lane's block space limit is not exceeded, and returns the transactions to be included in the block and the ones that need to be removed.
|
||||
The default `PrepareLaneHandler` is implemented in the [base lane](./proposals.go). It reaps transactions from the mempool, validates them, ensures that the lane's block space limit is not exceeded, and returns the transactions to be included in the block and the ones that need to be removed.
|
||||
|
||||
## ProcessLaneHandler
|
||||
|
||||
@@ -74,7 +74,7 @@ ProcessLaneHandler func(ctx sdk.Context, partialProposal []sdk.Tx) (
|
||||
)
|
||||
```
|
||||
|
||||
Note that block proposals built using the Block SDK contain contiguous sections of transactions in the block that belong to a given lane, to read more about how proposals are constructed relative to other lanes, please visit the [abci section](../../abci/README.md). As such, a given lane will recieve some transactions in (partialProposal) that belong to it and some that do not. The transactions that belong to it must be contiguous from the start, and the transactions that do not belong to it must be contiguous from the end. The lane must return the transactions that belong to it and the transactions that do not belong to it. The transactions that do not belong to it will be passed to the next lane in the proposal. The default `ProcessLaneHandler` is implemented in the [base lane](./handlers.go). It verifies the transactions that belong to the lane and returns them alongside the transactions that do not belong to the lane.
|
||||
Note that block proposals built using the Block SDK contain contiguous sections of transactions in the block that belong to a given lane, to read more about how proposals are constructed relative to other lanes, please visit the [abci section](../../abci/README.md). As such, a given lane will recieve some transactions in (partialProposal) that belong to it and some that do not. The transactions that belong to it must be contiguous from the start, and the transactions that do not belong to it must be contiguous from the end. The lane must return the transactions that belong to it and the transactions that do not belong to it. The transactions that do not belong to it will be passed to the next lane in the proposal. The default `ProcessLaneHandler` is implemented in the [base lane](./proposals.go). It verifies the transactions that belong to the lane and returns them alongside the transactions that do not belong to the lane.
|
||||
|
||||
Please visit the [MEV lane's](../../lanes/mev/abci.go) `ProcessLaneHandler` for an example of how to implement a custom handler.
|
||||
|
||||
|
||||
+37
-38
@@ -50,17 +50,35 @@ type BaseLane struct { //nolint
|
||||
func NewBaseLane(
|
||||
cfg LaneConfig,
|
||||
laneName string,
|
||||
laneMempool block.LaneMempool,
|
||||
matchHandlerFn MatchHandler,
|
||||
) *BaseLane {
|
||||
options ...LaneOption,
|
||||
) (*BaseLane, error) {
|
||||
lane := &BaseLane{
|
||||
cfg: cfg,
|
||||
laneName: laneName,
|
||||
LaneMempool: laneMempool,
|
||||
matchHandler: matchHandlerFn,
|
||||
cfg: cfg,
|
||||
laneName: laneName,
|
||||
}
|
||||
|
||||
return lane
|
||||
lane.LaneMempool = NewMempool(
|
||||
DefaultTxPriority(),
|
||||
lane.cfg.TxEncoder,
|
||||
lane.cfg.SignerExtractor,
|
||||
lane.cfg.MaxTxs,
|
||||
)
|
||||
|
||||
lane.matchHandler = DefaultMatchHandler()
|
||||
|
||||
handler := NewDefaultProposalHandler(lane)
|
||||
lane.prepareLaneHandler = handler.PrepareLaneHandler()
|
||||
lane.processLaneHandler = handler.ProcessLaneHandler()
|
||||
|
||||
for _, option := range options {
|
||||
option(lane)
|
||||
}
|
||||
|
||||
if err := lane.ValidateBasic(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return lane, nil
|
||||
}
|
||||
|
||||
// ValidateBasic ensures that the lane was constructed properly. In the case that
|
||||
@@ -83,39 +101,16 @@ func (l *BaseLane) ValidateBasic() error {
|
||||
}
|
||||
|
||||
if l.prepareLaneHandler == nil {
|
||||
l.prepareLaneHandler = l.DefaultPrepareLaneHandler()
|
||||
return fmt.Errorf("prepare lane handler cannot be nil")
|
||||
}
|
||||
|
||||
if l.processLaneHandler == nil {
|
||||
l.processLaneHandler = l.DefaultProcessLaneHandler()
|
||||
return fmt.Errorf("process lane handler cannot be nil")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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 *BaseLane) SetPrepareLaneHandler(prepareLaneHandler PrepareLaneHandler) {
|
||||
if prepareLaneHandler == nil {
|
||||
panic("prepare lane handler cannot be nil")
|
||||
}
|
||||
|
||||
l.prepareLaneHandler = prepareLaneHandler
|
||||
}
|
||||
|
||||
// SetProcessLaneHandler sets the process lane handler for the lane. This handler
|
||||
// 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 *BaseLane) SetProcessLaneHandler(processLaneHandler ProcessLaneHandler) {
|
||||
if processLaneHandler == nil {
|
||||
panic("process lane handler cannot be nil")
|
||||
}
|
||||
|
||||
l.processLaneHandler = processLaneHandler
|
||||
}
|
||||
|
||||
// Match returns true if the transaction should be processed by this lane. This
|
||||
// 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
|
||||
@@ -129,11 +124,6 @@ func (l *BaseLane) Name() string {
|
||||
return l.laneName
|
||||
}
|
||||
|
||||
// SetAnteHandler sets the ante handler for the lane.
|
||||
func (l *BaseLane) SetAnteHandler(anteHandler sdk.AnteHandler) {
|
||||
l.cfg.AnteHandler = anteHandler
|
||||
}
|
||||
|
||||
// Logger returns the logger for the lane.
|
||||
func (l *BaseLane) Logger() log.Logger {
|
||||
return l.cfg.Logger
|
||||
@@ -160,3 +150,12 @@ func (l *BaseLane) GetMaxBlockSpace() math.LegacyDec {
|
||||
func (l *BaseLane) SetMaxBlockSpace(maxBlockSpace math.LegacyDec) {
|
||||
l.cfg.MaxBlockSpace = maxBlockSpace
|
||||
}
|
||||
|
||||
// WithOptions returns a new lane with the given options.
|
||||
func (l *BaseLane) WithOptions(options ...LaneOption) *BaseLane {
|
||||
for _, option := range options {
|
||||
option(l)
|
||||
}
|
||||
|
||||
return l
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// DefaultMatchHandler returns a default implementation of the MatchHandler. It matches all
|
||||
// transactions.
|
||||
func DefaultMatchHandler() MatchHandler {
|
||||
return func(ctx sdk.Context, tx sdk.Tx) bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// VerifyNoMatches returns an error if any of the transactions match the lane.
|
||||
func (l *BaseLane) VerifyNoMatches(ctx sdk.Context, txs []sdk.Tx) error {
|
||||
for _, tx := range txs {
|
||||
if l.Match(ctx, tx) {
|
||||
return fmt.Errorf("transaction belongs to lane when it should not")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/block-sdk/block"
|
||||
)
|
||||
|
||||
// LaneOption defines a function that can be used to set options on a lane.
|
||||
type LaneOption func(*BaseLane)
|
||||
|
||||
// WithAnteHandler sets the ante handler for the lane.
|
||||
func WithAnteHandler(anteHandler sdk.AnteHandler) LaneOption {
|
||||
return func(l *BaseLane) { l.cfg.AnteHandler = anteHandler }
|
||||
}
|
||||
|
||||
// WithPrepareLaneHandler 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 WithPrepareLaneHandler(prepareLaneHandler PrepareLaneHandler) LaneOption {
|
||||
return func(l *BaseLane) {
|
||||
if prepareLaneHandler == nil {
|
||||
panic("prepare lane handler cannot be nil")
|
||||
}
|
||||
|
||||
l.prepareLaneHandler = prepareLaneHandler
|
||||
}
|
||||
}
|
||||
|
||||
// WithProcessLaneHandler sets the process lane handler for the lane. This handler
|
||||
// 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 WithProcessLaneHandler(processLaneHandler ProcessLaneHandler) LaneOption {
|
||||
return func(l *BaseLane) {
|
||||
if processLaneHandler == nil {
|
||||
panic("process lane handler cannot be nil")
|
||||
}
|
||||
|
||||
l.processLaneHandler = processLaneHandler
|
||||
}
|
||||
}
|
||||
|
||||
// WithMatchHandler sets the match handler for the lane. This handler is called
|
||||
// when a new transaction is being submitted to the lane and the lane needs to
|
||||
// determine if the transaction should be processed by the lane.
|
||||
func WithMatchHandler(matchHandler MatchHandler) LaneOption {
|
||||
return func(l *BaseLane) {
|
||||
if matchHandler == nil {
|
||||
panic("match handler cannot be nil")
|
||||
}
|
||||
|
||||
l.matchHandler = matchHandler
|
||||
}
|
||||
}
|
||||
|
||||
// WithMempool sets the mempool for the lane. This mempool is used to store
|
||||
// transactions that are waiting to be processed.
|
||||
func WithMempool(mempool block.LaneMempool) LaneOption {
|
||||
return func(l *BaseLane) {
|
||||
if mempool == nil {
|
||||
panic("mempool cannot be nil")
|
||||
}
|
||||
|
||||
l.LaneMempool = mempool
|
||||
}
|
||||
}
|
||||
|
||||
// WithMempoolConfigs sets the mempool for the lane with the given lane config
|
||||
// and TxPriority struct. This mempool is used to store transactions that are waiting
|
||||
// to be processed.
|
||||
func WithMempoolConfigs[C comparable](cfg LaneConfig, txPriority TxPriority[C]) LaneOption {
|
||||
return func(l *BaseLane) {
|
||||
l.LaneMempool = NewMempool(
|
||||
txPriority,
|
||||
cfg.TxEncoder,
|
||||
cfg.SignerExtractor,
|
||||
cfg.MaxTxs,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,24 @@ import (
|
||||
"github.com/skip-mev/block-sdk/block/proposals"
|
||||
)
|
||||
|
||||
// DefaultProposalHandler returns a default implementation of the PrepareLaneHandler and
|
||||
// ProcessLaneHandler.
|
||||
type DefaultProposalHandler struct {
|
||||
lane *BaseLane
|
||||
}
|
||||
|
||||
// NewDefaultProposalHandler returns a new default proposal handler.
|
||||
func NewDefaultProposalHandler(lane *BaseLane) *DefaultProposalHandler {
|
||||
return &DefaultProposalHandler{
|
||||
lane: lane,
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultPrepareLaneHandler returns a default implementation of the PrepareLaneHandler. It
|
||||
// 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 blockspace/gas for this
|
||||
// lane has been reached. Additionally, any transactions that are invalid will be returned.
|
||||
func (l *BaseLane) DefaultPrepareLaneHandler() PrepareLaneHandler {
|
||||
func (h *DefaultProposalHandler) PrepareLaneHandler() PrepareLaneHandler {
|
||||
return func(ctx sdk.Context, proposal proposals.Proposal, limit proposals.LaneLimits) ([]sdk.Tx, []sdk.Tx, error) {
|
||||
var (
|
||||
totalSize int64
|
||||
@@ -23,23 +36,23 @@ func (l *BaseLane) DefaultPrepareLaneHandler() PrepareLaneHandler {
|
||||
|
||||
// Select all transactions in the mempool that are valid and not already in the
|
||||
// partial proposal.
|
||||
for iterator := l.Select(ctx, nil); iterator != nil; iterator = iterator.Next() {
|
||||
for iterator := h.lane.Select(ctx, nil); iterator != nil; iterator = iterator.Next() {
|
||||
tx := iterator.Tx()
|
||||
|
||||
txInfo, err := l.GetTxInfo(ctx, tx)
|
||||
txInfo, err := h.lane.GetTxInfo(ctx, tx)
|
||||
if err != nil {
|
||||
l.Logger().Info("failed to get hash of tx", "err", err)
|
||||
h.lane.Logger().Info("failed to get hash of tx", "err", err)
|
||||
|
||||
txsToRemove = append(txsToRemove, tx)
|
||||
continue
|
||||
}
|
||||
|
||||
// Double check that the transaction belongs to this lane.
|
||||
if !l.Match(ctx, tx) {
|
||||
l.Logger().Info(
|
||||
if !h.lane.Match(ctx, tx) {
|
||||
h.lane.Logger().Info(
|
||||
"failed to select tx for lane; tx does not belong to lane",
|
||||
"tx_hash", txInfo.Hash,
|
||||
"lane", l.Name(),
|
||||
"lane", h.lane.Name(),
|
||||
)
|
||||
|
||||
txsToRemove = append(txsToRemove, tx)
|
||||
@@ -48,10 +61,10 @@ func (l *BaseLane) DefaultPrepareLaneHandler() PrepareLaneHandler {
|
||||
|
||||
// if the transaction is already in the (partial) block proposal, we skip it.
|
||||
if proposal.Contains(txInfo.Hash) {
|
||||
l.Logger().Info(
|
||||
h.lane.Logger().Info(
|
||||
"failed to select tx for lane; tx is already in proposal",
|
||||
"tx_hash", txInfo.Hash,
|
||||
"lane", l.Name(),
|
||||
"lane", h.lane.Name(),
|
||||
)
|
||||
|
||||
continue
|
||||
@@ -59,9 +72,9 @@ func (l *BaseLane) DefaultPrepareLaneHandler() PrepareLaneHandler {
|
||||
|
||||
// If the transaction is too large, we break and do not attempt to include more txs.
|
||||
if updatedSize := totalSize + txInfo.Size; updatedSize > limit.MaxTxBytes {
|
||||
l.Logger().Info(
|
||||
h.lane.Logger().Info(
|
||||
"failed to select tx for lane; tx bytes above the maximum allowed",
|
||||
"lane", l.Name(),
|
||||
"lane", h.lane.Name(),
|
||||
"tx_size", txInfo.Size,
|
||||
"total_size", totalSize,
|
||||
"max_tx_bytes", limit.MaxTxBytes,
|
||||
@@ -74,9 +87,9 @@ func (l *BaseLane) DefaultPrepareLaneHandler() PrepareLaneHandler {
|
||||
|
||||
// If the gas limit of the transaction is too large, we break and do not attempt to include more txs.
|
||||
if updatedGas := totalGas + txInfo.GasLimit; updatedGas > limit.MaxGasLimit {
|
||||
l.Logger().Info(
|
||||
h.lane.Logger().Info(
|
||||
"failed to select tx for lane; gas limit above the maximum allowed",
|
||||
"lane", l.Name(),
|
||||
"lane", h.lane.Name(),
|
||||
"tx_gas", txInfo.GasLimit,
|
||||
"total_gas", totalGas,
|
||||
"max_gas", limit.MaxGasLimit,
|
||||
@@ -88,8 +101,8 @@ func (l *BaseLane) DefaultPrepareLaneHandler() PrepareLaneHandler {
|
||||
}
|
||||
|
||||
// Verify the transaction.
|
||||
if err = l.VerifyTx(ctx, tx, false); err != nil {
|
||||
l.Logger().Info(
|
||||
if err = h.lane.VerifyTx(ctx, tx, false); err != nil {
|
||||
h.lane.Logger().Info(
|
||||
"failed to verify tx",
|
||||
"tx_hash", txInfo.Hash,
|
||||
"err", err,
|
||||
@@ -114,18 +127,18 @@ func (l *BaseLane) DefaultPrepareLaneHandler() PrepareLaneHandler {
|
||||
// 2. Transactions that do not belong to the lane must be contiguous from the end of the partial proposal.
|
||||
// 3. Transactions must be ordered respecting the priority defined by the lane (e.g. gas price).
|
||||
// 4. Transactions must be valid according to the verification logic of the lane.
|
||||
func (l *BaseLane) DefaultProcessLaneHandler() ProcessLaneHandler {
|
||||
func (h *DefaultProposalHandler) ProcessLaneHandler() ProcessLaneHandler {
|
||||
return func(ctx sdk.Context, partialProposal []sdk.Tx) ([]sdk.Tx, []sdk.Tx, error) {
|
||||
if len(partialProposal) == 0 {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
for index, tx := range partialProposal {
|
||||
if !l.Match(ctx, tx) {
|
||||
if !h.lane.Match(ctx, tx) {
|
||||
// If the transaction does not belong to this lane, we return the remaining transactions
|
||||
// iff there are no matches in the remaining transactions after this index.
|
||||
if index+1 < len(partialProposal) {
|
||||
if err := l.VerifyNoMatches(ctx, partialProposal[index+1:]); err != nil {
|
||||
if err := h.lane.VerifyNoMatches(ctx, partialProposal[index+1:]); err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to verify no matches: %w", err)
|
||||
}
|
||||
}
|
||||
@@ -136,12 +149,12 @@ func (l *BaseLane) DefaultProcessLaneHandler() ProcessLaneHandler {
|
||||
// If the transactions do not respect the priority defined by the mempool, we consider the proposal
|
||||
// to be invalid
|
||||
if index > 0 {
|
||||
if v, err := l.Compare(ctx, partialProposal[index-1], tx); v == -1 || err != nil {
|
||||
if v, err := h.lane.Compare(ctx, partialProposal[index-1], tx); v == -1 || err != nil {
|
||||
return nil, nil, fmt.Errorf("transaction at index %d has a higher priority than %d", index, index-1)
|
||||
}
|
||||
}
|
||||
|
||||
if err := l.VerifyTx(ctx, tx, false); err != nil {
|
||||
if err := h.lane.VerifyTx(ctx, tx, false); err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to verify tx: %w", err)
|
||||
}
|
||||
}
|
||||
@@ -151,38 +164,3 @@ func (l *BaseLane) DefaultProcessLaneHandler() ProcessLaneHandler {
|
||||
return partialProposal, nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
// VerifyNoMatches returns an error if any of the transactions match the lane.
|
||||
func (l *BaseLane) VerifyNoMatches(ctx sdk.Context, txs []sdk.Tx) error {
|
||||
for _, tx := range txs {
|
||||
if l.Match(ctx, tx) {
|
||||
return fmt.Errorf("transaction belongs to lane when it should not")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DefaultMatchHandler returns a default implementation of the MatchHandler. It matches all
|
||||
// transactions.
|
||||
func DefaultMatchHandler() MatchHandler {
|
||||
return func(ctx sdk.Context, tx sdk.Tx) bool {
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -67,9 +67,6 @@ type Lane interface {
|
||||
// Name returns the name of the lane.
|
||||
Name() string
|
||||
|
||||
// SetAnteHandler sets the lane's antehandler.
|
||||
SetAnteHandler(antehander sdk.AnteHandler)
|
||||
|
||||
// Match determines if a transaction belongs to this lane.
|
||||
Match(ctx sdk.Context, tx sdk.Tx) bool
|
||||
|
||||
|
||||
+14
-14
@@ -35,8 +35,8 @@ type BlockBusterTestSuite struct {
|
||||
|
||||
// Define all of the lanes utilized in the test suite
|
||||
mevLane *mev.MEVLane
|
||||
baseLane *defaultlane.DefaultLane
|
||||
freeLane *free.FreeLane
|
||||
baseLane *base.BaseLane
|
||||
freeLane *base.BaseLane
|
||||
gasTokenDenom string
|
||||
|
||||
// sdk module lanes
|
||||
@@ -138,7 +138,7 @@ func (suite *BlockBusterTestSuite) SetupTest() {
|
||||
|
||||
var err error
|
||||
suite.mempool, err = block.NewLanedMempool(
|
||||
log.NewTestLogger(suite.T()),
|
||||
log.NewNopLogger(),
|
||||
suite.lanes,
|
||||
mocks.NewMockLaneFetcher(func() (blocksdkmoduletypes.Lane, error) {
|
||||
return suite.baseSDKLane, nil
|
||||
@@ -189,7 +189,7 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
lanes := []block.Lane{defaultLane}
|
||||
|
||||
_, err := block.NewLanedMempool(
|
||||
log.NewTestLogger(suite.T()),
|
||||
log.NewNopLogger(),
|
||||
lanes,
|
||||
fetcher,
|
||||
)
|
||||
@@ -200,7 +200,7 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
lanes := []block.Lane{mevLane, defaultLane}
|
||||
|
||||
_, err := block.NewLanedMempool(
|
||||
log.NewTestLogger(suite.T()),
|
||||
log.NewNopLogger(),
|
||||
lanes,
|
||||
fetcher,
|
||||
)
|
||||
@@ -211,7 +211,7 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
lanes := []block.Lane{mevLane, defaultLane}
|
||||
|
||||
_, err := block.NewLanedMempool(
|
||||
log.NewTestLogger(suite.T()),
|
||||
log.NewNopLogger(),
|
||||
lanes,
|
||||
fetcher,
|
||||
)
|
||||
@@ -222,7 +222,7 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
lanes := []block.Lane{mevLane, freeLane, defaultLane}
|
||||
|
||||
_, err := block.NewLanedMempool(
|
||||
log.NewTestLogger(suite.T()),
|
||||
log.NewNopLogger(),
|
||||
lanes,
|
||||
fetcher,
|
||||
)
|
||||
@@ -233,7 +233,7 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
lanes := []block.Lane{mevLane, defaultLane, freeLane}
|
||||
|
||||
_, err := block.NewLanedMempool(
|
||||
log.NewTestLogger(suite.T()),
|
||||
log.NewNopLogger(),
|
||||
lanes,
|
||||
fetcher,
|
||||
)
|
||||
@@ -244,7 +244,7 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
lanes := []block.Lane{freeLane, mevLane, defaultLane}
|
||||
|
||||
_, err := block.NewLanedMempool(
|
||||
log.NewTestLogger(suite.T()),
|
||||
log.NewNopLogger(),
|
||||
lanes,
|
||||
fetcher,
|
||||
)
|
||||
@@ -255,7 +255,7 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
lanes := []block.Lane{defaultLane, freeLane, mevLane}
|
||||
|
||||
_, err := block.NewLanedMempool(
|
||||
log.NewTestLogger(suite.T()),
|
||||
log.NewNopLogger(),
|
||||
lanes,
|
||||
fetcher,
|
||||
)
|
||||
@@ -266,7 +266,7 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
lanes := []block.Lane{mevLane, freeLane}
|
||||
|
||||
_, err := block.NewLanedMempool(
|
||||
log.NewTestLogger(suite.T()),
|
||||
log.NewNopLogger(),
|
||||
lanes,
|
||||
fetcher,
|
||||
)
|
||||
@@ -277,7 +277,7 @@ func (suite *BlockBusterTestSuite) TestNewMempool() {
|
||||
lanes := []block.Lane{mevLane, defaultLane, mevLane}
|
||||
|
||||
_, err := block.NewLanedMempool(
|
||||
log.NewTestLogger(suite.T()),
|
||||
log.NewNopLogger(),
|
||||
lanes,
|
||||
fetcher,
|
||||
)
|
||||
@@ -640,7 +640,7 @@ func (suite *BlockBusterTestSuite) TestLanedMempool_Registry() {
|
||||
suite.Run(tc.name, func() {
|
||||
// setup mock mempool
|
||||
mempool, err := block.NewLanedMempool(
|
||||
log.NewTestLogger(suite.T()),
|
||||
log.NewNopLogger(),
|
||||
tc.registryLanes,
|
||||
mocks.NewMockLaneFetcher(func() (blocksdkmoduletypes.Lane, error) {
|
||||
return blocksdkmoduletypes.Lane{}, nil
|
||||
@@ -753,7 +753,7 @@ func (suite *BlockBusterTestSuite) TestLanedMempool_OrderLanes() {
|
||||
suite.Run(tc.name, func() {
|
||||
// setup mock mempool
|
||||
mempool, err := block.NewLanedMempool(
|
||||
log.NewTestLogger(suite.T()),
|
||||
log.NewNopLogger(),
|
||||
tc.registryLanes,
|
||||
mocks.NewMockLaneFetcher(func() (blocksdkmoduletypes.Lane, error) {
|
||||
return blocksdkmoduletypes.Lane{}, nil
|
||||
|
||||
@@ -251,11 +251,6 @@ func (_m *Lane) Select(_a0 context.Context, _a1 [][]byte) mempool.Iterator {
|
||||
return r0
|
||||
}
|
||||
|
||||
// SetAnteHandler provides a mock function with given fields: antehander
|
||||
func (_m *Lane) SetAnteHandler(antehander types.AnteHandler) {
|
||||
_m.Called(antehander)
|
||||
}
|
||||
|
||||
// SetMaxBlockSpace provides a mock function with given fields: _a0
|
||||
func (_m *Lane) SetMaxBlockSpace(_a0 math.LegacyDec) {
|
||||
_m.Called(_a0)
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestUpdateProposal(t *testing.T) {
|
||||
lane.On("GetMaxBlockSpace").Return(math.LegacyNewDec(1)).Maybe()
|
||||
|
||||
t.Run("can update with no transactions", func(t *testing.T) {
|
||||
proposal := proposals.NewProposal(log.NewTestLogger(t), 100, 100)
|
||||
proposal := proposals.NewProposal(log.NewNopLogger(), 100, 100)
|
||||
|
||||
err := proposal.UpdateProposal(lane, nil)
|
||||
require.NoError(t, err)
|
||||
@@ -64,7 +64,7 @@ func TestUpdateProposal(t *testing.T) {
|
||||
|
||||
size := len(txBzs[0])
|
||||
gasLimit := 100
|
||||
proposal := proposals.NewProposal(log.NewTestLogger(t), int64(size), uint64(gasLimit))
|
||||
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size), uint64(gasLimit))
|
||||
|
||||
txsWithInfo, err := getTxsWithInfo([]sdk.Tx{tx})
|
||||
require.NoError(t, err)
|
||||
@@ -113,7 +113,7 @@ func TestUpdateProposal(t *testing.T) {
|
||||
gasLimit += 100
|
||||
}
|
||||
|
||||
proposal := proposals.NewProposal(log.NewTestLogger(t), int64(size), gasLimit)
|
||||
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size), gasLimit)
|
||||
|
||||
txsWithInfo, err := getTxsWithInfo(txs)
|
||||
require.NoError(t, err)
|
||||
@@ -153,7 +153,7 @@ func TestUpdateProposal(t *testing.T) {
|
||||
|
||||
size := int64(len(txBzs[0]))
|
||||
gasLimit := uint64(100)
|
||||
proposal := proposals.NewProposal(log.NewTestLogger(t), size, gasLimit)
|
||||
proposal := proposals.NewProposal(log.NewNopLogger(), size, gasLimit)
|
||||
|
||||
txsWithInfo, err := getTxsWithInfo([]sdk.Tx{tx})
|
||||
require.NoError(t, err)
|
||||
@@ -219,7 +219,7 @@ func TestUpdateProposal(t *testing.T) {
|
||||
|
||||
size := len(txBzs[0]) + len(txBzs[1])
|
||||
gasLimit := 200
|
||||
proposal := proposals.NewProposal(log.NewTestLogger(t), int64(size), uint64(gasLimit))
|
||||
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size), uint64(gasLimit))
|
||||
|
||||
txsWithInfo, err := getTxsWithInfo([]sdk.Tx{tx})
|
||||
require.NoError(t, err)
|
||||
@@ -263,7 +263,7 @@ func TestUpdateProposal(t *testing.T) {
|
||||
|
||||
size := len(txBzs[0])
|
||||
gasLimit := 100
|
||||
proposal := proposals.NewProposal(log.NewTestLogger(t), int64(size), uint64(gasLimit))
|
||||
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size), uint64(gasLimit))
|
||||
|
||||
lane := mocks.NewLane(t)
|
||||
|
||||
@@ -304,7 +304,7 @@ func TestUpdateProposal(t *testing.T) {
|
||||
|
||||
size := len(txBzs[0])
|
||||
gasLimit := 100
|
||||
proposal := proposals.NewProposal(log.NewTestLogger(t), int64(size), uint64(gasLimit))
|
||||
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size), uint64(gasLimit))
|
||||
|
||||
lane := mocks.NewLane(t)
|
||||
|
||||
@@ -345,7 +345,7 @@ func TestUpdateProposal(t *testing.T) {
|
||||
|
||||
size := len(txBzs[0])
|
||||
gasLimit := 100
|
||||
proposal := proposals.NewProposal(log.NewTestLogger(t), int64(size)-1, uint64(gasLimit))
|
||||
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size)-1, uint64(gasLimit))
|
||||
|
||||
txsWithInfo, err := getTxsWithInfo([]sdk.Tx{tx})
|
||||
require.NoError(t, err)
|
||||
@@ -381,7 +381,7 @@ func TestUpdateProposal(t *testing.T) {
|
||||
|
||||
size := len(txBzs[0])
|
||||
gasLimit := 100
|
||||
proposal := proposals.NewProposal(log.NewTestLogger(t), int64(size), uint64(gasLimit)-1)
|
||||
proposal := proposals.NewProposal(log.NewNopLogger(), int64(size), uint64(gasLimit)-1)
|
||||
|
||||
txsWithInfo, err := getTxsWithInfo([]sdk.Tx{tx})
|
||||
require.NoError(t, err)
|
||||
@@ -425,7 +425,7 @@ func TestUpdateProposal(t *testing.T) {
|
||||
txBzs, err := utils.GetEncodedTxs(encodingConfig.TxConfig.TxEncoder(), []sdk.Tx{tx, tx2})
|
||||
require.NoError(t, err)
|
||||
|
||||
proposal := proposals.NewProposal(log.NewTestLogger(t), 10000, 10000)
|
||||
proposal := proposals.NewProposal(log.NewNopLogger(), 10000, 10000)
|
||||
|
||||
txsWithInfo, err := getTxsWithInfo([]sdk.Tx{tx})
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user