From 98c742c5d5d751be912bc235703e36d2d3524469 Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Thu, 19 Dec 2024 13:14:55 +0700 Subject: [PATCH] feat: upgrade cosmos-sdk and add upgrade handler --- app/app.go | 11 ++++++++++- app/upgrades/v4_2_6/constants.go | 2 +- app/upgrades/v4_2_7/constants.go | 7 +++++++ app/upgrades/v4_2_7/upgrades.go | 19 +++++++++++++++++++ go.mod | 4 ++-- go.sum | 8 ++++---- scripts/upgrade_test.sh | 4 ++-- 7 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 app/upgrades/v4_2_7/constants.go create mode 100644 app/upgrades/v4_2_7/upgrades.go diff --git a/app/app.go b/app/app.go index 2a625de6..a524af39 100644 --- a/app/app.go +++ b/app/app.go @@ -164,6 +164,7 @@ import ( v424 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_2_4" v425 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_2_5" v426 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_2_6" + v427 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_2_7" "github.com/rakyll/statik/fs" // unnamed import of statik for swagger UI support @@ -1229,6 +1230,14 @@ func (app *MigalooApp) setupUpgradeHandlers() { app.configurator, ), ) + app.UpgradeKeeper.SetUpgradeHandler( + v427.UpgradeName, + v427.CreateUpgradeHandler( + app.mm, + app.StakingKeeper, + app.configurator, + ), + ) // When a planned update height is reached, the old binary will panic // writing on disk the height and name of the update that triggered it @@ -1242,7 +1251,7 @@ func (app *MigalooApp) setupUpgradeHandlers() { return } - if upgradeInfo.Name == v426.UpgradeName { + if upgradeInfo.Name == v427.UpgradeName { storeUpgrades := &storetypes.StoreUpgrades{ Added: []string{}, Deleted: []string{}, diff --git a/app/upgrades/v4_2_6/constants.go b/app/upgrades/v4_2_6/constants.go index 58764605..27e86caf 100644 --- a/app/upgrades/v4_2_6/constants.go +++ b/app/upgrades/v4_2_6/constants.go @@ -1,6 +1,6 @@ package v4 -// UpgradeName defines the on-chain upgrade name for the Migaloo v4.2.5 upgrade. +// UpgradeName defines the on-chain upgrade name for the Migaloo v4.2.6 upgrade. // this upgrade includes the fix for pfm const ( UpgradeName = "v4.2.6" diff --git a/app/upgrades/v4_2_7/constants.go b/app/upgrades/v4_2_7/constants.go new file mode 100644 index 00000000..9f382b3d --- /dev/null +++ b/app/upgrades/v4_2_7/constants.go @@ -0,0 +1,7 @@ +package v4 + +// UpgradeName defines the on-chain upgrade name for the Migaloo v4.2.7 upgrade. +// this upgrade includes the fix for pfm +const ( + UpgradeName = "v4.2.7" +) diff --git a/app/upgrades/v4_2_7/upgrades.go b/app/upgrades/v4_2_7/upgrades.go new file mode 100644 index 00000000..0f5fad54 --- /dev/null +++ b/app/upgrades/v4_2_7/upgrades.go @@ -0,0 +1,19 @@ +package v4 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +// CreateUpgradeHandler that migrates the chain from v4.2.6 to v4.2.7 +func CreateUpgradeHandler( + mm *module.Manager, + _ *stakingKeeper.Keeper, + configurator module.Configurator, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, configurator, fromVM) + } +} diff --git a/go.mod b/go.mod index c0222473..b10af53a 100644 --- a/go.mod +++ b/go.mod @@ -3,14 +3,14 @@ module github.com/White-Whale-Defi-Platform/migaloo-chain/v4 go 1.22.9 require ( - cosmossdk.io/math v1.3.0 + cosmossdk.io/math v1.4.0 cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d cosmossdk.io/tools/rosetta v0.2.1 github.com/CosmWasm/wasmd v0.46.0 github.com/cometbft/cometbft v0.37.13 github.com/cometbft/cometbft-db v0.12.0 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.47.14 + github.com/cosmos/cosmos-sdk v0.47.15 github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20231017170841-8fd49ec0f017 github.com/cosmos/ibc-go/v7 v7.8.0 diff --git a/go.sum b/go.sum index b5048592..19c89bd5 100644 --- a/go.sum +++ b/go.sum @@ -192,8 +192,8 @@ cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM= cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU= -cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= -cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= +cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ= +cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk= cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d h1:E/8y0oG3u9hBR8l4F9MtC0LdZIamPCUwUoLlrHrX86I= cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d/go.mod h1:xbjky3L3DJEylaho6gXplkrMvJ5sFgv+qNX+Nn47bzY= cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= @@ -338,8 +338,8 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= -github.com/cosmos/cosmos-sdk v0.47.14 h1:vD9JyIdlbVaXMOE/BLamViQvylfUq0E0FpqdPVv/fWw= -github.com/cosmos/cosmos-sdk v0.47.14/go.mod h1:GrDj/zd9Tiuy8ZpG9PbUbhghCVU7lwyH0GS7CpxHpyM= +github.com/cosmos/cosmos-sdk v0.47.15 h1:xuIkX4IgpnRydiwxY2fI5nWy0SkRVvWvumWtGigwJdk= +github.com/cosmos/cosmos-sdk v0.47.15/go.mod h1:6L16fRG0ZinyyYMclrVAGqTUyb5UGu/hlx5oZEI6NAY= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= diff --git a/scripts/upgrade_test.sh b/scripts/upgrade_test.sh index 7b06d0f6..ecc44c74 100755 --- a/scripts/upgrade_test.sh +++ b/scripts/upgrade_test.sh @@ -3,13 +3,13 @@ # the upgrade is a fork, "true" otherwise FORK=${FORK:-"false"} -OLD_VERSION=v4.2.5 +OLD_VERSION=v4.2.6 UPGRADE_WAIT=${UPGRADE_WAIT:-20} HOME=mytestnet ROOT=$(pwd) DENOM=uwhale CHAIN_ID=localmigaloo -SOFTWARE_UPGRADE_NAME="v4.2.6" +SOFTWARE_UPGRADE_NAME="v4.2.7" ADDITIONAL_PRE_SCRIPTS=${ADDITIONAL_PRE_SCRIPTS:-""} ADDITIONAL_AFTER_SCRIPTS=${ADDITIONAL_AFTER_SCRIPTS:-""}