Skip to content

Commit

Permalink
Add upgrade handler for v8 (#1304)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon authored Apr 22, 2022
1 parent 84f0194 commit 68f2661
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
29 changes: 24 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions app/upgrades/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions app/upgrades/v8/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package v8

// UpgradeName defines the on-chain upgrade name for the Osmosis v7 upgrade.
const UpgradeName = "v8"
16 changes: 16 additions & 0 deletions app/upgrades/v8/upgrades.go
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 68f2661

Please sign in to comment.