This commit is contained in:
David Terpay 2023-08-16 11:09:54 -04:00
parent 8c5353950a
commit fe172ffba3
No known key found for this signature in database
GPG Key ID: 627EFB00DADF0CD1
10 changed files with 48 additions and 52 deletions

View File

@ -20,9 +20,9 @@ Skip has built out a number of plug-and-play `lanes` on the SDK that your protoc
Most Cosmos chains today utilize standard `CometBFT` block construction - which is too limited.
- The standard `CometBFT` block building is susceptible to MEV-related issues, such as front-running and sandwich attacks, since proposers have monopolistic rights on ordering and no verification of good behavior. MEV that is created cannot be redistributed to the protocol.
- The standard `CometBFT` block building uses a one-size-fits-all approach, which can result in inefficient transaction processing for specific applications or use cases and sub-optimal fee markets.
- Transactions tailored for specific applications may need custom prioritization, ordering or validation rules that the mempool is otherwise unaware of because transactions within a block are currently in-differentiable when a blockchain might want them to be.
* The standard `CometBFT` block building is susceptible to MEV-related issues, such as front-running and sandwich attacks, since proposers have monopolistic rights on ordering and no verification of good behavior. MEV that is created cannot be redistributed to the protocol.
* The standard `CometBFT` block building uses a one-size-fits-all approach, which can result in inefficient transaction processing for specific applications or use cases and sub-optimal fee markets.
* Transactions tailored for specific applications may need custom prioritization, ordering or validation rules that the mempool is otherwise unaware of because transactions within a block are currently in-differentiable when a blockchain might want them to be.
### ✅ Solution: The Block SDK
@ -57,12 +57,12 @@ A block with separate `lanes` can be used for:
#### Lane App Store
To read more about Skip's pre-built `lanes` and how to use them, check out the [Lane App Store]().
To read more about Skip's pre-built `lanes` and how to use them, check out the [Lane App Store](https://docs.skip.money/chains/lanes/existing-lanes/default).
#### How the Block SDK works
To read more about how the Block SDK works, check out the [How it Works]().
To read more about how the Block SDK works, check out the [How it Works](https://docs.skip.money/chains/how-it-works).
#### Lane Development
To read more about how to build your own custom `lanes`, check out the [Build Your Own Lane]().
To read more about how to build your own custom `lanes`, check out the [Build Your Own Lane](https://docs.skip.money/chains/lanes/build-your-own-lane).

View File

@ -16,9 +16,9 @@ import (
"github.com/skip-mev/pob/abci"
"github.com/skip-mev/pob/block"
"github.com/skip-mev/pob/block/base"
defaultlane "github.com/skip-mev/pob/lanes/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"
)
@ -724,7 +724,7 @@ func (s *ProposalsTestSuite) setUpAnteHandler(expectedExecution map[sdk.Tx]bool)
return anteHandler
}
func (s *ProposalsTestSuite) setUpStandardLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *standard.StandardLane {
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(),
@ -733,7 +733,7 @@ func (s *ProposalsTestSuite) setUpStandardLane(maxBlockSpace math.LegacyDec, exp
MaxBlockSpace: maxBlockSpace,
}
return standard.NewStandardLane(cfg)
return defaultlane.NewDefaultLane(cfg)
}
func (s *ProposalsTestSuite) setUpTOBLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *mev.MEVLane {

View File

@ -12,9 +12,9 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/skip-mev/pob/block"
"github.com/skip-mev/pob/block/base"
defaultlane "github.com/skip-mev/pob/lanes/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 *standard.StandardLane
baseLane *defaultlane.DefaultLane
freeLane *free.FreeLane
gasTokenDenom string
@ -92,7 +92,7 @@ func (suite *BlockBusterTestSuite) SetupTest() {
AnteHandler: nil,
MaxBlockSpace: math.LegacyZeroDec(),
}
suite.baseLane = standard.NewStandardLane(
suite.baseLane = defaultlane.NewDefaultLane(
baseConfig,
)

View File

@ -1,22 +1,14 @@
# Standard Lane
# Default Lane
> The Standard Lane is the most general and least restrictive lane. The Standard
> The Default Lane is the most general and least restrictive lane. The Default
> Lane accepts all transactions that are not accepted by the other lanes, is
> generally the lowest priority lane, and consumes all blockspace that is not
> consumed by the other lanes.
## 📖 Overview
Blockspace is valuable, and MEV bots find arbitrage opportunities to capture
value. The Block SDK provides a fair auction for these opportunities via the
x/auction module inside the Block SDK so that protocols are rewarded while
ensuring that users are not front-run or sandwiched in the process.
The Block SDK uses the app-side mempool, PrepareLane / ProcessLane, and CheckTx
to create an MEV marketplace inside the protocol. It introduces a new message
type, called a MsgAuctionBid, that allows the submitter to execute multiple
transactions at the top of the block atomically
(atomically = directly next to each other).
The default lane should be used to accept all transactions that are not accepted
by the other lanes.
## 🏗️ Setup
@ -46,17 +38,21 @@ your base application, you will need to create a `LanedMempool` composed of the
lanes that you want to use.
2. Next, order the lanes by priority. The first lane is the highest priority lane
and the last lane is the lowest priority lane. **It is recommended that the last
lane is the standard lane.**
lane is the default lane.**
3. You will also need to create a `PrepareProposalHandler` and a
`ProcessProposalHandler` that will be responsible for preparing and processing
proposals respectively. Configure the order of the lanes in the
`PrepareProposalHandler` and `ProcessProposalHandler` to match the order of the
lanes in the `LanedMempool`.
NOTE: This example walks through setting up the MEV, Free, and Default Lanes. To
only utilize the default lane, ignore the MEV and Free Lane setup.
```golang
import (
"github.com/skip-mev/block-sdk/abci"
"github.com/skip-mev/block-sdk/lanes/standard"
"github.com/skip-mev/block-sdk/block/base"
defaultlane "github.com/skip-mev/block-sdk/lanes/base"
)
...
@ -75,7 +71,7 @@ func NewApp() {
// visit the README in block-sdk/block/base.
//
// MEV lane hosts an action at the top of the block.
mevConfig := constructor.LaneConfig{
mevConfig := base.LaneConfig{
Logger: app.Logger(),
TxEncoder: app.txConfig.TxEncoder(),
TxDecoder: app.txConfig.TxDecoder(),
@ -88,7 +84,7 @@ func NewApp() {
)
// 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(),
@ -97,19 +93,19 @@ func NewApp() {
}
freeLane := free.NewFreeLane(
freeConfig,
constructor.DefaultTxPriority(),
base.DefaultTxPriority(),
free.DefaultMatchHandler(),
)
// Standard lane accepts all other transactions.
defaultConfig := constructor.LaneConfig{
// Default lane accepts all other transactions.
defaultConfig := base.LaneConfig{
Logger: app.Logger(),
TxEncoder: app.txConfig.TxEncoder(),
TxDecoder: app.txConfig.TxDecoder(),
MaxBlockSpace: math.LegacyZeroDec(),
MaxTxs: 0,
}
defaultLane := base.NewStandardLane(defaultConfig)
defaultLane := defaultlane.NewDefaultLane(defaultConfig)
// 2. Set up the relateive priority of lanes
lanes := []block.Lane{
@ -126,7 +122,7 @@ func NewApp() {
anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(),
...
utils.NewIgnoreDecorator(
utils.NewIgnoreDecorator( // free lane specific set up
ante.NewDeductFeeDecorator(
options.BaseOptions.AccountKeeper,
options.BaseOptions.BankKeeper,

View File

@ -1,4 +1,4 @@
package standard_test
package base_test
import (
"crypto/sha256"
@ -11,7 +11,7 @@ import (
"github.com/skip-mev/pob/block"
"github.com/skip-mev/pob/block/base"
"github.com/skip-mev/pob/block/utils/mocks"
"github.com/skip-mev/pob/lanes/standard"
defaultlane "github.com/skip-mev/pob/lanes/base"
testutils "github.com/skip-mev/pob/testutils"
)
@ -502,7 +502,7 @@ func (s *BaseTestSuite) TestCheckOrder() {
func (s *BaseTestSuite) initLane(
maxBlockSpace math.LegacyDec,
expectedExecution map[sdk.Tx]bool,
) *standard.StandardLane {
) *defaultlane.DefaultLane {
config := base.NewLaneConfig(
log.NewTestLogger(s.T()),
s.encodingConfig.TxConfig.TxEncoder(),
@ -511,7 +511,7 @@ func (s *BaseTestSuite) initLane(
maxBlockSpace,
)
return standard.NewStandardLane(config)
return defaultlane.NewDefaultLane(config)
}
func (s *BaseTestSuite) setUpAnteHandler(expectedExecution map[sdk.Tx]bool) sdk.AnteHandler {

View File

@ -1,4 +1,4 @@
package standard_test
package base_test
import (
"math/rand"

View File

@ -1,4 +1,4 @@
package standard
package base
import (
"github.com/skip-mev/pob/block"
@ -10,20 +10,20 @@ const (
LaneName = "default"
)
var _ block.Lane = (*StandardLane)(nil)
var _ block.Lane = (*DefaultLane)(nil)
// StandardLane defines a default lane implementation. The standard lane orders
// DefaultLane defines a default lane implementation. The default 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 similar fashion to how the
// CometBFT/Tendermint consensus engine builds and verifies blocks pre SDK version
// 0.47.0.
type StandardLane struct { //nolint
type DefaultLane struct { //nolint
*base.BaseLane
}
// NewStandardLane returns a new default lane.
func NewStandardLane(cfg base.LaneConfig) *StandardLane {
func NewDefaultLane(cfg base.LaneConfig) *DefaultLane {
lane := base.NewBaseLane(
cfg,
LaneName,
@ -35,7 +35,7 @@ func NewStandardLane(cfg base.LaneConfig) *StandardLane {
base.DefaultMatchHandler(),
)
return &StandardLane{
return &DefaultLane{
BaseLane: lane,
}
}

View File

@ -1,4 +1,4 @@
package standard_test
package base_test
import (
"cosmossdk.io/math"

View File

@ -64,9 +64,9 @@ import (
"github.com/skip-mev/pob/abci"
"github.com/skip-mev/pob/block"
"github.com/skip-mev/pob/block/base"
defaultlane "github.com/skip-mev/pob/lanes/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"
)
@ -297,7 +297,7 @@ func New(
MaxBlockSpace: math.LegacyZeroDec(),
MaxTxs: 0,
}
defaultLane := standard.NewStandardLane(defaultConfig)
defaultLane := defaultlane.NewDefaultLane(defaultConfig)
// Set the lanes into the mempool.
lanes := []block.Lane{

View File

@ -13,8 +13,8 @@ import (
"github.com/golang/mock/gomock"
"github.com/skip-mev/pob/block"
"github.com/skip-mev/pob/block/base"
defaultlane "github.com/skip-mev/pob/lanes/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 *standard.StandardLane
baseLane *defaultlane.DefaultLane
lanes []block.Lane
// Account set up
@ -105,7 +105,7 @@ func (suite *AnteTestSuite) SetupTest() {
MaxBlockSpace: math.LegacyZeroDec(),
IgnoreList: []block.Lane{suite.mevLane},
}
suite.baseLane = standard.NewStandardLane(baseConfig)
suite.baseLane = defaultlane.NewDefaultLane(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[standard.LaneName])
suite.Require().Equal(0, distribution[defaultlane.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[standard.LaneName])
suite.Require().Equal(0, distribution[defaultlane.LaneName])
}
// Create the actual mev tx and insert into the mempool