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(x/gov): migrations from 2 to 3 (min proposer deposit) (manual backport #298) #302

Merged
merged 1 commit into from
Jul 28, 2022
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
6 changes: 6 additions & 0 deletions x/gov/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
v043 "github.com/cosmos/cosmos-sdk/x/gov/legacy/v043"
v3 "github.com/cosmos/cosmos-sdk/x/gov/legacy/v3"
)

// Migrator is a struct for handling in-place store migrations.
Expand All @@ -19,3 +20,8 @@ func NewMigrator(keeper Keeper) Migrator {
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v043.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
}

// Migrate2to3 migrates from version 2 to 3.
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v3.MigrateStore(ctx, m.keeper.paramSpace)
}
5 changes: 2 additions & 3 deletions x/gov/legacy/v3/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package v3
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)

var minInitialDepositRatio = sdk.NewDec(25).Quo(sdk.NewDec(100))
Expand All @@ -16,12 +15,12 @@ var minInitialDepositRatio = sdk.NewDec(25).Quo(sdk.NewDec(100))
// The migration includes:
//
// - Setting the minimum deposit param in the paramstore.
func MigrateStore(ctx sdk.Context, paramstore paramtypes.Subspace) error {
func MigrateStore(ctx sdk.Context, paramstore types.ParamSubspace) error {
migrateParamsStore(ctx, paramstore)
return nil
}

func migrateParamsStore(ctx sdk.Context, paramstore paramtypes.Subspace) {
func migrateParamsStore(ctx sdk.Context, paramstore types.ParamSubspace) {
var depositParams types.DepositParams
paramstore.Get(ctx, types.ParamStoreKeyDepositParams, &depositParams)
depositParams.MinInitialDepositRatio = minInitialDepositRatio
Expand Down
4 changes: 4 additions & 0 deletions x/gov/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
if err != nil {
panic(err)
}
cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3)
if err != nil {
panic(err)
}
}

// InitGenesis performs genesis initialization for the gov module. It returns
Expand Down