Skip to content

Commit

Permalink
feat: add upgrade handler
Browse files Browse the repository at this point in the history
  • Loading branch information
duvbell committed Jul 5, 2024
1 parent f7dfbf6 commit 50a2d98
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ import (
v42 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_1_2"
v45 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_1_5"
v46 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_1_6"
v47 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_1_7"
"github.com/rakyll/statik/fs"

// unnamed import of statik for swagger UI support
Expand Down Expand Up @@ -1182,6 +1183,14 @@ func (app *MigalooApp) setupUpgradeHandlers() {
),
)

app.UpgradeKeeper.SetUpgradeHandler(
v47.UpgradeName,
v47.CreateUpgradeHandler(
app.mm,
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
// This will read that value, and execute the preparations for the upgrade.
Expand Down
7 changes: 7 additions & 0 deletions app/upgrades/v4_1_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.1.5 upgrade.
// this upgrade includes the fix for pfm
const (
UpgradeName = "v4.1.7"
)
17 changes: 17 additions & 0 deletions app/upgrades/v4_1_7/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package v4

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

// CreateUpgradeHandler that migrates the chain from v4.1.5 to v4.1.6
func CreateUpgradeHandler(
mm *module.Manager,
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 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.1.5
OLD_VERSION=v4.1.3
UPGRADE_WAIT=${UPGRADE_WAIT:-20}
HOME=mytestnet
ROOT=$(pwd)
DENOM=uwhale
CHAIN_ID=localmigaloo
SOFTWARE_UPGRADE_NAME="v4.1.6"
SOFTWARE_UPGRADE_NAME="v4.1.7"
ADDITIONAL_PRE_SCRIPTS=${ADDITIONAL_PRE_SCRIPTS:-""}
ADDITIONAL_AFTER_SCRIPTS=${ADDITIONAL_AFTER_SCRIPTS:-""}

Expand Down

0 comments on commit 50a2d98

Please sign in to comment.