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(app/block-sdk): Implement v25 upgrade handler #7935

Closed
Closed
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"OSMOSIS_E2E_SKIP_UPGRADE": "false",
"OSMOSIS_E2E_SKIP_CLEANUP": "true",
"OSMOSIS_E2E_SKIP_STATE_SYNC": "true",
"OSMOSIS_E2E_UPGRADE_VERSION": "v24",
"OSMOSIS_E2E_UPGRADE_VERSION": "v25",
"OSMOSIS_E2E_DEBUG_LOG": "false",
},
"preLaunchTask": "e2e-setup"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ LEDGER_ENABLED ?= true
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
BUILDDIR ?= $(CURDIR)/build
DOCKER := $(shell which docker)
E2E_UPGRADE_VERSION := "v24"
E2E_UPGRADE_VERSION := "v25"
#SHELL := /bin/bash

# Go version to be used in docker images
Expand Down
25 changes: 24 additions & 1 deletion app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
"github.com/skip-mev/block-sdk/block"

"github.com/cosmos/cosmos-sdk/client"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
ante "github.com/cosmos/cosmos-sdk/x/auth/ante"
Expand All @@ -21,8 +23,19 @@ import (

txfeeskeeper "github.com/osmosis-labs/osmosis/v24/x/txfees/keeper"
txfeestypes "github.com/osmosis-labs/osmosis/v24/x/txfees/types"
auctionkeeper "github.com/skip-mev/block-sdk/x/auction/keeper"

auctionante "github.com/skip-mev/block-sdk/x/auction/ante"
)

// BlockSDKAnteHandlerParams are the parameters necessary to configure the block-sdk antehandlers
type BlockSDKAnteHandlerParams struct {
freeLane block.Lane
mevLane auctionante.MEVLane
auctionKeeper auctionkeeper.Keeper
txConfig client.TxConfig
}

// Link to default ante handler used by cosmos sdk:
// https://github.com/cosmos/cosmos-sdk/blob/v0.43.0/x/auth/ante/ante.go#L41
// N.B. There is a sister file called `ante_no_seq.go` that is used for e2e testing.
Expand All @@ -39,6 +52,7 @@ func NewAnteHandler(
sigGasConsumer ante.SignatureVerificationGasConsumer,
signModeHandler signing.SignModeHandler,
channelKeeper *ibckeeper.Keeper,
blockSDKParams BlockSDKAnteHandlerParams,
) sdk.AnteHandler {
mempoolFeeOptions := txfeestypes.NewMempoolFeeOptions(appOpts)
mempoolFeeDecorator := txfeeskeeper.NewMempoolFeeDecorator(*txFeesKeeper, mempoolFeeOptions)
Expand All @@ -59,12 +73,21 @@ func NewAnteHandler(
ante.TxTimeoutHeightDecorator{},
ante.NewValidateMemoDecorator(ak),
ante.NewConsumeGasForTxSizeDecorator(ak),
deductFeeDecorator,
block.NewIgnoreDecorator(
deductFeeDecorator,
blockSDKParams.freeLane,
),
ante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(ak),
ante.NewSigGasConsumeDecorator(ak, sigGasConsumer),
ante.NewSigVerificationDecorator(ak, signModeHandler),
ante.NewIncrementSequenceDecorator(ak),
ibcante.NewRedundantRelayDecorator(channelKeeper),
// auction module antehandler
auctionante.NewAuctionDecorator(
blockSDKParams.auctionKeeper,
blockSDKParams.txConfig.TxEncoder(),
blockSDKParams.mevLane,
),
)
}
34 changes: 30 additions & 4 deletions app/ante_no_seq.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
"github.com/skip-mev/block-sdk/block"

"github.com/cosmos/cosmos-sdk/client"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
ante "github.com/cosmos/cosmos-sdk/x/auth/ante"
Expand All @@ -21,12 +23,26 @@ import (

txfeeskeeper "github.com/osmosis-labs/osmosis/v24/x/txfees/keeper"
txfeestypes "github.com/osmosis-labs/osmosis/v24/x/txfees/types"
auctionkeeper "github.com/skip-mev/block-sdk/x/auction/keeper"

auctionante "github.com/skip-mev/block-sdk/x/auction/ante"

txfeeskeeper "github.com/osmosis-labs/osmosis/v22/x/txfees/keeper"
txfeestypes "github.com/osmosis-labs/osmosis/v22/x/txfees/types"
)

