From 7efddc2ea3e8b9f0c69276a73d5ee11bedda8c46 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 13 Apr 2022 03:16:42 -0400 Subject: [PATCH] upgrade handlers for beta-net --- x/clp/keeper/migrations.go | 62 ---------------------------- x/clp/module.go | 10 +---- x/clp/types/keys.go | 19 --------- x/tokenregistry/keeper/migrations.go | 10 +---- 4 files changed, 3 insertions(+), 98 deletions(-) diff --git a/x/clp/keeper/migrations.go b/x/clp/keeper/migrations.go index f3a09a7bd3..7d57219cd9 100644 --- a/x/clp/keeper/migrations.go +++ b/x/clp/keeper/migrations.go @@ -43,65 +43,3 @@ func (m Migrator) MigrateToVer2(ctx sdk.Context) error { } return nil } - -func (m Migrator) MigrateToVer3(ctx sdk.Context) error { - // Initiate Rewards - m.keeper.SetRewardParams(ctx, types.GetDefaultRewardParams()) - // Initiate PMTP - m.keeper.SetPmtpRateParams(ctx, types.PmtpRateParams{ - PmtpPeriodBlockRate: sdk.ZeroDec(), - PmtpCurrentRunningRate: sdk.ZeroDec(), - PmtpInterPolicyRate: sdk.ZeroDec(), - }) - m.keeper.SetPmtpEpoch(ctx, types.PmtpEpoch{ - EpochCounter: 0, - BlockCounter: 0, - }) - m.keeper.SetPmtpParams(ctx, types.GetDefaultPmtpParams()) - m.keeper.SetPmtpInterPolicyRate(ctx, sdk.NewDec(0)) - pools := m.keeper.GetPools(ctx) - for _, pool := range pools { - spe := sdk.ZeroDec() - spn := sdk.ZeroDec() - rpnd := sdk.ZeroUint() - pool.SwapPriceExternal = &spe - pool.SwapPriceNative = &spn - pool.RewardPeriodNativeDistributed = rpnd - err := m.keeper.SetPool(ctx, pool) - if err != nil { - panic(err) - } - } - return nil -} - -func (m Migrator) MigrateToVer4(ctx sdk.Context) error { - // Initiate Rewards - m.keeper.SetRewardParams(ctx, types.GetDefaultRewardParams()) - // Initiate PMTP - m.keeper.SetPmtpRateParams(ctx, types.PmtpRateParams{ - PmtpPeriodBlockRate: sdk.ZeroDec(), - PmtpCurrentRunningRate: sdk.ZeroDec(), - PmtpInterPolicyRate: sdk.ZeroDec(), - }) - m.keeper.SetPmtpEpoch(ctx, types.PmtpEpoch{ - EpochCounter: 0, - BlockCounter: 0, - }) - m.keeper.SetPmtpParams(ctx, types.GetDefaultPmtpParams()) - m.keeper.SetPmtpInterPolicyRate(ctx, sdk.NewDec(0)) - pools := m.keeper.GetPools(ctx) - for _, pool := range pools { - spe := sdk.ZeroDec() - spn := sdk.ZeroDec() - rpnd := sdk.ZeroUint() - pool.SwapPriceExternal = &spe - pool.SwapPriceNative = &spn - pool.RewardPeriodNativeDistributed = rpnd - err := m.keeper.SetPool(ctx, pool) - if err != nil { - panic(err) - } - } - return nil -} diff --git a/x/clp/module.go b/x/clp/module.go index 1d0c43eb60..cf190be17f 100644 --- a/x/clp/module.go +++ b/x/clp/module.go @@ -136,14 +136,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err != nil { panic(err) } - err = cfg.RegisterMigration(types.ModuleName, 2, m.MigrateToVer3) - if err != nil { - panic(err) - } - err = cfg.RegisterMigration(types.ModuleName, 3, m.MigrateToVer4) - if err != nil { - panic(err) - } } // InitGenesis performs genesis initialization for the clp module. It returns @@ -173,4 +165,4 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val return EndBlocker(ctx, am.keeper) } -func (AppModule) ConsensusVersion() uint64 { return 4 } +func (AppModule) ConsensusVersion() uint64 { return 2 } diff --git a/x/clp/types/keys.go b/x/clp/types/keys.go index fad6936c04..6eb68d8528 100644 --- a/x/clp/types/keys.go +++ b/x/clp/types/keys.go @@ -52,25 +52,6 @@ func GetLiquidityProviderKey(externalTicker string, lp string) []byte { return append(LiquidityProviderPrefix, key...) } -// TODO remove -// func DefaultRewardsPeriod() []*RewardPeriod { -// rp_1_allocation := sdk.NewUintFromString("10000000000000000000000") -// cethMultiplier := sdk.MustNewDecFromStr("1.5") -// rewardPeriods := []*RewardPeriod{ -// { -// RewardPeriodId: "RP_1", -// RewardPeriodStartBlock: 1, -// RewardPeriodEndBlock: 12 * 60 * 24 * 7, -// RewardPeriodAllocation: &rp_1_allocation, -// RewardPeriodPoolMultipliers: []*PoolMultiplier{{ -// PoolMultiplierAsset: "ceth", -// Multiplier: &cethMultiplier, -// }}, -// }, -// } -// return rewardPeriods -// } - func GetDefaultRewardParams() *RewardParams { return &RewardParams{ LiquidityRemovalLockPeriod: 12 * 60 * 24 * 7, diff --git a/x/tokenregistry/keeper/migrations.go b/x/tokenregistry/keeper/migrations.go index 7c906e339d..1a85231186 100644 --- a/x/tokenregistry/keeper/migrations.go +++ b/x/tokenregistry/keeper/migrations.go @@ -26,14 +26,8 @@ func (m Migrator) MigrateToVer2(ctx sdk.Context) error { } func (m Migrator) MigrateToVer3(ctx sdk.Context) error { - accounts := tkrtypes.AdminAccounts{} - if ctx.ChainID() == "sifchain-1" { - gen := tkrtypes.ProdAdminAccounts() - accounts = *gen - } else { - gen := tkrtypes.InitialAdminAccounts() - accounts = *gen - } + gen := tkrtypes.ProdAdminAccounts() + accounts := *gen m.keeper.DeleteOldAdminAccount(ctx) for _, account := range accounts.AdminAccounts { m.keeper.SetAdminAccount(ctx, account)