Skip to content

Commit

Permalink
feat: upgrade cosmos-sdk and add upgrade handler
Browse files Browse the repository at this point in the history
  • Loading branch information
hoank101 committed Dec 19, 2024
1 parent 76ff5e3 commit 98c742c
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 10 deletions.
11 changes: 10 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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{},
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v4_2_6/constants.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
7 changes: 7 additions & 0 deletions app/upgrades/v4_2_7/constants.go
Original file line number Diff line number Diff line change
@@ -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"
)
19 changes: 19 additions & 0 deletions app/upgrades/v4_2_7/upgrades.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions scripts/upgrade_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:-""}

Expand Down

0 comments on commit 98c742c

Please sign in to comment.