From 9bcc8c911a9329fe95cf385890423d779b8d7d39 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 07:49:29 +0000 Subject: [PATCH 1/2] chore(deps): bump google.golang.org/grpc from 1.69.2 to 1.69.4 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.69.2 to 1.69.4. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.69.2...v1.69.4) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 76aecd86e..7ba9baa86 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 golang.org/x/tools v0.28.0 google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 - google.golang.org/grpc v1.69.2 + google.golang.org/grpc v1.69.4 google.golang.org/protobuf v1.36.1 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 12e607f1d..5f946c87d 100644 --- a/go.sum +++ b/go.sum @@ -2033,8 +2033,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.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU= -google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= +google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A= +google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= 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= From 805149420b34a48613f59d5448d50bd4f521a6ed Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Tue, 14 May 2024 13:55:43 +0100 Subject: [PATCH 2/2] remove old ics code that is unused --- .../keeper/rewards_holdings.go | 37 +------- .../keeper/rewards_holdings_test.go | 92 ++----------------- 2 files changed, 11 insertions(+), 118 deletions(-) diff --git a/x/participationrewards/keeper/rewards_holdings.go b/x/participationrewards/keeper/rewards_holdings.go index 819bce798..41bd591f4 100644 --- a/x/participationrewards/keeper/rewards_holdings.go +++ b/x/participationrewards/keeper/rewards_holdings.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/quicksilver-zone/quicksilver/utils" - "github.com/quicksilver-zone/quicksilver/utils/addressutils" airdroptypes "github.com/quicksilver-zone/quicksilver/x/airdrop/types" cmtypes "github.com/quicksilver-zone/quicksilver/x/claimsmanager/types" icstypes "github.com/quicksilver-zone/quicksilver/x/interchainstaking/types" @@ -17,7 +16,7 @@ func (k Keeper) AllocateHoldingsRewards(ctx sdk.Context) error { // obtain and iterate all claim records for each zone k.icsKeeper.IterateZones(ctx, func(index int64, zone *icstypes.Zone) (stop bool) { k.Logger(ctx).Info("zones", "zone", zone.ChainId) - userAllocations, remaining, _ := k.CalcUserHoldingsAllocations(ctx, zone) + userAllocations, remaining := k.CalcUserHoldingsAllocations(ctx, zone) if err := k.DistributeToUsersFromModule(ctx, userAllocations); err != nil { k.Logger(ctx).Error("failed to distribute to users", "ua", userAllocations, "err", err) @@ -41,19 +40,16 @@ func (k Keeper) AllocateHoldingsRewards(ctx sdk.Context) error { } // CalcUserHoldingsAllocations calculates allocations per user for a given zone, based upon claims submitted and zone. -func (k Keeper) CalcUserHoldingsAllocations(ctx sdk.Context, zone *icstypes.Zone) ([]types.UserAllocation, math.Int, []types.UserAllocation) { +func (k Keeper) CalcUserHoldingsAllocations(ctx sdk.Context, zone *icstypes.Zone) ([]types.UserAllocation, math.Int) { k.Logger(ctx).Info("CalcUserHoldingsAllocations", "zone", zone.ChainId, "allocations", zone.HoldingsAllocation) userAllocations := make([]types.UserAllocation, 0) - icsRewardsAllocations := make([]types.UserAllocation, 0) - icsRewardsBalance := sdk.NewCoins() - icsRewardsPerAsset := make(map[string]sdk.Dec, 0) supply := k.bankKeeper.GetSupply(ctx, zone.LocalDenom) if zone.HoldingsAllocation == 0 || !supply.Amount.IsPositive() { k.Logger(ctx).Info("holdings allocation is zero, nothing to allocate") - return userAllocations, math.NewIntFromUint64(zone.HoldingsAllocation), icsRewardsAllocations + return userAllocations, math.NewIntFromUint64(zone.HoldingsAllocation) } // calculate user totals and zone total (held assets) @@ -83,26 +79,12 @@ func (k Keeper) CalcUserHoldingsAllocations(ctx sdk.Context, zone *icstypes.Zone if !zoneAmount.IsPositive() { k.Logger(ctx).Info("zero claims for zone", "zone", zone.ChainId) - return userAllocations, math.NewIntFromUint64(zone.HoldingsAllocation), icsRewardsAllocations + return userAllocations, math.NewIntFromUint64(zone.HoldingsAllocation) } zoneAllocation := math.NewIntFromUint64(zone.HoldingsAllocation) tokensPerAsset := sdk.NewDecFromInt(zoneAllocation).Quo(sdk.NewDecFromInt(supply.Amount)) - if zone.WithdrawalAddress != nil { - // determine ics rewards to be distributed per token. - icsRewardsAddr, err := addressutils.AddressFromBech32(zone.WithdrawalAddress.Address, zone.AccountPrefix) - if err != nil { - panic("unable to unmarshal withdrawal address") - } - icsRewardsBalance = k.bankKeeper.GetAllBalances(ctx, icsRewardsAddr) - icsRewardsPerAsset = make(map[string]sdk.Dec, len(icsRewardsBalance)) - for _, rewardsAsset := range icsRewardsBalance { - icsRewardsPerAsset[rewardsAsset.Denom] = sdk.NewDecFromInt(rewardsAsset.Amount).Quo(sdk.NewDecFromInt(supply.Amount)) - } - - k.Logger(ctx).Info("ics rewards per asset", "zone", zone.ChainId, "icsrpa", icsRewardsPerAsset) - } k.Logger(ctx).Info("tokens per asset", "zone", zone.ChainId, "tpa", tokensPerAsset) for _, address := range utils.Keys(userAmountsMap) { @@ -118,16 +100,7 @@ func (k Keeper) CalcUserHoldingsAllocations(ctx sdk.Context, zone *icstypes.Zone panic("user allocation overflow") } - // allocate ics rewards - for _, rewardsAsset := range icsRewardsBalance { - icsRewardsAllocation := types.UserAllocation{ - Address: address, - Amount: sdk.NewCoin(rewardsAsset.Denom, sdk.NewDecFromInt(amount).Mul(icsRewardsPerAsset[rewardsAsset.Denom]).TruncateInt()), - } - icsRewardsAllocations = append(icsRewardsAllocations, icsRewardsAllocation) - } - } - return userAllocations, zoneAllocation, icsRewardsAllocations + return userAllocations, zoneAllocation } diff --git a/x/participationrewards/keeper/rewards_holdings_test.go b/x/participationrewards/keeper/rewards_holdings_test.go index 69ce369f4..fa120c993 100644 --- a/x/participationrewards/keeper/rewards_holdings_test.go +++ b/x/participationrewards/keeper/rewards_holdings_test.go @@ -18,13 +18,11 @@ func (suite *KeeperTestSuite) TestCalcUserHoldingsAllocations() { ctx := suite.chainA.GetContext() bondDenom := appA.StakingKeeper.BondDenom(ctx) tests := []struct { - name string - malleate func(ctx sdk.Context, appA *app.Quicksilver) - want []types.UserAllocation - icsWant []types.UserAllocation - remainder math.Int - icsRemainder sdk.Coins - wantErr string + name string + malleate func(ctx sdk.Context, appA *app.Quicksilver) + want []types.UserAllocation + remainder math.Int + wantErr string }{ { "zero claims; no allocation", @@ -34,9 +32,7 @@ func (suite *KeeperTestSuite) TestCalcUserHoldingsAllocations() { appA.InterchainstakingKeeper.SetZone(ctx, &zone) }, []types.UserAllocation{}, - []types.UserAllocation{}, sdk.ZeroInt(), - sdk.NewCoins(), "", }, { @@ -49,9 +45,7 @@ func (suite *KeeperTestSuite) TestCalcUserHoldingsAllocations() { appA.ClaimsManagerKeeper.SetLastEpochClaim(ctx, &cmtypes.Claim{UserAddress: user2.String(), ChainId: "otherchain-1", Module: cmtypes.ClaimTypeLiquidToken, SourceChainId: suite.chainA.ChainID, Amount: math.NewInt(1000)}) }, []types.UserAllocation{}, - []types.UserAllocation{}, sdk.NewInt(64000), - sdk.NewCoins(), "", }, { @@ -75,9 +69,7 @@ func (suite *KeeperTestSuite) TestCalcUserHoldingsAllocations() { Amount: sdk.NewCoin(bondDenom, sdk.NewInt(2500)), }, }, - []types.UserAllocation{}, sdk.ZeroInt(), - sdk.NewCoins(), "", }, { @@ -101,9 +93,7 @@ func (suite *KeeperTestSuite) TestCalcUserHoldingsAllocations() { Amount: sdk.NewCoin(bondDenom, sdk.NewInt(2000)), // 1000 / 2500 (0.4) * 5000 = 2000 }, }, - []types.UserAllocation{}, sdk.NewInt(2000), - sdk.NewCoins(), "", }, { @@ -127,9 +117,7 @@ func (suite *KeeperTestSuite) TestCalcUserHoldingsAllocations() { Amount: sdk.NewCoin(bondDenom, sdk.NewInt(3333)), // 1000/1500 (0.66666) * 5000 = 3333 }, }, - []types.UserAllocation{}, sdk.OneInt(), - sdk.NewCoins(), "", }, { @@ -155,18 +143,7 @@ func (suite *KeeperTestSuite) TestCalcUserHoldingsAllocations() { Amount: sdk.NewCoin(bondDenom, sdk.NewInt(3333)), // 1000/1500 (0.66666) * 5000 = 3333 }, }, - []types.UserAllocation{ - { - Address: user1.String(), - Amount: sdk.NewCoin("testcoin", sdk.NewInt(300)), // 500/1500 (0.33333) * 900 == 300 - }, - { - Address: user2.String(), - Amount: sdk.NewCoin("testcoin", sdk.NewInt(600)), // 1000/1500 (0.66666) * 900 = 600 - }, - }, sdk.OneInt(), - sdk.NewCoins(), "", }, { @@ -197,34 +174,7 @@ func (suite *KeeperTestSuite) TestCalcUserHoldingsAllocations() { Amount: sdk.NewCoin(bondDenom, sdk.NewInt(3333)), // 1000/1500 (0.66666) * 5000 = 3333 }, }, - []types.UserAllocation{ - { - Address: user1.String(), - Amount: sdk.NewCoin("testcoin", sdk.NewInt(300)), // 500/1500 (0.33333) * 900 == 300 - }, - { - Address: user2.String(), - Amount: sdk.NewCoin("testcoin", sdk.NewInt(600)), // 1000/1500 (0.66666) * 900 = 600 - }, - { - Address: user1.String(), - Amount: sdk.NewCoin("testcoin2", sdk.NewInt(6000)), // 500/1500 (0.33333) * 18k == 6k - }, - { - Address: user2.String(), - Amount: sdk.NewCoin("testcoin2", sdk.NewInt(12001)), // 1000/1500 (0.66666) * 18k = 12k - }, - { - Address: user1.String(), - Amount: sdk.NewCoin("testcoin3", sdk.NewInt(50)), // 500/1500 (0.33333) * 150 == 50 - }, - { - Address: user2.String(), - Amount: sdk.NewCoin("testcoin3", sdk.NewInt(100)), // 1000/1500 (0.66666) * 150 = 100 - }, - }, sdk.OneInt(), - sdk.NewCoins(sdk.NewCoin("testcoin2", sdk.NewIntFromUint64(1))), "", }, @@ -254,29 +204,7 @@ func (suite *KeeperTestSuite) TestCalcUserHoldingsAllocations() { Amount: sdk.NewCoin(bondDenom, sdk.NewInt(2000)), // 1000 / 2500 (0.4) * 5000 = 2000 }, }, - []types.UserAllocation{ - { - Address: user1.String(), - Amount: sdk.NewCoin("testcoin", sdk.NewInt(180)), // 500/1500 (0.33333) * 900 == 300 - }, - { - Address: user2.String(), - Amount: sdk.NewCoin("testcoin", sdk.NewInt(360)), // 1000/1500 (0.66666) * 900 = 600 - }, - { - Address: user1.String(), - Amount: sdk.NewCoin("testcoin2", sdk.NewInt(3600)), // 500/1500 (0.33333) * 18k == 6k - }, - { - Address: user2.String(), - Amount: sdk.NewCoin("testcoin2", sdk.NewInt(7200)), // 1000/1500 (0.66666) * 18k = 12k - }, - }, sdk.NewInt(2000), - sdk.NewCoins( - sdk.NewCoin("testcoin", sdk.NewInt(360)), - sdk.NewCoin("testcoin2", sdk.NewInt(7202)), - ), "", }, } @@ -299,17 +227,9 @@ func (suite *KeeperTestSuite) TestCalcUserHoldingsAllocations() { suite.NoError(appA.BankKeeper.MintCoins(ctx, "mint", sdk.NewCoins(sdk.NewCoin(appA.StakingKeeper.BondDenom(ctx), sdk.NewIntFromUint64(zone.HoldingsAllocation))))) suite.NoError(appA.BankKeeper.SendCoinsFromModuleToModule(ctx, "mint", types.ModuleName, sdk.NewCoins(sdk.NewCoin(appA.StakingKeeper.BondDenom(ctx), sdk.NewIntFromUint64(zone.HoldingsAllocation))))) - allocations, remainder, icsRewardsAllocations := appA.ParticipationRewardsKeeper.CalcUserHoldingsAllocations(ctx, &zone) + allocations, remainder := appA.ParticipationRewardsKeeper.CalcUserHoldingsAllocations(ctx, &zone) suite.ElementsMatch(tt.want, allocations) - suite.ElementsMatch(tt.icsWant, icsRewardsAllocations) suite.True(tt.remainder.Equal(remainder)) - - // distribute assets to users; check remainder (to be distributed next time!) - err := appA.ParticipationRewardsKeeper.DistributeToUsersFromAddress(ctx, icsRewardsAllocations, zone.WithdrawalAddress.Address) - suite.NoError(err) - icsAddress, _ := addressutils.AddressFromBech32(zone.WithdrawalAddress.Address, "") - icsBalance := appA.BankKeeper.GetAllBalances(ctx, icsAddress) - suite.ElementsMatch(tt.icsRemainder, icsBalance) }) } }