From 2f6b4008b46f0dffd4df628fde91e86d7ba21425 Mon Sep 17 00:00:00 2001 From: Lockwarr Date: Wed, 15 Mar 2023 17:21:19 +0200 Subject: [PATCH] feat: set upgrade handler for v0.2.2 --- app/app.go | 4 -- app/upgrades.go | 115 ++--------------------------------- app/upgrades/v0/constants.go | 26 -------- app/upgrades/v0/upgrades.go | 20 ------ 4 files changed, 6 insertions(+), 159 deletions(-) delete mode 100644 app/upgrades/v0/constants.go delete mode 100644 app/upgrades/v0/upgrades.go diff --git a/app/app.go b/app/app.go index f5ccdca1..5f5ae393 100644 --- a/app/app.go +++ b/app/app.go @@ -39,8 +39,6 @@ import ( "github.com/Nolus-Protocol/nolus-core/app/keepers" appparams "github.com/Nolus-Protocol/nolus-core/app/params" - "github.com/Nolus-Protocol/nolus-core/app/upgrades" - v0 "github.com/Nolus-Protocol/nolus-core/app/upgrades/v0" "github.com/Nolus-Protocol/nolus-core/docs" "github.com/CosmWasm/wasmd/x/wasm" @@ -54,8 +52,6 @@ const ( var ( // DefaultNodeHome default home directories for the application daemon. DefaultNodeHome string - - Upgrades = []upgrades.Upgrade{v0.Upgrade} ) var ( diff --git a/app/upgrades.go b/app/upgrades.go index 41485dbd..dfea98db 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -1,8 +1,6 @@ package app import ( - "encoding/json" - "github.com/Nolus-Protocol/nolus-core/app/keepers" "github.com/Nolus-Protocol/nolus-core/app/upgrades" @@ -10,14 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - contractmanagermoduletypes "github.com/neutron-org/neutron/x/contractmanager/types" - "github.com/neutron-org/neutron/x/feerefunder" - feeRefunderTypes "github.com/neutron-org/neutron/x/feerefunder/types" - "github.com/neutron-org/neutron/x/interchainqueries" - interchainqueriestypes "github.com/neutron-org/neutron/x/interchainqueries/types" - "github.com/neutron-org/neutron/x/interchaintxs" - interchaintxstypes "github.com/neutron-org/neutron/x/interchaintxs/types" ) func (app *App) RegisterUpgradeHandlers() { @@ -26,37 +16,7 @@ func (app *App) RegisterUpgradeHandlers() { panic(err) } - app.registerUpgradeV1_43(upgradeInfo) - app.registerUpgradeV1_44(upgradeInfo) - app.registerUpgradeV2_0(upgradeInfo) - app.registerUpgradeV2_1_testnet(upgradeInfo) -} - -// performs upgrade from v0.1.39 -> v0.1.43. -func (app *App) registerUpgradeV1_43(_ storetypes.UpgradeInfo) { - const UpgradeV1_43Plan = "v0.1.43" - app.UpgradeKeeper.SetUpgradeHandler(UpgradeV1_43Plan, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Upgrade handler execution", "name", UpgradeV1_43Plan) - return fromVM, nil - }) -} - -// performs upgrade from v0.1.43 -> v0.1.44. -func (app *App) registerUpgradeV1_44(_ storetypes.UpgradeInfo) { - const UpgradeV1_44Plan = "v0.1.44" - app.UpgradeKeeper.SetUpgradeHandler(UpgradeV1_44Plan, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Upgrade handler execution", "name", UpgradeV1_44Plan) - return fromVM, nil - }) -} - -// performs upgrade from v0.1.43 -> v0.2.0. -func (app *App) registerUpgradeV2_0(_ storetypes.UpgradeInfo) { - const UpgradeV2_0Plan = "v0.2.0" - app.UpgradeKeeper.SetUpgradeHandler(UpgradeV2_0Plan, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Upgrade handler execution", "name", UpgradeV2_0Plan) - return fromVM, nil - }) + app.registerUpgrade(upgradeInfo) } func (app *App) createUpgradeHandlerTestnet( @@ -65,82 +25,19 @@ func (app *App) createUpgradeHandlerTestnet( keepers *keepers.AppKeepers, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Upgrade handler execution", "name", "v0.2.1") - appCodec := app.appCodec - // Register the consensus version in the version map - // to avoid the SDK from triggering the default - // InitGenesis function. - fromVM["interchainqueries"] = interchainqueries.AppModule{}.ConsensusVersion() - - // Make custom genesis state and run InitGenesis for interchainqueries - interchainQueriesCustomGenesis := interchainqueriestypes.GenesisState{ - Params: interchainqueriestypes.Params{ - QuerySubmitTimeout: 1036800, - QueryDeposit: sdk.NewCoins(sdk.NewCoin("unls", sdk.NewInt(1000000))), - }, - RegisteredQueries: []*interchainqueriestypes.RegisteredQuery{}, - } - interchainQueriesCustomGenesisJSON, err := json.Marshal(interchainQueriesCustomGenesis) - if err != nil { - return nil, err - } - app.mm.Modules["interchainqueries"].InitGenesis(ctx, appCodec, interchainQueriesCustomGenesisJSON) - - // Register the consensus version in the version map - // to avoid the SDK from triggering the default - // InitGenesis function. - fromVM["interchaintxs"] = interchaintxs.AppModule{}.ConsensusVersion() - - // Make custom genesis state and run InitGenesis for interchaintxs - interchainTxsCustomGenesis := interchaintxstypes.GenesisState{ - Params: interchaintxstypes.Params{ - MsgSubmitTxMaxMessages: 16, - }, - } - interchainTxsCustomGenesisJSON, err := json.Marshal(interchainTxsCustomGenesis) - if err != nil { - return nil, err - } - app.mm.Modules["interchaintxs"].InitGenesis(ctx, appCodec, interchainTxsCustomGenesisJSON) - - // Register the consensus version in the version map - // to avoid the SDK from triggering the default - // InitGenesis function. - fromVM[feeRefunderTypes.ModuleName] = feerefunder.AppModule{}.ConsensusVersion() - - // Make custom genesis state and run InitGenesis for interchaintxs - feeRefunderCustomGenesis := feeRefunderTypes.GenesisState{ - Params: feeRefunderTypes.Params{ - MinFee: feeRefunderTypes.Fee{ - AckFee: sdk.Coins{ - sdk.NewCoin("unls", sdk.NewInt(1)), - }, - TimeoutFee: sdk.Coins{ - sdk.NewCoin("unls", sdk.NewInt(1)), - }, - }, - }, - } - feeRefunderCustomGenesisJSON, err := json.Marshal(feeRefunderCustomGenesis) - if err != nil { - return nil, err - } - app.mm.Modules[feeRefunderTypes.ModuleName].InitGenesis(ctx, appCodec, feeRefunderCustomGenesisJSON) - + ctx.Logger().Info("Upgrade handler execution", "name", "v0.2.2") ctx.Logger().Info("Running migrations") return app.mm.RunMigrations(ctx, app.configurator, fromVM) } } -func (app *App) registerUpgradeV2_1_testnet(_ storetypes.UpgradeInfo) { +// upgrade v0.2.2 +func (app *App) registerUpgrade(_ storetypes.UpgradeInfo) { testnetUpgrade := upgrades.Upgrade{ - UpgradeName: "v0.2.1", + UpgradeName: "v0.2.2", CreateUpgradeHandler: app.createUpgradeHandlerTestnet, StoreUpgrades: storetypes.StoreUpgrades{ - Added: []string{ - contractmanagermoduletypes.ModuleName, - feeRefunderTypes.ModuleName, - }, + Added: []string{}, }, } app.UpgradeKeeper.SetUpgradeHandler( diff --git a/app/upgrades/v0/constants.go b/app/upgrades/v0/constants.go deleted file mode 100644 index d0cd146f..00000000 --- a/app/upgrades/v0/constants.go +++ /dev/null @@ -1,26 +0,0 @@ -package v0 - -import ( - "github.com/Nolus-Protocol/nolus-core/app/upgrades" - - store "github.com/cosmos/cosmos-sdk/store/types" - interchainqueries "github.com/neutron-org/neutron/x/interchainqueries/types" - interchaintxs "github.com/neutron-org/neutron/x/interchaintxs/types" -) - -// TODO Start using this method to upgrade the app after export app state is fixed. -const ( - // UpgradeName defines the on-chain upgrade name. - UpgradeName = "v0.2.1" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{ - interchainqueries.ModuleName, - interchaintxs.ModuleName, - }, - }, -} diff --git a/app/upgrades/v0/upgrades.go b/app/upgrades/v0/upgrades.go deleted file mode 100644 index 87f82dab..00000000 --- a/app/upgrades/v0/upgrades.go +++ /dev/null @@ -1,20 +0,0 @@ -package v0 - -import ( - "github.com/Nolus-Protocol/nolus-core/app/keepers" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" -) - -// TODO Start using this method to upgrade the app after export app state is fixed. -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - keepers *keepers.AppKeepers, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - return mm.RunMigrations(ctx, configurator, fromVM) - } -}