From ae1a27e95b2bb717bb36da54f50a1c211a92e8ec Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Wed, 6 Mar 2024 13:46:16 +0400 Subject: [PATCH 1/5] lint (#1244) --- x/claimsmanager/keeper/grpc_query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/claimsmanager/keeper/grpc_query.go b/x/claimsmanager/keeper/grpc_query.go index 6414bd4b1..0b2ae7726 100644 --- a/x/claimsmanager/keeper/grpc_query.go +++ b/x/claimsmanager/keeper/grpc_query.go @@ -99,7 +99,7 @@ func (k Keeper) UserLastEpochClaims(c context.Context, q *types.QueryClaimsReque } // First byte was 0x01, so no need to consider it; + 1 to skip the separator. - idx += 1 + idx++ if bytes.Equal(key[idx:idx+len(addrBytes)], addrBytes) { out = append(out, claim) From d222e1850890318e6417756c84724adc6809de7f Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Wed, 6 Mar 2024 13:53:56 +0400 Subject: [PATCH 2/5] v1.5.0-rc1 upgrade handler (#1235) * refactor: upgrade handlers by version * v1.5.0-rc1 upgrade handler * lint --- app/upgrades/account_migrations.go | 9 - app/upgrades/types.go | 2 + app/upgrades/upgrades.go | 256 +------------------ app/upgrades/v1_4.go | 253 +++++++++++++++++++ app/upgrades/v1_5.go | 198 +++++++++++++++ app/upgrades/v1_6.go | 23 ++ app/upgrades_test.go | 387 +++++++++++++++++++++++++++-- 7 files changed, 840 insertions(+), 288 deletions(-) create mode 100644 app/upgrades/v1_4.go create mode 100644 app/upgrades/v1_5.go create mode 100644 app/upgrades/v1_6.go diff --git a/app/upgrades/account_migrations.go b/app/upgrades/account_migrations.go index 39f188026..b2c0d62ce 100644 --- a/app/upgrades/account_migrations.go +++ b/app/upgrades/account_migrations.go @@ -15,15 +15,6 @@ import ( type ProcessMigrateAccountStrategy func(ctx sdk.Context, appKeepers *keepers.AppKeepers, from sdk.AccAddress, to sdk.AccAddress) error -// Migrate the Ingenuity genesis allocation to Notional. -func migrateIngenuityMultisigToNotional(ctx sdk.Context, appKeepers *keepers.AppKeepers) error { - // migrate ingenuity multisig to notional multisig. - migrations := map[string]string{ - "quick1e22za5qrqqp488h5p7vw2pfx8v0y4u444ufeuw": "quick1gxrks2rcj9gthzfgrkjk5lnk0g00cg0cpyntlm", - } - return migrateVestingAccounts(ctx, appKeepers, migrations, migratePeriodicVestingAccount) -} - // Migrate a map of address pairs and migrate from key -> value func migrateVestingAccounts(ctx sdk.Context, appKeepers *keepers.AppKeepers, migrations map[string]string, strategy ProcessMigrateAccountStrategy) error { for _, fromBech32 := range utils.Keys(migrations) { diff --git a/app/upgrades/types.go b/app/upgrades/types.go index b542d2b44..249ec4856 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -23,12 +23,14 @@ const ( V010407rc1UpgradeName = "v1.4.7-rc1" V010407rc2UpgradeName = "v1.4.7-rc2" V010500rc0UpgradeName = "v1.5.0-rc0" + V010500rc1UpgradeName = "v1.5.0-rc1" // mainnet upgrades V010217UpgradeName = "v1.2.17" V010405UpgradeName = "v1.4.5" V010406UpgradeName = "v1.4.6" V010407UpgradeName = "v1.4.7" + V010500UpgradeName = "v1.5.0" V010600UpgradeName = "v1.6.0" ) diff --git a/app/upgrades/upgrades.go b/app/upgrades/upgrades.go index a5b54b359..3817ad8f0 100644 --- a/app/upgrades/upgrades.go +++ b/app/upgrades/upgrades.go @@ -1,19 +1,11 @@ package upgrades import ( - "fmt" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/types/query" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/quicksilver-zone/quicksilver/app/keepers" - icstypes "github.com/quicksilver-zone/quicksilver/x/interchainstaking/types" ) func Upgrades() []Upgrade { @@ -25,12 +17,14 @@ func Upgrades() []Upgrade { {UpgradeName: V010407rc1UpgradeName, CreateUpgradeHandler: V010407rc1UpgradeHandler}, {UpgradeName: V010407rc2UpgradeName, CreateUpgradeHandler: V010407rc2UpgradeHandler}, {UpgradeName: V010500rc0UpgradeName, CreateUpgradeHandler: NoOpHandler}, + {UpgradeName: V010500rc1UpgradeName, CreateUpgradeHandler: V010500rc1UpgradeHandler}, // v1.2: this needs to be present to support upgrade on mainnet {UpgradeName: V010217UpgradeName, CreateUpgradeHandler: NoOpHandler}, {UpgradeName: V010405UpgradeName, CreateUpgradeHandler: NoOpHandler}, {UpgradeName: V010406UpgradeName, CreateUpgradeHandler: V010406UpgradeHandler}, {UpgradeName: V010407UpgradeName, CreateUpgradeHandler: V010407UpgradeHandler}, + {UpgradeName: V010500UpgradeName, CreateUpgradeHandler: V010500UpgradeHandler}, {UpgradeName: V010600UpgradeName, CreateUpgradeHandler: V010600UpgradeHandler}, } } @@ -45,249 +39,3 @@ func NoOpHandler( return mm.RunMigrations(ctx, configurator, fromVM) } } - -func V010406UpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - appKeepers *keepers.AppKeepers, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *icstypes.Zone) (stop bool) { - // add new fields - zone.DepositsEnabled = true - zone.ReturnToSender = false - zone.UnbondingEnabled = true - zone.Decimals = 6 - zone.Is_118 = true - if zone.ChainId == "cosmoshub-4" { - zone.LiquidityModule = true - } - - // migrate all validators from within the zone struct, to own KV store. - for _, val := range zone.Validators { - newVal := icstypes.Validator{ - ValoperAddress: val.ValoperAddress, - CommissionRate: val.CommissionRate, - DelegatorShares: val.DelegatorShares, - VotingPower: val.VotingPower, - Score: val.Score, - Status: val.Status, - Jailed: val.Jailed, - Tombstoned: val.Tombstoned, - JailedSince: val.JailedSince, - ValidatorBondShares: val.ValidatorBondShares, - LiquidShares: val.LiquidShares, - } - err := appKeepers.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, newVal) - if err != nil { - panic(err) - } - - // trigger a valset refresh to update all vals. - query := stakingtypes.QueryValidatorsRequest{} - _ = appKeepers.InterchainstakingKeeper.EmitValSetQuery(ctx, zone.ConnectionId, zone.ChainId, query, math.NewInt(-1)) - } - - appKeepers.InterchainstakingKeeper.SetAddressZoneMapping(ctx, zone.DepositAddress.Address, zone.ChainId) - appKeepers.InterchainstakingKeeper.SetAddressZoneMapping(ctx, zone.DelegationAddress.Address, zone.ChainId) - appKeepers.InterchainstakingKeeper.SetAddressZoneMapping(ctx, zone.PerformanceAddress.Address, zone.ChainId) - appKeepers.InterchainstakingKeeper.SetAddressZoneMapping(ctx, zone.WithdrawalAddress.Address, zone.ChainId) - - zone.Validators = nil - appKeepers.InterchainstakingKeeper.SetZone(ctx, zone) - return false - }) - - // set lsm caps - appKeepers.InterchainstakingKeeper.SetLsmCaps(ctx, "cosmoshub-4", - icstypes.LsmCaps{ - ValidatorCap: sdk.NewDecWithPrec(100, 2), - ValidatorBondCap: sdk.NewDec(250), - GlobalCap: sdk.NewDecWithPrec(25, 2), - }, - ) - - // migrate vesting accounts for misplaced testnet wallets - if err := migrateTestnetIncentives(ctx, appKeepers); err != nil { - panic(fmt.Sprintf("unable to migrate testnet incentives: %v", err)) - } - - // migrate vesting account from ingenuity to notional - if err := migrateIngenuityMultisigToNotional(ctx, appKeepers); err != nil { - panic(fmt.Sprintf("unable to migrate ingenuity multisig: %v", err)) - } - - return mm.RunMigrations(ctx, configurator, fromVM) - } -} - -// Migrate the outstanding testnet incentives with misplaced wallets. -// N.B. these assets are only returning to their original testnet addresses. -func migrateTestnetIncentives(ctx sdk.Context, appKeepers *keepers.AppKeepers) error { - migrations := map[string]string{ - "quick1qlckz3nplj3sf323n4ma7n75fmv60lpclq5ccc": "quick15dhqkz3mxxg4tt3m8uz5yy3mzfckgzzh5hpaqp", - "quick1edavtxhdfs8luyvedgkjcxjc9dtvks3ve7etku": "quick1dz3y9k9harjal8nyqg3vl570aj7slaemmxgn86", - "quick1pajjuywnj6w3y6pclp4tj55a7ngz9tp2z4pgep": "quick15sr0uhelt0hw4x7l9zsy4a7hqkaw6jepq4ald9", - "quick1vhd4n5u8rsmsdgs4h7zsn4h4klsej6n8spvsl3": "quick12fyxjyxt64c2q5y0sdts6m4uxcy4cmff7l0ffx", - "quick1rufya429ss9nlhdram0xkcu0jejsz5atap0xan": "quick124pvdf300p2wmq6cl8wwy2z0637du6ec0nhxen", - "quick1f8jp5tr86gn5yvwecr7a4a9zypqf2mg85p96rw": "quick1f708swcmeej2ddfksyvtpaxe07fz0r03f79dlq", - } - return migrateVestingAccounts(ctx, appKeepers, migrations, migratePeriodicVestingAccount) -} - -func V010407rc1UpgradeHandler( - 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) { - // remove osmo-test-5 so we can reinstate - appKeepers.InterchainstakingKeeper.RemoveZoneAndAssociatedRecords(ctx, "osmo-test-5") - } - - return mm.RunMigrations(ctx, configurator, fromVM) - } -} - -func V010407rc2UpgradeHandler( - 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) || isDevnet(ctx) { - 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) - - appKeepers.InterchainQueryKeeper.MakeRequest( - ctx, - zone.ConnectionId, - zone.ChainId, - "cosmos.staking.v1beta1.Query/DelegatorDelegations", - bz, - sdk.NewInt(-1), - icstypes.ModuleName, - "delegations", - 0, - ) - - balancesQuery := banktypes.QueryAllBalancesRequest{Address: zone.DelegationAddress.Address} - bz = appKeepers.InterchainstakingKeeper.GetCodec().MustMarshal(&balancesQuery) - appKeepers.InterchainQueryKeeper.MakeRequest( - ctx, - zone.ConnectionId, - zone.ChainId, - "cosmos.bank.v1beta1.Query/AllBalances", - bz, - sdk.NewInt(-1), - icstypes.ModuleName, - "delegationaccountbalances", - 0, - ) - // increment waitgroup; decremented in delegationaccountbalance callback - zone.WithdrawalWaitgroup++ - - appKeepers.InterchainstakingKeeper.SetZone(ctx, zone) - - return false - }) - } - - return mm.RunMigrations(ctx, configurator, fromVM) - } -} - -func V010407UpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - appKeepers *keepers.AppKeepers, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // set redemption rate to value correct as of 2024-02-01T20:00UTC. - rates := map[string]sdk.Dec{ - "cosmoshub-4": sdk.NewDecFromInt(math.NewInt(219_280_116_789)).QuoInt64(186_283_929_157), - "stargaze-1": sdk.NewDecFromInt(math.NewInt(7_883_310_380_922)).QuoInt64(6_142_958_768_078), - "osmosis-1": sdk.NewDecFromInt(math.NewInt(363_909_524_952)).QuoInt64(322_912_055_083), - "sommelier-3": sdk.NewDecFromInt(math.NewInt(657_103_764_225)).QuoInt64(637_871_903_193), - "regen-1": sdk.NewDecFromInt(math.NewInt(5_606_819_529_428)).QuoInt64(4_543_207_966_192), - "juno-1": sdk.NewDecFromInt(math.NewInt(7_439_000_263)).QuoInt64(7_018_171_980), - } - - // trigger redemption rate update immediately after upgrade. - 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) - - appKeepers.InterchainQueryKeeper.MakeRequest( - ctx, - zone.ConnectionId, - zone.ChainId, - "cosmos.staking.v1beta1.Query/DelegatorDelegations", - bz, - sdk.NewInt(-1), - icstypes.ModuleName, - "delegations", - 0, - ) - - balancesQuery := banktypes.QueryAllBalancesRequest{Address: zone.DelegationAddress.Address} - bz = appKeepers.InterchainstakingKeeper.GetCodec().MustMarshal(&balancesQuery) - appKeepers.InterchainQueryKeeper.MakeRequest( - ctx, - zone.ConnectionId, - zone.ChainId, - "cosmos.bank.v1beta1.Query/AllBalances", - bz, - sdk.NewInt(-1), - icstypes.ModuleName, - "delegationaccountbalances", - 0, - ) - // increment waitgroup; decremented in delegationaccountbalance callback - zone.WithdrawalWaitgroup++ - zone.RedemptionRate = rates[zone.ChainId] - zone.LastRedemptionRate = rates[zone.ChainId] - appKeepers.InterchainstakingKeeper.SetZone(ctx, zone) - - return false - }) - - // migrate testnet user account. - migrations := map[string]string{ - "quick1k67rz3vn73tzp2tatlka2kn2ngtjdw8gpw8zq2": "quick1plq2mrsn0uw2dkksptr9dsyyk62dkk6t7w79j2", - } - - if err := migrateVestingAccounts(ctx, appKeepers, migrations, migratePeriodicVestingAccount); err != nil { - panic(err) - } - - return mm.RunMigrations(ctx, configurator, fromVM) - } -} - -func V010600UpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - appKeepers *keepers.AppKeepers, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *icstypes.Zone) (stop bool) { - appKeepers.InterchainstakingKeeper.SetLocalDenomZoneMapping(ctx, zone) - return false - }) - migrations := map[string]string{ - "quick1a7n7z45gs0dut2syvkszffgwmgps6scqen3e5l": "quick1h0sqndv2y4xty6uk0sv4vckgyc5aa7n5at7fll", - "quick1m0anwr4kcz0y9s65czusun2ahw35g3humv4j7f": "quick1n4g6037cjm0e0v2nvwj2ngau7pk758wtwk6lwq", - } - - if err := migrateVestingAccounts(ctx, appKeepers, migrations, migrateVestingAccountWithActions); err != nil { - panic(err) - } - - return mm.RunMigrations(ctx, configurator, fromVM) - } -} diff --git a/app/upgrades/v1_4.go b/app/upgrades/v1_4.go new file mode 100644 index 000000000..3f950bbaa --- /dev/null +++ b/app/upgrades/v1_4.go @@ -0,0 +1,253 @@ +package upgrades + +import ( + "fmt" + + "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/types/query" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/quicksilver-zone/quicksilver/app/keepers" + icstypes "github.com/quicksilver-zone/quicksilver/x/interchainstaking/types" +) + +// ======================== TESTNET UPGRADE HANDLER ========================= + +func V010407rc1UpgradeHandler( + 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) { + // remove osmo-test-5 so we can reinstate + appKeepers.InterchainstakingKeeper.RemoveZoneAndAssociatedRecords(ctx, "osmo-test-5") + } + + return mm.RunMigrations(ctx, configurator, fromVM) + } +} + +func V010407rc2UpgradeHandler( + 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) || isDevnet(ctx) { + 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) + + appKeepers.InterchainQueryKeeper.MakeRequest( + ctx, + zone.ConnectionId, + zone.ChainId, + "cosmos.staking.v1beta1.Query/DelegatorDelegations", + bz, + sdk.NewInt(-1), + icstypes.ModuleName, + "delegations", + 0, + ) + + balancesQuery := banktypes.QueryAllBalancesRequest{Address: zone.DelegationAddress.Address} + bz = appKeepers.InterchainstakingKeeper.GetCodec().MustMarshal(&balancesQuery) + appKeepers.InterchainQueryKeeper.MakeRequest( + ctx, + zone.ConnectionId, + zone.ChainId, + "cosmos.bank.v1beta1.Query/AllBalances", + bz, + sdk.NewInt(-1), + icstypes.ModuleName, + "delegationaccountbalances", + 0, + ) + // increment waitgroup; decremented in delegationaccountbalance callback + zone.WithdrawalWaitgroup++ + + appKeepers.InterchainstakingKeeper.SetZone(ctx, zone) + + return false + }) + } + + return mm.RunMigrations(ctx, configurator, fromVM) + } +} + +// ======================= PRODUCTION UPGRADE HANDLER ====================== + +func V010406UpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + appKeepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *icstypes.Zone) (stop bool) { + // add new fields + zone.DepositsEnabled = true + zone.ReturnToSender = false + zone.UnbondingEnabled = true + zone.Decimals = 6 + zone.Is_118 = true + if zone.ChainId == "cosmoshub-4" { + zone.LiquidityModule = true + } + + // migrate all validators from within the zone struct, to own KV store. + for _, val := range zone.Validators { + newVal := icstypes.Validator{ + ValoperAddress: val.ValoperAddress, + CommissionRate: val.CommissionRate, + DelegatorShares: val.DelegatorShares, + VotingPower: val.VotingPower, + Score: val.Score, + Status: val.Status, + Jailed: val.Jailed, + Tombstoned: val.Tombstoned, + JailedSince: val.JailedSince, + ValidatorBondShares: val.ValidatorBondShares, + LiquidShares: val.LiquidShares, + } + err := appKeepers.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, newVal) + if err != nil { + panic(err) + } + + // trigger a valset refresh to update all vals. + query := stakingtypes.QueryValidatorsRequest{} + _ = appKeepers.InterchainstakingKeeper.EmitValSetQuery(ctx, zone.ConnectionId, zone.ChainId, query, math.NewInt(-1)) + } + + appKeepers.InterchainstakingKeeper.SetAddressZoneMapping(ctx, zone.DepositAddress.Address, zone.ChainId) + appKeepers.InterchainstakingKeeper.SetAddressZoneMapping(ctx, zone.DelegationAddress.Address, zone.ChainId) + appKeepers.InterchainstakingKeeper.SetAddressZoneMapping(ctx, zone.PerformanceAddress.Address, zone.ChainId) + appKeepers.InterchainstakingKeeper.SetAddressZoneMapping(ctx, zone.WithdrawalAddress.Address, zone.ChainId) + + zone.Validators = nil + appKeepers.InterchainstakingKeeper.SetZone(ctx, zone) + return false + }) + + // set lsm caps + appKeepers.InterchainstakingKeeper.SetLsmCaps(ctx, "cosmoshub-4", + icstypes.LsmCaps{ + ValidatorCap: sdk.NewDecWithPrec(100, 2), + ValidatorBondCap: sdk.NewDec(250), + GlobalCap: sdk.NewDecWithPrec(25, 2), + }, + ) + + // migrate vesting accounts for misplaced testnet wallets + if err := migrateTestnetIncentives146(ctx, appKeepers); err != nil { + panic(fmt.Sprintf("unable to migrate testnet incentives: %v", err)) + } + + // migrate vesting account from ingenuity to notional + if err := migrateIngenuityMultisigToNotional(ctx, appKeepers); err != nil { + panic(fmt.Sprintf("unable to migrate ingenuity multisig: %v", err)) + } + + return mm.RunMigrations(ctx, configurator, fromVM) + } +} + +// Migrate the Ingenuity genesis allocation to Notional. +func migrateIngenuityMultisigToNotional(ctx sdk.Context, appKeepers *keepers.AppKeepers) error { + // migrate ingenuity multisig to notional multisig. + migrations := map[string]string{ + "quick1e22za5qrqqp488h5p7vw2pfx8v0y4u444ufeuw": "quick1gxrks2rcj9gthzfgrkjk5lnk0g00cg0cpyntlm", + } + return migrateVestingAccounts(ctx, appKeepers, migrations, migratePeriodicVestingAccount) +} + +// Migrate the outstanding testnet incentives with misplaced wallets. +// N.B. these assets are only returning to their original testnet addresses. +func migrateTestnetIncentives146(ctx sdk.Context, appKeepers *keepers.AppKeepers) error { + migrations := map[string]string{ + "quick1qlckz3nplj3sf323n4ma7n75fmv60lpclq5ccc": "quick15dhqkz3mxxg4tt3m8uz5yy3mzfckgzzh5hpaqp", + "quick1edavtxhdfs8luyvedgkjcxjc9dtvks3ve7etku": "quick1dz3y9k9harjal8nyqg3vl570aj7slaemmxgn86", + "quick1pajjuywnj6w3y6pclp4tj55a7ngz9tp2z4pgep": "quick15sr0uhelt0hw4x7l9zsy4a7hqkaw6jepq4ald9", + "quick1vhd4n5u8rsmsdgs4h7zsn4h4klsej6n8spvsl3": "quick12fyxjyxt64c2q5y0sdts6m4uxcy4cmff7l0ffx", + "quick1rufya429ss9nlhdram0xkcu0jejsz5atap0xan": "quick124pvdf300p2wmq6cl8wwy2z0637du6ec0nhxen", + "quick1f8jp5tr86gn5yvwecr7a4a9zypqf2mg85p96rw": "quick1f708swcmeej2ddfksyvtpaxe07fz0r03f79dlq", + } + return migrateVestingAccounts(ctx, appKeepers, migrations, migratePeriodicVestingAccount) +} + +func V010407UpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + appKeepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // set redemption rate to value correct as of 2024-02-01T20:00UTC. + rates := map[string]sdk.Dec{ + "cosmoshub-4": sdk.NewDecFromInt(math.NewInt(219_280_116_789)).QuoInt64(186_283_929_157), + "stargaze-1": sdk.NewDecFromInt(math.NewInt(7_883_310_380_922)).QuoInt64(6_142_958_768_078), + "osmosis-1": sdk.NewDecFromInt(math.NewInt(363_909_524_952)).QuoInt64(322_912_055_083), + "sommelier-3": sdk.NewDecFromInt(math.NewInt(657_103_764_225)).QuoInt64(637_871_903_193), + "regen-1": sdk.NewDecFromInt(math.NewInt(5_606_819_529_428)).QuoInt64(4_543_207_966_192), + "juno-1": sdk.NewDecFromInt(math.NewInt(7_439_000_263)).QuoInt64(7_018_171_980), + } + + // trigger redemption rate update immediately after upgrade. + 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) + + appKeepers.InterchainQueryKeeper.MakeRequest( + ctx, + zone.ConnectionId, + zone.ChainId, + "cosmos.staking.v1beta1.Query/DelegatorDelegations", + bz, + sdk.NewInt(-1), + icstypes.ModuleName, + "delegations", + 0, + ) + + balancesQuery := banktypes.QueryAllBalancesRequest{Address: zone.DelegationAddress.Address} + bz = appKeepers.InterchainstakingKeeper.GetCodec().MustMarshal(&balancesQuery) + appKeepers.InterchainQueryKeeper.MakeRequest( + ctx, + zone.ConnectionId, + zone.ChainId, + "cosmos.bank.v1beta1.Query/AllBalances", + bz, + sdk.NewInt(-1), + icstypes.ModuleName, + "delegationaccountbalances", + 0, + ) + // increment waitgroup; decremented in delegationaccountbalance callback + zone.WithdrawalWaitgroup++ + zone.RedemptionRate = rates[zone.ChainId] + zone.LastRedemptionRate = rates[zone.ChainId] + appKeepers.InterchainstakingKeeper.SetZone(ctx, zone) + + return false + }) + + // migrate testnet user account. + migrations := map[string]string{ + "quick1k67rz3vn73tzp2tatlka2kn2ngtjdw8gpw8zq2": "quick1plq2mrsn0uw2dkksptr9dsyyk62dkk6t7w79j2", + } + + if err := migrateVestingAccounts(ctx, appKeepers, migrations, migratePeriodicVestingAccount); err != nil { + panic(err) + } + + return mm.RunMigrations(ctx, configurator, fromVM) + } +} diff --git a/app/upgrades/v1_5.go b/app/upgrades/v1_5.go new file mode 100644 index 000000000..b4a56c498 --- /dev/null +++ b/app/upgrades/v1_5.go @@ -0,0 +1,198 @@ +package upgrades + +import ( + "fmt" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/quicksilver-zone/quicksilver/app/keepers" + "github.com/quicksilver-zone/quicksilver/utils" + icstypes "github.com/quicksilver-zone/quicksilver/x/interchainstaking/types" +) + +// =========== TESTNET UPGRADE HANDLER =========== + +func V010500rc1UpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + appKeepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // 993/1229 - pre-populate zone/denom mapping. + appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *icstypes.Zone) (stop bool) { + appKeepers.InterchainstakingKeeper.SetLocalDenomZoneMapping(ctx, zone) + return false + }) + + // migrate notional vesting accounts to new addresses - source addresses are not prod multisigs, but test vesting accounts with delegations. + migrations := map[string]string{ + "quick190yw7mfa8d8lgj9m4nyfh808s9pv7vz6cufff0": "quick1h0sqndv2y4xty6uk0sv4vckgyc5aa7n5at7fll", + "quick14rptnkqsvwtumvezug6uvd537kxql8up3863cf": "quick1n4g6037cjm0e0v2nvwj2ngau7pk758wtwk6lwq", + } + + if err := migrateVestingAccounts(ctx, appKeepers, migrations, migrateVestingAccountWithActions); err != nil { + panic(err) + } + + // initialise new withdrawal record sequence number + appKeepers.InterchainstakingKeeper.InitWithdrawalRecordSequence(ctx) + + collateRequeuedWithdrawals(ctx, appKeepers) + + return mm.RunMigrations(ctx, configurator, fromVM) + } +} + +// =========== PRODUCTION UPGRADE HANDLER =========== + +func V010500UpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + appKeepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // 993/1229 - pre-populate zone/denom mapping. + appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *icstypes.Zone) (stop bool) { + appKeepers.InterchainstakingKeeper.SetLocalDenomZoneMapping(ctx, zone) + return false + }) + + // migrate notional vesting accounts to new addresses + migrations := map[string]string{ + "quick1a7n7z45gs0dut2syvkszffgwmgps6scqen3e5l": "quick1h0sqndv2y4xty6uk0sv4vckgyc5aa7n5at7fll", + "quick1m0anwr4kcz0y9s65czusun2ahw35g3humv4j7f": "quick1n4g6037cjm0e0v2nvwj2ngau7pk758wtwk6lwq", + } + + if err := migrateVestingAccounts(ctx, appKeepers, migrations, migrateVestingAccountWithActions); err != nil { + panic(err) + } + + // initialise new withdrawal record sequence number + appKeepers.InterchainstakingKeeper.InitWithdrawalRecordSequence(ctx) + + // collate requeued withdrawal records + collateRequeuedWithdrawals(ctx, appKeepers) + + // add claims metadata + + return mm.RunMigrations(ctx, configurator, fromVM) + } +} + +// collateRequeuedWithdrawals will iterate, per zone, over requeued queued and active withdrawal records and +// collate them into a single record for a delegator/recipient/epoch tuple. +func collateRequeuedWithdrawals(ctx sdk.Context, appKeepers *keepers.AppKeepers) { + appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(_ int64, zone *icstypes.Zone) (stop bool) { + newRecords := map[string]icstypes.WithdrawalRecord{} + + appKeepers.InterchainstakingKeeper.IterateZoneStatusWithdrawalRecords(ctx, zone.ChainId, icstypes.WithdrawStatusQueued, func(_ int64, record icstypes.WithdrawalRecord) (stop bool) { + if !record.Requeued { + return false + } + + // this is a requeued record. + mapKey := fmt.Sprintf("%s/%s", record.Delegator, record.Recipient) + newRecord, ok := newRecords[mapKey] + if !ok { + newRecord = icstypes.WithdrawalRecord{ + ChainId: record.ChainId, + Delegator: record.Delegator, + Distribution: nil, + Recipient: record.Recipient, + Amount: nil, + BurnAmount: record.BurnAmount, + Txhash: fmt.Sprintf("%064d", appKeepers.InterchainstakingKeeper.GetNextWithdrawalRecordSequence(ctx)), + Status: icstypes.WithdrawStatusQueued, + CompletionTime: time.Time{}, + Requeued: true, + Acknowledged: false, + EpochNumber: record.EpochNumber, + } + } else { + newRecord.BurnAmount = newRecord.BurnAmount.Add(record.BurnAmount) + } + newRecords[mapKey] = newRecord + + // delete old record + appKeepers.InterchainstakingKeeper.DeleteWithdrawalRecord(ctx, record.ChainId, record.Txhash, record.Status) + + return false + }) + + for _, key := range utils.Keys(newRecords) { + appKeepers.InterchainstakingKeeper.SetWithdrawalRecord(ctx, newRecords[key]) + } + + newRecords = map[string]icstypes.WithdrawalRecord{} + + appKeepers.InterchainstakingKeeper.IterateZoneStatusWithdrawalRecords(ctx, zone.ChainId, icstypes.WithdrawStatusUnbond, func(_ int64, record icstypes.WithdrawalRecord) (stop bool) { + if !record.Requeued || !record.Acknowledged { + return false + } + + // this is a requeued AND acknowledged record. + mapKey := fmt.Sprintf("%s/%s/%d", record.Delegator, record.Recipient, record.EpochNumber) + newRecord, ok := newRecords[mapKey] + if !ok { + newRecord = icstypes.WithdrawalRecord{ + ChainId: record.ChainId, + Delegator: record.Delegator, + Distribution: record.Distribution, + Recipient: record.Recipient, + Amount: record.Amount, + BurnAmount: record.BurnAmount, + Txhash: fmt.Sprintf("%064d", appKeepers.InterchainstakingKeeper.GetNextWithdrawalRecordSequence(ctx)), + Status: icstypes.WithdrawStatusUnbond, + CompletionTime: record.CompletionTime, + Requeued: true, + Acknowledged: true, + EpochNumber: record.EpochNumber, + } + } else { + newRecord.BurnAmount = newRecord.BurnAmount.Add(record.BurnAmount) + newRecord.Amount = newRecord.Amount.Add(record.Amount...) + // update completion time if incoming is later. + if record.CompletionTime.After(newRecord.CompletionTime) { + newRecord.CompletionTime = record.CompletionTime + } + // merge distributions + newRecord.Distribution = func(dist1, dist2 []*icstypes.Distribution) []*icstypes.Distribution { + distMap := map[string]uint64{} + for _, dist := range dist1 { + distMap[dist.Valoper] = dist.Amount + } + + for _, dist := range dist2 { + if _, ok = distMap[dist.Valoper]; !ok { + distMap[dist.Valoper] = 0 + } + distMap[dist.Valoper] += dist.Amount + } + + out := make([]*icstypes.Distribution, 0, len(distMap)) + for _, key := range utils.Keys(distMap) { + out = append(out, &icstypes.Distribution{Valoper: key, Amount: distMap[key]}) + } + + return out + }(newRecord.Distribution, record.Distribution) + } + + newRecords[mapKey] = newRecord + + // delete old record + appKeepers.InterchainstakingKeeper.DeleteWithdrawalRecord(ctx, record.ChainId, record.Txhash, record.Status) + + return false + }) + + for _, key := range utils.Keys(newRecords) { + appKeepers.InterchainstakingKeeper.SetWithdrawalRecord(ctx, newRecords[key]) + } + + return false + }) +} diff --git a/app/upgrades/v1_6.go b/app/upgrades/v1_6.go new file mode 100644 index 000000000..e75acc380 --- /dev/null +++ b/app/upgrades/v1_6.go @@ -0,0 +1,23 @@ +package upgrades + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/quicksilver-zone/quicksilver/app/keepers" +) + +// =========== PRODUCTION UPGRADE HANDLER =========== + +func V010600UpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + appKeepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // no action yet. + + return mm.RunMigrations(ctx, configurator, fromVM) + } +} diff --git a/app/upgrades_test.go b/app/upgrades_test.go index 85d35b33f..3a2a1ab6c 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -1,6 +1,7 @@ package app import ( + "fmt" "testing" "time" @@ -271,7 +272,7 @@ func (s *AppTestSuite) TestV010406UpgradeHandler() { s.Nil(noTestZone) } -func (s *AppTestSuite) InitV160TestZones() { +func (s *AppTestSuite) InitV150TestZones() { cosmosWithdrawal := addressutils.GenerateAddressForTestWithPrefix("cosmos") cosmosPerformance := addressutils.GenerateAddressForTestWithPrefix("cosmos") cosmosDeposit := addressutils.GenerateAddressForTestWithPrefix("cosmos") @@ -312,8 +313,8 @@ func (s *AppTestSuite) InitV160TestZones() { addVestingAccount(s.chainA.GetContext(), &s.GetQuicksilverApp(s.chainA).AccountKeeper, "quick1m0anwr4kcz0y9s65czusun2ahw35g3humv4j7f", 10, 864000, 5000000000) } -func (s *AppTestSuite) TestV010600UpgradeHandler() { - s.InitV160TestZones() +func (s *AppTestSuite) TestV010500UpgradeHandler() { + s.InitV150TestZones() app := s.GetQuicksilverApp(s.chainA) ctx := s.chainA.GetContext() validators := app.StakingKeeper.GetAllValidators(ctx) @@ -322,57 +323,393 @@ func (s *AppTestSuite) TestV010600UpgradeHandler() { err := app.BankKeeper.SendCoins(ctx, s.chainA.SenderAccount.GetAddress(), accountA.GetAddress(), sdk.Coins{ sdk.NewInt64Coin("stake", 100), }) - s.Require().NoError(err) + s.NoError(err) accountB := app.AccountKeeper.GetAccount(ctx, addressutils.MustAccAddressFromBech32("quick1m0anwr4kcz0y9s65czusun2ahw35g3humv4j7f", "")) err = app.BankKeeper.SendCoins(ctx, s.chainA.SenderAccount.GetAddress(), accountB.GetAddress(), sdk.Coins{ sdk.NewInt64Coin("stake", 300), }) - s.Require().NoError(err) + s.NoError(err) // Stake old account amountA, _ := sdk.NewIntFromString("100") _, err = app.StakingKeeper.Delegate(ctx, accountA.GetAddress(), amountA, stakingtypes.Unbonded, validators[0], true) - s.Require().NoError(err) + s.NoError(err) amountB, _ := sdk.NewIntFromString("100") _, err = app.StakingKeeper.Delegate(ctx, accountB.GetAddress(), amountB, stakingtypes.Unbonded, validators[0], true) - s.Require().NoError(err) + s.NoError(err) amountB, _ = sdk.NewIntFromString("200") _, err = app.StakingKeeper.Delegate(ctx, accountB.GetAddress(), amountB, stakingtypes.Unbonded, validators[1], true) - s.Require().NoError(err) + s.NoError(err) + + // set withdrawal records + zone, found := app.InterchainstakingKeeper.GetZone(ctx, "cosmoshub-4") + s.True(found) + + user1 := addressutils.GenerateAddressForTestWithPrefix("quick") + user2 := addressutils.GenerateAddressForTestWithPrefix("quick") + recipient1 := addressutils.GenerateAddressForTestWithPrefix("quick") + recipient2 := addressutils.GenerateAddressForTestWithPrefix("quick") + + // queued + app.InterchainstakingKeeper.SetWithdrawalRecord(s.chainA.GetContext(), icstypes.WithdrawalRecord{ + ChainId: zone.ChainId, + Delegator: user1, + Recipient: recipient1, + BurnAmount: sdk.NewCoin("uqatom", math.NewInt(3000)), + Requeued: true, + Txhash: fmt.Sprintf("%064d", 1), + Acknowledged: false, + Status: icstypes.WithdrawStatusQueued, + EpochNumber: 1, + }) + app.InterchainstakingKeeper.SetWithdrawalRecord(s.chainA.GetContext(), icstypes.WithdrawalRecord{ + ChainId: zone.ChainId, + Delegator: user1, + Recipient: recipient1, + BurnAmount: sdk.NewCoin("uqatom", math.NewInt(3000)), + Requeued: true, + Txhash: fmt.Sprintf("%064d", 2), + Acknowledged: false, + Status: icstypes.WithdrawStatusQueued, + EpochNumber: 1, + }) + app.InterchainstakingKeeper.SetWithdrawalRecord(s.chainA.GetContext(), icstypes.WithdrawalRecord{ + ChainId: zone.ChainId, + Delegator: user1, + Recipient: recipient1, + BurnAmount: sdk.NewCoin("uqatom", math.NewInt(3000)), + Requeued: true, + Txhash: fmt.Sprintf("%064d", 3), + Acknowledged: false, + Status: icstypes.WithdrawStatusQueued, + EpochNumber: 1, + }) + app.InterchainstakingKeeper.SetWithdrawalRecord(s.chainA.GetContext(), icstypes.WithdrawalRecord{ + ChainId: zone.ChainId, + Delegator: user1, + Recipient: recipient2, + BurnAmount: sdk.NewCoin("uqatom", math.NewInt(4000)), + Requeued: true, + Txhash: fmt.Sprintf("%064d", 4), + Acknowledged: false, + Status: icstypes.WithdrawStatusQueued, + EpochNumber: 1, + }) + app.InterchainstakingKeeper.SetWithdrawalRecord(s.chainA.GetContext(), icstypes.WithdrawalRecord{ + ChainId: zone.ChainId, + Delegator: user2, + Recipient: recipient2, + BurnAmount: sdk.NewCoin("uqatom", math.NewInt(5000)), + Requeued: true, + Txhash: fmt.Sprintf("%064d", 5), + Acknowledged: false, + Status: icstypes.WithdrawStatusQueued, + EpochNumber: 1, + }) + + // unbonding + + app.InterchainstakingKeeper.SetWithdrawalRecord(s.chainA.GetContext(), icstypes.WithdrawalRecord{ + ChainId: zone.ChainId, + Delegator: user1, + Recipient: recipient1, + Distribution: []*icstypes.Distribution{ + { + Valoper: "cosmosvaloper100000000000000000000000000000000000", + Amount: 600, + }, + { + Valoper: "cosmosvaloper111111111111111111111111111111111111", + Amount: 400, + }, + { + Valoper: "cosmosvaloper122222222222222222222222222222222222", + Amount: 200, + }, + }, + BurnAmount: sdk.NewCoin("uqatom", math.NewInt(1000)), + Amount: sdk.NewCoins(sdk.NewCoin("uatom", math.NewInt(1200))), + Requeued: true, + Txhash: fmt.Sprintf("%064d", 6), + Acknowledged: true, + Status: icstypes.WithdrawStatusUnbond, + EpochNumber: 1, + CompletionTime: ctx.BlockTime().Add(180 * time.Minute), + }) + app.InterchainstakingKeeper.SetWithdrawalRecord(s.chainA.GetContext(), icstypes.WithdrawalRecord{ + ChainId: zone.ChainId, + Delegator: user1, + Recipient: recipient1, + Distribution: []*icstypes.Distribution{ + { + Valoper: "cosmosvaloper100000000000000000000000000000000000", + Amount: 600, + }, + { + Valoper: "cosmosvaloper111111111111111111111111111111111111", + Amount: 800, + }, + { + Valoper: "cosmosvaloper122222222222222222222222222222222222", + Amount: 800, + }, + { + Valoper: "cosmosvaloper133333333333333333333333333333333333", + Amount: 800, + }, + }, + BurnAmount: sdk.NewCoin("uqatom", math.NewInt(2000)), + Amount: sdk.NewCoins(sdk.NewCoin("uatom", math.NewInt(2400))), + Requeued: true, + Txhash: fmt.Sprintf("%064d", 7), + Acknowledged: true, + Status: icstypes.WithdrawStatusUnbond, + EpochNumber: 1, + CompletionTime: ctx.BlockTime().Add(182 * time.Minute), + }) + app.InterchainstakingKeeper.SetWithdrawalRecord(s.chainA.GetContext(), icstypes.WithdrawalRecord{ + ChainId: zone.ChainId, + Delegator: user2, + Recipient: recipient2, + Distribution: []*icstypes.Distribution{ + { + Valoper: "cosmosvaloper100000000000000000000000000000000000", + Amount: 600, + }, + { + Valoper: "cosmosvaloper122222222222222222222222222222222222", + Amount: 200, + }, + { + Valoper: "cosmosvaloper133333333333333333333333333333333333", + Amount: 800, + }, + { + Valoper: "cosmosvaloper144444444444444444444444444444444444", + Amount: 2000, + }, + }, + BurnAmount: sdk.NewCoin("uqatom", math.NewInt(3000)), + Amount: sdk.NewCoins(sdk.NewCoin("uatom", math.NewInt(3600))), + Requeued: true, + Txhash: fmt.Sprintf("%064d", 8), + Acknowledged: true, + Status: icstypes.WithdrawStatusUnbond, + EpochNumber: 1, + CompletionTime: ctx.BlockTime().Add(182 * time.Minute), + }) + app.InterchainstakingKeeper.SetWithdrawalRecord(s.chainA.GetContext(), icstypes.WithdrawalRecord{ + ChainId: zone.ChainId, + Delegator: user2, + Recipient: recipient2, + Distribution: []*icstypes.Distribution{ + { + Valoper: "cosmosvaloper100000000000000000000000000000000000", + Amount: 800, + }, + { + Valoper: "cosmosvaloper122222222222222222222222222222222222", + Amount: 400, + }, + { + Valoper: "cosmosvaloper133333333333333333333333333333333333", + Amount: 1200, + }, + { + Valoper: "cosmosvaloper144444444444444444444444444444444444", + Amount: 2200, + }, + }, + BurnAmount: sdk.NewCoin("uqatom", math.NewInt(4000)), + Amount: sdk.NewCoins(sdk.NewCoin("uatom", math.NewInt(4800))), + Requeued: true, + Txhash: fmt.Sprintf("%064d", 9), + Acknowledged: true, + Status: icstypes.WithdrawStatusUnbond, + EpochNumber: 1, + }) + app.InterchainstakingKeeper.SetWithdrawalRecord(s.chainA.GetContext(), icstypes.WithdrawalRecord{ + ChainId: zone.ChainId, + Delegator: user2, + Recipient: recipient1, + Distribution: []*icstypes.Distribution{ + { + Valoper: "cosmosvaloper100000000000000000000000000000000000", + Amount: 1000, + }, + { + Valoper: "cosmosvaloper122222222222222222222222222222222222", + Amount: 1200, + }, + { + Valoper: "cosmosvaloper133333333333333333333333333333333333", + Amount: 1200, + }, + { + Valoper: "cosmosvaloper144444444444444444444444444444444444", + Amount: 1600, + }, + }, + BurnAmount: sdk.NewCoin("uqatom", math.NewInt(5000)), + Amount: sdk.NewCoins(sdk.NewCoin("uatom", math.NewInt(6000))), + Requeued: true, + Txhash: fmt.Sprintf("%064d", 10), + Acknowledged: false, + Status: icstypes.WithdrawStatusUnbond, + EpochNumber: 1, + }) + app.InterchainstakingKeeper.SetWithdrawalRecord(s.chainA.GetContext(), icstypes.WithdrawalRecord{ + ChainId: zone.ChainId, + Delegator: user1, + Recipient: recipient1, + Distribution: []*icstypes.Distribution{ + { + Valoper: "cosmosvaloper100000000000000000000000000000000000", + Amount: 1500, + }, + { + Valoper: "cosmosvaloper122222222222222222222222222222222222", + Amount: 1500, + }, + { + Valoper: "cosmosvaloper133333333333333333333333333333333333", + Amount: 1500, + }, + { + Valoper: "cosmosvaloper144444444444444444444444444444444444", + Amount: 1500, + }, + { + Valoper: "cosmosvaloper155555555555555555555555555555555555", + Amount: 1500, + }, + }, + BurnAmount: sdk.NewCoin("uqatom", math.NewInt(6000)), + Amount: sdk.NewCoins(sdk.NewCoin("uatom", math.NewInt(7500))), + Requeued: true, + Txhash: fmt.Sprintf("%064d", 11), + Acknowledged: true, + Status: icstypes.WithdrawStatusUnbond, + EpochNumber: 2, + }) + app.InterchainstakingKeeper.SetWithdrawalRecord(s.chainA.GetContext(), icstypes.WithdrawalRecord{ + ChainId: zone.ChainId, + Delegator: user2, + Recipient: recipient2, + Distribution: []*icstypes.Distribution{ + { + Valoper: "cosmosvaloper100000000000000000000000000000000000", + Amount: 1750, + }, + { + Valoper: "cosmosvaloper122222222222222222222222222222222222", + Amount: 1750, + }, + { + Valoper: "cosmosvaloper133333333333333333333333333333333333", + Amount: 1750, + }, + { + Valoper: "cosmosvaloper144444444444444444444444444444444444", + Amount: 1750, + }, + { + Valoper: "cosmosvaloper155555555555555555555555555555555555", + Amount: 1750, + }, + }, + BurnAmount: sdk.NewCoin("uqatom", math.NewInt(7000)), + Amount: sdk.NewCoins(sdk.NewCoin("uatom", math.NewInt(8750))), + Requeued: true, + Txhash: fmt.Sprintf("%064d", 12), + Acknowledged: true, + Status: icstypes.WithdrawStatusUnbond, + EpochNumber: 2, + }) - handler := upgrades.V010600UpgradeHandler(app.mm, + handler := upgrades.V010500UpgradeHandler(app.mm, app.configurator, &app.AppKeepers) _, err = handler(ctx, types.Plan{}, app.mm.GetVersionMap()) - s.Require().NoError(err) + s.NoError(err) - _, found := app.StakingKeeper.GetDelegation(ctx, accountA.GetAddress(), validators[0].GetOperator()) - s.Require().False(found) + _, found = app.StakingKeeper.GetDelegation(ctx, accountA.GetAddress(), validators[0].GetOperator()) + s.False(found) migratedA := app.AccountKeeper.GetAccount(ctx, addressutils.MustAccAddressFromBech32("quick1h0sqndv2y4xty6uk0sv4vckgyc5aa7n5at7fll", "")) stakeBalanceA := app.BankKeeper.GetBalance(ctx, migratedA.GetAddress(), "stake") - s.Require().Equal(int64(100), stakeBalanceA.Amount.Int64()) + s.Equal(int64(100), stakeBalanceA.Amount.Int64()) migratedB := app.AccountKeeper.GetAccount(ctx, addressutils.MustAccAddressFromBech32("quick1n4g6037cjm0e0v2nvwj2ngau7pk758wtwk6lwq", "")) stakeBalanceB := app.BankKeeper.GetBalance(ctx, migratedB.GetAddress(), "stake") - s.Require().Equal(int64(300), stakeBalanceB.Amount.Int64()) + s.Equal(int64(300), stakeBalanceB.Amount.Int64()) // Check the vest period of new account vestMigratedA, ok := migratedA.(*vestingtypes.PeriodicVestingAccount) - s.Require().True(ok) - s.Require().Equal(int64(5000000000), vestMigratedA.OriginalVesting.AmountOf("uqck").Int64()) - s.Require().Equal(float64(864000), vestMigratedA.VestingPeriods[0].Duration().Seconds()) + s.True(ok) + s.Equal(int64(5000000000), vestMigratedA.OriginalVesting.AmountOf("uqck").Int64()) + s.Equal(float64(864000), vestMigratedA.VestingPeriods[0].Duration().Seconds()) vestMigratedB, ok := migratedB.(*vestingtypes.PeriodicVestingAccount) - s.Require().True(ok) - s.Require().Equal(int64(5000000000), vestMigratedB.OriginalVesting.AmountOf("uqck").Int64()) - s.Require().Equal(float64(864000), vestMigratedB.VestingPeriods[0].Duration().Seconds()) - - zone, existed := app.InterchainstakingKeeper.GetLocalDenomZoneMapping(ctx, "uqatom") - s.Require().True(existed) - s.Require().Equal(zone.ChainId, "cosmoshub-4") - s.Require().Equal(zone.ConnectionId, "connection-77001") + s.True(ok) + s.Equal(int64(5000000000), vestMigratedB.OriginalVesting.AmountOf("uqck").Int64()) + s.Equal(float64(864000), vestMigratedB.VestingPeriods[0].Duration().Seconds()) + + z, existed := app.InterchainstakingKeeper.GetLocalDenomZoneMapping(ctx, "uqatom") + s.True(existed) + s.Equal(z.ChainId, "cosmoshub-4") + s.Equal(z.ConnectionId, "connection-77001") + + // 512 should be the sum of 01, 02, 03 + wdr, found := app.InterchainstakingKeeper.GetWithdrawalRecord(ctx, z.ChainId, fmt.Sprintf("%064d", 512), icstypes.WithdrawStatusQueued) + s.True(found) + s.Equal(wdr.BurnAmount, sdk.NewCoin("uqatom", math.NewInt(9000))) + s.Equal(wdr.CompletionTime, time.Time{}) + s.True(wdr.Requeued) + s.Nil(wdr.Amount) + s.Nil(wdr.Distribution) + + // 513 and 514 should be 04 and 05 requeued respectively (due to differing recipient) + wdr, found = app.InterchainstakingKeeper.GetWithdrawalRecord(ctx, z.ChainId, fmt.Sprintf("%064d", 513), icstypes.WithdrawStatusQueued) + fmt.Println(wdr) + s.True(found) + s.Equal(wdr.BurnAmount, sdk.NewCoin("uqatom", math.NewInt(4000))) + s.Equal(wdr.CompletionTime, time.Time{}) + s.True(wdr.Requeued) + s.Nil(wdr.Amount) + s.Nil(wdr.Distribution) + + wdr, found = app.InterchainstakingKeeper.GetWithdrawalRecord(ctx, z.ChainId, fmt.Sprintf("%064d", 514), icstypes.WithdrawStatusQueued) + s.True(found) + s.Equal(wdr.BurnAmount, sdk.NewCoin("uqatom", math.NewInt(5000))) + s.Equal(wdr.CompletionTime, time.Time{}) + s.True(wdr.Requeued) + s.Nil(wdr.Amount) + s.Nil(wdr.Distribution) + + // 010 shouldn't be touched; it was not acknowledged and will be requeued. + wdr, found = app.InterchainstakingKeeper.GetWithdrawalRecord(ctx, z.ChainId, fmt.Sprintf("%064d", 10), icstypes.WithdrawStatusUnbond) + s.True(found) + s.Equal(wdr.BurnAmount, sdk.NewCoin("uqatom", math.NewInt(5000))) + s.Equal(wdr.CompletionTime, time.Time{}) + s.True(wdr.Requeued) + s.False(wdr.Acknowledged) + s.Equal(wdr.Amount, sdk.NewCoins(sdk.NewCoin("uatom", math.NewInt(6000)))) + + // 06 + 07 are a pair; distribution should be merged. + wdr, found = app.InterchainstakingKeeper.GetWithdrawalRecord(ctx, z.ChainId, fmt.Sprintf("%064d", 515), icstypes.WithdrawStatusUnbond) + s.True(found) + s.Equal(wdr.BurnAmount, sdk.NewCoin("uqatom", math.NewInt(3000))) + // use the latest completion time (+182 mins) + s.Equal(wdr.CompletionTime, ctx.BlockTime().Add(182*time.Minute)) + s.True(wdr.Requeued) + s.True(wdr.Acknowledged) + s.Equal(wdr.Amount, sdk.NewCoins(sdk.NewCoin("uatom", math.NewInt(3600)))) + s.ElementsMatch(wdr.Distribution, []*icstypes.Distribution{{Valoper: "cosmosvaloper100000000000000000000000000000000000", Amount: 1200}, {Valoper: "cosmosvaloper111111111111111111111111111111111111", Amount: 1200}, {Valoper: "cosmosvaloper122222222222222222222222222222222222", Amount: 1000}, {Valoper: "cosmosvaloper133333333333333333333333333333333333", Amount: 800}}) + + wdrs := app.InterchainstakingKeeper.AllWithdrawalRecords(ctx) + s.Equal(len(wdrs), 8) } From dc3db0db1f27279875fadf621b7a92352bb8ec21 Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Wed, 6 Mar 2024 14:25:19 +0400 Subject: [PATCH 3/5] update dependencies and run `make proto-gen` (#1245) --- docs/swagger.yml | 20 +---- go.mod | 6 +- go.sum | 12 +-- x/airdrop/types/messages.pb.go | 84 ++++++++++----------- x/interchainquery/types/messages.pb.go | 8 +- x/interchainstaking/types/messages.pb.go | 34 ++++----- x/participationrewards/types/messages.pb.go | 64 ++++++++-------- 7 files changed, 108 insertions(+), 120 deletions(-) diff --git a/docs/swagger.yml b/docs/swagger.yml index f13e353f8..321e4855e 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -1647,10 +1647,7 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. + type.googleapis.com. Schemes other than `http`, `https` (or the empty scheme) @@ -1695,10 +1692,6 @@ paths: if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } Example 3: Pack and unpack a message in Python. @@ -1738,6 +1731,7 @@ paths: name "y.z". + JSON ==== @@ -1964,10 +1958,7 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. + type.googleapis.com. Schemes other than `http`, `https` (or the empty scheme) @@ -2012,10 +2003,6 @@ paths: if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } Example 3: Pack and unpack a message in Python. @@ -2055,6 +2042,7 @@ paths: name "y.z". + JSON ==== diff --git a/go.mod b/go.mod index 165526317..e47f7c5b5 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/cosmos/gogoproto v1.4.11 github.com/cosmos/ibc-go/v5 v5.3.2 github.com/gogo/protobuf v1.3.3 - github.com/golang/protobuf v1.5.3 + github.com/golang/protobuf v1.5.4 github.com/golangci/golangci-lint v1.56.2 github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/grpc-gateway v1.16.0 @@ -36,8 +36,8 @@ require ( golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc golang.org/x/tools v0.19.0 google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 - google.golang.org/grpc v1.62.0 - google.golang.org/protobuf v1.32.0 + google.golang.org/grpc v1.62.1 + google.golang.org/protobuf v1.33.0 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 mvdan.cc/gofumpt v0.6.0 diff --git a/go.sum b/go.sum index 0a9e1baf3..837361fc9 100644 --- a/go.sum +++ b/go.sum @@ -637,8 +637,8 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= @@ -1990,8 +1990,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= -google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= +google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -2008,8 +2008,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/x/airdrop/types/messages.pb.go b/x/airdrop/types/messages.pb.go index de5757778..04c0d1a38 100644 --- a/x/airdrop/types/messages.pb.go +++ b/x/airdrop/types/messages.pb.go @@ -200,48 +200,48 @@ func init() { } var fileDescriptor_2b0828c7de1949a1 = []byte{ - // 655 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x3d, 0x6f, 0x13, 0x4d, - 0x10, 0xf6, 0xd9, 0x79, 0xf3, 0xb1, 0xaf, 0xde, 0x0f, 0x8e, 0x10, 0x1c, 0x0b, 0xee, 0xac, 0x43, - 0x91, 0x4c, 0x90, 0xef, 0xe2, 0xf0, 0x11, 0xc9, 0x1d, 0x0e, 0x4d, 0x8a, 0xa0, 0xe0, 0x74, 0x34, - 0xd6, 0xfa, 0x6e, 0xd9, 0xac, 0xe2, 0xdb, 0x39, 0x6e, 0xd7, 0x56, 0x42, 0x85, 0x22, 0x21, 0x51, - 0x22, 0xf1, 0x07, 0x52, 0x53, 0x51, 0x20, 0x7a, 0xba, 0x94, 0x11, 0x34, 0x54, 0x06, 0x25, 0x48, - 0x50, 0xe7, 0x17, 0xa0, 0xdb, 0xdb, 0x73, 0xce, 0x22, 0x24, 0xa2, 0xf2, 0xde, 0xcc, 0x33, 0xcf, - 0xcc, 0x3c, 0x33, 0x63, 0xb4, 0xf0, 0xb4, 0xcf, 0xfc, 0x6d, 0xc1, 0x7a, 0x03, 0x12, 0x7b, 0x98, - 0xc5, 0x41, 0x0c, 0x91, 0x37, 0x68, 0x78, 0x21, 0x11, 0x02, 0x53, 0x22, 0xdc, 0x28, 0x06, 0x09, - 0xe6, 0x5c, 0x0e, 0xe6, 0x6a, 0x98, 0x3b, 0x68, 0x54, 0x2c, 0x1f, 0x44, 0x08, 0xc2, 0xeb, 0x62, - 0x41, 0xbc, 0x41, 0xa3, 0x4b, 0x24, 0x6e, 0x78, 0x3e, 0x30, 0x9e, 0xc6, 0x55, 0xae, 0x6a, 0x7f, - 0x28, 0xa8, 0x62, 0x15, 0x54, 0x3b, 0xe6, 0x53, 0x47, 0x47, 0x7d, 0x79, 0xe9, 0x87, 0x76, 0xcd, - 0x52, 0xa0, 0x90, 0xda, 0x93, 0x97, 0xb6, 0x5e, 0xa3, 0x00, 0xb4, 0x47, 0x3c, 0x1c, 0x31, 0x0f, - 0x73, 0x0e, 0x12, 0x4b, 0x06, 0x3c, 0x8b, 0x59, 0xca, 0xb7, 0xe1, 0xf7, 0x30, 0x0b, 0x45, 0x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f7, 0x8f, 0xe0, 0xa3, 0x4a, - 0x9b, 0xaa, 0xd2, 0x3b, 0x49, 0xa5, 0xde, 0x39, 0x95, 0xb2, 0x8c, 0xa1, 0x13, 0x01, 0xf4, 0x3a, - 0x22, 0xe1, 0x68, 0x3d, 0x3a, 0x38, 0xb2, 0x8c, 0xc3, 0x23, 0xcb, 0xf8, 0x7a, 0x64, 0x19, 0xaf, - 0x8e, 0xad, 0xc2, 0xe1, 0xb1, 0x55, 0xf8, 0x7c, 0x6c, 0x15, 0x1e, 0xaf, 0xe4, 0x06, 0x99, 0x23, - 0xad, 0x3f, 0x03, 0x4e, 0xc6, 0xb2, 0xec, 0x8c, 0x32, 0xa8, 0xe9, 0x76, 0x27, 0xd5, 0x7f, 0xc2, - 0xed, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x63, 0x6a, 0x3e, 0x7f, 0x0e, 0x05, 0x00, 0x00, + // 654 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xbb, 0x6f, 0x13, 0x4f, + 0x10, 0xf6, 0xd9, 0xf9, 0xe5, 0xb1, 0x3f, 0xf1, 0x3a, 0x42, 0x70, 0x2c, 0xf0, 0x59, 0x87, 0x22, + 0x19, 0x23, 0xdf, 0xc5, 0xe1, 0x11, 0xc9, 0x1d, 0x0e, 0x4d, 0x8a, 0xa0, 0xe0, 0x74, 0x34, 0xd6, + 0xfa, 0x6e, 0xd9, 0xac, 0xe2, 0xdb, 0x39, 0x6e, 0xd7, 0x56, 0x42, 0x85, 0x22, 0x21, 0x51, 0x22, + 0xf1, 0x0f, 0xa4, 0xa6, 0xa2, 0x40, 0xf4, 0x74, 0x29, 0x23, 0x68, 0xa8, 0x0c, 0x4a, 0x90, 0xa0, + 0xce, 0x5f, 0x80, 0x6e, 0x6f, 0xcf, 0x39, 0x8b, 0x90, 0x88, 0xca, 0x7b, 0x33, 0xdf, 0x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+ 0xfb, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xd7, 0xb2, 0xd0, 0x7c, 0x0e, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/interchainquery/types/messages.pb.go b/x/interchainquery/types/messages.pb.go index 1b170fce0..5723a80ef 100644 --- a/x/interchainquery/types/messages.pb.go +++ b/x/interchainquery/types/messages.pb.go @@ -149,12 +149,12 @@ var fileDescriptor_0640fcbc3e895a79 = []byte{ 0x82, 0x9d, 0x94, 0xce, 0xa4, 0x76, 0xf9, 0xcd, 0xd4, 0x2b, 0xbc, 0x9f, 0x7a, 0xe0, 0xe7, 0xd4, 0x2b, 0xf8, 0x35, 0xcb, 0x5d, 0xff, 0xab, 0xf3, 0xb3, 0xf5, 0x19, 0x58, 0xc5, 0x7d, 0x49, 0xec, 0x8f, 0xc0, 0xda, 0x5d, 0xf7, 0x24, 0xf7, 0xe0, 0xbf, 0x97, 0x07, 0xae, 0xcf, 0x5f, 0x7d, 0xf0, - 0x7f, 0x71, 0xf9, 0xe9, 0xb7, 0x5e, 0x7f, 0xfd, 0xf1, 0x6e, 0xe3, 0x4e, 0x1b, 0xdc, 0xf6, 0x6f, - 0x9e, 0x59, 0x71, 0x75, 0x8c, 0xc6, 0xcd, 0x1e, 0x56, 0x61, 0x13, 0x49, 0x9d, 0x43, 0xcb, 0x9d, + 0x7f, 0x71, 0xf9, 0xe9, 0xb7, 0x5e, 0x7f, 0xfd, 0xf1, 0x6e, 0xe3, 0x8e, 0x7f, 0xf3, 0xcc, 0x7e, + 0xab, 0x63, 0x34, 0x6e, 0xf6, 0xb0, 0x0a, 0x9b, 0x48, 0xea, 0x04, 0x5a, 0x6e, 0x83, 0xdb, 0x9d, 0xe7, 0x9f, 0xe6, 0x2e, 0x38, 0x99, 0xbb, 0xe0, 0xfb, 0xdc, 0x05, 0x6f, 0x17, 0x6e, 0xe1, 0x64, 0xe1, 0x16, 0xbe, 0x2d, 0xdc, 0xc2, 0x8b, 0x87, 0x84, 0xaa, 0xc1, 0xa8, 0x07, 0xfb, 0x3c, 0x46, - 0x2b, 0x7d, 0x35, 0x5e, 0x71, 0x86, 0x57, 0x05, 0x74, 0x7c, 0xb6, 0xd6, 0x24, 0xc1, 0xb2, 0x57, - 0xd2, 0xbb, 0x7b, 0xf7, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa3, 0xc4, 0x93, 0xfb, 0x7a, 0x03, + 0x2b, 0x7d, 0x35, 0x5e, 0x71, 0x86, 0x57, 0x05, 0x74, 0x7c, 0xb6, 0xdc, 0x24, 0xc1, 0xb2, 0x57, + 0xd2, 0xbb, 0x7b, 0xf7, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4a, 0xd0, 0x97, 0x34, 0x7a, 0x03, 0x00, 0x00, } diff --git a/x/interchainstaking/types/messages.pb.go b/x/interchainstaking/types/messages.pb.go index d53cf6b26..189d51d48 100644 --- a/x/interchainstaking/types/messages.pb.go +++ b/x/interchainstaking/types/messages.pb.go @@ -286,7 +286,7 @@ func init() { } var fileDescriptor_ee484030fa140a82 = []byte{ - // 760 bytes of a gzipped FileDescriptorProto + // 761 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4f, 0x4f, 0x1b, 0x47, 0x18, 0xc6, 0x3d, 0xd0, 0x16, 0x18, 0x68, 0xa1, 0x0b, 0x52, 0xf1, 0x0a, 0xad, 0xe9, 0x9e, 0x50, 0x5b, 0x76, 0xb1, 0x69, 0x69, 0x6b, 0x0a, 0x12, 0x76, 0x25, 0x44, 0x55, 0x1f, 0xba, 0xdc, 0xda, @@ -319,22 +319,22 @@ var fileDescriptor_ee484030fa140a82 = []byte{ 0xf6, 0xb4, 0xa0, 0x1a, 0x9d, 0x2d, 0x77, 0xd5, 0xa9, 0x3c, 0xfe, 0xee, 0x4a, 0xee, 0x4e, 0x7f, 0x4a, 0x4f, 0x26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0x50, 0x6d, 0x12, 0x4a, 0xc1, 0x95, 0x7e, 0xce, + 0x94, 0xed, 0x8a, 0x4a, 0xfe, 0x63, 0x18, 0x55, 0x17, 0x65, 0x23, 0x46, 0xf9, 0x55, 0x2d, 0x65, + 0x43, 0x89, 0x2c, 0xea, 0x66, 0xe2, 0x11, 0x61, 0x9c, 0x20, 0x3c, 0xb3, 0xcd, 0x42, 0x03, 0x98, + 0x0f, 0xb4, 0xc3, 0xf1, 0x4b, 0xd6, 0x44, 0x7d, 0x32, 0x79, 0x63, 0x28, 0x59, 0x97, 0x64, 0x33, + 0x26, 0xf9, 0x4d, 0x5d, 0xcd, 0x78, 0x35, 0x22, 0x8f, 0x5e, 0x94, 0x67, 0x08, 0x7f, 0xbd, 0xcd, + 0xc2, 0x5d, 0x10, 0x7f, 0x73, 0xaf, 0x4a, 0x7c, 0x2e, 0x95, 0xb2, 0x06, 0xba, 0xd4, 0xc8, 0xe5, + 0xdb, 0x6b, 0xee, 0x8a, 0xa0, 0xf2, 0xdf, 0xc9, 0x99, 0x82, 0x4e, 0xcf, 0x14, 0xf4, 0xf6, 0x4c, + 0x41, 0x0f, 0xcf, 0x95, 0xdc, 0xe9, 0xb9, 0x92, 0x7b, 0x73, 0xae, 0xe4, 0xfe, 0xdd, 0xb2, 0x1d, + 0xd1, 0x6c, 0x35, 0x34, 0x93, 0x79, 0xbd, 0xde, 0xcb, 0xf7, 0x18, 0x85, 0xbe, 0x8f, 0x1d, 0x0c, + 0xf8, 0x90, 0x38, 0xf4, 0x81, 0x37, 0xbe, 0x8a, 0xff, 0x00, 0xac, 0x7e, 0x0c, 0x00, 0x00, 0xff, + 0xff, 0x6f, 0xce, 0x36, 0x50, 0xf6, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/participationrewards/types/messages.pb.go b/x/participationrewards/types/messages.pb.go index 5596f44f0..2d7a43fa4 100644 --- a/x/participationrewards/types/messages.pb.go +++ b/x/participationrewards/types/messages.pb.go @@ -122,38 +122,38 @@ func init() { var fileDescriptor_b87e3ea017f90b50 = []byte{ // 513 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0xb1, 0x6f, 0xd3, 0x4e, - 0x14, 0xc7, 0xe3, 0xa4, 0xbf, 0xaa, 0xbf, 0x2b, 0xea, 0x70, 0x2a, 0xc8, 0x58, 0xc8, 0x8d, 0xd2, - 0x81, 0x08, 0x29, 0x36, 0x71, 0x16, 0xd4, 0x80, 0x04, 0xa5, 0xd0, 0xa9, 0x52, 0xe5, 0x32, 0x31, - 0x10, 0x5d, 0x9c, 0xe3, 0x38, 0x61, 0xfb, 0x1d, 0x77, 0x17, 0xd3, 0x32, 0x32, 0x31, 0x21, 0x24, - 0xfe, 0x81, 0xae, 0xec, 0x2c, 0xfc, 0x07, 0x8c, 0x15, 0x2c, 0x8c, 0x28, 0x01, 0x89, 0x3f, 0x03, - 0xf9, 0xec, 0x56, 0xb6, 0x14, 0xa1, 0x08, 0xb6, 0xbb, 0xe7, 0xfb, 0xbc, 0xf7, 0xfd, 0xbe, 0xf7, - 0x8c, 0x82, 0x17, 0x53, 0x1e, 0x3d, 0x57, 0x3c, 0xce, 0xa8, 0xf4, 0x05, 0x91, 0x9a, 0x47, 0x5c, - 0x10, 0xcd, 0x21, 0x95, 0xf4, 0x25, 0x91, 0x13, 0xe5, 0x67, 0x7d, 0x3f, 0xa1, 0x4a, 0x11, 0x46, - 0x95, 0x27, 0x24, 0x68, 0xc0, 0xdb, 0x15, 0xc6, 0x5b, 0xc4, 0x78, 0x59, 0xdf, 0xb9, 0x1a, 0x81, - 0x4a, 0x40, 0x8d, 0x0c, 0xe2, 0x17, 0x97, 0x82, 0x77, 0x36, 0x19, 0x30, 0x28, 0xe2, 0xf9, 0xa9, - 0x8c, 0x5e, 0x63, 0x00, 0x2c, 0xa6, 0x3e, 0x11, 0xdc, 0x27, 0x69, 0x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 0xe4, 0xe6, 0xd8, 0x0e, 0x78, 0xd1, 0xe0, 0xad, 0xfb, 0x3e, 0xda, 0x21, 0xbf, 0x10, + 0xbe, 0xba, 0x0f, 0x69, 0xc0, 0x62, 0x48, 0xd9, 0x61, 0xb6, 0x01, 0x21, 0x44, 0x7b, 0xd4, 0x50, + 0x72, 0x77, 0x59, 0x41, 0x0b, 0xf1, 0xfa, 0xc3, 0xff, 0xc2, 0x2f, 0x9c, 0x3d, 0xb2, 0xce, 0xee, + 0x35, 0x07, 0xcb, 0x3a, 0x53, 0x36, 0xd7, 0xfc, 0xa7, 0x0b, 0x21, 0x1a, 0x53, 0x43, 0xfb, 0x68, + 0x67, 0xf7, 0xe9, 0x97, 0xa9, 0x8b, 0xce, 0xa6, 0x2e, 0xfa, 0x31, 0x75, 0xd1, 0xfb, 0x99, 0x5b, + 0x39, 0x9b, 0xb9, 0x95, 0xef, 0x33, 0xb7, 0xf2, 0x64, 0x8f, 0x0b, 0xf3, 0x7c, 0x32, 0xf2, 0x42, + 0x88, 0x8b, 0x35, 0xda, 0xd9, 0x32, 0x96, 0x8a, 0x1e, 0x2f, 0x2e, 0x98, 0xed, 0x9a, 0x1e, 0xad, + 0xda, 0x82, 0xbd, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x88, 0xb9, 0xa5, 0xbf, 0x4e, 0x04, 0x00, 0x00, } From 2d3647986c9eb6dec9747483d945265516c58772 Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Wed, 6 Mar 2024 15:09:37 +0400 Subject: [PATCH 4/5] handle panic in SetValidator if incoming validator has been reduced to zero VP through slashing (#1230) * handle panic in SetValidator if incoming validator has been reduced to zero VP through dslashing * lint fix; --- x/interchainstaking/keeper/callbacks_test.go | 69 +++++++++++++------ x/interchainstaking/keeper/keeper.go | 26 ++++--- .../keeper/withdrawal_record.go | 5 +- 3 files changed, 68 insertions(+), 32 deletions(-) diff --git a/x/interchainstaking/keeper/callbacks_test.go b/x/interchainstaking/keeper/callbacks_test.go index 1e7fb90a5..4704d6f4f 100644 --- a/x/interchainstaking/keeper/callbacks_test.go +++ b/x/interchainstaking/keeper/callbacks_test.go @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -399,46 +400,69 @@ func (suite *KeeperTestSuite) TestHandleValidatorCallbackNilValue() { func (suite *KeeperTestSuite) TestHandleValidatorCallback() { newVal := addressutils.GenerateAddressForTestWithPrefix("cosmosvaloper") - zone := icstypes.Zone{ConnectionId: "connection-0", ChainId: "cosmoshub-4", AccountPrefix: "cosmos", LocalDenom: "uqatom", BaseDenom: "uatom", Is_118: true} - err := suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) - suite.NoError(err) - err = suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper156gqf9837u7d4c4678yt3rl4ls9c5vuursrrzf", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) - suite.NoError(err) + setup := func(ctx sdk.Context, quicksilver *app.Quicksilver) { + zone, found := quicksilver.InterchainstakingKeeper.GetZone(ctx, suite.chainB.ChainID) + suite.True(found) + err := suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) + suite.NoError(err) - err = suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper14lultfckehtszvzw4ehu0apvsr77afvyju5zzy", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) - suite.NoError(err) + err = suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper156gqf9837u7d4c4678yt3rl4ls9c5vuursrrzf", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) + suite.NoError(err) - err = suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper1a3yjj7d3qnx4spgvjcwjq9cw9snrrrhu5h6jll", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) - suite.NoError(err) + err = suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper14lultfckehtszvzw4ehu0apvsr77afvyju5zzy", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) + suite.NoError(err) - err = suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper1z8zjv3lntpwxua0rtpvgrcwl0nm0tltgpgs6l7", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) - suite.NoError(err) + err = suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper1a3yjj7d3qnx4spgvjcwjq9cw9snrrrhu5h6jll", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) + suite.NoError(err) + + err = suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper1z8zjv3lntpwxua0rtpvgrcwl0nm0tltgpgs6l7", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) + suite.NoError(err) + } + + pk := ed25519.GenPrivKeyFromSecret([]byte("seed")) + pub := pk.PubKey() + anyPk := codectypes.UnsafePackAny(pub) tests := []struct { name string validator stakingtypes.Validator - expected icstypes.Validator + expected func(ctx sdk.Context) icstypes.Validator }{ { name: "valid - no-op", validator: stakingtypes.Validator{OperatorAddress: "cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0", Jailed: false, Status: stakingtypes.Bonded, Tokens: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000), Commission: stakingtypes.NewCommission(sdk.MustNewDecFromStr("0.2"), sdk.MustNewDecFromStr("0.2"), sdk.MustNewDecFromStr("0.2"))}, - expected: icstypes.Validator{ValoperAddress: "cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000), Score: sdk.ZeroDec(), Status: "BOND_STATUS_BONDED", LiquidShares: sdk.ZeroDec(), ValidatorBondShares: sdk.ZeroDec()}, + expected: func(ctx sdk.Context) icstypes.Validator { + return icstypes.Validator{ValoperAddress: "cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000), Score: sdk.ZeroDec(), Status: "BOND_STATUS_BONDED", LiquidShares: sdk.ZeroDec(), ValidatorBondShares: sdk.ZeroDec()} + }, }, { name: "valid - +2000 tokens/shares", validator: stakingtypes.Validator{OperatorAddress: "cosmosvaloper156gqf9837u7d4c4678yt3rl4ls9c5vuursrrzf", Jailed: false, Status: stakingtypes.Bonded, Tokens: sdk.NewInt(4000), DelegatorShares: sdk.NewDec(4000), Commission: stakingtypes.NewCommission(sdk.MustNewDecFromStr("0.2"), sdk.MustNewDecFromStr("0.2"), sdk.MustNewDecFromStr("0.2"))}, - expected: icstypes.Validator{ValoperAddress: "cosmosvaloper156gqf9837u7d4c4678yt3rl4ls9c5vuursrrzf", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(4000), DelegatorShares: sdk.NewDec(4000), Score: sdk.ZeroDec(), Status: "BOND_STATUS_BONDED", LiquidShares: sdk.ZeroDec(), ValidatorBondShares: sdk.ZeroDec()}, + expected: func(ctx sdk.Context) icstypes.Validator { + return icstypes.Validator{ValoperAddress: "cosmosvaloper156gqf9837u7d4c4678yt3rl4ls9c5vuursrrzf", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(4000), DelegatorShares: sdk.NewDec(4000), Score: sdk.ZeroDec(), Status: "BOND_STATUS_BONDED", LiquidShares: sdk.ZeroDec(), ValidatorBondShares: sdk.ZeroDec()} + }, }, { name: "valid - inc. commission", validator: stakingtypes.Validator{OperatorAddress: "cosmosvaloper14lultfckehtszvzw4ehu0apvsr77afvyju5zzy", Jailed: false, Status: stakingtypes.Bonded, Tokens: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000), Commission: stakingtypes.NewCommission(sdk.MustNewDecFromStr("0.5"), sdk.MustNewDecFromStr("0.2"), sdk.MustNewDecFromStr("0.2"))}, - expected: icstypes.Validator{ValoperAddress: "cosmosvaloper14lultfckehtszvzw4ehu0apvsr77afvyju5zzy", CommissionRate: sdk.MustNewDecFromStr("0.5"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000), Score: sdk.ZeroDec(), Status: "BOND_STATUS_BONDED", LiquidShares: sdk.ZeroDec(), ValidatorBondShares: sdk.ZeroDec()}, + expected: func(ctx sdk.Context) icstypes.Validator { + return icstypes.Validator{ValoperAddress: "cosmosvaloper14lultfckehtszvzw4ehu0apvsr77afvyju5zzy", CommissionRate: sdk.MustNewDecFromStr("0.5"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000), Score: sdk.ZeroDec(), Status: "BOND_STATUS_BONDED", LiquidShares: sdk.ZeroDec(), ValidatorBondShares: sdk.ZeroDec()} + }, }, { name: "valid - new validator", validator: stakingtypes.Validator{OperatorAddress: newVal, Jailed: false, Status: stakingtypes.Bonded, Tokens: sdk.NewInt(3000), DelegatorShares: sdk.NewDec(3050), Commission: stakingtypes.NewCommission(sdk.MustNewDecFromStr("0.25"), sdk.MustNewDecFromStr("0.2"), sdk.MustNewDecFromStr("0.2"))}, - expected: icstypes.Validator{ValoperAddress: newVal, CommissionRate: sdk.MustNewDecFromStr("0.25"), VotingPower: sdk.NewInt(3000), DelegatorShares: sdk.NewDec(3050), Score: sdk.ZeroDec(), Status: "BOND_STATUS_BONDED", LiquidShares: sdk.ZeroDec(), ValidatorBondShares: sdk.ZeroDec()}, + expected: func(ctx sdk.Context) icstypes.Validator { + return icstypes.Validator{ValoperAddress: newVal, CommissionRate: sdk.MustNewDecFromStr("0.25"), VotingPower: sdk.NewInt(3000), DelegatorShares: sdk.NewDec(3050), Score: sdk.ZeroDec(), Status: "BOND_STATUS_BONDED", LiquidShares: sdk.ZeroDec(), ValidatorBondShares: sdk.ZeroDec()} + }, + }, + { + name: "valid - validator vp to zero", + validator: stakingtypes.Validator{OperatorAddress: "cosmosvaloper14lultfckehtszvzw4ehu0apvsr77afvyju5zzy", Jailed: true, Status: stakingtypes.Unbonded, Tokens: sdk.NewInt(0), DelegatorShares: sdk.NewDec(0), Commission: stakingtypes.NewCommission(sdk.MustNewDecFromStr("0.25"), sdk.MustNewDecFromStr("0.2"), sdk.MustNewDecFromStr("0.2")), ConsensusPubkey: anyPk}, + expected: func(ctx sdk.Context) icstypes.Validator { + return icstypes.Validator{ValoperAddress: "cosmosvaloper14lultfckehtszvzw4ehu0apvsr77afvyju5zzy", CommissionRate: sdk.MustNewDecFromStr("0.25"), VotingPower: sdk.NewInt(0), DelegatorShares: sdk.NewDec(0), Score: sdk.ZeroDec(), Status: "BOND_STATUS_UNBONDED", LiquidShares: sdk.ZeroDec(), ValidatorBondShares: sdk.ZeroDec(), Jailed: true, JailedSince: ctx.BlockTime()} + }, }, } @@ -452,7 +476,10 @@ func (suite *KeeperTestSuite) TestHandleValidatorCallback() { quicksilver.InterchainstakingKeeper.CallbackHandler().RegisterCallbacks() ctx := suite.chainA.GetContext() - quicksilver.InterchainstakingKeeper.SetZone(ctx, &zone) + setup(ctx, quicksilver) + + zone, found := quicksilver.InterchainstakingKeeper.GetZone(ctx, suite.chainB.ChainID) + suite.True(found) bz, err := quicksilver.AppCodec().Marshal(&test.validator) suite.NoError(err) @@ -460,14 +487,12 @@ func (suite *KeeperTestSuite) TestHandleValidatorCallback() { err = keeper.ValidatorCallback(quicksilver.InterchainstakingKeeper, ctx, bz, icqtypes.Query{ChainId: zone.ChainId}) suite.NoError(err) - zone, found := quicksilver.InterchainstakingKeeper.GetZone(ctx, zone.ChainId) - suite.True(found) - - valAddrBytes, err := addressutils.ValAddressFromBech32(test.expected.ValoperAddress, zone.GetValoperPrefix()) + expected := test.expected(ctx) + valAddrBytes, err := addressutils.ValAddressFromBech32(expected.ValoperAddress, zone.GetValoperPrefix()) suite.NoError(err) val, found := quicksilver.InterchainstakingKeeper.GetValidator(ctx, zone.ChainId, valAddrBytes) suite.True(found) - suite.Equal(test.expected, val) + suite.Equal(expected, val) }) } } diff --git a/x/interchainstaking/keeper/keeper.go b/x/interchainstaking/keeper/keeper.go index 9aa0d2587..c81db1681 100644 --- a/x/interchainstaking/keeper/keeper.go +++ b/x/interchainstaking/keeper/keeper.go @@ -406,16 +406,24 @@ func (k *Keeper) SetValidatorForZone(ctx sdk.Context, zone *types.Zone, data []b if !val.VotingPower.IsPositive() { return fmt.Errorf("existing voting power must be greater than zero, received %s", val.VotingPower) } - if !validator.Tokens.IsPositive() { - return fmt.Errorf("incoming voting power must be greater than zero, received %s", validator.Tokens) + if validator.Tokens.IsNegative() { + return fmt.Errorf("incoming voting power must not be negative, received %s", validator.Tokens) } - // determine difference between previous vp/shares ratio and new ratio. - prevRatio := val.DelegatorShares.Quo(sdk.NewDecFromInt(val.VotingPower)) - newRatio := validator.DelegatorShares.Quo(sdk.NewDecFromInt(validator.Tokens)) - delta := newRatio.Quo(prevRatio) - err = k.UpdateWithdrawalRecordsForSlash(ctx, zone, val.ValoperAddress, delta) - if err != nil { - return err + if validator.Tokens.IsZero() { + // edge case: if validator tokens is now zero, val was slashed to zero. + err = k.UpdateWithdrawalRecordsForSlash(ctx, zone, val.ValoperAddress, sdk.ZeroDec()) + if err != nil { + return err + } + } else { + // determine difference between previous vp/shares ratio and new ratio. + prevRatio := val.DelegatorShares.Quo(sdk.NewDecFromInt(val.VotingPower)) + newRatio := validator.DelegatorShares.Quo(sdk.NewDecFromInt(validator.Tokens)) + delta := newRatio.Quo(prevRatio) + err = k.UpdateWithdrawalRecordsForSlash(ctx, zone, val.ValoperAddress, delta) + if err != nil { + return err + } } } else if val.Jailed && !validator.IsJailed() { k.Logger(ctx).Debug("Transitioning validator to unjailed state", "valoper", validator.OperatorAddress) diff --git a/x/interchainstaking/keeper/withdrawal_record.go b/x/interchainstaking/keeper/withdrawal_record.go index 922f39c9a..0f6c47996 100644 --- a/x/interchainstaking/keeper/withdrawal_record.go +++ b/x/interchainstaking/keeper/withdrawal_record.go @@ -276,7 +276,10 @@ func (k *Keeper) UpdateWithdrawalRecordsForSlash(ctx sdk.Context, zone *types.Zo return true } - newAmount := distAmount.Quo(delta).TruncateInt() + newAmount := sdkmath.ZeroInt() + if !delta.IsZero() { + newAmount = distAmount.Quo(delta).TruncateInt() + } thisSubAmount := distAmount.TruncateInt().Sub(newAmount) recordSubAmount = recordSubAmount.Add(thisSubAmount) d.Amount = newAmount.Uint64() From 9fae09714bd5a9d3eb6edcb1f7e7ae4d0b0d3d66 Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Wed, 6 Mar 2024 19:39:55 +0400 Subject: [PATCH 5/5] fix: unbonding records have nil amount field, so query burnAmount instead (#1247) * fix: unbonding records have nil amount * fix test after burnamount fix --- x/interchainstaking/keeper/keeper_test.go | 12 ++++++------ x/interchainstaking/keeper/zones.go | 7 +++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/x/interchainstaking/keeper/keeper_test.go b/x/interchainstaking/keeper/keeper_test.go index 21d865c6c..69ccb307c 100644 --- a/x/interchainstaking/keeper/keeper_test.go +++ b/x/interchainstaking/keeper/keeper_test.go @@ -748,7 +748,7 @@ func (suite *KeeperTestSuite) TestGetQueuedTokensAndCount() { name: "one queued withdrawal", records: func(zone icstypes.Zone) []icstypes.WithdrawalRecord { out := make([]icstypes.WithdrawalRecord, 0) - out = append(out, icstypes.WithdrawalRecord{ChainId: zone.ChainId, Delegator: zone.DelegationAddress.Address, Recipient: addressutils.GenerateAddressForTestWithPrefix(zone.AccountPrefix), Amount: sdk.NewCoins(sdk.NewCoin(zone.BaseDenom, math.NewInt(3000000))), Status: icstypes.WithdrawStatusQueued, Txhash: randomutils.GenerateRandomHashAsHex(64)}) + out = append(out, icstypes.WithdrawalRecord{ChainId: zone.ChainId, Delegator: zone.DelegationAddress.Address, Recipient: addressutils.GenerateAddressForTestWithPrefix(zone.AccountPrefix), BurnAmount: sdk.NewCoin(zone.LocalDenom, math.NewInt(3000000)), Status: icstypes.WithdrawStatusQueued, Txhash: randomutils.GenerateRandomHashAsHex(64)}) return out }, expectedAmount: math.NewInt(3000000), @@ -769,9 +769,9 @@ func (suite *KeeperTestSuite) TestGetQueuedTokensAndCount() { records: func(zone icstypes.Zone) []icstypes.WithdrawalRecord { out := make([]icstypes.WithdrawalRecord, 0) out = append(out, - icstypes.WithdrawalRecord{ChainId: zone.ChainId, Delegator: zone.DelegationAddress.Address, Recipient: addressutils.GenerateAddressForTestWithPrefix(zone.AccountPrefix), Amount: sdk.NewCoins(sdk.NewCoin(zone.BaseDenom, math.NewInt(3000000))), Status: icstypes.WithdrawStatusQueued, Txhash: randomutils.GenerateRandomHashAsHex(64)}, - icstypes.WithdrawalRecord{ChainId: zone.ChainId, Delegator: zone.DelegationAddress.Address, Recipient: addressutils.GenerateAddressForTestWithPrefix(zone.AccountPrefix), Amount: sdk.NewCoins(sdk.NewCoin(zone.BaseDenom, math.NewInt(10000000))), Status: icstypes.WithdrawStatusQueued, Txhash: randomutils.GenerateRandomHashAsHex(64)}, - icstypes.WithdrawalRecord{ChainId: zone.ChainId, Delegator: zone.DelegationAddress.Address, Recipient: addressutils.GenerateAddressForTestWithPrefix(zone.AccountPrefix), Amount: sdk.NewCoins(sdk.NewCoin(zone.BaseDenom, math.NewInt(1500000))), Status: icstypes.WithdrawStatusQueued, Txhash: randomutils.GenerateRandomHashAsHex(64)}, + icstypes.WithdrawalRecord{ChainId: zone.ChainId, Delegator: zone.DelegationAddress.Address, Recipient: addressutils.GenerateAddressForTestWithPrefix(zone.AccountPrefix), BurnAmount: sdk.NewCoin(zone.LocalDenom, math.NewInt(3000000)), Status: icstypes.WithdrawStatusQueued, Txhash: randomutils.GenerateRandomHashAsHex(64)}, + icstypes.WithdrawalRecord{ChainId: zone.ChainId, Delegator: zone.DelegationAddress.Address, Recipient: addressutils.GenerateAddressForTestWithPrefix(zone.AccountPrefix), BurnAmount: sdk.NewCoin(zone.LocalDenom, math.NewInt(10000000)), Status: icstypes.WithdrawStatusQueued, Txhash: randomutils.GenerateRandomHashAsHex(64)}, + icstypes.WithdrawalRecord{ChainId: zone.ChainId, Delegator: zone.DelegationAddress.Address, Recipient: addressutils.GenerateAddressForTestWithPrefix(zone.AccountPrefix), BurnAmount: sdk.NewCoin(zone.LocalDenom, math.NewInt(1500000)), Status: icstypes.WithdrawStatusQueued, Txhash: randomutils.GenerateRandomHashAsHex(64)}, ) return out }, @@ -784,7 +784,7 @@ func (suite *KeeperTestSuite) TestGetQueuedTokensAndCount() { out := make([]icstypes.WithdrawalRecord, 0) out = append(out, icstypes.WithdrawalRecord{ChainId: zone.ChainId, Delegator: zone.DelegationAddress.Address, Recipient: addressutils.GenerateAddressForTestWithPrefix(zone.AccountPrefix), Amount: sdk.NewCoins(sdk.NewCoin(zone.BaseDenom, math.NewInt(3000000))), Status: icstypes.WithdrawStatusUnbond, Txhash: randomutils.GenerateRandomHashAsHex(64)}, - icstypes.WithdrawalRecord{ChainId: zone.ChainId, Delegator: zone.DelegationAddress.Address, Recipient: addressutils.GenerateAddressForTestWithPrefix(zone.AccountPrefix), Amount: sdk.NewCoins(sdk.NewCoin(zone.BaseDenom, math.NewInt(10000000))), Status: icstypes.WithdrawStatusQueued, Txhash: randomutils.GenerateRandomHashAsHex(64)}, + icstypes.WithdrawalRecord{ChainId: zone.ChainId, Delegator: zone.DelegationAddress.Address, Recipient: addressutils.GenerateAddressForTestWithPrefix(zone.AccountPrefix), BurnAmount: sdk.NewCoin(zone.LocalDenom, math.NewInt(10000000)), Status: icstypes.WithdrawStatusQueued, Txhash: randomutils.GenerateRandomHashAsHex(64)}, icstypes.WithdrawalRecord{ChainId: zone.ChainId, Delegator: zone.DelegationAddress.Address, Recipient: addressutils.GenerateAddressForTestWithPrefix(zone.AccountPrefix), Amount: sdk.NewCoins(sdk.NewCoin(zone.BaseDenom, math.NewInt(1500000))), Status: icstypes.WithdrawStatusCompleted, Txhash: randomutils.GenerateRandomHashAsHex(64)}, ) return out @@ -810,7 +810,7 @@ func (suite *KeeperTestSuite) TestGetQueuedTokensAndCount() { actualAmount, actualCount := icsKeeper.GetQueuedTokensAndCount(ctx, &zone) suite.Equal(tt.expectedAmount, actualAmount.Amount) - suite.Equal(zone.BaseDenom, actualAmount.Denom) + suite.Equal(zone.LocalDenom, actualAmount.Denom) suite.Equal(tt.expectedCount, actualCount) }) } diff --git a/x/interchainstaking/keeper/zones.go b/x/interchainstaking/keeper/zones.go index 1fc279401..31b254674 100644 --- a/x/interchainstaking/keeper/zones.go +++ b/x/interchainstaking/keeper/zones.go @@ -111,12 +111,11 @@ func (k *Keeper) GetUnbondingTokensAndCount(ctx sdk.Context, zone *types.Zone) ( } func (k *Keeper) GetQueuedTokensAndCount(ctx sdk.Context, zone *types.Zone) (sdk.Coin, uint32) { - out := sdk.NewCoin(zone.BaseDenom, sdk.ZeroInt()) + out := sdk.NewCoin(zone.LocalDenom, sdk.ZeroInt()) var count uint32 k.IterateZoneStatusWithdrawalRecords(ctx, zone.ChainId, types.WithdrawStatusQueued, func(index int64, wr types.WithdrawalRecord) (stop bool) { - amount := wr.Amount[0] - if !amount.IsNegative() { - out = out.Add(amount) + if !wr.BurnAmount.IsNegative() { + out = out.Add(wr.BurnAmount) } count++ return false