Skip to content

Commit

Permalink
populate fields
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 committed Nov 1, 2023
1 parent 99059cd commit ec7e69a
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 60 deletions.
51 changes: 28 additions & 23 deletions abci/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
signeradaptors "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter"
"github.com/skip-mev/block-sdk/block"
"github.com/skip-mev/block-sdk/block/base"
baseblockmocks "github.com/skip-mev/block-sdk/block/base/mocks"
"github.com/skip-mev/block-sdk/block/proposals"
"github.com/skip-mev/block-sdk/block/proposals/types"
"github.com/skip-mev/block-sdk/block/utils"
Expand Down Expand Up @@ -58,50 +59,54 @@ func (s *ProposalsTestSuite) setUpAnteHandler(expectedExecution map[sdk.Tx]bool)

func (s *ProposalsTestSuite) setUpStandardLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *defaultlane.DefaultLane {
cfg := base.LaneConfig{
Logger: log.NewTestLogger(s.T()),
TxEncoder: s.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: s.encodingConfig.TxConfig.TxDecoder(),
AnteHandler: s.setUpAnteHandler(expectedExecution),
MaxBlockSpace: maxBlockSpace,
SignerExtractor: signeradaptors.NewDefaultAdapter(),
Logger: log.NewTestLogger(s.T()),
TxEncoder: s.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: s.encodingConfig.TxConfig.TxDecoder(),
AnteHandler: s.setUpAnteHandler(expectedExecution),
MaxBlockSpace: maxBlockSpace,
SignerExtractor: signeradaptors.NewDefaultAdapter(),
ModuleLaneFetcher: baseblockmocks.NewLaneFetcher(s.T()),
}

return defaultlane.NewDefaultLane(cfg)
}

func (s *ProposalsTestSuite) setUpTOBLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *mev.MEVLane {
cfg := base.LaneConfig{
Logger: log.NewTestLogger(s.T()),
TxEncoder: s.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: s.encodingConfig.TxConfig.TxDecoder(),
AnteHandler: s.setUpAnteHandler(expectedExecution),
MaxBlockSpace: maxBlockSpace,
SignerExtractor: signeradaptors.NewDefaultAdapter(),
Logger: log.NewTestLogger(s.T()),
TxEncoder: s.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: s.encodingConfig.TxConfig.TxDecoder(),
AnteHandler: s.setUpAnteHandler(expectedExecution),
MaxBlockSpace: maxBlockSpace,
SignerExtractor: signeradaptors.NewDefaultAdapter(),
ModuleLaneFetcher: baseblockmocks.NewLaneFetcher(s.T()),
}

return mev.NewMEVLane(cfg, mev.NewDefaultAuctionFactory(cfg.TxDecoder, signeradaptors.NewDefaultAdapter()))
}

func (s *ProposalsTestSuite) setUpFreeLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *free.FreeLane {
cfg := base.LaneConfig{
Logger: log.NewTestLogger(s.T()),
TxEncoder: s.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: s.encodingConfig.TxConfig.TxDecoder(),
AnteHandler: s.setUpAnteHandler(expectedExecution),
MaxBlockSpace: maxBlockSpace,
SignerExtractor: signeradaptors.NewDefaultAdapter(),
Logger: log.NewTestLogger(s.T()),
TxEncoder: s.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: s.encodingConfig.TxConfig.TxDecoder(),
AnteHandler: s.setUpAnteHandler(expectedExecution),
MaxBlockSpace: maxBlockSpace,
SignerExtractor: signeradaptors.NewDefaultAdapter(),
ModuleLaneFetcher: baseblockmocks.NewLaneFetcher(s.T()),
}

return free.NewFreeLane(cfg, base.DefaultTxPriority(), free.DefaultMatchHandler())
}

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,
SignerExtractor: signeradaptors.NewDefaultAdapter(),
Logger: log.NewTestLogger(s.T()),
TxEncoder: s.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: s.encodingConfig.TxConfig.TxDecoder(),
MaxBlockSpace: maxBlockSpace,
SignerExtractor: signeradaptors.NewDefaultAdapter(),
ModuleLaneFetcher: baseblockmocks.NewLaneFetcher(s.T()),
}

