Skip to content

Commit

Permalink
v1.7.4 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Bowman authored and joe-bowman committed Nov 26, 2024
1 parent 3377d70 commit c9ecfb3
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const (

V010700UpgradeName = "v1.7.0"
V010702UpgradeName = "v1.7.2"
V010704UpgradeName = "v1.7.4"
)

// 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 @@ -26,6 +26,7 @@ func Upgrades() []Upgrade {
{UpgradeName: V010604UpgradeName, CreateUpgradeHandler: V010604UpgradeHandler},
{UpgradeName: V010700UpgradeName, CreateUpgradeHandler: V010700UpgradeHandler},
{UpgradeName: V010702UpgradeName, CreateUpgradeHandler: V010702UpgradeHandler},
{UpgradeName: V010704UpgradeName, CreateUpgradeHandler: V010704UpgradeHandler},
}
}

Expand Down
65 changes: 65 additions & 0 deletions app/upgrades/v1_7.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package upgrades

import (
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
Expand Down Expand Up @@ -73,3 +75,66 @@ func V010702UpgradeHandler(
return mm.RunMigrations(ctx, configurator, fromVM)
}
}

func V010704UpgradeHandler(
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) {

// delete previously sent records. this record was not removed in the previous upgrade because it was not in the unbond status.
hashes := []struct {
Zone string
Hash string
Status int32
}{
{Zone: "stargaze-1", Hash: "10af0ee10a97f01467039a69cbfb8df05dc3111c975d955ca51adda201f36555", Status: icstypes.WithdrawStatusSend},
}
for _, hashRecord := range hashes {
// delete duplicate records.
appKeepers.InterchainstakingKeeper.DeleteWithdrawalRecord(ctx, hashRecord.Zone, hashRecord.Hash, hashRecord.Status)
}

hashes = []struct {
Zone string
Hash string
Status int32
}{
{Zone: "cosmoshub-4", Hash: "02c2d4bcb869b9ddf26540c2854c2ca09d70492a3831170da293f4101fda32b3", Status: icstypes.WithdrawStatusUnbond},
}
for _, hashRecord := range hashes {
// requeue duplicate records.
record, found := appKeepers.InterchainstakingKeeper.GetWithdrawalRecord(ctx, hashRecord.Zone, hashRecord.Hash, hashRecord.Status)
if !found {
panic("record not found")
}
record.SendErrors = 0
record.Amount = nil
record.Distribution = nil
record.CompletionTime = time.Time{}
record.Acknowledged = false

appKeepers.InterchainstakingKeeper.UpdateWithdrawalRecordStatus(ctx, &record, icstypes.WithdrawStatusQueued)
}

// get zone
zone, found := appKeepers.InterchainstakingKeeper.GetZone(ctx, "cosmoshub-4")
if !found {
panic("zone not found")
}

appKeepers.InterchainstakingKeeper.OverrideRedemptionRateNoCap(ctx, &zone)
// set new redemption rate to 1.37
zone.LastRedemptionRate = sdk.NewDecWithPrec(137, 2)
appKeepers.InterchainstakingKeeper.SetZone(ctx, &zone)

// remove 2x old icq queries that will never be satisfied.
appKeepers.InterchainQueryKeeper.DeleteQuery(ctx, "d611198d85fed38e7486b9402480e561533911059a35258abce1220479b7bb7e")
appKeepers.InterchainQueryKeeper.DeleteQuery(ctx, "533f78f574edcfe6153c753d7769072e86b6586cf9837fe9fec1ad84354433ec")
}

return mm.RunMigrations(ctx, configurator, fromVM)
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/celestiaorg/go-square/v2 v2.0.0
github.com/celestiaorg/nmt v0.22.2
github.com/client9/misspell v0.3.4
github.com/cometbft/cometbft-db v1.0.1
github.com/cometbft/cometbft-db v0.12.0
github.com/confio/ics23/go v0.9.1
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.46.16
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONN
github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c=
github.com/cometbft/cometbft v0.34.33 h1:2nnMU8smD1fpkY4JP6GWSaWmxE4BhqL60LG+Sr+Ijzo=
github.com/cometbft/cometbft v0.34.33/go.mod h1:S1rXDQyGEJQVle3vneIHV570I1ulneWgF1ScGvUO+bI=
github.com/cometbft/cometbft-db v1.0.1 h1:SylKuLseMLQKw3+i8y8KozZyJcQSL98qEe2CGMCGTYE=
github.com/cometbft/cometbft-db v1.0.1/go.mod h1:EBrFs1GDRiTqrWXYi4v90Awf/gcdD5ExzdPbg4X8+mk=
github.com/cometbft/cometbft-db v0.12.0 h1:v77/z0VyfSU7k682IzZeZPFZrQAKiQwkqGN0QzAjMi0=
github.com/cometbft/cometbft-db v0.12.0/go.mod h1:aX2NbCrjNVd2ZajYxt1BsiFf/Z+TQ2MN0VxdicheYuw=
github.com/confio/ics23/go v0.9.1 h1:3MV46eeWwO3xCauKyAtuAdJYMyPnnchW4iLr2bTw6/U=
github.com/confio/ics23/go v0.9.1/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak=
github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg=
Expand Down
Loading

0 comments on commit c9ecfb3

Please sign in to comment.