diff --git a/app/app.go b/app/app.go index 4045317f..4fe51043 100644 --- a/app/app.go +++ b/app/app.go @@ -56,13 +56,13 @@ import ( "github.com/persistenceOne/persistenceCore/v11/app/keepers" "github.com/persistenceOne/persistenceCore/v11/app/upgrades" - v11_15_0_rc0 "github.com/persistenceOne/persistenceCore/v11/app/upgrades/testnet/v11.15.0-rc0" + v11_15_0 "github.com/persistenceOne/persistenceCore/v11/app/upgrades/v11.15.0" "github.com/persistenceOne/persistenceCore/v11/client/docs" ) var ( DefaultNodeHome string - Upgrades = []upgrades.Upgrade{v11_15_0_rc0.Upgrade} + Upgrades = []upgrades.Upgrade{v11_15_0.Upgrade} ModuleBasics = module.NewBasicManager(keepers.AppModuleBasics...) ) diff --git a/app/upgrades/v11.15.0/constants.go b/app/upgrades/v11.15.0/constants.go new file mode 100644 index 00000000..0352ac08 --- /dev/null +++ b/app/upgrades/v11.15.0/constants.go @@ -0,0 +1,18 @@ +package v11_15_0 + +import ( + store "github.com/cosmos/cosmos-sdk/store/types" + + "github.com/persistenceOne/persistenceCore/v11/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrade name. + UpgradeName = "v11.15.0" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{}, +} diff --git a/app/upgrades/v11.15.0/upgrades.go b/app/upgrades/v11.15.0/upgrades.go new file mode 100644 index 00000000..9016b3d4 --- /dev/null +++ b/app/upgrades/v11.15.0/upgrades.go @@ -0,0 +1,51 @@ +package v11_15_0 + +import ( + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/module" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/persistenceOne/persistenceCore/v11/app/upgrades" +) + +func CreateUpgradeHandler(args upgrades.UpgradeHandlerArgs) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("running module migrations...") + err := MigrateVestingAccounts(ctx, args) + if err != nil { + return vm, err + } + return args.ModuleManager.RunMigrations(ctx, args.Configurator, vm) + } +} + +func MigrateVestingAccounts(ctx sdk.Context, args upgrades.UpgradeHandlerArgs) error { + accounts := args.Keepers.AccountKeeper.GetAllAccounts(ctx) + for _, account := range accounts { + switch account.(type) { + case *vestingtypes.PeriodicVestingAccount: + a, ok := account.(*vestingtypes.PeriodicVestingAccount) + if !ok { + return errors.Wrapf(sdkerrors.ErrInvalidType, "invalid account type: %T", account) + } + args.Keepers.AccountKeeper.SetAccount(ctx, a.BaseAccount) + case *vestingtypes.ContinuousVestingAccount: + a, ok := account.(*vestingtypes.ContinuousVestingAccount) + if !ok { + return errors.Wrapf(sdkerrors.ErrInvalidType, "invalid account type: %T", account) + } + args.Keepers.AccountKeeper.SetAccount(ctx, a.BaseAccount) + case *vestingtypes.DelayedVestingAccount: + a, ok := account.(*vestingtypes.DelayedVestingAccount) + if !ok { + return errors.Wrapf(sdkerrors.ErrInvalidType, "invalid account type: %T", account) + } + args.Keepers.AccountKeeper.SetAccount(ctx, a.BaseAccount) + default: + } + } + return nil +} diff --git a/interchaintest/chain_upgrade_test.go b/interchaintest/chain_upgrade_test.go index 6d3e1cc5..dee5387c 100644 --- a/interchaintest/chain_upgrade_test.go +++ b/interchaintest/chain_upgrade_test.go @@ -29,8 +29,8 @@ const ( func TestPersistenceUpgradeBasic(t *testing.T) { var ( chainName = "persistence" - initialVersion = "v11.13.0-rc0" - upgradeName = "v11.15.0-rc0" + initialVersion = "v11.14.0" + upgradeName = "v11.15.0" upgradeRepo = PersistenceCoreImage.Repository upgradeBranchVersion = PersistenceCoreImage.Version )