lane := base.NewBaseLane(
Expand Down
4 changes: 4 additions & 0 deletions block/base/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,9 @@ func (c *LaneConfig) ValidateBasic() error {
return fmt.Errorf("max block space must be set to a value between 0 and 1")
}

if c.ModuleLaneFetcher == nil {
return fmt.Errorf("module lane fetcher must be set")
}

return nil
}
42 changes: 23 additions & 19 deletions block/mempool_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package block_test

import (
baseblockmocks "github.com/skip-mev/block-sdk/block/base/mocks"

Check failure on line 4 in block/mempool_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)
"math/rand"
"testing"
"time"
Expand Down Expand Up @@ -29,7 +30,7 @@ type BlockBusterTestSuite struct {
// Define basic tx configuration
encodingConfig testutils.EncodingConfig

// Define all of the lanes utilized in the test suite
// Define all the lanes utilized in the test suite
mevLane *mev.MEVLane
baseLane *defaultlane.DefaultLane
freeLane *free.FreeLane
Expand Down Expand Up @@ -61,12 +62,13 @@ func (suite *BlockBusterTestSuite) SetupTest() {
// TOB lane set up
suite.gasTokenDenom = "stake"
mevConfig := base.LaneConfig{
Logger: log.NewNopLogger(),
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
SignerExtractor: signer_extraction.NewDefaultAdapter(),
AnteHandler: nil,
MaxBlockSpace: math.LegacyZeroDec(),
Logger: log.NewNopLogger(),
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
SignerExtractor: signer_extraction.NewDefaultAdapter(),
AnteHandler: nil,
MaxBlockSpace: math.LegacyZeroDec(),
ModuleLaneFetcher: baseblockmocks.NewLaneFetcher(suite.T()),
}
suite.mevLane = mev.NewMEVLane(
mevConfig,
Expand All @@ -75,12 +77,13 @@ func (suite *BlockBusterTestSuite) SetupTest() {

// Free lane set up
freeConfig := base.LaneConfig{
Logger: log.NewNopLogger(),
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
SignerExtractor: signer_extraction.NewDefaultAdapter(),
AnteHandler: nil,
MaxBlockSpace: math.LegacyZeroDec(),
Logger: log.NewNopLogger(),
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
SignerExtractor: signer_extraction.NewDefaultAdapter(),
AnteHandler: nil,
MaxBlockSpace: math.LegacyZeroDec(),
ModuleLaneFetcher: baseblockmocks.NewLaneFetcher(suite.T()),
}
suite.freeLane = free.NewFreeLane(
freeConfig,
Expand All @@ -90,12 +93,13 @@ func (suite *BlockBusterTestSuite) SetupTest() {

// Base lane set up
baseConfig := base.LaneConfig{
Logger: log.NewNopLogger(),
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
SignerExtractor: signer_extraction.NewDefaultAdapter(),
AnteHandler: nil,
MaxBlockSpace: math.LegacyZeroDec(),
Logger: log.NewNopLogger(),
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
SignerExtractor: signer_extraction.NewDefaultAdapter(),
AnteHandler: nil,
MaxBlockSpace: math.LegacyZeroDec(),
ModuleLaneFetcher: baseblockmocks.NewLaneFetcher(suite.T()),
}
suite.baseLane = defaultlane.NewDefaultLane(
baseConfig,
Expand Down
1 change: 1 addition & 0 deletions lanes/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func NewApp() {
TxDecoder: app.txConfig.TxDecoder(),
MaxBlockSpace: math.LegacyZeroDec(),
MaxTxs: 0,
ModuleLaneFetcher: app.blocksdkKeeper,
}
defaultLane := defaultlane.NewDefaultLane(defaultConfig)

Expand Down
1 change: 1 addition & 0 deletions lanes/build-your-own/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ config := base.LaneConfig{
MaxTxs: 0,
MaxBlockSpace: math.LegacyZeroDec(),
IgnoreList: []block.Lane{},
ModuleLaneFetcher: app.blocksdkKeeper,
}
```

Expand Down
2 changes: 2 additions & 0 deletions lanes/free/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func NewApp() {
TxDecoder: app.txConfig.TxDecoder(),
MaxBlockSpace: math.LegacyZeroDec(),
MaxTxs: 0,
ModuleLaneFetcher: app.blocksdkKeeper,
}
freeLane := freelane.NewFreeLane(freeConfig, base.DefaultTxPriority(), freelane.DefaultMatchHandler())

Expand All @@ -80,6 +81,7 @@ func NewApp() {
TxDecoder: app.txConfig.TxDecoder(),
MaxBlockSpace: math.LegacyZeroDec(),
MaxTxs: 0,
ModuleLaneFetcher: app.blocksdkKeeper,
}
defaultLane := defaultlane.NewDefaultLane(defaultConfig)

Expand Down
2 changes: 2 additions & 0 deletions lanes/mev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ NOTE: This example walks through setting up the MEV and Default lanes.
TxDecoder: app.txConfig.TxDecoder(),
MaxBlockSpace: math.LegacyZeroDec(),
MaxTxs: 0,
ModuleLaneFetcher: app.blocksdkKeeper,
}
mevLane := mev.NewMEVLane(
mevConfig,
Expand All @@ -143,6 +144,7 @@ NOTE: This example walks through setting up the MEV and Default lanes.
TxDecoder: app.txConfig.TxDecoder(),
MaxBlockSpace: math.LegacyZeroDec(),
MaxTxs: 0,
ModuleLaneFetcher: app.blocksdkKeeper,
}
defaultLane := base.NewStandardLane(defaultConfig)
Expand Down
39 changes: 21 additions & 18 deletions tests/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,13 @@ func New(
// lane and the last lane is the lowest priority lane.
// MEV lane allows transactions to bid for inclusion at the top of the next block.
mevConfig := base.LaneConfig{
Logger: app.Logger(),
TxEncoder: app.txConfig.TxEncoder(),
TxDecoder: app.txConfig.TxDecoder(),
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.2"),
SignerExtractor: signer_extraction.NewDefaultAdapter(),
MaxTxs: 1000,
Logger: app.Logger(),
TxEncoder: app.txConfig.TxEncoder(),
TxDecoder: app.txConfig.TxDecoder(),
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.2"),
SignerExtractor: signer_extraction.NewDefaultAdapter(),
MaxTxs: 1000,
ModuleLaneFetcher: app.blocksdkKeeper,
}
mevLane := mev.NewMEVLane(
mevConfig,
Expand All @@ -285,12 +286,13 @@ func New(

// Free lane allows transactions to be included in the next block for free.
freeConfig := base.LaneConfig{
Logger: app.Logger(),
TxEncoder: app.txConfig.TxEncoder(),
TxDecoder: app.txConfig.TxDecoder(),
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.2"),
SignerExtractor: signer_extraction.NewDefaultAdapter(),
MaxTxs: 1000,
Logger: app.Logger(),
TxEncoder: app.txConfig.TxEncoder(),
TxDecoder: app.txConfig.TxDecoder(),
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.2"),
SignerExtractor: signer_extraction.NewDefaultAdapter(),
MaxTxs: 1000,
ModuleLaneFetcher: app.blocksdkKeeper,
}
freeLane := free.NewFreeLane(
freeConfig,
Expand All @@ -300,12 +302,13 @@ func New(

// Default lane accepts all other transactions.
defaultConfig := base.LaneConfig{
Logger: app.Logger(),
TxEncoder: app.txConfig.TxEncoder(),
TxDecoder: app.txConfig.TxDecoder(),
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.6"),
SignerExtractor: signer_extraction.NewDefaultAdapter(),
MaxTxs: 1000,
Logger: app.Logger(),
TxEncoder: app.txConfig.TxEncoder(),
TxDecoder: app.txConfig.TxDecoder(),
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.6"),
SignerExtractor: signer_extraction.NewDefaultAdapter(),
MaxTxs: 1000,
ModuleLaneFetcher: app.blocksdkKeeper,
}
defaultLane := defaultlane.NewDefaultLane(defaultConfig)

Expand Down

0 comments on commit ec7e69a

Please sign in to comment.