From 68f26618acf3364a1e3bc30bb2eeac631ca17cae Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Thu, 21 Apr 2022 22:38:05 -0500 Subject: [PATCH] Add upgrade handler for v8 (#1304) --- app/app.go | 29 ++++++++++++++++++++++++----- app/upgrades/README.md | 1 + app/upgrades/v8/constants.go | 4 ++++ app/upgrades/v8/upgrades.go | 16 ++++++++++++++++ 4 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 app/upgrades/v8/constants.go create mode 100644 app/upgrades/v8/upgrades.go diff --git a/app/app.go b/app/app.go index 00ada88ae00..fc5e909d335 100644 --- a/app/app.go +++ b/app/app.go @@ -46,6 +46,7 @@ import ( v4 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v4" v5 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v5" v7 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v7" + v8 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v8" _ "github.com/osmosis-labs/osmosis/v7/client/docs/statik" superfluidtypes "github.com/osmosis-labs/osmosis/v7/x/superfluid/types" ) @@ -421,15 +422,25 @@ func (app *OsmosisApp) setupUpgradeStoreLoaders() { panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) } - if upgradeInfo.Name == v7.UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - // @Frey do we do this for Cosmwasm? - storeUpgrades := store.StoreUpgrades{ + if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + return + } + + storeUpgrades := store.StoreUpgrades{} + + if upgradeInfo.Name == v7.UpgradeName { + storeUpgrades = store.StoreUpgrades{ Added: []string{wasm.ModuleName, superfluidtypes.ModuleName}, } + } - // configure store loader that checks if version == upgradeHeight and applies store upgrades - app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) + if upgradeInfo.Name == v8.UpgradeName { + // TODO: Add claims module as deleted here + storeUpgrades = store.StoreUpgrades{} } + + // configure store loader that checks if version == upgradeHeight and applies store upgrades + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) } func (app *OsmosisApp) setupUpgradeHandlers() { @@ -471,6 +482,14 @@ func (app *OsmosisApp) setupUpgradeHandlers() { app.AccountKeeper, ), ) + + app.UpgradeKeeper.SetUpgradeHandler( + v8.UpgradeName, + v8.CreateUpgradeHandler( + app.mm, + app.configurator, + ), + ) } // RegisterSwaggerAPI registers swagger route with API Server. diff --git a/app/upgrades/README.md b/app/upgrades/README.md index 7d4a3dd4049..2ca15b6116c 100644 --- a/app/upgrades/README.md +++ b/app/upgrades/README.md @@ -8,5 +8,6 @@ This folder contains logic for every osmosis upgrade. (Both state migrations, an * v5 - Boron State migration * v6 - hard fork for IBC bug fix * v7 - Carbon State migration +* v8 - Nitrogen State migration ## TODO: Make a fork-upgrade struct and a state-migration upgrade struct diff --git a/app/upgrades/v8/constants.go b/app/upgrades/v8/constants.go new file mode 100644 index 00000000000..ada824db4ec --- /dev/null +++ b/app/upgrades/v8/constants.go @@ -0,0 +1,4 @@ +package v8 + +// UpgradeName defines the on-chain upgrade name for the Osmosis v7 upgrade. +const UpgradeName = "v8" diff --git a/app/upgrades/v8/upgrades.go b/app/upgrades/v8/upgrades.go new file mode 100644 index 00000000000..49de914fcdf --- /dev/null +++ b/app/upgrades/v8/upgrades.go @@ -0,0 +1,16 @@ +package v8 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, configurator, vm) + } +}