feat(BB): Update match function to include sdk.Context (#234)

This commit is contained in:
David Terpay
2023-08-10 17:01:52 +00:00
committed by GitHub
parent 128cc26f1a
commit 14f83b5e25
20 changed files with 402 additions and 265 deletions
+2 -7
View File
@@ -23,7 +23,7 @@ type (
// Mempool is an interface that defines the methods required to interact with the application-side mempool.
Mempool interface {
Contains(tx sdk.Tx) (bool, error)
Contains(tx sdk.Tx) bool
}
// BuilderDecorator is an AnteDecorator that validates the auction bid and bundled transactions.
@@ -49,12 +49,7 @@ func NewBuilderDecorator(ak keeper.Keeper, txEncoder sdk.TxEncoder, lane TOBLane
func (bd BuilderDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
// If comet is re-checking a transaction, we only need to check if the transaction is in the application-side mempool.
if ctx.IsReCheckTx() {
contains, err := bd.mempool.Contains(tx)
if err != nil {
return ctx, err
}
if !contains {
if !bd.mempool.Contains(tx) {
return ctx, fmt.Errorf("transaction not found in application-side mempool")
}
}
+13 -4
View File
@@ -5,6 +5,7 @@ import (
"testing"
"time"
"cosmossdk.io/log"
"cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
@@ -82,7 +83,7 @@ func (suite *AnteTestSuite) SetupTest() {
// Lanes configuration
//
// TOB lane set up
config := blockbuster.BaseLaneConfig{
tobConfig := blockbuster.BaseLaneConfig{
Logger: suite.ctx.Logger(),
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
@@ -90,17 +91,25 @@ func (suite *AnteTestSuite) SetupTest() {
MaxBlockSpace: math.LegacyZeroDec(),
}
suite.tobLane = auction.NewTOBLane(
config,
tobConfig,
0, // No bound on the number of transactions in the lane
auction.NewDefaultAuctionFactory(suite.encodingConfig.TxConfig.TxDecoder()),
)
// Base lane set up
suite.baseLane = base.NewDefaultLane(config)
baseConfig := blockbuster.BaseLaneConfig{
Logger: suite.ctx.Logger(),
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
AnteHandler: suite.anteHandler,
MaxBlockSpace: math.LegacyZeroDec(),
IgnoreList: []blockbuster.Lane{suite.tobLane},
}
suite.baseLane = base.NewDefaultLane(baseConfig)
// Mempool set up
suite.lanes = []blockbuster.Lane{suite.tobLane, suite.baseLane}
suite.mempool = blockbuster.NewMempool(suite.lanes...)
suite.mempool = blockbuster.NewMempool(log.NewTestLogger(suite.T()), suite.lanes...)
}
func (suite *AnteTestSuite) anteHandler(ctx sdk.Context, tx sdk.Tx, _ bool) (sdk.Context, error) {