Skip to content

Commit

Permalink
Merge pull request #5 from initia-labs/feat/eip-191
Browse files Browse the repository at this point in the history
feat: eip 191 with lane fixes
  • Loading branch information
beer-1 authored Dec 14, 2023
2 parents 7cc2de7 + c82d1a1 commit 5c4105e
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 952 deletions.
26 changes: 11 additions & 15 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,12 @@ import (
opchild "github.com/initia-labs/OPinit/x/opchild"
opchildkeeper "github.com/initia-labs/OPinit/x/opchild/keeper"
opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"
initialanes "github.com/initia-labs/initia/app/lanes"

mevabci "github.com/skip-mev/block-sdk/abci"
signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter"
"github.com/skip-mev/block-sdk/block"
blockbase "github.com/skip-mev/block-sdk/block/base"
baselane "github.com/skip-mev/block-sdk/lanes/base"
freelane "github.com/skip-mev/block-sdk/lanes/free"
mevlane "github.com/skip-mev/block-sdk/lanes/mev"
"github.com/skip-mev/block-sdk/x/auction"
auctionante "github.com/skip-mev/block-sdk/x/auction/ante"
Expand Down Expand Up @@ -740,9 +739,11 @@ func NewMinitiaApp(
MaxTxs: 0,
SignerExtractor: signerExtractor,
}
factor := mevlane.NewDefaultAuctionFactory(app.txConfig.TxDecoder(), signerExtractor)
mevLane := mevlane.NewMEVLane(
mevConfig,
mevlane.NewDefaultAuctionFactory(app.txConfig.TxDecoder(), signerExtractor),
factor,
factor.MatchHandler(),
)

freeConfig := blockbase.LaneConfig{
Expand All @@ -753,11 +754,7 @@ func NewMinitiaApp(
MaxTxs: 10,
SignerExtractor: signerExtractor,
}
freeLane := freelane.NewFreeLane(
freeConfig,
blockbase.DefaultTxPriority(),
applanes.FreeLaneMatchHandler(),
)
freeLane := initialanes.NewFreeLane(freeConfig, applanes.FreeLaneMatchHandler())

defaultLaneConfig := blockbase.LaneConfig{
Logger: app.Logger(),
Expand All @@ -767,16 +764,16 @@ func NewMinitiaApp(
MaxTxs: 0,
SignerExtractor: signerExtractor,
}
defaultLane := baselane.NewDefaultLane(defaultLaneConfig)
defaultLane := initialanes.NewDefaultLane(defaultLaneConfig)

lanes := []block.Lane{mevLane, freeLane, defaultLane}
mempool := block.NewLanedMempool(app.Logger(), true, lanes...)
app.SetMempool(mempool)
mempool, err := block.NewLanedMempool(app.Logger(), lanes)
if err != nil {
panic(err)
}

app.SetMempool(mempool)
anteHandler := app.setAnteHandler(mevLane, freeLane)
for _, lane := range lanes {
lane.SetAnteHandler(anteHandler)
}

// override the base-app's ABCI methods (CheckTx, PrepareProposal, ProcessProposal)
proposalHandlers := mevabci.NewProposalHandler(
Expand Down Expand Up @@ -842,7 +839,6 @@ func (app *MinitiaApp) setAnteHandler(
BankKeeper: app.BankKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
SignModeHandler: app.txConfig.SignModeHandler(),
SigGasConsumer: cosmosante.DefaultSigVerificationGasConsumer,
},
IBCkeeper: app.IBCKeeper,
Codec: app.appCodec,
Expand Down
10 changes: 6 additions & 4 deletions app/lanes/free.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@ package lanes
import (
sdk "github.com/cosmos/cosmos-sdk/types"

clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"

"github.com/skip-mev/block-sdk/block/base"
)

// FreeLaneMatchHandler returns the default match handler for the free lane. The
// default implementation matches transactions that are ibc related. In particular,
// any transaction that is a MsgTimeout, MsgAcknowledgement.
// any transaction that is a MsgUpdateClient, MsgTimeout, MsgAcknowledgement.
func FreeLaneMatchHandler() base.MatchHandler {
return func(ctx sdk.Context, tx sdk.Tx) bool {
for _, msg := range tx.GetMsgs() {
switch msg.(type) {
case *clienttypes.MsgUpdateClient:
case *channeltypes.MsgTimeout:
return true
case *channeltypes.MsgAcknowledgement:
return true
default:
return false
}
}

return false
return true
}
}
39 changes: 0 additions & 39 deletions app/params/config.go

This file was deleted.

2 changes: 1 addition & 1 deletion app/params/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func MakeEncodingConfig() EncodingConfig {
amino := codec.NewLegacyAmino()
interfaceRegistry := types.NewInterfaceRegistry()
marshaler := codec.NewProtoCodec(interfaceRegistry)
txCfg := NewTxConfig(marshaler, tx.DefaultSignModes)
txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes)

return EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Expand Down
Loading

0 comments on commit 5c4105e

Please sign in to comment.