diff --git a/app/upgrades/types.go b/app/upgrades/types.go index 540319c15..d9c2fd6d2 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -52,6 +52,7 @@ const ( V010700UpgradeName = "v1.7.0" V010702UpgradeName = "v1.7.2" V010704UpgradeName = "v1.7.4" + V010705UpgradeName = "v1.7.5" ) // Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal diff --git a/app/upgrades/upgrades.go b/app/upgrades/upgrades.go index 79150d741..223acf389 100644 --- a/app/upgrades/upgrades.go +++ b/app/upgrades/upgrades.go @@ -27,6 +27,7 @@ func Upgrades() []Upgrade { {UpgradeName: V010700UpgradeName, CreateUpgradeHandler: V010700UpgradeHandler}, {UpgradeName: V010702UpgradeName, CreateUpgradeHandler: V010702UpgradeHandler}, {UpgradeName: V010704UpgradeName, CreateUpgradeHandler: V010704UpgradeHandler}, + {UpgradeName: V010705UpgradeName, CreateUpgradeHandler: V010705UpgradeHandler}, } } diff --git a/app/upgrades/v1_7.go b/app/upgrades/v1_7.go index faf897a64..9a26689e6 100644 --- a/app/upgrades/v1_7.go +++ b/app/upgrades/v1_7.go @@ -138,3 +138,24 @@ func V010704UpgradeHandler( return mm.RunMigrations(ctx, configurator, fromVM) } } + +func V010705UpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + appKeepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + if isMainnet(ctx) || isTest(ctx) { + // get zone + zone, found := appKeepers.InterchainstakingKeeper.GetZone(ctx, "cosmoshub-4") + if !found { + panic("zone not found") + } + + appKeepers.InterchainstakingKeeper.OverrideRedemptionRateNoCap(ctx, &zone) + zone.LastRedemptionRate = sdk.NewDecWithPrec(138, 2) // correct as of 3/12 + appKeepers.InterchainstakingKeeper.SetZone(ctx, &zone) + } + return mm.RunMigrations(ctx, configurator, fromVM) + } +} diff --git a/app/upgrades_test.go b/app/upgrades_test.go index c63343583..222f62487 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -469,3 +469,49 @@ func (s *AppTestSuite) TestV010604UpgradeHandler() { s.True(record.CompletionTime.IsZero()) } } + +func (s *AppTestSuite) TestV010705UpgradeHandler() { + s.InitV160TestZones() + app := s.GetQuicksilverApp(s.chainA) + + ctx := s.chainA.GetContext() + completion, err := time.Parse("2006-01-02T15:04:05Z", "2024-12-20T17:00:47Z") + s.NoError(err) + + record := icstypes.WithdrawalRecord{ + ChainId: "cosmoshub-4", + Delegator: "quick1efpktthkfsuzqhsnqdyyjxv5fl9eemchrlmhyd", + Recipient: "cosmos1efpktthkfsuzqhsnqdyyjxv5fl9eemchgmt9al", + Txhash: "02c2d4bcb869b9ddf26540c2854c2ca09d70492a3831170da293f4101fda32b3", + Status: icstypes.WithdrawStatusUnbond, + BurnAmount: sdk.NewCoin("uqatom", math.NewInt(3534090000)), + Amount: sdk.NewCoins(sdk.NewCoin("uatom", math.NewInt(4841699172))), + Acknowledged: true, + CompletionTime: completion, + } + + zone, found := app.InterchainstakingKeeper.GetZone(ctx, "cosmoshub-4") + s.True(found) + + delegation := icstypes.Delegation{ + DelegationAddress: zone.DelegationAddress.Address, + ValidatorAddress: "cosmosvaloper1efpktthkfsuzqhsnqdyyjxv5fl9eemchd0ls3v", + Amount: sdk.NewCoin("uatom", math.NewInt(37848188596)), + } + + app.InterchainstakingKeeper.SetDelegation(ctx, "cosmoshub-4", delegation) + + s.NoError(app.BankKeeper.MintCoins(ctx, icstypes.ModuleName, sdk.NewCoins(sdk.NewCoin("uqatom", math.NewInt(30811987786))))) + s.NoError(app.BankKeeper.SendCoinsFromModuleToModule(ctx, icstypes.ModuleName, icstypes.EscrowModuleAccount, sdk.NewCoins(sdk.NewCoin("uqatom", math.NewInt(3534090000))))) + s.NoError(app.InterchainstakingKeeper.SetWithdrawalRecord(ctx, record)) + + handler := upgrades.V010705UpgradeHandler(app.mm, app.configurator, &app.AppKeepers) + + _, err = handler(ctx, types.Plan{}, app.mm.GetVersionMap()) + s.NoError(err) + + zone, found = app.InterchainstakingKeeper.GetZone(ctx, "cosmoshub-4") + s.True(found) + s.Equal(sdk.NewDecWithPrec(1387503864591246254, 18), zone.RedemptionRate) + s.Equal(sdk.NewDecWithPrec(138, 2), zone.LastRedemptionRate) +}