From eced8c4968b56a99450f3a9de70dad533d2bfcec Mon Sep 17 00:00:00 2001 From: Hieu Vu Date: Thu, 2 Nov 2023 12:28:21 +0700 Subject: [PATCH 1/2] add upgrade handler for v3.0.2 --- app/app.go | 3 ++- app/upgrades/v3_0_2/constants.go | 14 ++++++++++++++ app/upgrades/v3_0_2/upgrades.go | 17 +++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 app/upgrades/v3_0_2/constants.go create mode 100644 app/upgrades/v3_0_2/upgrades.go diff --git a/app/app.go b/app/app.go index 8b70fba9..cbc298df 100644 --- a/app/app.go +++ b/app/app.go @@ -147,6 +147,7 @@ import ( v2 "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades/v2" "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades/v2_2_5" v3 "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades/v3" + v3_0_2 "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades/v3_0_2" ) const ( @@ -165,7 +166,7 @@ var ( // https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34 EnableSpecificProposals = "" - Upgrades = []upgrades.Upgrade{v2.Upgrade, v2_2_5.Upgrade, v3.Upgrade} + Upgrades = []upgrades.Upgrade{v2.Upgrade, v2_2_5.Upgrade, v3.Upgrade, v3_0_2.Upgrade} ) // GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to diff --git a/app/upgrades/v3_0_2/constants.go b/app/upgrades/v3_0_2/constants.go new file mode 100644 index 00000000..2670b147 --- /dev/null +++ b/app/upgrades/v3_0_2/constants.go @@ -0,0 +1,14 @@ +package v3 + +import ( + "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades" +) + +// UpgradeName defines the on-chain upgrade name for the Migaloo v3.0.2 upgrade. +// this upgrade includes the fix for pfm +const UpgradeName = "v3.0.2" + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, +} diff --git a/app/upgrades/v3_0_2/upgrades.go b/app/upgrades/v3_0_2/upgrades.go new file mode 100644 index 00000000..7095d92b --- /dev/null +++ b/app/upgrades/v3_0_2/upgrades.go @@ -0,0 +1,17 @@ +package v3 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +// small security fix, can be a no-op, running mm.RunMigarions just to be sure +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) + } +} From 185693c18897b1ed88e3414da5adb7863421b063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=E1=BA=B7c?= Date: Thu, 2 Nov 2023 13:34:44 +0700 Subject: [PATCH 2/2] lint --- app/app.go | 1 + 1 file changed, 1 insertion(+) diff --git a/app/app.go b/app/app.go index cbc298df..d4fd3f84 100644 --- a/app/app.go +++ b/app/app.go @@ -1100,6 +1100,7 @@ func (app *MigalooApp) setupUpgradeHandlers(cfg module.Configurator) { } for _, upgrade := range Upgrades { + upgrade := upgrade if upgradeInfo.Name == upgrade.UpgradeName { app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades)) }