Skip to content

Commit

Permalink
fix: Add gov proposal migration in v0.3.1 upgrade handler (backport #478
Browse files Browse the repository at this point in the history
) (#479)

* fix: Add gov proposal migration in v0.3.1 upgrade handler (#478)

(cherry picked from commit 2965d45)

# Conflicts:
#	app/upgrades.go

* fix conflict

---------

Co-authored-by: ryanbajollari <[email protected]>
Co-authored-by: rbajollari <[email protected]>
  • Loading branch information
3 people authored Jul 18, 2024
1 parent 2d3ebd7 commit 787e16e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
Expand Down Expand Up @@ -186,8 +187,16 @@ func (app *App) registerUpgrade0_3_1Rc2(_ upgradetypes.Plan) {

func (app *App) registerUpgrade0_3_1(_ upgradetypes.Plan) {
const planName = "v0.3.1"

app.UpgradeKeeper.SetUpgradeHandler(planName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// migrate old proposals
govMigrator := govkeeper.NewMigrator(&app.GovKeeper, app.GetSubspace(govtypes.ModuleName))
err := govMigrator.Migrate2to3(ctx)
if err != nil {
panic("failed to migrate governance module")
}

ctx.Logger().Info("Upgrade handler execution", "name", planName)
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
},
Expand Down

0 comments on commit 787e16e

Please sign in to comment.