Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: eip 191 with lane fixes #5

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 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 @@ -207,8 +206,6 @@ type MinitiaApp struct {
txConfig client.TxConfig
interfaceRegistry types.InterfaceRegistry

invCheckPeriod uint

// keys to access the substores
keys map[string]*storetypes.KVStoreKey
tkeys map[string]*storetypes.TransientStoreKey
Expand Down Expand Up @@ -732,9 +729,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 @@ -745,11 +744,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 @@ -759,16 +754,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 @@ -834,7 +829,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
14 changes: 7 additions & 7 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ func SetupWithGenesisAccounts(
) *MinitiaApp {
app, genesisState := setup(nil, true)

if len(genAccs) == 0 {
privAcc := secp256k1.GenPrivKey()
genAccs = []authtypes.GenesisAccount{
authtypes.NewBaseAccount(privAcc.PubKey().Address().Bytes(), privAcc.PubKey(), 0, 0),
}
}

// set genesis accounts
authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs)
genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis)
Expand All @@ -93,13 +100,6 @@ func SetupWithGenesisAccounts(
valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})
}

if genAccs == nil || len(genAccs) == 0 {
privAcc := secp256k1.GenPrivKey()
genAccs = []authtypes.GenesisAccount{
authtypes.NewBaseAccount(privAcc.PubKey().Address().Bytes(), privAcc.PubKey(), 0, 0),
}
}

validators := make([]opchildtypes.Validator, 0, len(valSet.Validators))

for _, val := range valSet.Validators {
Expand Down
Loading
Loading