// BlockSDKAnteHandlerParams are the parameters necessary to configure the block-sdk antehandlers
type BlockSDKAnteHandlerParams struct {
freeLane block.Lane
mevLane auctionante.MEVLane
auctionKeeper auctionkeeper.Keeper
txConfig client.TxConfig
}

// Link to default ante handler used by cosmos sdk:
// https://github.com/cosmos/cosmos-sdk/blob/v0.43.0/x/auth/ante/ante.go#L41
// N.B. There is a sister file called `ante_eq.go` that is used for production.
// Opposite to this, it also chains `IncrementSequenceDecorator` which is not needed for e2e testing but is critical for production.
// Opposite to this, it also chains `SigVerificationDecorator` which is not needed for e2e testing but is critical for production.
// If you make a change here, make sure to make the same change in `ante.go`.
func NewAnteHandler(
appOpts servertypes.AppOptions,
Expand All @@ -39,6 +55,7 @@ func NewAnteHandler(
sigGasConsumer ante.SignatureVerificationGasConsumer,
signModeHandler signing.SignModeHandler,
channelKeeper *ibckeeper.Keeper,
blockSDKParams BlockSDKAnteHandlerParams,
) sdk.AnteHandler {
mempoolFeeOptions := txfeestypes.NewMempoolFeeOptions(appOpts)
mempoolFeeDecorator := txfeeskeeper.NewMempoolFeeDecorator(*txFeesKeeper, mempoolFeeOptions)
Expand All @@ -59,12 +76,21 @@ func NewAnteHandler(
ante.TxTimeoutHeightDecorator{},
ante.NewValidateMemoDecorator(ak),
ante.NewConsumeGasForTxSizeDecorator(ak),
deductFeeDecorator,
block.NewIgnoreDecorator(
deductFeeDecorator,
blockSDKParams.freeLane,
),
ante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(ak),
ante.NewSigGasConsumeDecorator(ak, sigGasConsumer),
ante.NewSigVerificationDecorator(ak, signModeHandler),
// ante.NewIncrementSequenceDecorator(ak),
// ante.NewSigVerificationDecorator(ak, signModeHandler) <-- removed this to prevent failures resulting from invalid tx orders in e2e
ante.NewIncrementSequenceDecorator(ak),
ibcante.NewRedundantRelayDecorator(channelKeeper),
// auction module antehandler
auctionante.NewAuctionDecorator(
blockSDKParams.auctionKeeper,
blockSDKParams.txConfig.TxEncoder(),
blockSDKParams.mevLane,
),
)
}
88 changes: 87 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"time"

wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/skip-mev/block-sdk/block"
"github.com/skip-mev/block-sdk/block/base"
PaddyMc marked this conversation as resolved.
Show resolved Hide resolved

"github.com/cosmos/cosmos-sdk/x/auth"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
Expand Down Expand Up @@ -107,6 +109,7 @@ import (
v22 "github.com/osmosis-labs/osmosis/v24/app/upgrades/v22"
v23 "github.com/osmosis-labs/osmosis/v24/app/upgrades/v23"
v24 "github.com/osmosis-labs/osmosis/v24/app/upgrades/v24"
v25 "github.com/osmosis-labs/osmosis/v24/app/upgrades/v25"
PaddyMc marked this conversation as resolved.
Show resolved Hide resolved
v3 "github.com/osmosis-labs/osmosis/v24/app/upgrades/v3"
v4 "github.com/osmosis-labs/osmosis/v24/app/upgrades/v4"
v5 "github.com/osmosis-labs/osmosis/v24/app/upgrades/v5"
Expand All @@ -116,6 +119,9 @@ import (
v9 "github.com/osmosis-labs/osmosis/v24/app/upgrades/v9"
_ "github.com/osmosis-labs/osmosis/v24/client/docs/statik"
"github.com/osmosis-labs/osmosis/v24/x/mint"

blocksdkabci "github.com/skip-mev/block-sdk/abci"
"github.com/skip-mev/block-sdk/abci/checktx"
PaddyMc marked this conversation as resolved.
Show resolved Hide resolved
)

const appName = "OsmosisApp"
Expand Down Expand Up @@ -153,7 +159,7 @@ var (

_ runtime.AppI = (*OsmosisApp)(nil)

Upgrades = []upgrades.Upgrade{v4.Upgrade, v5.Upgrade, v7.Upgrade, v9.Upgrade, v11.Upgrade, v12.Upgrade, v13.Upgrade, v14.Upgrade, v15.Upgrade, v16.Upgrade, v17.Upgrade, v18.Upgrade, v19.Upgrade, v20.Upgrade, v21.Upgrade, v22.Upgrade, v23.Upgrade, v24.Upgrade}
Upgrades = []upgrades.Upgrade{v4.Upgrade, v5.Upgrade, v7.Upgrade, v9.Upgrade, v11.Upgrade, v12.Upgrade, v13.Upgrade, v14.Upgrade, v15.Upgrade, v16.Upgrade, v17.Upgrade, v18.Upgrade, v19.Upgrade, v20.Upgrade, v21.Upgrade, v22.Upgrade, v23.Upgrade, v24.Upgrade, v25.Upgrade}
Forks = []upgrades.Fork{v3.Fork, v6.Fork, v8.Fork, v10.Fork}

// rpcAddressConfigName is the name of the config key that holds the RPC address.
Expand All @@ -176,6 +182,8 @@ type OsmosisApp struct {
sm *module.SimulationManager
configurator module.Configurator
homePath string

checkTxHandler checktx.CheckTx
PaddyMc marked this conversation as resolved.
Show resolved Hide resolved
}

// init sets DefaultNodeHome to default osmosisd install location.
Expand Down Expand Up @@ -392,6 +400,20 @@ func NewOsmosisApp(

app.sm.RegisterStoreDecoders()

// initialize lanes + mempool
mevLane, freeLane, defaultLane := CreateLanes(app, txConfig)

// create the mempool
lanedMempool, err := block.NewLanedMempool(
app.Logger(),
[]block.Lane{mevLane, freeLane, defaultLane},
)
if err != nil {
panic(err)
}
// set the mempool
app.SetMempool(lanedMempool)
PaddyMc marked this conversation as resolved.
Show resolved Hide resolved

// initialize stores
app.MountKVStores(app.GetKVStoreKey())
app.MountTransientStores(app.GetTransientStoreKey())
Expand All @@ -408,8 +430,59 @@ func NewOsmosisApp(
ante.DefaultSigVerificationGasConsumer,
encodingConfig.TxConfig.SignModeHandler(),
app.IBCKeeper,
BlockSDKAnteHandlerParams{
freeLane: freeLane,
mevLane: mevLane,
auctionKeeper: *app.AppKeepers.AuctionKeeper,
txConfig: txConfig,
},
)

// update ante-handlers on lanes
opt := []base.LaneOption{
base.WithAnteHandler(anteHandler),
}
mevLane.WithOptions(opt...)
defaultLane.WithOptions(opt...)
freeLane.WithOptions(opt...)

// ABCI handlers
// prepare proposal
proposalHandler := blocksdkabci.NewProposalHandler(
app.Logger(),
txConfig.TxDecoder(),
txConfig.TxEncoder(),
lanedMempool,
)

// we use the block-sdk's PrepareProposal logic to build blocks
app.SetPrepareProposal(proposalHandler.PrepareProposalHandler())

// we use a no-op ProcessProposal, this way, we accept all proposals in avoidance
// of liveness failures due to Prepare / Process inconsistency. In other words,
// this ProcessProposal always returns ACCEPT.
app.SetProcessProposal(baseapp.NoOpProcessProposal())

// check-tx
mevCheckTxHandler := checktx.NewMEVCheckTxHandler(
app,
txConfig.TxDecoder(),
mevLane,
anteHandler,
app.BaseApp.CheckTx,
app.ChainID(),
)
PaddyMc marked this conversation as resolved.
Show resolved Hide resolved

// wrap checkTxHandler with mempool parity handler
parityCheckTx := checktx.NewMempoolParityCheckTx(
app.Logger(),
lanedMempool,
txConfig.TxDecoder(),
mevCheckTxHandler.CheckTx(),
)

app.SetCheckTx(parityCheckTx.CheckTx())

// initialize BaseApp
app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker)
Expand Down Expand Up @@ -727,6 +800,19 @@ func InitOsmosisAppForTestnet(app *OsmosisApp, newValAddr bytes.HexBytes, newVal
return app
}

// CheckTx will check the transaction with the provided checkTxHandler. We override the default
// handler so that we can verify bid transactions before they are inserted into the mempool.
// With the BlockSDK CheckTx, we can verify the bid transaction and all of the bundled transactions
// before inserting the bid transaction into the mempool.
func (app *OsmosisApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx {
return app.checkTxHandler(req)
}
PaddyMc marked this conversation as resolved.
Show resolved Hide resolved

// SetCheckTx sets the checkTxHandler for the app.
func (app *OsmosisApp) SetCheckTx(handler checktx.CheckTx) {
app.checkTxHandler = handler
}
PaddyMc marked this conversation as resolved.
Show resolved Hide resolved

// MakeCodecs returns the application codec and a legacy Amino codec.
func MakeCodecs() (codec.Codec, *codec.LegacyAmino) {
config := MakeEncodingConfig()
Expand Down
20 changes: 20 additions & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ import (
epochskeeper "github.com/osmosis-labs/osmosis/x/epochs/keeper"
epochstypes "github.com/osmosis-labs/osmosis/x/epochs/types"

auctionkeeper "github.com/skip-mev/block-sdk/x/auction/keeper"
auctiontypes "github.com/skip-mev/block-sdk/x/auction/types"
PaddyMc marked this conversation as resolved.
Show resolved Hide resolved

storetypes "github.com/cosmos/cosmos-sdk/store/types"
)

Expand Down Expand Up @@ -178,6 +181,9 @@ type AppKeepers struct {
HooksICS4Wrapper ibchooks.ICS4Middleware
PacketForwardKeeper *packetforwardkeeper.Keeper

// BlockSDK
AuctionKeeper *auctionkeeper.Keeper

// keys to access the substores
keys map[string]*storetypes.KVStoreKey
tkeys map[string]*storetypes.TransientStoreKey
Expand Down Expand Up @@ -505,6 +511,18 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appKeepers.LockupKeeper,
)

// initialize the auction keeper
auctionKeeper := auctionkeeper.NewKeeper(
appCodec,
appKeepers.keys[auctiontypes.StoreKey],
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.DistrKeeper,
appKeepers.StakingKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
appKeepers.AuctionKeeper = &auctionKeeper

appKeepers.ValidatorSetPreferenceKeeper = &validatorSetPreferenceKeeper

appKeepers.SuperfluidKeeper = superfluidkeeper.NewKeeper(
Expand Down Expand Up @@ -751,6 +769,7 @@ func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legac
paramsKeeper.Subspace(cosmwasmpooltypes.ModuleName)
paramsKeeper.Subspace(ibchookstypes.ModuleName)
paramsKeeper.Subspace(txfeestypes.ModuleName)
paramsKeeper.Subspace(auctiontypes.ModuleName)

return paramsKeeper
}
Expand Down Expand Up @@ -873,5 +892,6 @@ func KVStoreKeys() []string {
icqtypes.StoreKey,
packetforwardtypes.StoreKey,
cosmwasmpooltypes.StoreKey,
auctiontypes.StoreKey,
}
}
2 changes: 2 additions & 0 deletions app/keepers/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import (
valsetprefmodule "github.com/osmosis-labs/osmosis/v24/x/valset-pref/valpref-module"
"github.com/osmosis-labs/osmosis/x/epochs"
ibc_hooks "github.com/osmosis-labs/osmosis/x/ibc-hooks"
"github.com/skip-mev/block-sdk/x/auction"
)

// AppModuleBasics returns ModuleBasics for the module BasicManager.
Expand Down Expand Up @@ -130,4 +131,5 @@ var AppModuleBasics = []module.AppModuleBasic{
packetforward.AppModuleBasic{},
cosmwasmpoolmodule.AppModuleBasic{},
tendermint.AppModuleBasic{},
auction.AppModuleBasic{},
}
Loading