Skip to content

Commit

Permalink
fix: remove use of iota (#484)
Browse files Browse the repository at this point in the history
* fix: remove use of iota

* upgrade handler for v1.4.4-beta.5

* fix: correct current values for unbonding records
  • Loading branch information
Joe Bowman authored Jul 4, 2023
1 parent 2622c62 commit 2d841bf
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 29 deletions.
1 change: 1 addition & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
V010403rc0UpgradeName = "v1.4.3-rc0"
V010404beta0UpgradeName = "v1.4.4-beta.0"
V010404beta1UpgradeName = "v1.4.4-beta.1"
V010404beta5UpgradeName = "v1.4.4-beta.5"
)

// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal
Expand Down
59 changes: 50 additions & 9 deletions app/upgrades/upgrades.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package upgrades

import (
"errors"
"time"

sdkmath "cosmossdk.io/math"
Expand All @@ -12,7 +13,7 @@ import (

"github.com/ingenuity-build/quicksilver/app/keepers"
"github.com/ingenuity-build/quicksilver/utils/addressutils"
"github.com/ingenuity-build/quicksilver/x/interchainstaking/types"
icstypes "github.com/ingenuity-build/quicksilver/x/interchainstaking/types"
prtypes "github.com/ingenuity-build/quicksilver/x/participationrewards/types"
)

Expand Down Expand Up @@ -48,9 +49,9 @@ func V010402rc1UpgradeHandler(
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
if isTestnet(ctx) || isTest(ctx) {
appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *types.Zone) (stop bool) {
appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *icstypes.Zone) (stop bool) {
for _, val := range zone.Validators {
newVal := types.Validator{
newVal := icstypes.Validator{
ValoperAddress: val.ValoperAddress,
CommissionRate: val.CommissionRate,
DelegatorShares: val.DelegatorShares,
Expand Down Expand Up @@ -115,7 +116,7 @@ func V010402rc4UpgradeHandler(
appKeepers.ParticipationRewardsKeeper.DeleteProtocolData(ctx, prtypes.GetProtocolDataKey(prtypes.ProtocolDataType(pdType), []byte("osmo-test-5/ibc/FBD3AC18A981B89F60F9FE5B21BD7F1DE87A53C3505D5A5E438E2399409CFB6F")))
appKeepers.ParticipationRewardsKeeper.DeleteProtocolData(ctx, prtypes.GetProtocolDataKey(prtypes.ProtocolDataType(pdType), []byte("rhye-1/uqosmo")))
rcptTime := time.Unix(1682932342, 0)
rcpt1 := types.Receipt{
rcpt1 := icstypes.Receipt{
ChainId: "theta-testnet-001",
Sender: "cosmos1e6p7tk969ftlzmz82drp84ruukwge6z6udand8",
Txhash: "005AABC399866544CBEC4DC57887A7297289BF40C056A1544D3CE18946DB7DB9",
Expand All @@ -124,7 +125,7 @@ func V010402rc4UpgradeHandler(
Completed: nil,
}

rcpt2 := types.Receipt{
rcpt2 := icstypes.Receipt{
ChainId: "elgafar-1",
Sender: "stars1e6p7tk969ftlzmz82drp84ruukwge6z6g32wxk",
Txhash: "01041964B4CDDD3ECA1C9F1EFC039B547C2D30D5B85C55089EB6F7DF311786B6",
Expand Down Expand Up @@ -152,7 +153,7 @@ func V010402rc5UpgradeHandler(

rcptTime := time.Unix(1682932342, 0)

rcpts := []types.Receipt{
rcpts := []icstypes.Receipt{
{
ChainId: "theta-testnet-001",
Sender: "cosmos1e6p7tk969ftlzmz82drp84ruukwge6z6udand8",
Expand Down Expand Up @@ -229,7 +230,7 @@ func V010402rc6UpgradeHandler(
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
if isTestnet(ctx) || isTest(ctx) {
// for each zone, trigger an icq request to update all delegations.
appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *types.Zone) (stop bool) {
appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *icstypes.Zone) (stop bool) {
vals := appKeepers.InterchainstakingKeeper.GetValidators(ctx, zone.ChainId)
delegationQuery := stakingtypes.QueryDelegatorDelegationsRequest{DelegatorAddr: zone.DelegationAddress.Address, Pagination: &query.PageRequest{Limit: uint64(len(vals))}}
bz := appKeepers.InterchainstakingKeeper.GetCodec().MustMarshal(&delegationQuery)
Expand All @@ -241,7 +242,7 @@ func V010402rc6UpgradeHandler(
"cosmos.staking.v1beta1.Query/DelegatorDelegations",
bz,
sdk.NewInt(-1),
types.ModuleName,
icstypes.ModuleName,
"delegations",
0,
)
Expand Down Expand Up @@ -284,7 +285,7 @@ func V010404beta0UpgradeHandler(
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
if isTestnet(ctx) || isTest(ctx) {
appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *types.Zone) (stop bool) {
appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *icstypes.Zone) (stop bool) {
zone.Is_118 = true
appKeepers.InterchainstakingKeeper.SetZone(ctx, zone)
return false
Expand All @@ -295,6 +296,46 @@ func V010404beta0UpgradeHandler(
}
}

func V010404beta5UpgradeHandler(
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 isDevnet(ctx) || isTest(ctx) {
// 6d3cc69d3276dd59a93a252e1ea15fc1e507c56512266c87c615fac4dcddb5cb
wr, found := appKeepers.InterchainstakingKeeper.GetWithdrawalRecord(ctx, "theta-testnet-001", "6d3cc69d3276dd59a93a252e1ea15fc1e507c56512266c87c615fac4dcddb5cb", 3)
if !found {
return nil, errors.New("unable to find withdrawal record 6d3cc69d3276dd59a93a252e1ea15fc1e507c56512266c87c615fac4dcddb5cb")
}
appKeepers.InterchainstakingKeeper.UpdateWithdrawalRecordStatus(ctx, &wr, icstypes.WithdrawStatusQueued)

// b9c6587af3317bfb4b21a29df3f7e1a00709c25b0590446cceb01b8c6996b656
wr, found = appKeepers.InterchainstakingKeeper.GetWithdrawalRecord(ctx, "theta-testnet-001", "b9c6587af3317bfb4b21a29df3f7e1a00709c25b0590446cceb01b8c6996b656", 3)
if !found {
return nil, errors.New("unable to find withdrawal record b9c6587af3317bfb4b21a29df3f7e1a00709c25b0590446cceb01b8c6996b656")
}
appKeepers.InterchainstakingKeeper.UpdateWithdrawalRecordStatus(ctx, &wr, icstypes.WithdrawStatusQueued)

// 995c6a77a568a7c03906ce6c7d470c11daa7e506f33264360cf1fec71fc774fe
wr, found = appKeepers.InterchainstakingKeeper.GetWithdrawalRecord(ctx, "regen-redwood-1", "995c6a77a568a7c03906ce6c7d470c11daa7e506f33264360cf1fec71fc774fe", 4)
if !found {
return nil, errors.New("unable to find withdrawal record 995c6a77a568a7c03906ce6c7d470c11daa7e506f33264360cf1fec71fc774fe")
}
appKeepers.InterchainstakingKeeper.UpdateWithdrawalRecordStatus(ctx, &wr, icstypes.WithdrawStatusUnbond)

// 95aec506a8281c90cb45395ecc7b562248135f8643e1017db469d847db125fbd
wr, found = appKeepers.InterchainstakingKeeper.GetWithdrawalRecord(ctx, "uni-6", "95aec506a8281c90cb45395ecc7b562248135f8643e1017db469d847db125fbd", 4)
if !found {
return nil, errors.New("unable to find withdrawal record 95aec506a8281c90cb45395ecc7b562248135f8643e1017db469d847db125fbd")
}
appKeepers.InterchainstakingKeeper.UpdateWithdrawalRecordStatus(ctx, &wr, icstypes.WithdrawStatusUnbond)
}

return mm.RunMigrations(ctx, configurator, fromVM)
}
}

// func V010400UpgradeHandler(
// mm *module.Manager,
// configurator module.Configurator,
Expand Down
2 changes: 1 addition & 1 deletion x/epochs/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (

// prefix bytes for the epoch persistent store.
const (
prefixEpoch = iota + 1
prefixEpoch = 0x01
)

const (
Expand Down
6 changes: 3 additions & 3 deletions x/interchainquery/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const (

// prefix bytes for the interchainquery persistent store.
const (
prefixData = iota + 1
prefixQuery = iota + 1
prefixLatestHeight = iota + 1
prefixData = 0x01
prefixQuery = 0x02
prefixLatestHeight = 0x03
)

var (
Expand Down
10 changes: 5 additions & 5 deletions x/interchainstaking/types/withdrawal_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const (
DefaultWithdrawalRequeueDelay = 6 * time.Hour

// setting WithdrawStatusTokenize as 0 causes the value to be omitted when (un)marshalling :/.
WithdrawStatusTokenize int32 = iota + 1
WithdrawStatusQueued int32 = iota + 1
WithdrawStatusUnbond int32 = iota + 1
WithdrawStatusSend int32 = iota + 1
WithdrawStatusCompleted int32 = iota + 1
WithdrawStatusTokenize int32 = 1
WithdrawStatusQueued int32 = 2
WithdrawStatusUnbond int32 = 3
WithdrawStatusSend int32 = 4
WithdrawStatusCompleted int32 = 5
)

// DelayCompletion updates a withdrawal record completion date to:
Expand Down
14 changes: 3 additions & 11 deletions x/interchainstaking/types/zones.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,10 @@ COINS:
return out
}

// decode memo
// field_id = [
// 0x00 = map
// 0x01 = rts
// 0x02 = validator intent
// ] // will scale to future fields

const (
FieldTypeAccountMap int = iota
FieldTypeReturnToSender
FieldTypeIntent
// add more here.
FieldTypeAccountMap int = 0x00
FieldTypeReturnToSender int = 0x01
FieldTypeIntent int = 0x02
)

type MemoField struct {
Expand Down

0 comments on commit 2d841bf

Please sign in to comment.