Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix missing upgrade handlers #260

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
// 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 (
Expand All @@ -157,7 +158,7 @@
// 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
Expand Down Expand Up @@ -1042,21 +1043,27 @@

// 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))

Check failure on line 1057 in app/app.go

View workflow job for this annotation

GitHub Actions / lint

G601: Implicit memory aliasing in for loop. (gosec)
}
app.UpgradeKeeper.SetUpgradeHandler(
upgrade.UpgradeName,
upgrade.CreateUpgradeHandler(
app.mm,
cfg,
),
)

}
}

Expand Down
15 changes: 15 additions & 0 deletions app/upgrades/v2_2_5/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package v2_2_5

Check warning on line 1 in app/upgrades/v2_2_5/constants.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: don't use an underscore in package name (revive)

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{},
}
19 changes: 19 additions & 0 deletions app/upgrades/v2_2_5/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package v2_2_5

Check warning on line 1 in app/upgrades/v2_2_5/upgrades.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: don't use an underscore in package name (revive)

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)
}
}
Loading