Skip to content

Commit

Permalink
Merge pull request #2987 from irisnet/fix/upgrade
Browse files Browse the repository at this point in the history
fix: prioritize upgrade module in module manager
  • Loading branch information
mitch1024 authored Jan 2, 2025
2 parents aabde0c + b145a09 commit fc5f567
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
12 changes: 12 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/log"
upgradetypes "cosmossdk.io/x/upgrade/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -137,6 +138,11 @@ func NewIrisApp(
// must be passed by reference here.
app.mm = module.NewManager(appModules(app, encodingConfig, skipGenesisInvariants)...)

// NOTE: upgrade module is required to be prioritized
app.mm.SetOrderPreBlockers(
upgradetypes.ModuleName,
)

// During begin block slashing happens after distr.BeginBlocker so that
// there is nothing left over in the validator fee pool, so as to keep the
// CanWithdrawInvariant invariant.
Expand Down Expand Up @@ -209,6 +215,7 @@ func NewIrisApp(
app.Init()
app.SetAnteHandler(anteHandler)
app.SetInitChainer(app.InitChainer)
app.SetPreBlocker(app.PreBlocker)
app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker)
app.RegisterUpgradePlans()
Expand All @@ -233,6 +240,11 @@ func NewIrisApp(
// Name returns the name of the App
func (app *IrisApp) Name() string { return app.BaseApp.Name() }

// PreBlocker application updates every pre block
func (app *IrisApp) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) {
return app.mm.PreBlock(ctx)
}

// BeginBlocker application updates every begin block
func (app *IrisApp) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) {
return app.mm.BeginBlock(ctx)
Expand Down
11 changes: 8 additions & 3 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import (
icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper"
"github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
Expand Down Expand Up @@ -613,6 +614,10 @@ func initParamsKeeper(
) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)

// register the key tables for legacy param subspaces
keyTable := ibcclienttypes.ParamKeyTable()
keyTable.RegisterParamSet(&ibcconnectiontypes.Params{})

paramsKeeper.Subspace(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable())
paramsKeeper.Subspace(banktypes.ModuleName).WithKeyTable(banktypes.ParamKeyTable())
paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable())
Expand All @@ -621,16 +626,16 @@ func initParamsKeeper(
paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName).WithKeyTable(crisistypes.ParamKeyTable())
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(tokentypes.ModuleName).WithKeyTable(tokenv1.ParamKeyTable())
paramsKeeper.Subspace(recordtypes.ModuleName)
paramsKeeper.Subspace(htlctypes.ModuleName).WithKeyTable(htlctypes.ParamKeyTable())
paramsKeeper.Subspace(coinswaptypes.ModuleName).WithKeyTable(coinswaptypes.ParamKeyTable())
paramsKeeper.Subspace(servicetypes.ModuleName).WithKeyTable(servicetypes.ParamKeyTable())
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(farmtypes.ModuleName).WithKeyTable(farmtypes.ParamKeyTable())
paramsKeeper.Subspace(tibchost.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable)
paramsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable())
paramsKeeper.Subspace(icahosttypes.SubModuleName).WithKeyTable(icahosttypes.ParamKeyTable())

// ethermint subspaces
paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable())
Expand Down
3 changes: 1 addition & 2 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
"github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v8/modules/core"

//ibcclientclient "github.com/cosmos/ibc-go/v8/modules/core/02-client/client"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
Expand Down Expand Up @@ -478,8 +479,6 @@ NOTE: capability module's beginblocker must come before any modules using capabi

func orderBeginBlockers() []string {
return []string{
// upgrades should be run first
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
minttypes.ModuleName,
feemarkettypes.ModuleName,
Expand Down
4 changes: 4 additions & 0 deletions app/rpc/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ func overrideAuthServices(cdc codec.Codec, cfg module.Configurator, appKeepers k
if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil {
panic(fmt.Sprintf("failed to migrate x/%s from version 3 to 4: %v", types.ModuleName, err))
}

if err := cfg.RegisterMigration(types.ModuleName, 4, m.Migrate4To5); err != nil {
panic(fmt.Sprintf("failed to migrate x/%s from version 4 to 5", types.ModuleName))
}
}

// Since: cosmos-sdk 0.43
Expand Down

0 comments on commit fc5f567

Please sign in to comment.