From 3cfae57a3efaf680a77b3b0c3873a3773e587b9e Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 27 Aug 2023 12:32:54 -0500 Subject: [PATCH] Add v19 upgrade handler (#6187) --- app/app.go | 3 ++- app/upgrades/v19/constants.go | 19 +++++++++++++++++ app/upgrades/v19/upgrades.go | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 app/upgrades/v19/constants.go create mode 100644 app/upgrades/v19/upgrades.go diff --git a/app/app.go b/app/app.go index 27715c592e9..39049932423 100644 --- a/app/app.go +++ b/app/app.go @@ -59,6 +59,7 @@ import ( v16 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v16" v17 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v17" v18 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v18" + v19 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v19" v3 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v3" v4 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v4" v5 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v5" @@ -104,7 +105,7 @@ var ( // _ sdksimapp.App = (*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} + 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} Forks = []upgrades.Fork{v3.Fork, v6.Fork, v8.Fork, v10.Fork} ) diff --git a/app/upgrades/v19/constants.go b/app/upgrades/v19/constants.go new file mode 100644 index 00000000000..6591e8ea4d8 --- /dev/null +++ b/app/upgrades/v19/constants.go @@ -0,0 +1,19 @@ +package v18 + +import ( + "github.com/osmosis-labs/osmosis/v19/app/upgrades" + + store "github.com/cosmos/cosmos-sdk/store/types" +) + +// UpgradeName defines the on-chain upgrade name for the Osmosis v18 upgrade. +const UpgradeName = "v18" + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{ + Added: []string{}, + Deleted: []string{}, + }, +} diff --git a/app/upgrades/v19/upgrades.go b/app/upgrades/v19/upgrades.go new file mode 100644 index 00000000000..7547d3849c7 --- /dev/null +++ b/app/upgrades/v19/upgrades.go @@ -0,0 +1,39 @@ +package v18 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/osmosis-labs/osmosis/v19/app/keepers" + "github.com/osmosis-labs/osmosis/v19/app/upgrades" +) + +// OSMO / DAI CL pool ID +const lastPoolToCorrect = 1066 + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + bpm upgrades.BaseAppParamManager, + keepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // Run migrations before applying any other state changes. + // NOTE: DO NOT PUT ANY STATE CHANGES BEFORE RunMigrations(). + migrations, err := mm.RunMigrations(ctx, configurator, fromVM) + if err != nil { + return nil, err + } + + for id := 1; id < lastPoolToCorrect; id++ { + resetSuperfluidSumtree(keepers, ctx, uint64(id)) + } + return migrations, nil + } +} + +func resetSuperfluidSumtree(keepers *keepers.AppKeepers, ctx sdk.Context, id uint64) { + // denom := gammtypes.GetPoolShareDenom(id) + // keepers.LockupKeeper.RebuildAccumulationStoreForDenom(ctx, denom) +}