Skip to content

Commit

Permalink
add upgrade handler for v1.7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-bowman committed Dec 3, 2024
1 parent 2be465f commit 644d7fd
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/upgrades/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func Upgrades() []Upgrade {
{UpgradeName: V010700UpgradeName, CreateUpgradeHandler: V010700UpgradeHandler},
{UpgradeName: V010702UpgradeName, CreateUpgradeHandler: V010702UpgradeHandler},
{UpgradeName: V010704UpgradeName, CreateUpgradeHandler: V010704UpgradeHandler},
{UpgradeName: V010705UpgradeName, CreateUpgradeHandler: V010705UpgradeHandler},
}
}

Expand Down
21 changes: 21 additions & 0 deletions app/upgrades/v1_7.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
46 changes: 46 additions & 0 deletions app/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 644d7fd

Please sign in to comment.