Skip to content

Commit

Permalink
eh ig we dont need it rn
Browse files Browse the repository at this point in the history
  • Loading branch information
davidterpay committed Nov 28, 2023
1 parent 397e6bf commit 99eb742
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 35 deletions.
14 changes: 9 additions & 5 deletions tests/app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ Following the example above:

### Match Handlers

Match handlers are responsible for matching transactions to lanes. Each lane should have a unique match handler. We want each lane to be mutually exclusive, so we create a match handler that matches transactions that belong in the lane and do not match with any of the other lanes.
Match handlers are responsible for matching transactions to lanes. Each lane should have a unique match handler. By default, we recommend that the default lane be the last lane in your application. This is because the default lane matches all transactions that do not match to any of the other lanes. If you want to have a lane after the default lane, please see the section below.

For example, the default match handler provided by the Block SDK matches all transactions to the lane. However, if we want to ignore transactions that would match to the `MEV` and `Free` lanes, we utilize `base.NewMatchHandler`. This allows us to input our match handler and all other match handlers we want to ignore.
#### (OPTIONAL) Having Lanes after the Default Lane

If you want to have lanes after the default lane, you will need to utilize the `base.NewMatchHandler` function. This function allows you to construct a match handler that can ignore other lane's match handlers.

For example, if we wanted the free and MEV lanes to be processed after the default lane - default, MEV, free - we can do the following:

```go
// Create the final match handler for the default lane.
Expand All @@ -68,17 +72,17 @@ defaultMatchHandler := base.NewMatchHandler(
)
```

Following the example seen in `lanes.go`, we can see the following:
Following the example, we can see the following:

* `base.DefaultMatchHandler()`: This is the default match handler provided by the Block SDK. This matches all transactions to the lane.
* `factory.MatchHandler()`: This is the MEV lane's match handler. This is passed as a parameter to the `base.NewMatchHandler` function - which means that all transactions that match to the MEV lane will be ignored by the default match handler.
* `freelane.DefaultMatchHandler()`: This is the default match handler for the free lane. This is passed as a parameter to the `base.NewMatchHandler` function - which means that all transactions that match to the free lane will be ignored by the default match handler.

**This will allow the default match handler to only match transactions that do not match to the MEV lane or the free lane.**

### Laned Mempool
### Block SDK Mempool

After constructing the lanes, we can create the Block SDK mempool. This object is responsible for managing the lanes and processing transactions.
After constructing the lanes, we can create the Block SDK mempool - `LanedMempool`. This object is responsible for managing the lanes and processing transactions.

```go
// STEP 1: Create the Block SDK lanes.
Expand Down
12 changes: 6 additions & 6 deletions tests/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ func New(
// ---------------------------------------------------------------------------- //
// ------------------------- Begin Custom Code -------------------------------- //
// ---------------------------------------------------------------------------- //
// STEP 1: Create the Block SDK lanes.
// STEP 1-3: Create the Block SDK lanes.
mevLane, freeLane, defaultLane := CreateLanes(app)

// STEP 2: Construct a mempool based off the lanes. Note that the order of the lanes
// STEP 4: Construct a mempool based off the lanes. Note that the order of the lanes
// matters. Blocks are constructed from the top lane to the bottom lane. The top lane
// is the first lane in the array and the bottom lane is the last lane in the array.
mempool, err := block.NewLanedMempool(
Expand All @@ -223,10 +223,10 @@ func New(
panic(err)
}

// STEP 3: Set the mempool on the app. The application is now powered by the Block SDK!
// The application's mempool is now powered by the Block SDK!
app.App.SetMempool(mempool)

// STEP 4: Create a global ante handler that will be called on each transaction when
// STEP 5: Create a global ante handler that will be called on each transaction when
// proposals are being built and verified. Note that this step must be done before
// setting the ante handler on the lanes.
handlerOptions := ante.HandlerOptions{
Expand All @@ -252,7 +252,7 @@ func New(
freeLane.SetAnteHandler(anteHandler)
defaultLane.SetAnteHandler(anteHandler)

// Step 5: Create the proposal handler and set it on the app. Now the application
// Step 6: Create the proposal handler and set it on the app. Now the application
// will build and verify proposals using the Block SDK!
proposalHandler := abci.NewProposalHandler(
app.Logger(),
Expand All @@ -263,7 +263,7 @@ func New(
app.App.SetPrepareProposal(proposalHandler.PrepareProposalHandler())
app.App.SetProcessProposal(proposalHandler.ProcessProposalHandler())

// Step 6: Set the custom CheckTx handler on BaseApp. This is only required if you
// Step 7: Set the custom CheckTx handler on BaseApp. This is only required if you
// use the MEV lane.
checkTxHandler := mev.NewCheckTxHandler(
app.App,
Expand Down
29 changes: 5 additions & 24 deletions tests/app/lanes.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,17 @@ func CreateLanes(app *TestApp) (*mevlane.MEVLane, *freelane.FreeLane, *defaultla
}

// 3. Create the match handlers for each lane. These match handlers determine whether or not
// a transaction belongs in the lane. We want each lane to be mutually exclusive, so we create
// a match handler that matches transactions that belong in the lane and do not match with any
// of the other lanes. The outcome of this looks like the following:
// - MEV Lane: Matches transactions that belong in the MEV lane and do not match the free lane
// transactions. We do not consider the default lane transactions as this accepts all transactions
// and would always return false.
// - Free Lane: Matches transactions that belong in the free lane and do not match the MEV lane
// transactions.
// - Default Lane: Matches transactions that belong in the default lane and do not match the MEV
// or free lane.
factory := mevlane.NewDefaultAuctionFactory(app.txConfig.TxDecoder(), signerAdapter)
// a transaction belongs in the lane.

// Create the final match handler for the mev lane.
mevMatchHandler := base.NewMatchHandler(
factory.MatchHandler(),
freelane.DefaultMatchHandler(),
)
factory := mevlane.NewDefaultAuctionFactory(app.txConfig.TxDecoder(), signerAdapter)
mevMatchHandler := factory.MatchHandler()

// Create the final match handler for the free lane.
freeMatchHandler := base.NewMatchHandler(
freelane.DefaultMatchHandler(),
factory.MatchHandler(),
)
freeMatchHandler := freelane.DefaultMatchHandler()

// Create the final match handler for the default lane.
defaultMatchHandler := base.NewMatchHandler(
base.DefaultMatchHandler(),
factory.MatchHandler(),
freelane.DefaultMatchHandler(),
)
defaultMatchHandler := base.DefaultMatchHandler()

// 4. Create the lanes.
mevLane := mevlane.NewMEVLane(
Expand Down

0 comments on commit 99eb742

Please sign in to comment.