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

add upgrade handler for v1.7.5 #1767

Merged
merged 1 commit into from
Dec 3, 2024
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
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 @@
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")

Check warning on line 152 in app/upgrades/v1_7.go

View check run for this annotation

Codecov / codecov/patch

app/upgrades/v1_7.go#L152

Added line #L152 was not covered by tests
}

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)
}
}
joe-bowman marked this conversation as resolved.
Show resolved Hide resolved
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 @@
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",
Dismissed Show dismissed Hide dismissed
joe-bowman marked this conversation as resolved.
Show resolved Hide resolved
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)
}
joe-bowman marked this conversation as resolved.
Show resolved Hide resolved
Loading