Skip to content

Commit

Permalink
add upgrade handler (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajansari95 authored Jul 25, 2023
1 parent 9baf8c3 commit b69a5ee
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
DevnetChainID = "magic-1"
TestChainID = "testchain1"
OsmosisTestnetChainID = "osmo-test-5"
JunoTestnetChainID = "uni-6"

V010402rc1UpgradeName = "v1.4.2-rc1"
V010402rc2UpgradeName = "v1.4.2-rc2"
Expand All @@ -31,6 +32,7 @@ const (
V010404beta7UpgradeName = "v1.4.4-beta.7"
V010404rc0UpgradeName = "v1.4.4-rc.0"
V010404beta8UpgradeName = "v1.4.4-beta.8"
V010404rc1UpgradeName = "v1.4.4-rc.1"
)

// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal
Expand Down
40 changes: 40 additions & 0 deletions app/upgrades/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func Upgrades() []Upgrade {
{UpgradeName: V010404beta7UpgradeName, CreateUpgradeHandler: V010404beta7UpgradeHandler},
{UpgradeName: V010404rc0UpgradeName, CreateUpgradeHandler: V010404rc0UpgradeHandler},
{UpgradeName: V010404beta8UpgradeName, CreateUpgradeHandler: V010404beta8UpgradeHandler},
{UpgradeName: V010404rc1UpgradeName, CreateUpgradeHandler: V010404rc1UpgradeHandler},
}
}

Expand Down Expand Up @@ -467,6 +468,45 @@ func V010404beta8UpgradeHandler(
}
}

func V010404rc1UpgradeHandler(
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 isTestnet(ctx) || isTest(ctx) || isDevnet(ctx) {

appKeepers.InterchainstakingKeeper.RemoveZoneAndAssociatedRecords(ctx, JunoTestnetChainID)
vals := appKeepers.InterchainstakingKeeper.GetValidators(ctx, JunoTestnetChainID)
for _, val := range vals {
valoper, _ := addressutils.ValAddressFromBech32(val.ValoperAddress, "junovaloper")
appKeepers.InterchainstakingKeeper.DeleteValidator(ctx, JunoTestnetChainID, valoper)
}

pdType, exists := prtypes.ProtocolDataType_value["ProtocolDataTypeConnection"]
if !exists {
panic("connection protocol data type not found")
}

appKeepers.ParticipationRewardsKeeper.DeleteProtocolData(ctx, prtypes.GetProtocolDataKey(prtypes.ProtocolDataType(pdType), []byte(JunoTestnetChainID)))

appKeepers.InterchainstakingKeeper.IterateWithdrawalRecords(ctx, func(index int64, record icstypes.WithdrawalRecord) (stop bool) {
if (record.Status == icstypes.WithdrawStatusSend) || record.Requeued || ((record.CompletionTime != time.Time{}) && (record.CompletionTime.Before(ctx.BlockTime()))) {
record.Acknowledged = true
}

if (record.ChainId == "elgafar-1") && (record.CompletionTime == time.Time{}) {
record.Acknowledged = true
}

appKeepers.InterchainstakingKeeper.SetWithdrawalRecord(ctx, record)
return false
})
}
return mm.RunMigrations(ctx, configurator, fromVM)
}
}

// func V010400UpgradeHandler(
// mm *module.Manager,
// configurator module.Configurator,
Expand Down

0 comments on commit b69a5ee

Please sign in to comment.