From 1bd1d53db4a95895a8606c3c3b85d17984367c54 Mon Sep 17 00:00:00 2001 From: Yaroms <103432884+Yaroms@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:54:03 +0300 Subject: [PATCH] feat: CNS-validator-rewards-query (#1624) * added a query to fetch tracked cu * add query for spectrackedinfo * add query for estimated rewards * fix * now it works * fix cli * add cli for tracked cu * pr changes * can take into account the provider/delegation address * add community and tax * pr changes * fix * added community and validator tax for iprpc * done * fix * pr changes * typo * add cli * fix for self delegation * update lava spec * remove cosmwasm from lava spec * added event * fix unit test * added leftover pool * add test. make sure to distribute the rewards from all kinds of tokens * add test * pr fix * fix * fix * lint --------- Co-authored-by: Yarom Swisa Co-authored-by: Yaroms Co-authored-by: Omer <100387053+omerlavanet@users.noreply.github.com> Co-authored-by: Oren Co-authored-by: oren-lava <111131399+oren-lava@users.noreply.github.com> --- app/app.go | 1 + cookbook/specs/lava.json | 146 +++- cookbook/specs/lava_mainnet.json | 400 ++++++++++- proto/lavanet/lava/subscription/query.proto | 20 +- x/rewards/keeper/grpc_query_pools.go | 4 + x/rewards/keeper/iprpc.go | 12 + x/rewards/keeper/iprpc_test.go | 31 +- x/rewards/keeper/pool_test.go | 19 + x/rewards/keeper/providers.go | 26 +- x/rewards/keeper/rewards.go | 28 +- x/rewards/types/types.go | 10 + x/subscription/client/cli/query.go | 1 + .../cli/query_estimated_validators_rewards.go | 55 ++ .../grpc_query_estimated_validator_rewards.go | 117 +++ x/subscription/types/expected_keepers.go | 6 + x/subscription/types/query.pb.go | 668 +++++++++++++++--- x/subscription/types/query.pb.gw.go | 123 ++++ 17 files changed, 1558 insertions(+), 109 deletions(-) create mode 100644 x/subscription/client/cli/query_estimated_validators_rewards.go create mode 100644 x/subscription/keeper/grpc_query_estimated_validator_rewards.go diff --git a/app/app.go b/app/app.go index 3b6f3c30a6..a0bb60bc43 100644 --- a/app/app.go +++ b/app/app.go @@ -282,6 +282,7 @@ var ( subscriptionmoduletypes.ModuleName: {authtypes.Burner, authtypes.Staking}, string(rewardsmoduletypes.ValidatorsRewardsAllocationPoolName): {authtypes.Minter, authtypes.Staking}, string(rewardsmoduletypes.ValidatorsRewardsDistributionPoolName): {authtypes.Burner, authtypes.Staking}, + string(rewardsmoduletypes.ValidatorsRewardsLeftOverPoolName): {authtypes.Burner, authtypes.Staking}, string(rewardsmoduletypes.ProviderRewardsDistributionPool): {authtypes.Burner, authtypes.Staking}, string(rewardsmoduletypes.ProvidersRewardsAllocationPool): {authtypes.Minter, authtypes.Staking}, dualstakingmoduletypes.ModuleName: {authtypes.Burner, authtypes.Staking}, diff --git a/cookbook/specs/lava.json b/cookbook/specs/lava.json index 27517a0d60..ca343c40a2 100644 --- a/cookbook/specs/lava.json +++ b/cookbook/specs/lava.json @@ -8,7 +8,7 @@ "name": "lava testnet", "enabled": true, "imports": [ - "COSMOSSDKFULL" + "COSMOSSDK" ], "providers_types": 1, "reliability_threshold": 268435455, @@ -1383,6 +1383,78 @@ "stateful": 0 }, "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/subscription/estimated_validator_rewards/{validator}/{amount_delegator}", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/subscription/tracked_usage/{subscription}", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/subscription/estimated_rewards/{provider}/{chain_id}/{amount_delegator}", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/rewards/SpecTrackedInfo/{chain_id}/{provider}", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 } ], "headers": [], @@ -2743,6 +2815,78 @@ "stateful": 0 }, "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.subscription.Query/EstimatedRewards", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.rewards.Query/SpecTrackedInfo", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.subscription.Query/EstimatedValidatorRewards", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.subscription.Query/TrackedUsage", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 } ], "headers": [], diff --git a/cookbook/specs/lava_mainnet.json b/cookbook/specs/lava_mainnet.json index c2472c7538..1923cbde0f 100644 --- a/cookbook/specs/lava_mainnet.json +++ b/cookbook/specs/lava_mainnet.json @@ -8,7 +8,7 @@ "name": "lava mainnet", "enabled": true, "imports": [ - "COSMOSSDKFULL" + "COSMOSSDK" ], "providers_types": 1, "reliability_threshold": 268435455, @@ -1239,6 +1239,204 @@ "stateful": 0 }, "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/rewards/iprpc_spec_reward/{spec}", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/subscription/estimated_rewards/{provider}/{chain_id}/{amount_delegator}", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/subscription/tracked_usage/{subscription}", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/rewards/iprpc_provider_reward/{provider}", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/subscription/estimated_validator_rewards/{validator}/{amount_delegator}", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/dualstaking/delegator_rewards/{delegator}", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/rewards/SpecTrackedInfo/{chain_id}/{provider}", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/pairing/providers_epoch_cu", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/pairing/provider/{address}/{chainID}", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/pairing/provider_pairing_chance/{provider}/{chainID}/{geolocation}/{cluster}", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "/lavanet/lava/rewards/show_iprpc_data", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 } ], "headers": [], @@ -2455,6 +2653,204 @@ "stateful": 0 }, "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.subscription.Query/EstimatedRewards", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.rewards.Query/IprpcProviderRewardEstimation", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.subscription.Query/TrackedUsage", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.subscription.Query/EstimatedValidatorRewards", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.dualstaking.Query/DelegatorRewardsList", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.rewards.Query/IprpcSpecReward", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.pairing.Query/ProvidersEpochCu", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.rewards.Query/SpecTrackedInfo", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.pairing.Query/Provider", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.pairing.Query/ProviderPairingChance", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "lavanet.lava.rewards.Query/ShowIprpcData", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 10, + "enabled": true, + "category": { + "deterministic": true, + "local": false, + "subscription": false, + "stateful": 0 + }, + "extra_compute_units": 0 } ], "headers": [], @@ -2540,5 +2936,5 @@ } ] }, - "deposit": "10000000ulava" + "deposit": "1750000000ulava" } \ No newline at end of file diff --git a/proto/lavanet/lava/subscription/query.proto b/proto/lavanet/lava/subscription/query.proto index 245a91450f..64e0b2ef02 100644 --- a/proto/lavanet/lava/subscription/query.proto +++ b/proto/lavanet/lava/subscription/query.proto @@ -49,6 +49,10 @@ rpc EstimatedRewards(QueryEstimatedRewardsRequest) returns (QueryEstimatedReward option (google.api.http).get = "/lavanet/lava/subscription/estimated_rewards/{provider}/{chain_id}/{amount_delegator}"; } +rpc EstimatedValidatorRewards(QueryEstimatedValidatorRewardsRequest) returns (QueryEstimatedValidatorRewardsResponse) { + option (google.api.http).get = "/lavanet/lava/subscription/estimated_validator_rewards/{validator}/{amount_delegator}"; +} + // this line is used by starport scaffolding # 2 } @@ -143,4 +147,18 @@ message QueryEstimatedRewardsResponse { (amino.dont_omitempty) = true ]; } -// this line is used by starport scaffolding # 3 \ No newline at end of file + +message QueryEstimatedValidatorRewardsRequest { + string validator = 1; + string amount_delegator = 2; +} + +message QueryEstimatedValidatorRewardsResponse { + repeated EstimatedRewardInfo info = 1 [(gogoproto.nullable) = true]; + repeated cosmos.base.v1beta1.DecCoin total = 2 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; +} +// this line is used by starport scaffolding # 3 diff --git a/x/rewards/keeper/grpc_query_pools.go b/x/rewards/keeper/grpc_query_pools.go index e79d69521c..f975e36783 100644 --- a/x/rewards/keeper/grpc_query_pools.go +++ b/x/rewards/keeper/grpc_query_pools.go @@ -29,6 +29,10 @@ func (k Keeper) Pools(goCtx context.Context, req *types.QueryPoolsRequest) (*typ Name: string(types.ProviderRewardsDistributionPool), Balance: k.TotalPoolTokens(ctx, types.ProviderRewardsDistributionPool), }, + { + Name: string(types.ValidatorsRewardsLeftOverPoolName), + Balance: k.TotalPoolTokens(ctx, types.ValidatorsRewardsLeftOverPoolName), + }, { Name: string(types.ProvidersRewardsAllocationPool), Balance: k.TotalPoolTokens(ctx, types.ProvidersRewardsAllocationPool), diff --git a/x/rewards/keeper/iprpc.go b/x/rewards/keeper/iprpc.go index 7d658ee5ee..1cd944c396 100644 --- a/x/rewards/keeper/iprpc.go +++ b/x/rewards/keeper/iprpc.go @@ -148,6 +148,18 @@ func (k Keeper) distributeIprpcRewards(ctx sdk.Context, iprpcReward types.IprpcR continue } + // tax the rewards to the community and validators + fundAfterTax := sdk.NewCoins() + for _, coin := range specFund.Fund { + leftover, err := k.ContributeToValidatorsAndCommunityPool(ctx, coin, string(types.IprpcPoolName)) + if err != nil { + // if ContributeToValidatorsAndCommunityPool fails we continue with the next providerrewards + continue + } + fundAfterTax = fundAfterTax.Add(leftover) + } + specFund.Fund = fundAfterTax + UsedReward := sdk.NewCoins() // distribute IPRPC reward for spec for _, providerCU := range specCu.ProvidersCu { diff --git a/x/rewards/keeper/iprpc_test.go b/x/rewards/keeper/iprpc_test.go index 59d2c943ca..84d08d5e7d 100644 --- a/x/rewards/keeper/iprpc_test.go +++ b/x/rewards/keeper/iprpc_test.go @@ -156,6 +156,7 @@ func TestFundIprpcTX(t *testing.T) { func TestIprpcProviderRewardQuery(t *testing.T) { ts := newTester(t, true) ts.setupForIprpcTests(true) // setup funds IPRPC for mock2 spec + ts.Keepers.Distribution.SetParams(ts.Ctx, distributiontypes.Params{CommunityTax: sdk.OneDec().QuoInt64(2)}) // get consumers and providers (note, only c1 is IPRPC eligible) c1Acc, _ := ts.GetAccount(common.CONSUMER, 0) @@ -189,6 +190,7 @@ func TestIprpcProviderRewardQuery(t *testing.T) { provider string fund sdk.Coins } + tax := sdk.NewInt(100).SubRaw(10).SubRaw(45) // tax is 10% validators and 45% community expectedProviderRewards := []providerRewards{ {provider: p1, fund: iprpcFunds.Sub(minIprpcCost).QuoInt(sdk.NewInt(5))}, {provider: p2, fund: iprpcFunds.Sub(minIprpcCost).MulInt(sdk.NewInt(4)).QuoInt(sdk.NewInt(5))}, @@ -207,7 +209,7 @@ func TestIprpcProviderRewardQuery(t *testing.T) { for i, expectedProviderReward := range expectedProviderRewards { res2, err := ts.QueryDualstakingDelegatorRewards(providerAccs[i].GetVaultAddr(), expectedProviderReward.provider, ts.specs[1].Index) require.NoError(t, err) - require.True(t, res2.Rewards[0].Amount.IsEqual(expectedProviderReward.fund)) // taking 0 index because there are no delegators + require.True(t, res2.Rewards[0].Amount.IsEqual(expectedProviderReward.fund.MulInt(tax).QuoInt(sdk.NewInt(100)))) // taking 0 index because there are no delegators } } @@ -434,6 +436,10 @@ func TestIprpcRewardObjectsUpdate(t *testing.T) { func TestFundIprpcTwice(t *testing.T) { ts := newTester(t, true) ts.setupForIprpcTests(false) + ts.Keepers.Distribution.SetParams(ts.Ctx, distributiontypes.Params{CommunityTax: sdk.OneDec().QuoInt64(2)}) + validatorTax := sdk.NewInt(10) + tax := sdk.NewInt(100).Sub(validatorTax).SubRaw(45) // tax is 10% validators and 45% community + consumerAcc, consumer := ts.GetAccount(common.CONSUMER, 0) p1Acc, p1 := ts.GetAccount(common.PROVIDER, 0) @@ -460,7 +466,11 @@ func TestFundIprpcTwice(t *testing.T) { // check rewards - should be only from first funding (=iprpcFunds) res, err := ts.QueryDualstakingDelegatorRewards(p1Acc.GetVaultAddr(), p1, mockSpec2) require.NoError(t, err) - require.True(t, iprpcFunds.Sub(minIprpcCost).IsEqual(res.Rewards[0].Amount)) + require.True(t, iprpcFunds.Sub(minIprpcCost).MulInt(tax).QuoInt(sdk.NewInt(100)).IsEqual(res.Rewards[0].Amount)) + + taxed := iprpcFunds.Sub(minIprpcCost).MulInt(validatorTax).QuoInt(sdk.NewInt(100)) + validatorDistributionPoolTokens := ts.Keepers.Rewards.TotalPoolTokens(ts.Ctx, rewardstypes.ValidatorsRewardsDistributionPoolName) + require.Equal(t, validatorDistributionPoolTokens.AmountOf(ibcDenom), taxed.AmountOf(ibcDenom)) // make a provider service an IPRPC eligible consumer and advance month again relay = ts.SendRelay(p1, consumerAcc, []string{ts.specs[1].Index}, 100) @@ -472,7 +482,7 @@ func TestFundIprpcTwice(t *testing.T) { // check rewards - should be only from first + second funding (=iprpcFunds*3) res, err = ts.QueryDualstakingDelegatorRewards(p1Acc.GetVaultAddr(), p1, mockSpec2) require.NoError(t, err) - require.True(t, iprpcFunds.Sub(minIprpcCost).MulInt(math.NewInt(3)).IsEqual(res.Rewards[0].Amount)) + require.True(t, iprpcFunds.Sub(minIprpcCost).MulInt(math.NewInt(3)).MulInt(tax).QuoInt(sdk.NewInt(100)).IsEqual(res.Rewards[0].Amount)) } // TestIprpcMinCost tests that a fund TX fails if it doesn't have enough tokens to cover for the minimum IPRPC costs @@ -696,10 +706,10 @@ func TestMultipleIprpcSpec(t *testing.T) { } // TestIprpcRewardWithZeroSubRewards checks that even if a subscription is free (providers won't get paid for their service) -// if the providers service an IPRPC eligible subscription, they get IPRPC rewards +// if the providers service an IPRPC eligible subscription, they get IPRPC rewards (which are taxed) // Scenarios: -// 0. consumer is IPRPC eligible and community tax = 100% -> provider won't get paid for its service -// 1. two providers provide service -> they get IPRPC reward relative to their serviced CU +// consumer is IPRPC eligible and community tax = 100% -> provider won't get paid for its service and IPRPC +// rewards will be transffered to the community pool func TestIprpcRewardWithZeroSubRewards(t *testing.T) { ts := newTester(t, true) ts.setupForIprpcTests(true) // create a consumer and buys subscription + funds iprpc @@ -728,16 +738,13 @@ func TestIprpcRewardWithZeroSubRewards(t *testing.T) { ts.AdvanceEpoch() ts.AdvanceBlocks(ts.BlocksToSave() + 1) - // check provider rewards (should be only expected IPRPC rewards) - p1ExpectedReward := iprpcFunds.Sub(minIprpcCost).QuoInt(sdk.NewInt(5)) + // check there are no provider rewards res1, err := ts.QueryDualstakingDelegatorRewards(p1Acc.GetVaultAddr(), p1, mockSpec2) require.NoError(t, err) - require.True(t, p1ExpectedReward.IsEqual(res1.Rewards[0].Amount)) - - p2ExpectedReward := p1ExpectedReward.MulInt(sdk.NewInt(4)) + require.Len(t, res1.Rewards, 0) res2, err := ts.QueryDualstakingDelegatorRewards(p2Acc.GetVaultAddr(), p2, mockSpec2) require.NoError(t, err) - require.True(t, p2ExpectedReward.IsEqual(res2.Rewards[0].Amount)) + require.Len(t, res2.Rewards, 0) } // TestMinIprpcCostForSeveralMonths checks that if a user sends fund=1.1*minIprpcCost with duration=2 diff --git a/x/rewards/keeper/pool_test.go b/x/rewards/keeper/pool_test.go index a688744725..1a0398d9f1 100644 --- a/x/rewards/keeper/pool_test.go +++ b/x/rewards/keeper/pool_test.go @@ -4,7 +4,9 @@ import ( "testing" "time" + abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" + distribution "github.com/cosmos/cosmos-sdk/x/distribution" "github.com/lavanet/lava/v2/testutil/common" testkeeper "github.com/lavanet/lava/v2/testutil/keeper" "github.com/lavanet/lava/v2/utils" @@ -382,3 +384,20 @@ func TestRefillPoolsTimerStore(t *testing.T) { month = ts.GetNextMonth(ts.BlockTime()) - ts.BlockTime().UTC().Unix() } } + +// TestBlockRewardsWith2Tokens tests that block rewatds from the distribution pool works with more than 1 kind of token +func TestBlockRewardsWith2Tokens(t *testing.T) { + ts := newTester(t, true) + startTokens := ts.Keepers.Rewards.TotalPoolTokens(ts.Ctx, types.ValidatorsRewardsDistributionPoolName) + err := ts.Keepers.BankKeeper.AddToBalance(testkeeper.GetModuleAddress(string(types.ValidatorsRewardsDistributionPoolName)), + sdk.NewCoins(sdk.NewCoin(ibcDenom, startTokens[0].Amount))) + require.NoError(t, err) + startTokens = ts.Keepers.Rewards.TotalPoolTokens(ts.Ctx, types.ValidatorsRewardsDistributionPoolName) + + ts.AdvanceBlock() + distribution.BeginBlocker(ts.Ctx, abci.RequestBeginBlock{}, ts.Keepers.Distribution) + + currentTokens := ts.Keepers.Rewards.TotalPoolTokens(ts.Ctx, types.ValidatorsRewardsDistributionPoolName) + require.Equal(t, currentTokens.AmountOf(ibcDenom), currentTokens.AmountOf(ts.BondDenom())) + require.True(t, currentTokens.IsAllLT(startTokens)) +} diff --git a/x/rewards/keeper/providers.go b/x/rewards/keeper/providers.go index 514a88baf8..d9dcacae07 100644 --- a/x/rewards/keeper/providers.go +++ b/x/rewards/keeper/providers.go @@ -10,6 +10,7 @@ import ( "github.com/lavanet/lava/v2/utils" "github.com/lavanet/lava/v2/x/rewards/types" + timerstoretypes "github.com/lavanet/lava/v2/x/timerstore/types" ) const DAY_SECONDS = 60 * 60 * 24 @@ -194,12 +195,12 @@ func (k Keeper) ContributeToValidatorsAndCommunityPool(ctx sdk.Context, reward s } // send validators participation + validatorPool := types.ValidatorsRewardsDistributionPoolName if !validatorsParticipationReward.AmountOf(reward.Denom).IsZero() { - pool := types.ValidatorsRewardsDistributionPoolName if k.isEndOfMonth(ctx) { - pool = types.ValidatorsRewardsAllocationPoolName + validatorPool = types.ValidatorsRewardsLeftOverPoolName } - err = k.bankKeeper.SendCoinsFromModuleToModule(ctx, senderModule, string(pool), validatorsParticipationReward) + err = k.bankKeeper.SendCoinsFromModuleToModule(ctx, senderModule, string(validatorPool), validatorsParticipationReward) if err != nil { return reward, utils.LavaFormatError("sending validators participation failed", err, utils.Attribute{Key: "validators_participation_reward", Value: validatorsParticipationReward.String()}, @@ -219,6 +220,10 @@ func (k Keeper) ContributeToValidatorsAndCommunityPool(ctx sdk.Context, reward s } } + utils.LogLavaEvent(ctx, ctx.Logger(), types.ValidatorsAndCommunityFund, + map[string]string{"community": communityParticipationReward.String(), "validators": validatorsParticipationReward.String(), "validator_pool": string(validatorPool)}, + "contribution to validators pool and community pool") + // update reward amount reward = reward.SubAmount(communityParticipationReward.AmountOf(reward.Denom)).SubAmount(validatorsParticipationReward.AmountOf(reward.Denom)) @@ -255,7 +260,7 @@ func (k Keeper) CalculateValidatorsAndCommunityParticipationRewards(ctx sdk.Cont // CalculateContributionPercentages calculates the providers' rewards participation to the validators and community pool func (k Keeper) CalculateContributionPercentages(ctx sdk.Context, reward math.Int) (validatorsParticipation math.LegacyDec, communityParticipation math.LegacyDec, err error) { - communityTax := k.distributionKeeper.GetParams(ctx).CommunityTax + communityTax := k.GetCommunityTax(ctx) if communityTax.Equal(sdk.OneDec()) { return sdk.ZeroDec(), sdk.OneDec(), nil } @@ -307,5 +312,16 @@ func (k Keeper) FundCommunityPoolFromModule(ctx sdk.Context, amount sdk.Coins, s // isEndOfMonth checks that we're close to next timer expiry by at least 24 hours func (k Keeper) isEndOfMonth(ctx sdk.Context) bool { - return ctx.BlockTime().UTC().Unix()+DAY_SECONDS > k.TimeToNextTimerExpiry(ctx) + _, expiries, _ := k.refillRewardsPoolTS.GetFrontTimers(ctx, timerstoretypes.BlockTime) + if len(expiries) == 0 { + // there is no next timer, this is called in between the end and start of the new timer this is the end of the month + return true + } + + NextExpiery := int64(expiries[0]) - ctx.BlockTime().UTC().Unix() + return ctx.BlockTime().UTC().Unix()+DAY_SECONDS > NextExpiery +} + +func (k Keeper) GetCommunityTax(ctx sdk.Context) math.LegacyDec { + return k.distributionKeeper.GetParams(ctx).CommunityTax } diff --git a/x/rewards/keeper/rewards.go b/x/rewards/keeper/rewards.go index c0ec6c591a..985e6d7fd9 100644 --- a/x/rewards/keeper/rewards.go +++ b/x/rewards/keeper/rewards.go @@ -20,8 +20,7 @@ func (k Keeper) DistributeBlockReward(ctx sdk.Context) { blocksToNextTimerExpiry := k.BlocksToNextTimerExpiry(ctx) // get validator distribution pool balance - coins := k.TotalPoolTokens(ctx, types.ValidatorsRewardsDistributionPoolName) - distributionPoolBalance := coins.AmountOf(k.stakingKeeper.BondDenom(ctx)) + distributionPoolBalance := k.TotalPoolTokens(ctx, types.ValidatorsRewardsDistributionPoolName) if blocksToNextTimerExpiry == 0 { utils.LavaFormatWarning("blocksToNextTimerExpiry is zero", fmt.Errorf("critical: Attempt to divide by zero"), utils.LogAttr("blocksToNextTimerExpiry", blocksToNextTimerExpiry), @@ -31,15 +30,13 @@ func (k Keeper) DistributeBlockReward(ctx sdk.Context) { } // validators bonus rewards = (distributionPoolBalance * bondedTargetFactor) / blocksToNextTimerExpiry - validatorsRewards := bondedTargetFactor.MulInt(distributionPoolBalance).QuoInt64(blocksToNextTimerExpiry).TruncateInt() + validatorsRewards, _ := sdk.NewDecCoinsFromCoins(distributionPoolBalance...).MulDec(bondedTargetFactor).QuoDecTruncate(sdk.NewDec(blocksToNextTimerExpiry)).TruncateDecimal() if !validatorsRewards.IsZero() { - coins := sdk.NewCoins(sdk.NewCoin(k.stakingKeeper.BondDenom(ctx), validatorsRewards)) - // distribute rewards to validators (same as Cosmos mint module) - err := k.addCollectedFees(ctx, coins) + err := k.addCollectedFees(ctx, validatorsRewards) if err != nil { utils.LavaFormatWarning("could not send validators rewards to fee collector", err, - utils.Attribute{Key: "rewards", Value: coins.String()}, + utils.Attribute{Key: "rewards", Value: validatorsRewards.String()}, ) } } @@ -71,6 +68,7 @@ func (k Keeper) RefillRewardsPools(ctx sdk.Context, _ []byte, data []byte) { burnRate := k.GetParams(ctx).LeftoverBurnRate k.refillDistributionPool(ctx, monthsLeft, types.ValidatorsRewardsAllocationPoolName, types.ValidatorsRewardsDistributionPoolName, burnRate) k.refillDistributionPool(ctx, monthsLeft, types.ProvidersRewardsAllocationPool, types.ProviderRewardsDistributionPool, sdk.OneDec()) + k.MovePoolToPool(ctx, types.ValidatorsRewardsLeftOverPoolName, types.ValidatorsRewardsDistributionPoolName) if monthsLeft > 1 { monthsLeft -= 1 @@ -101,6 +99,22 @@ func (k Keeper) RefillRewardsPools(ctx sdk.Context, _ []byte, data []byte) { utils.LogLavaEvent(ctx, k.Logger(ctx), types.DistributionPoolRefillEventName, details, "distribution rewards pools refilled successfully") } +func (k Keeper) MovePoolToPool(ctx sdk.Context, from types.Pool, to types.Pool) { + coins := k.TotalPoolTokens(ctx, from) + if coins.IsZero() { + return + } + err := k.bankKeeper.SendCoinsFromModuleToModule( + ctx, + string(from), + string(to), + coins, + ) + if err != nil { + panic(err) + } +} + func (k Keeper) refillDistributionPool(ctx sdk.Context, monthsLeft uint64, allocationPool types.Pool, distributionPool types.Pool, burnRate sdkmath.LegacyDec) { // burn remaining tokens in the distribution pool coins := k.TotalPoolTokens(ctx, distributionPool) diff --git a/x/rewards/types/types.go b/x/rewards/types/types.go index be518a4ae7..8485f37371 100644 --- a/x/rewards/types/types.go +++ b/x/rewards/types/types.go @@ -29,6 +29,11 @@ const ( ProvidersBonusRewardsEventName = "provider_bonus_rewards" ) +// Validators leftover pool for coins that were moved near the end of the month +const ( + ValidatorsRewardsLeftOverPoolName Pool = "validators_rewards_leftover_pool" +) + // BlocksToTimerExpirySlackFactor is used to calculate the number of blocks until the // next timer expiry which determine the validators block rewards. // since the time/blocks conversion can be errornous, we multiply our calculated number @@ -55,6 +60,11 @@ const ( TransferIprpcRewardToNextMonthEventName = "transfer_iprpc_reward_to_next_month" ) +// Events +const ( + ValidatorsAndCommunityFund = "validators_and_community_fund" +) + // helper struct to track the serviced IPRPC CU for each spec+provider type SpecCuType struct { ProvidersCu []ProviderCuType diff --git a/x/subscription/client/cli/query.go b/x/subscription/client/cli/query.go index a1594461c6..36d5f678bd 100644 --- a/x/subscription/client/cli/query.go +++ b/x/subscription/client/cli/query.go @@ -27,6 +27,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdQueryParams()) cmd.AddCommand(CmdCurrent()) cmd.AddCommand(CmdEstimatedRewards()) + cmd.AddCommand(CmdEstimatedValidatorsRewards()) cmd.AddCommand(CmdTrackedCuUsage()) cmd.AddCommand(CmdListProjects()) diff --git a/x/subscription/client/cli/query_estimated_validators_rewards.go b/x/subscription/client/cli/query_estimated_validators_rewards.go new file mode 100644 index 0000000000..da08bf7803 --- /dev/null +++ b/x/subscription/client/cli/query_estimated_validators_rewards.go @@ -0,0 +1,55 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/lavanet/lava/v2/utils" + "github.com/lavanet/lava/v2/x/subscription/types" + "github.com/spf13/cobra" +) + +func CmdEstimatedValidatorsRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "estimated--validator-rewards [validator] {optional: amount/delegator}", + Short: "calculates the rewards estimation for a validator delegation", + Long: `Query to estimate the rewards a delegator will get for 1 month from the validator, if used without optional args the calculations will be for the validator itself. + optional args can be amount for new delegation or address for an existing one. + The estimation takes into account subscription rewards, block rewards and iprpc rewards, as well as commisions. + args: + [validator] validator address. + [amount/delegator] optional: delegation amount for the estimation Or delegator address for existing delegation. if not used the rewards will be calculated for the validator. + `, + Args: cobra.RangeArgs(1, 2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + req := types.QueryEstimatedValidatorRewardsRequest{} + req.Validator = args[0] + + if len(args) == 2 { + address, err := utils.ParseCLIAddress(clientCtx, args[1]) + if err != nil { + req.AmountDelegator = args[1] + } else { + req.AmountDelegator = address + } + } + + res, err := queryClient.EstimatedValidatorRewards(cmd.Context(), &req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/subscription/keeper/grpc_query_estimated_validator_rewards.go b/x/subscription/keeper/grpc_query_estimated_validator_rewards.go new file mode 100644 index 0000000000..38cb5ae662 --- /dev/null +++ b/x/subscription/keeper/grpc_query_estimated_validator_rewards.go @@ -0,0 +1,117 @@ +package keeper + +import ( + "context" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + rewardstypes "github.com/lavanet/lava/v2/x/rewards/types" + "github.com/lavanet/lava/v2/x/subscription/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) EstimatedValidatorRewards(goCtx context.Context, req *types.QueryEstimatedValidatorRewardsRequest) (*types.QueryEstimatedValidatorRewardsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + res := types.QueryEstimatedValidatorRewardsResponse{} + + valAddress, err := sdk.ValAddressFromBech32(req.Validator) + if err != nil { + return nil, err + } + + val, found := k.stakingKeeper.GetValidator(ctx, valAddress) + if !found { + return nil, fmt.Errorf("validator not found") + } + + var delegatorPart sdk.Dec + delAddress := sdk.AccAddress(valAddress) + totalStakedTokens := sdk.ZeroInt() + // self delegation + if req.AmountDelegator == "" { + del, found := k.stakingKeeper.GetDelegation(ctx, delAddress, valAddress) + if !found { + return nil, fmt.Errorf("self delegation not found") + } + delegatorPart = del.Shares.Quo(val.DelegatorShares).Add(val.DelegatorShares.Sub(del.Shares).Quo(val.DelegatorShares).Mul(val.Commission.Rate)) + } else { + delAddress, err := sdk.AccAddressFromBech32(req.AmountDelegator) + // existing delegator + if err == nil { + del, found := k.stakingKeeper.GetDelegation(ctx, delAddress, valAddress) + if !found { + return nil, fmt.Errorf("delegation not found") + } + delegatorPart = del.Shares.Quo(val.DelegatorShares).Mul(sdk.OneDec().Sub(val.Commission.Rate)) + } else { // potential delegator + coins, err := sdk.ParseCoinsNormalized(req.AmountDelegator) + if err != nil { + return nil, fmt.Errorf("failed to parse input, input should be a valid lava delegator account or coins") + } + + totalStakedTokens = coins[0].Amount + var shares sdk.Dec + val, shares = val.AddTokensFromDel(coins[0].Amount) + delegatorPart = shares.Quo(val.DelegatorShares).Mul(sdk.OneDec().Sub(val.Commission.Rate)) + } + } + + validators := k.stakingKeeper.GetBondedValidatorsByPower(ctx) + + for _, v := range validators { + totalStakedTokens = totalStakedTokens.Add(v.Tokens) + } + delegatorPart = delegatorPart.MulInt(val.Tokens).QuoInt(totalStakedTokens) + + totalSubsRewards := sdk.Coins{} + subsIndices := k.GetAllSubscriptionsIndices(ctx) + for _, subIndex := range subsIndices { + sub, found := k.GetSubscription(ctx, subIndex) + if found { + sub.Credit.Amount = sub.Credit.Amount.Quo(sdk.NewIntFromUint64(sub.DurationLeft)) + totalSubsRewards = totalSubsRewards.Add(sub.Credit) + } + } + + valRewardsFromSubscriptions, _, err := k.rewardsKeeper.CalculateValidatorsAndCommunityParticipationRewards(ctx, totalSubsRewards[0]) + if err != nil { + return nil, fmt.Errorf("failed to calculate Validators And Community Participation Rewards") + } + + monthsLeft := k.rewardsKeeper.AllocationPoolMonthsLeft(ctx) + allocationPool := k.rewardsKeeper.TotalPoolTokens(ctx, rewardstypes.ValidatorsRewardsAllocationPoolName) + blockRewards := sdk.NewDecCoinsFromCoins(allocationPool...).QuoDec(sdk.NewDec(monthsLeft)) + communityTax := k.rewardsKeeper.GetCommunityTax(ctx) + blockRewards = blockRewards.MulDec(sdk.OneDec().Sub(communityTax)) + + iprpcReward, found := k.rewardsKeeper.GetIprpcReward(ctx, k.rewardsKeeper.GetIprpcRewardsCurrentId(ctx)) + if found { + for _, fund := range iprpcReward.SpecFunds { + coinsForSpec := sdk.NewCoins() + for _, coin := range fund.Fund { + validatorCoins, _, err := k.rewardsKeeper.CalculateValidatorsAndCommunityParticipationRewards(ctx, coin) + if err != nil { + return nil, fmt.Errorf("failed to calculate Validators And Community Participation Rewards for iprpc") + } + coinsForSpec = coinsForSpec.Add(validatorCoins...) + } + + res.Info = append(res.Info, &types.EstimatedRewardInfo{Source: "iprpc_" + fund.Spec, Amount: sdk.NewDecCoinsFromCoins(coinsForSpec...).MulDec(delegatorPart)}) + } + } + + res.Info = append(res.Info, &types.EstimatedRewardInfo{Source: "subscriptions", Amount: sdk.NewDecCoinsFromCoins(valRewardsFromSubscriptions...).MulDec(delegatorPart)}) + res.Info = append(res.Info, &types.EstimatedRewardInfo{Source: "blocks", Amount: blockRewards.MulDec(delegatorPart)}) + + res.Total = sdk.NewDecCoins() + for _, k := range res.Info { + res.Total = res.Total.Add(k.Amount...) + } + + return &res, nil +} diff --git a/x/subscription/types/expected_keepers.go b/x/subscription/types/expected_keepers.go index ed9c0ce8fb..ec6e3cb6d4 100644 --- a/x/subscription/types/expected_keepers.go +++ b/x/subscription/types/expected_keepers.go @@ -5,6 +5,7 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" dualstakingtypes "github.com/lavanet/lava/v2/x/dualstaking/types" epochstoragetypes "github.com/lavanet/lava/v2/x/epochstorage/types" fixationtypes "github.com/lavanet/lava/v2/x/fixationstore/types" @@ -84,10 +85,15 @@ type RewardsKeeper interface { SpecTotalPayout(ctx sdk.Context, totalMonthlyPayout math.Int, totalProvidersBaseRewards sdk.Dec, spec rewardstypes.SpecEmissionPart) math.LegacyDec GetIprpcRewardsCurrentId(ctx sdk.Context) uint64 GetIprpcReward(ctx sdk.Context, id uint64) (val rewardstypes.IprpcReward, found bool) + AllocationPoolMonthsLeft(ctx sdk.Context) int64 + GetCommunityTax(ctx sdk.Context) math.LegacyDec } type StakingKeeper interface { BondDenom(ctx sdk.Context) string + GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) + GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) + GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator } type SpecKeeper interface { diff --git a/x/subscription/types/query.pb.go b/x/subscription/types/query.pb.go index 546b53362c..2c09be133d 100644 --- a/x/subscription/types/query.pb.go +++ b/x/subscription/types/query.pb.go @@ -904,6 +904,112 @@ func (m *QueryEstimatedRewardsResponse) GetTotal() github_com_cosmos_cosmos_sdk_ return nil } +type QueryEstimatedValidatorRewardsRequest struct { + Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` + AmountDelegator string `protobuf:"bytes,2,opt,name=amount_delegator,json=amountDelegator,proto3" json:"amount_delegator,omitempty"` +} + +func (m *QueryEstimatedValidatorRewardsRequest) Reset() { *m = QueryEstimatedValidatorRewardsRequest{} } +func (m *QueryEstimatedValidatorRewardsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryEstimatedValidatorRewardsRequest) ProtoMessage() {} +func (*QueryEstimatedValidatorRewardsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e870698c9d8ccc09, []int{17} +} +func (m *QueryEstimatedValidatorRewardsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEstimatedValidatorRewardsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEstimatedValidatorRewardsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryEstimatedValidatorRewardsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEstimatedValidatorRewardsRequest.Merge(m, src) +} +func (m *QueryEstimatedValidatorRewardsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryEstimatedValidatorRewardsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEstimatedValidatorRewardsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEstimatedValidatorRewardsRequest proto.InternalMessageInfo + +func (m *QueryEstimatedValidatorRewardsRequest) GetValidator() string { + if m != nil { + return m.Validator + } + return "" +} + +func (m *QueryEstimatedValidatorRewardsRequest) GetAmountDelegator() string { + if m != nil { + return m.AmountDelegator + } + return "" +} + +type QueryEstimatedValidatorRewardsResponse struct { + Info []*EstimatedRewardInfo `protobuf:"bytes,1,rep,name=info,proto3" json:"info,omitempty"` + Total github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=total,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"total"` +} + +func (m *QueryEstimatedValidatorRewardsResponse) Reset() { + *m = QueryEstimatedValidatorRewardsResponse{} +} +func (m *QueryEstimatedValidatorRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryEstimatedValidatorRewardsResponse) ProtoMessage() {} +func (*QueryEstimatedValidatorRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e870698c9d8ccc09, []int{18} +} +func (m *QueryEstimatedValidatorRewardsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEstimatedValidatorRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEstimatedValidatorRewardsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryEstimatedValidatorRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEstimatedValidatorRewardsResponse.Merge(m, src) +} +func (m *QueryEstimatedValidatorRewardsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryEstimatedValidatorRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEstimatedValidatorRewardsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEstimatedValidatorRewardsResponse proto.InternalMessageInfo + +func (m *QueryEstimatedValidatorRewardsResponse) GetInfo() []*EstimatedRewardInfo { + if m != nil { + return m.Info + } + return nil +} + +func (m *QueryEstimatedValidatorRewardsResponse) GetTotal() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.Total + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "lavanet.lava.subscription.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "lavanet.lava.subscription.QueryParamsResponse") @@ -922,6 +1028,8 @@ func init() { proto.RegisterType((*QueryEstimatedRewardsRequest)(nil), "lavanet.lava.subscription.QueryEstimatedRewardsRequest") proto.RegisterType((*EstimatedRewardInfo)(nil), "lavanet.lava.subscription.EstimatedRewardInfo") proto.RegisterType((*QueryEstimatedRewardsResponse)(nil), "lavanet.lava.subscription.QueryEstimatedRewardsResponse") + proto.RegisterType((*QueryEstimatedValidatorRewardsRequest)(nil), "lavanet.lava.subscription.QueryEstimatedValidatorRewardsRequest") + proto.RegisterType((*QueryEstimatedValidatorRewardsResponse)(nil), "lavanet.lava.subscription.QueryEstimatedValidatorRewardsResponse") } func init() { @@ -929,87 +1037,91 @@ func init() { } var fileDescriptor_e870698c9d8ccc09 = []byte{ - // 1269 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcd, 0x4f, 0x1b, 0x47, - 0x14, 0x67, 0x89, 0x31, 0xe6, 0xd9, 0x24, 0x64, 0x88, 0xa2, 0xc5, 0x4a, 0x4d, 0xd8, 0x84, 0xf2, - 0x91, 0xb0, 0x23, 0xa0, 0x15, 0xe4, 0x12, 0x2a, 0x48, 0xaa, 0x12, 0xd1, 0x8a, 0x6c, 0x48, 0x22, - 0x55, 0x6a, 0x57, 0xeb, 0xf5, 0xd8, 0x6c, 0x63, 0xef, 0x38, 0xbb, 0xb3, 0x04, 0x84, 0x90, 0xaa, - 0x1e, 0x39, 0x55, 0xed, 0xb9, 0x87, 0xde, 0xaa, 0x9e, 0x7a, 0xee, 0xad, 0xb7, 0x1c, 0xa3, 0xf6, - 0xd0, 0x4a, 0x95, 0xda, 0x0a, 0x22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6, 0xe0, 0x52, 0x25, 0x0a, 0x44, 0x51, 0xdb, 0x65, 0x1a, 0xd5, 0xb6, 0x99, 0x7e, 0xe1, 0xba, - 0x36, 0x9d, 0xb1, 0x2e, 0xc6, 0xe2, 0x55, 0x21, 0x45, 0x37, 0x60, 0xb8, 0xa5, 0x58, 0x27, 0x55, - 0xa6, 0x67, 0x84, 0x5a, 0x21, 0x16, 0x6e, 0x90, 0x2a, 0x43, 0x13, 0x50, 0x68, 0x50, 0x9f, 0x6d, - 0xdb, 0x64, 0xb7, 0xe9, 0x05, 0x7b, 0xfa, 0x80, 0xd0, 0xc9, 0x0b, 0xd9, 0x7d, 0x21, 0x42, 0x37, - 0xe1, 0xa2, 0x54, 0xe1, 0x07, 0x84, 0x32, 0xa7, 0xae, 0x67, 0x25, 0x90, 0x90, 0xae, 0x45, 0x5b, - 0x5c, 0x86, 0x0c, 0x18, 0x6e, 0x69, 0x09, 0x6f, 0x83, 0x09, 0xa4, 0xb5, 0x48, 0x38, 0xd3, 0x61, - 0xd0, 0xad, 0x47, 0x21, 0x23, 0x81, 0x9e, 0x13, 0x11, 0xc5, 0x4b, 0x34, 0x09, 0x2d, 0xf6, 0xca, - 0xc7, 0x90, 0x30, 0x6f, 0x45, 0x20, 0x9d, 0x2c, 0xc2, 0x55, 0x27, 0x62, 0xd4, 0x0e, 0x88, 0x4f, - 0x5e, 0x38, 0x75, 0xdb, 0x27, 0xbb, 0xcc, 0x16, 0x19, 0xca, 0x0b, 0xbc, 0x51, 0xfe, 0xd5, 0x92, - 0x1f, 0x3f, 0x21, 0xbb, 0x6c, 0x93, 0x27, 0xec, 0x73, 0x18, 0xad, 0x46, 0x2c, 0x0a, 0x88, 0xdd, - 0x56, 0x4e, 0x05, 0x51, 0xb4, 0x73, 0x29, 0x7b, 0xf9, 0xa1, 0xb0, 0x4a, 0x96, 0xae, 0x85, 0xaa, - 0x27, 0x64, 0x68, 0x1e, 0xb2, 0x6e, 0x40, 0x2a, 0x1e, 0xd3, 0x87, 0x05, 0xe4, 0x98, 0x29, 0xfb, - 0x96, 0xc9, 0xfb, 0x96, 0xa9, 0xfa, 0x96, 0xb9, 0x46, 0x3d, 0xdf, 0x52, 0x8a, 0x0f, 0x32, 0x39, - 0x18, 0xc9, 0x1b, 0xe3, 0xf0, 0x8e, 0xa8, 0x37, 0xce, 0x74, 0x8b, 0x7e, 0xfc, 0x26, 0xe5, 0x71, - 0x41, 0x6e, 0xc2, 0xa5, 0x2d, 0xaf, 0x41, 0x02, 0x29, 0xe5, 0x35, 0x93, 0x5a, 0x2d, 0x9d, 0x7b, - 0xd9, 0x7f, 0x62, 0x2f, 0x8d, 0x5d, 0x28, 0x75, 0x73, 0xa9, 0xea, 0xfd, 0x09, 0x0c, 0x27, 0x93, - 0x10, 0xaa, 0x9a, 0x9f, 0x4d, 0xc9, 0x53, 0x07, 0x47, 0x55, 0xf4, 0xed, 0x30, 0xc6, 0x03, 0xb8, - 0x29, 0x3c, 0x27, 0x53, 0xb7, 0x25, 0xda, 0x6d, 0xe5, 0x71, 0xe8, 0xd4, 0xc8, 0x79, 0x4e, 0xfd, - 0x9f, 0x1a, 0x4c, 0xf6, 0x00, 0x53, 0xd1, 0x3c, 0x3c, 0x05, 0xed, 0xdc, 0x9d, 0xaa, 0x0d, 0x02, - 0xdd, 0x85, 0x81, 0x88, 0xfb, 0xd0, 0xfb, 0x45, 0x62, 0xa6, 0xd3, 0x12, 0x23, 0x29, 0xad, 0x45, - 0x3c, 0x2d, 0x96, 0x34, 0x43, 0xe3, 0x90, 0x17, 0x15, 0x6e, 0x4b, 0x14, 0x79, 0x76, 0x41, 0x88, - 0x04, 0x77, 0xe3, 0x4b, 0x0d, 0xae, 0x89, 0xe8, 0xee, 0x87, 0xcc, 0x6b, 0x38, 0x8c, 0x54, 0x2c, - 0xf2, 0xc2, 0x09, 0x2a, 0x61, 0xa2, 0x53, 0x37, 0x03, 0xba, 0xe3, 0x55, 0xde, 0xd4, 0x40, 0xbc, - 0x46, 0x63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 0x26, 0x02, 0x79, - 0x8a, 0x1e, 0xa7, 0x04, 0x42, 0x62, 0x63, 0x3b, 0x90, 0xd6, 0x78, 0x3f, 0x9e, 0x56, 0x07, 0x78, - 0x3f, 0x1e, 0x56, 0x07, 0x78, 0xbf, 0x73, 0x38, 0x1d, 0xac, 0xae, 0xbf, 0x3c, 0x2a, 0x69, 0xaf, - 0x8e, 0x4a, 0xda, 0x3f, 0x47, 0x25, 0xed, 0xeb, 0xe3, 0x52, 0xdf, 0xab, 0xe3, 0x52, 0xdf, 0x1f, - 0xc7, 0xa5, 0xbe, 0x4f, 0x71, 0xa2, 0xbf, 0xb6, 0xb9, 0xde, 0x59, 0xc0, 0xbb, 0x1d, 0x89, 0xe4, - 0xcd, 0xb6, 0x9c, 0x15, 0xff, 0xb4, 0x16, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x7a, 0x1d, 0xcc, - 0xe0, 0xc2, 0x0e, 0x00, 0x00, + // 1343 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x57, 0xcd, 0x6f, 0x13, 0x47, + 0x14, 0xcf, 0x06, 0xc7, 0x49, 0x5e, 0x1c, 0x08, 0x13, 0x84, 0x1c, 0x2b, 0x75, 0xc8, 0xf2, 0x1d, + 0x60, 0x47, 0x09, 0xad, 0x02, 0x17, 0xa0, 0x09, 0x54, 0x05, 0xd1, 0x2a, 0x2c, 0x01, 0xa4, 0x4a, + 0xed, 0x6a, 0xbc, 0x3b, 0x71, 0xb6, 0xd8, 0x3b, 0xcb, 0xee, 0x6c, 0x08, 0x8a, 0x22, 0x55, 0x3d, + 0xa2, 0x1e, 0xaa, 0xf6, 0xdc, 0x43, 0x6f, 0x55, 0x4f, 0x3d, 0xf7, 0xd6, 0x1b, 0x47, 0xd4, 0x1e, + 0x5a, 0xa9, 0x52, 0x8b, 0x00, 0xa9, 0x7f, 0x46, 0xab, 0xf9, 0x58, 0x67, 0xed, 0xd8, 0xeb, 0x84, + 0xaa, 0x87, 0x5e, 0xe2, 0x9d, 0x37, 0xef, 0xfd, 0xde, 0xef, 0xbd, 0x79, 0x33, 0xef, 0x05, 0x4e, + 0x36, 0xc8, 0x06, 0x09, 0x28, 0xc7, 0xe2, 0x17, 0xc7, 0x49, 0x2d, 0x76, 0x23, 0x3f, 0xe4, 0x3e, + 0x0b, 0xf0, 0xa3, 0x84, 0x46, 0x4f, 0xac, 0x30, 0x62, 0x9c, 0xa1, 0x29, 0xad, 0x66, 0x89, 0x5f, + 0x2b, 0xab, 0x56, 0x99, 0x73, 0x59, 0xdc, 0x64, 0x31, 0xae, 0x91, 0x98, 0x2a, 0x1b, 0xbc, 0x31, + 0x5f, 0xa3, 0x9c, 0xcc, 0xe3, 0x90, 0xd4, 0xfd, 0x80, 0x08, 0x2d, 0x05, 0x53, 0xa9, 0x66, 0x75, + 0x53, 0x2d, 0x97, 0xf9, 0xe9, 0xfe, 0x91, 0x3a, 0xab, 0x33, 0xf9, 0x89, 0xc5, 0x97, 0x96, 0x4e, + 0xd7, 0x19, 0xab, 0x37, 0x28, 0x26, 0xa1, 0x8f, 0x49, 0x10, 0x30, 0x2e, 0x21, 0x63, 0xbd, 0x3b, + 0xd7, 0x3b, 0x02, 0x37, 0x71, 0x78, 0x44, 0xdc, 0x87, 0x34, 0xd2, 0xba, 0xa7, 0x7a, 0xeb, 0x86, + 0x24, 0x22, 0xcd, 0x14, 0xf3, 0x7c, 0x6f, 0xbd, 0xec, 0x42, 0x6b, 0x1f, 0x26, 0x4d, 0x3f, 0x60, + 0x58, 0xfe, 0x55, 0x22, 0xf3, 0x08, 0xa0, 0x3b, 0x22, 0x15, 0x2b, 0x12, 0xd5, 0xa6, 0x8f, 0x12, + 0x1a, 0x73, 0xf3, 0x3e, 0x4c, 0xb6, 0x49, 0xe3, 0x90, 0x05, 0x31, 0x45, 0x57, 0xa1, 0xa8, 0xbc, + 0x97, 0x8d, 0x63, 0x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0xbf, 0x72, 0xed, 0xcd, 0x01, 0xf6, 0x51, 0x25, 0xea, 0xff, 0x3b, 0x4f, 0xb5, + 0xde, 0xce, 0x2a, 0x79, 0x6d, 0xc0, 0x44, 0x67, 0x3f, 0x41, 0x8b, 0xfd, 0x78, 0xf5, 0x68, 0xd2, + 0x95, 0x4b, 0xfb, 0x37, 0xd4, 0x81, 0x7c, 0x2c, 0x03, 0x79, 0x80, 0xee, 0xe5, 0x04, 0x42, 0x53, + 0x63, 0x27, 0x52, 0xd6, 0x78, 0x2b, 0x1d, 0x01, 0xb6, 0xf1, 0x56, 0x3a, 0x01, 0x6c, 0xe3, 0xad, + 0xce, 0x2e, 0xb0, 0x8d, 0xfe, 0x36, 0x60, 0xaa, 0xe7, 0x53, 0x8f, 0xae, 0xed, 0x99, 0x76, 0x8f, + 0xc6, 0x54, 0x79, 0xf7, 0x5f, 0x20, 0xbc, 0x51, 0x06, 0x5a, 0x5d, 0x6f, 0x27, 0x17, 0x2d, 0x51, + 0xb7, 0x0c, 0x2c, 0xdd, 0x7c, 0xf6, 0xb2, 0x6a, 0x3c, 0x7f, 0x59, 0x35, 0x5e, 0xbc, 0xac, 0x1a, + 0x5f, 0xbe, 0xaa, 0x0e, 0x3c, 0x7f, 0x55, 0x1d, 0xf8, 0xed, 0x55, 0x75, 0xe0, 0x23, 0x9c, 0xe9, + 0x30, 0x6d, 0xae, 0x37, 0x16, 0xf0, 0x66, 0x47, 0x29, 0x89, 0x76, 0x53, 0x2b, 0xca, 0x7f, 0xe0, + 0x2f, 0xfe, 0x13, 0x00, 0x00, 0xff, 0xff, 0x5a, 0x8e, 0xd1, 0x11, 0x19, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1038,6 +1150,7 @@ type QueryClient interface { TrackedUsage(ctx context.Context, in *QuerySubscriptionTrackedUsageRequest, opts ...grpc.CallOption) (*QuerySubscriptionTrackedUsageResponse, error) // Queries a rewards estimation. EstimatedRewards(ctx context.Context, in *QueryEstimatedRewardsRequest, opts ...grpc.CallOption) (*QueryEstimatedRewardsResponse, error) + EstimatedValidatorRewards(ctx context.Context, in *QueryEstimatedValidatorRewardsRequest, opts ...grpc.CallOption) (*QueryEstimatedValidatorRewardsResponse, error) } type queryClient struct { @@ -1111,6 +1224,15 @@ func (c *queryClient) EstimatedRewards(ctx context.Context, in *QueryEstimatedRe return out, nil } +func (c *queryClient) EstimatedValidatorRewards(ctx context.Context, in *QueryEstimatedValidatorRewardsRequest, opts ...grpc.CallOption) (*QueryEstimatedValidatorRewardsResponse, error) { + out := new(QueryEstimatedValidatorRewardsResponse) + err := c.cc.Invoke(ctx, "/lavanet.lava.subscription.Query/EstimatedValidatorRewards", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -1127,6 +1249,7 @@ type QueryServer interface { TrackedUsage(context.Context, *QuerySubscriptionTrackedUsageRequest) (*QuerySubscriptionTrackedUsageResponse, error) // Queries a rewards estimation. EstimatedRewards(context.Context, *QueryEstimatedRewardsRequest) (*QueryEstimatedRewardsResponse, error) + EstimatedValidatorRewards(context.Context, *QueryEstimatedValidatorRewardsRequest) (*QueryEstimatedValidatorRewardsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1154,6 +1277,9 @@ func (*UnimplementedQueryServer) TrackedUsage(ctx context.Context, req *QuerySub func (*UnimplementedQueryServer) EstimatedRewards(ctx context.Context, req *QueryEstimatedRewardsRequest) (*QueryEstimatedRewardsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method EstimatedRewards not implemented") } +func (*UnimplementedQueryServer) EstimatedValidatorRewards(ctx context.Context, req *QueryEstimatedValidatorRewardsRequest) (*QueryEstimatedValidatorRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EstimatedValidatorRewards not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1285,6 +1411,24 @@ func _Query_EstimatedRewards_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Query_EstimatedValidatorRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryEstimatedValidatorRewardsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).EstimatedValidatorRewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lavanet.lava.subscription.Query/EstimatedValidatorRewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).EstimatedValidatorRewards(ctx, req.(*QueryEstimatedValidatorRewardsRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "lavanet.lava.subscription.Query", HandlerType: (*QueryServer)(nil), @@ -1317,6 +1461,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "EstimatedRewards", Handler: _Query_EstimatedRewards_Handler, }, + { + MethodName: "EstimatedValidatorRewards", + Handler: _Query_EstimatedValidatorRewards_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "lavanet/lava/subscription/query.proto", @@ -1988,6 +2136,94 @@ func (m *QueryEstimatedRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *QueryEstimatedValidatorRewardsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryEstimatedValidatorRewardsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEstimatedValidatorRewardsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AmountDelegator) > 0 { + i -= len(m.AmountDelegator) + copy(dAtA[i:], m.AmountDelegator) + i = encodeVarintQuery(dAtA, i, uint64(len(m.AmountDelegator))) + i-- + dAtA[i] = 0x12 + } + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryEstimatedValidatorRewardsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryEstimatedValidatorRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEstimatedValidatorRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Total) > 0 { + for iNdEx := len(m.Total) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Total[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Info) > 0 { + for iNdEx := len(m.Info) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Info[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -2284,6 +2520,44 @@ func (m *QueryEstimatedRewardsResponse) Size() (n int) { return n } +func (m *QueryEstimatedValidatorRewardsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.AmountDelegator) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryEstimatedValidatorRewardsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Info) > 0 { + for _, e := range m.Info { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.Total) > 0 { + for _, e := range m.Total { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -4089,6 +4363,238 @@ func (m *QueryEstimatedRewardsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryEstimatedValidatorRewardsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryEstimatedValidatorRewardsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEstimatedValidatorRewardsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountDelegator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AmountDelegator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryEstimatedValidatorRewardsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryEstimatedValidatorRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEstimatedValidatorRewardsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Info = append(m.Info, &EstimatedRewardInfo{}) + if err := m.Info[len(m.Info)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Total", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Total = append(m.Total, types.DecCoin{}) + if err := m.Total[len(m.Total)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/subscription/types/query.pb.gw.go b/x/subscription/types/query.pb.gw.go index 76186add11..51e6e69a42 100644 --- a/x/subscription/types/query.pb.gw.go +++ b/x/subscription/types/query.pb.gw.go @@ -347,6 +347,82 @@ func local_request_Query_EstimatedRewards_0(ctx context.Context, marshaler runti } +func request_Query_EstimatedValidatorRewards_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEstimatedValidatorRewardsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["validator"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator") + } + + protoReq.Validator, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator", err) + } + + val, ok = pathParams["amount_delegator"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "amount_delegator") + } + + protoReq.AmountDelegator, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "amount_delegator", err) + } + + msg, err := client.EstimatedValidatorRewards(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_EstimatedValidatorRewards_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEstimatedValidatorRewardsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["validator"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator") + } + + protoReq.Validator, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator", err) + } + + val, ok = pathParams["amount_delegator"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "amount_delegator") + } + + protoReq.AmountDelegator, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "amount_delegator", err) + } + + msg, err := server.EstimatedValidatorRewards(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -514,6 +590,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_EstimatedValidatorRewards_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_EstimatedValidatorRewards_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_EstimatedValidatorRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -695,6 +794,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_EstimatedValidatorRewards_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_EstimatedValidatorRewards_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_EstimatedValidatorRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -712,6 +831,8 @@ var ( pattern_Query_TrackedUsage_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 2}, []string{"lavanet", "lava", "subscription", "tracked_usage"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_EstimatedRewards_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5, 1, 0, 4, 1, 5, 6}, []string{"lavanet", "lava", "subscription", "estimated_rewards", "provider", "chain_id", "amount_delegator"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_EstimatedValidatorRewards_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"lavanet", "lava", "subscription", "estimated_validator_rewards", "validator", "amount_delegator"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -728,4 +849,6 @@ var ( forward_Query_TrackedUsage_0 = runtime.ForwardResponseMessage forward_Query_EstimatedRewards_0 = runtime.ForwardResponseMessage + + forward_Query_EstimatedValidatorRewards_0 = runtime.ForwardResponseMessage )