diff --git a/app/app.go b/app/app.go index b3f552b9..d9840cbf 100644 --- a/app/app.go +++ b/app/app.go @@ -139,6 +139,7 @@ import ( // Upgrade Handler upgrades "github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app/upgrades" v2 "github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app/upgrades/v2" + v2_2_5 "github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app/upgrades/v2_2_5" ) const ( @@ -157,7 +158,7 @@ var ( // https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34 EnableSpecificProposals = "" - Upgrades = []upgrades.Upgrade{v2.Upgrade} + Upgrades = []upgrades.Upgrade{v2.Upgrade, v2_2_5.Upgrade} ) // GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to @@ -1042,14 +1043,19 @@ func RegisterSwaggerAPI(rtr *mux.Router) { // Setup Upgrade Handler func (app *MigalooApp) setupUpgradeHandlers(cfg module.Configurator) { - for _, upgrade := range Upgrades { - upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() - if err != nil { - panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) - } + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() + if err != nil { + panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) + } - app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades)) + if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + return + } + for _, upgrade := range Upgrades { + if upgradeInfo.Name == upgrade.UpgradeName { + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades)) + } app.UpgradeKeeper.SetUpgradeHandler( upgrade.UpgradeName, upgrade.CreateUpgradeHandler( @@ -1057,6 +1063,7 @@ func (app *MigalooApp) setupUpgradeHandlers(cfg module.Configurator) { cfg, ), ) + } } diff --git a/app/upgrades/v2_2_5/constants.go b/app/upgrades/v2_2_5/constants.go new file mode 100644 index 00000000..dedf8b2d --- /dev/null +++ b/app/upgrades/v2_2_5/constants.go @@ -0,0 +1,15 @@ +package v2_2_5 + +import ( + "github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app/upgrades" + store "github.com/cosmos/cosmos-sdk/store/types" +) + +// UpgradeName defines the on-chain upgrade name for the Migaloo v2 upgrade. +const UpgradeName = "v2.2.5" + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{}, +} diff --git a/app/upgrades/v2_2_5/upgrades.go b/app/upgrades/v2_2_5/upgrades.go new file mode 100644 index 00000000..1093fd38 --- /dev/null +++ b/app/upgrades/v2_2_5/upgrades.go @@ -0,0 +1,19 @@ +package v2_2_5 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +// We set the app version to pre-upgrade because it will be incremented by one +// after the upgrade is applied by the handler. + +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) + } +}