diff --git a/proto/lavanet/lava/rewards/query.proto b/proto/lavanet/lava/rewards/query.proto index fe81f3a9a0..d8ba5a3c33 100644 --- a/proto/lavanet/lava/rewards/query.proto +++ b/proto/lavanet/lava/rewards/query.proto @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "lavanet/lava/rewards/params.proto"; +import "lavanet/lava/rewards/iprpc.proto"; import "cosmos/base/v1beta1/coin.proto"; // this line is used by starport scaffolding # 1 @@ -31,11 +32,21 @@ service Query { rpc ShowIprpcData(QueryShowIprpcDataRequest) returns (QueryShowIprpcDataResponse) { option (google.api.http).get = "/lavanet/lava/rewards/show_iprpc_data"; } + // ProviderReward queries for the providers reward for their services rpc ProviderReward(QueryProviderRewardRequest) returns (QueryProviderRewardResponse) { option (google.api.http).get = "/lavanet/lava/rewards/provider_reward"; } + // IprpcProviderRewardEstimation queries for a provider's current IPRPC reward (relative to its serviced CU) + rpc IprpcProviderRewardEstimation(QueryIprpcProviderRewardEstimationRequest) returns (QueryIprpcProviderRewardEstimationResponse) { + option (google.api.http).get = "/lavanet/lava/rewards/iprpc_provider_reward/{provider}"; + } + + // IprpcSpecReward queries for a spec's IPRPC reward + rpc IprpcSpecReward(QueryIprpcSpecRewardRequest) returns (QueryIprpcSpecRewardResponse) { + option (google.api.http).get = "/lavanet/lava/rewards/iprpc_spec_reward/{spec}"; + } // this line is used by starport scaffolding # 2 } @@ -102,4 +113,25 @@ message QueryProviderRewardResponse { repeated RewardInfo rewards = 1 [(gogoproto.nullable) = false]; } +// QueryIprpcProviderRewardEstimationRequest is request type for the Query/IprpcProviderRewardEstimation RPC method. +message QueryIprpcProviderRewardEstimationRequest { + string provider = 1; +} + +// QueryIprpcProviderRewardEstimationResponse is response type for the Query/IprpcProviderRewardEstimation RPC method. +message QueryIprpcProviderRewardEstimationResponse { + repeated Specfund spec_funds = 1 [(gogoproto.nullable) = false]; +} + +// QueryIprpcSpecRewardRequest is request type for the Query/IprpcSpecReward RPC method. +message QueryIprpcSpecRewardRequest { + string spec = 1; +} + +// QueryIprpcSpecRewardResponse is response type for the Query/IprpcSpecReward RPC method. +message QueryIprpcSpecRewardResponse { + repeated IprpcReward iprpc_rewards = 1 [(gogoproto.nullable) = false]; + uint64 current_month_id = 2; +} + // this line is used by starport scaffolding # 3 \ No newline at end of file diff --git a/scripts/cli_test.sh b/scripts/cli_test.sh index 581eace97b..8ae9117c3d 100755 --- a/scripts/cli_test.sh +++ b/scripts/cli_test.sh @@ -183,6 +183,8 @@ echo "Testing rewards q commands" trace lavad q rewards pools >/dev/null trace lavad q rewards block-reward >/dev/null trace lavad q rewards show-iprpc-data > /dev/null +trace lavad q rewards iprpc-provider-reward > /dev/null +trace lavad q rewards iprpc-spec-reward > /dev/null trace lavad q rewards provider-reward >/dev/null echo "Testing events command" diff --git a/testutil/common/tester.go b/testutil/common/tester.go index 0cf83469b8..d3e775421e 100644 --- a/testutil/common/tester.go +++ b/testutil/common/tester.go @@ -307,6 +307,10 @@ func (ts *Tester) GetBalance(accAddr sdk.AccAddress) int64 { return ts.Keepers.BankKeeper.GetBalance(ts.Ctx, accAddr, denom).Amount.Int64() } +func (ts *Tester) GetBalances(accAddr sdk.AccAddress) sdk.Coins { + return ts.Keepers.BankKeeper.GetAllBalances(ts.Ctx, accAddr) +} + func (ts *Tester) FindPlan(index string, block uint64) (planstypes.Plan, bool) { return ts.Keepers.Plans.FindPlan(ts.Ctx, index, block) } @@ -610,9 +614,14 @@ func (ts *Tester) TxPairingUnfreezeProvider(addr, chainID string) (*pairingtypes return ts.Servers.PairingServer.UnfreezeProvider(ts.GoCtx, msg) } -func (ts *Tester) TxRewardsSetIprpcDataProposal(ctx sdk.Context, authority string, cost sdk.Coin, subs []string) (*rewardstypes.MsgSetIprpcDataResponse, error) { +func (ts *Tester) TxRewardsSetIprpcDataProposal(authority string, cost sdk.Coin, subs []string) (*rewardstypes.MsgSetIprpcDataResponse, error) { msg := rewardstypes.NewMsgSetIprpcData(authority, cost, subs) - return ts.Servers.RewardsServer.SetIprpcData(sdk.WrapSDKContext(ctx), msg) + return ts.Servers.RewardsServer.SetIprpcData(ts.GoCtx, msg) +} + +func (ts *Tester) TxRewardsFundIprpc(creator string, spec string, duration uint64, fund sdk.Coins) (*rewardstypes.MsgFundIprpcResponse, error) { + msg := rewardstypes.NewMsgFundIprpc(creator, spec, duration, fund) + return ts.Servers.RewardsServer.FundIprpc(ts.GoCtx, msg) } // TxCreateValidator: implement 'tx staking createvalidator' and bond its tokens @@ -859,11 +868,26 @@ func (ts *Tester) QueryRewardsBlockReward() (*rewardstypes.QueryBlockRewardRespo return ts.Keepers.Rewards.BlockReward(ts.GoCtx, msg) } -func (ts *Tester) QueryShowIprpcData() (*rewardstypes.QueryShowIprpcDataResponse, error) { +// QueryRewardsShowIprpcData implements 'q rewards show-iprpc-data' +func (ts *Tester) QueryRewardsShowIprpcData() (*rewardstypes.QueryShowIprpcDataResponse, error) { msg := &rewardstypes.QueryShowIprpcDataRequest{} return ts.Keepers.Rewards.ShowIprpcData(ts.GoCtx, msg) } +func (ts *Tester) QueryRewardsIprpcProviderRewardEstimation(provider string) (*rewardstypes.QueryIprpcProviderRewardEstimationResponse, error) { + msg := &rewardstypes.QueryIprpcProviderRewardEstimationRequest{ + Provider: provider, + } + return ts.Keepers.Rewards.IprpcProviderRewardEstimation(ts.GoCtx, msg) +} + +func (ts *Tester) QueryRewardsIprpcSpecReward(spec string) (*rewardstypes.QueryIprpcSpecRewardResponse, error) { + msg := &rewardstypes.QueryIprpcSpecRewardRequest{ + Spec: spec, + } + return ts.Keepers.Rewards.IprpcSpecReward(ts.GoCtx, msg) +} + // block/epoch helpers // QueryRewardsProviderReward implements 'q rewards provider-reward' func (ts *Tester) QueryRewardsProviderReward(chainID string, provider string) (*rewardstypes.QueryProviderRewardResponse, error) { diff --git a/testutil/keeper/mock_keepers.go b/testutil/keeper/mock_keepers.go index fbe2c741ce..d8512793d1 100644 --- a/testutil/keeper/mock_keepers.go +++ b/testutil/keeper/mock_keepers.go @@ -77,15 +77,9 @@ func (k mockBankKeeper) GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk } func (k mockBankKeeper) SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error { - // TODO support multiple coins moduleAcc := GetModuleAddress(recipientModule) - if amt.Len() > 1 { - return fmt.Errorf("mockbankkeeper dont support more than 1 coin") - } - coin := amt[0] - - accountCoin := k.GetBalance(ctx, senderAddr, coin.Denom) - if coin.Amount.GT(accountCoin.Amount) { + accountCoins := k.GetAllBalances(ctx, senderAddr) + if !accountCoins.IsAllGTE(amt) { return fmt.Errorf("not enough coins") } @@ -99,47 +93,20 @@ func (k mockBankKeeper) UndelegateCoinsFromModuleToAccount(ctx sdk.Context, send } func (k mockBankKeeper) SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error { - // TODO support multiple coins moduleAcc := GetModuleAddress(senderModule) - - if amt.Len() > 1 { - return fmt.Errorf("mockbankkeeper doesn't support more than 1 coin") - } - coin := amt[0] - - accountCoin := k.GetBalance(ctx, moduleAcc, coin.Denom) - if coin.Amount.GT(accountCoin.Amount) { + accountCoins := k.GetAllBalances(ctx, moduleAcc) + if !accountCoins.IsAllGTE(amt) { return fmt.Errorf("not enough coins") } k.SubFromBalance(moduleAcc, amt) - k.AddToBalance(recipientAddr, amt) - return nil } func (k mockBankKeeper) SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error { - // TODO support multiple coins - senderModuleAcc := GetModuleAddress(senderModule) - recipientModuleAcc := GetModuleAddress(recipientModule) - - if amt.Len() > 1 { - return fmt.Errorf("mockbankkeeper doesn't support more than 1 coin") - } - coin := amt[0] - - senderAccountCoin := k.GetBalance(ctx, senderModuleAcc, coin.Denom) - if coin.Amount.GT(senderAccountCoin.Amount) { - return fmt.Errorf("not enough coins") - } - - k.SubFromBalance(senderModuleAcc, amt) - - k.AddToBalance(recipientModuleAcc, amt) - - return nil + return k.SendCoinsFromAccountToModule(ctx, senderModuleAcc, recipientModule, amt) } func (k mockBankKeeper) DelegateCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error { diff --git a/x/pairing/client/cli/query_effective_policy.go b/x/pairing/client/cli/query_effective_policy.go index 74a4dad791..b772915ead 100644 --- a/x/pairing/client/cli/query_effective_policy.go +++ b/x/pairing/client/cli/query_effective_policy.go @@ -21,7 +21,7 @@ func CmdEffectivePolicy() *cobra.Command { if len(args) > 1 { address = args[1] } else { - clientCtxForTx, err := client.GetClientTxContext(cmd) + clientCtxForTx, err := client.GetClientQueryContext(cmd) if err != nil { return err } diff --git a/x/protocol/types/message_set_version_test.go b/x/protocol/types/message_set_version_test.go index 33b4d3f60c..58e2757ad2 100644 --- a/x/protocol/types/message_set_version_test.go +++ b/x/protocol/types/message_set_version_test.go @@ -17,13 +17,7 @@ func TestSetVersion_ValidateBasic(t *testing.T) { name: "invalid authority address", msg: MsgSetVersion{ Authority: "invalid_address", - }, - valid: false, - }, - { - name: "invalid subscription address", - msg: MsgSetVersion{ - Authority: sample.AccAddress(), + Version: &DefaultGenesis().Params.Version, }, valid: false, }, @@ -31,6 +25,7 @@ func TestSetVersion_ValidateBasic(t *testing.T) { name: "valid message", msg: MsgSetVersion{ Authority: sample.AccAddress(), + Version: &DefaultGenesis().Params.Version, }, valid: true, }, diff --git a/x/rewards/client/cli/query.go b/x/rewards/client/cli/query.go index 8793601319..bb32aa4781 100644 --- a/x/rewards/client/cli/query.go +++ b/x/rewards/client/cli/query.go @@ -28,6 +28,8 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdQueryPools()) cmd.AddCommand(CmdQueryBlockReward()) cmd.AddCommand(CmdQueryShowIprpcData()) + cmd.AddCommand(CmdQueryIprpcProviderRewardEstimation()) + cmd.AddCommand(CmdQueryIprpcSpecReward()) cmd.AddCommand(CmdQueryProviderReward()) // this line is used by starport scaffolding # 1 diff --git a/x/rewards/client/cli/query_block_reward.go b/x/rewards/client/cli/query_block_reward.go index 12d7dbece9..55957e4dd0 100644 --- a/x/rewards/client/cli/query_block_reward.go +++ b/x/rewards/client/cli/query_block_reward.go @@ -17,7 +17,7 @@ func CmdQueryBlockReward() *cobra.Command { Short: "Query for amount of validator rewards for proposing a block", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, err := client.GetClientTxContext(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err } diff --git a/x/rewards/client/cli/query_iprpc_provider_reward_estimation.go b/x/rewards/client/cli/query_iprpc_provider_reward_estimation.go new file mode 100644 index 0000000000..09b7771a49 --- /dev/null +++ b/x/rewards/client/cli/query_iprpc_provider_reward_estimation.go @@ -0,0 +1,43 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/lavanet/lava/x/rewards/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdQueryIprpcProviderRewardEstimation() *cobra.Command { + cmd := &cobra.Command{ + Use: "iprpc-provider-reward-estimation [provider]", + Short: "Query for current estimation of IPRPC reward for a specific provider", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryIprpcProviderRewardEstimationRequest{ + Provider: args[0], + } + + res, err := queryClient.IprpcProviderRewardEstimation(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rewards/client/cli/query_iprpc_spec_reward.go b/x/rewards/client/cli/query_iprpc_spec_reward.go new file mode 100644 index 0000000000..f10ccdaddf --- /dev/null +++ b/x/rewards/client/cli/query_iprpc_spec_reward.go @@ -0,0 +1,48 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/lavanet/lava/x/rewards/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdQueryIprpcSpecReward() *cobra.Command { + cmd := &cobra.Command{ + Use: "iprpc-spec-reward {spec}", + Short: "Query for IPRPC rewards for a specific spec. If no spec is given, all IPRPC rewards will be shown", + Args: cobra.RangeArgs(0, 1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + var spec string + if len(args) > 0 { + spec = args[0] + } + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryIprpcSpecRewardRequest{ + Spec: spec, + } + + res, err := queryClient.IprpcSpecReward(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rewards/client/cli/query_params.go b/x/rewards/client/cli/query_params.go index 29c8fdf565..7efc38eb5a 100644 --- a/x/rewards/client/cli/query_params.go +++ b/x/rewards/client/cli/query_params.go @@ -15,8 +15,10 @@ func CmdQueryParams() *cobra.Command { Short: "shows the parameters of the module", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } queryClient := types.NewQueryClient(clientCtx) res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) diff --git a/x/rewards/client/cli/query_pools.go b/x/rewards/client/cli/query_pools.go index 7a2c7a25eb..9911dc7272 100644 --- a/x/rewards/client/cli/query_pools.go +++ b/x/rewards/client/cli/query_pools.go @@ -17,7 +17,7 @@ func CmdQueryPools() *cobra.Command { Short: "Query for validators and providers rewards pools information", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, err := client.GetClientTxContext(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err } diff --git a/x/rewards/client/cli/query_show_iprpc_data.go b/x/rewards/client/cli/query_show_iprpc_data.go index 4448e42323..c07c4a25bf 100644 --- a/x/rewards/client/cli/query_show_iprpc_data.go +++ b/x/rewards/client/cli/query_show_iprpc_data.go @@ -17,7 +17,7 @@ func CmdQueryShowIprpcData() *cobra.Command { Short: "Query for IPRPC data: min cost and IPRPC eligible subscriptions", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, err := client.GetClientTxContext(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err } diff --git a/x/rewards/keeper/base_pay.go b/x/rewards/keeper/base_pay.go index 61b8a978e3..d61ab0370d 100644 --- a/x/rewards/keeper/base_pay.go +++ b/x/rewards/keeper/base_pay.go @@ -54,7 +54,7 @@ func (k Keeper) SetAllBasePay(ctx sdk.Context, list []types.BasePayGenesis) { } } -func (k Keeper) GetAllBasePayForChain(ctx sdk.Context, chainID string, provider string) (list []types.BasePayWithIndex) { +func (k Keeper) getAllBasePayForChain(ctx sdk.Context, chainID string, provider string) (list []types.BasePayWithIndex) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BasePayPrefix)) iterator := sdk.KVStorePrefixIterator(store, []byte(types.BasePayIndex{ChainID: chainID, Provider: provider}.String())) diff --git a/x/rewards/keeper/grpc_query_iprpc_provider_reward.go b/x/rewards/keeper/grpc_query_iprpc_provider_reward.go new file mode 100644 index 0000000000..fcdb1f3b21 --- /dev/null +++ b/x/rewards/keeper/grpc_query_iprpc_provider_reward.go @@ -0,0 +1,57 @@ +package keeper + +import ( + "context" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/lavanet/lava/x/rewards/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) IprpcProviderRewardEstimation(goCtx context.Context, req *types.QueryIprpcProviderRewardEstimationRequest) (*types.QueryIprpcProviderRewardEstimationResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + // get current month IPRPC reward + id := k.GetIprpcRewardsCurrentId(ctx) + iprpcReward, found := k.GetIprpcReward(ctx, id) + if !found { + return nil, fmt.Errorf("current month IPRPC reward does not exist") + } + + // go over all the IPRPC reward specs and get the provider's relative reward (by CU) + providerSpecFunds := []types.Specfund{} + for _, specFund := range iprpcReward.SpecFunds { + // get all spec basepays and count IPRPC CU + bps, _ := k.specProvidersBasePay(ctx, specFund.Spec, false) + providerIprpcCu := uint64(0) + totalIprpcCu := uint64(0) + providerBpIndex := types.BasePayIndex{Provider: req.Provider, ChainID: specFund.Spec} + for _, bp := range bps { + if bp.BasePayIndex.String() == providerBpIndex.String() { + providerIprpcCu = bp.IprpcCu + } + totalIprpcCu += bp.IprpcCu + } + + // get the provider's relative reward by CU + providerFund, isValid := specFund.Fund.SafeMulInt(sdk.NewIntFromUint64(providerIprpcCu)) + if !isValid { + continue + } + providerFund, isValid = providerFund.SafeQuoInt(sdk.NewIntFromUint64(totalIprpcCu)) + if !isValid { + continue + } + + // save the provider's reward + providerSpecFunds = append(providerSpecFunds, types.Specfund{Spec: specFund.Spec, Fund: providerFund}) + } + + return &types.QueryIprpcProviderRewardEstimationResponse{SpecFunds: providerSpecFunds}, nil +} diff --git a/x/rewards/keeper/grpc_query_iprpc_spec_reward.go b/x/rewards/keeper/grpc_query_iprpc_spec_reward.go new file mode 100644 index 0000000000..2f0d67693b --- /dev/null +++ b/x/rewards/keeper/grpc_query_iprpc_spec_reward.go @@ -0,0 +1,37 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/lavanet/lava/x/rewards/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) IprpcSpecReward(goCtx context.Context, req *types.QueryIprpcSpecRewardRequest) (*types.QueryIprpcSpecRewardResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + iprpcRewards := k.GetAllIprpcReward(ctx) + currentMonthId := k.GetIprpcRewardsCurrentId(ctx) + + if req.Spec == "" { + return &types.QueryIprpcSpecRewardResponse{IprpcRewards: iprpcRewards, CurrentMonthId: currentMonthId}, nil + } + + specIprpcRewards := []types.IprpcReward{} + for _, iprpcReward := range iprpcRewards { + for _, specFund := range iprpcReward.SpecFunds { + if specFund.Spec == req.Spec { + specIprpcReward := types.IprpcReward{Id: iprpcReward.Id, SpecFunds: []types.Specfund{specFund}} + specIprpcRewards = append(specIprpcRewards, specIprpcReward) + break + } + } + } + + return &types.QueryIprpcSpecRewardResponse{IprpcRewards: specIprpcRewards, CurrentMonthId: currentMonthId}, nil +} diff --git a/x/rewards/keeper/grpc_query_provider_reward.go b/x/rewards/keeper/grpc_query_provider_reward.go index 80d7ab1f67..b123e721b9 100644 --- a/x/rewards/keeper/grpc_query_provider_reward.go +++ b/x/rewards/keeper/grpc_query_provider_reward.go @@ -18,7 +18,7 @@ func (k Keeper) ProviderReward(goCtx context.Context, req *types.QueryProviderRe var rewards []types.RewardInfo - for _, basepay := range k.GetAllBasePayForChain(ctx, req.ChainId, req.ChainId) { + for _, basepay := range k.getAllBasePayForChain(ctx, req.ChainId, req.ChainId) { rewards = append(rewards, types.RewardInfo{Provider: basepay.Provider, ChainId: basepay.ChainID, Amount: sdk.NewCoin(k.stakingKeeper.BondDenom(ctx), basepay.BasePay.Total)}) } diff --git a/x/rewards/keeper/helpers_test.go b/x/rewards/keeper/helpers_test.go index e2d009ab50..6c9be49dfb 100644 --- a/x/rewards/keeper/helpers_test.go +++ b/x/rewards/keeper/helpers_test.go @@ -2,15 +2,18 @@ package keeper_test import ( "testing" + "time" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + commontypes "github.com/lavanet/lava/common/types" "github.com/lavanet/lava/testutil/common" testkeeper "github.com/lavanet/lava/testutil/keeper" planstypes "github.com/lavanet/lava/x/plans/types" - rewardsTypes "github.com/lavanet/lava/x/rewards/types" + rewardstypes "github.com/lavanet/lava/x/rewards/types" spectypes "github.com/lavanet/lava/x/spec/types" "github.com/stretchr/testify/require" ) @@ -22,10 +25,20 @@ const ( feeCollectorName = authtypes.FeeCollectorName ) +var ( + ibcDenom string = "uibc" + minIprpcCost sdk.Coin = sdk.NewCoin(commontypes.TokenDenom, sdk.NewInt(100)) + iprpcFunds sdk.Coins = sdk.NewCoins( + sdk.NewCoin(commontypes.TokenDenom, sdk.NewInt(1100)), + sdk.NewCoin(ibcDenom, sdk.NewInt(500)), + ) + mockSpec2 string = "mock2" +) + type tester struct { common.Tester - plan planstypes.Plan - spec spectypes.Spec + plan planstypes.Plan + specs []spectypes.Spec } func newTester(t *testing.T, addValidator bool) *tester { @@ -38,14 +51,14 @@ func newTester(t *testing.T, addValidator bool) *tester { } ts.plan = common.CreateMockPlan() - coins := ts.Keepers.Rewards.TotalPoolTokens(ts.Ctx, rewardsTypes.ProviderRewardsDistributionPool) + coins := ts.Keepers.Rewards.TotalPoolTokens(ts.Ctx, rewardstypes.ProviderRewardsDistributionPool) _, monthlyProvidersPool := coins.Find(ts.BondDenom()) ts.plan.Price.Amount = monthlyProvidersPool.Amount.QuoRaw(5).AddRaw(5) ts.plan.PlanPolicy.EpochCuLimit = monthlyProvidersPool.Amount.Uint64() * 5 ts.plan.PlanPolicy.TotalCuLimit = monthlyProvidersPool.Amount.Uint64() * 5 ts.plan.PlanPolicy.MaxProvidersToPair = 5 ts.AddPlan(ts.plan.Index, ts.plan) - ts.spec = ts.AddSpec("mock", common.CreateMockSpec()).Spec("mock") + ts.specs = []spectypes.Spec{ts.AddSpec("mock", common.CreateMockSpec()).Spec("mock")} return ts } @@ -61,11 +74,70 @@ func (ts *tester) feeCollector() sdk.AccAddress { return testkeeper.GetModuleAddress(feeCollectorName) } -func (ts *tester) getPoolBalance(pool rewardsTypes.Pool, denom string) math.Int { +func (ts *tester) getPoolBalance(pool rewardstypes.Pool, denom string) math.Int { coins := ts.Keepers.Rewards.TotalPoolTokens(ts.Ctx, pool) return coins.AmountOf(denom) } +func (ts *tester) iprpcAuthority() string { + return authtypes.NewModuleAddress(govtypes.ModuleName).String() +} + +// setupForIprpcTests performs the following to set a proper env for iprpc tests: +// 0. it assumes that ts.newTester(t) was already executed +// 1. setting IPRPC data +// 2. fund the iprpc pool (optional, can specify if to fund from the next month) +func (ts *tester) setupForIprpcTests(fundIprpcPool bool) { + // add two consumers and buy subscriptions + consumerAcc, consumer := ts.AddAccount(common.CONSUMER, 0, testBalance*10000) + _, consumer2 := ts.AddAccount(common.CONSUMER, 1, testBalance*10000) + _, err := ts.TxSubscriptionBuy(consumer, consumer, ts.plan.Index, 5, true, false) + require.NoError(ts.T, err) + _, err = ts.TxSubscriptionBuy(consumer2, consumer2, ts.plan.Index, 5, true, false) + require.NoError(ts.T, err) + + // set iprpc data (only consumer is IPRPC eligible) + _, err = ts.TxRewardsSetIprpcDataProposal(ts.iprpcAuthority(), minIprpcCost, []string{consumer}) + require.NoError(ts.T, err) + + // create a new spec + spec2 := common.CreateMockSpec() + spec2.Index = mockSpec2 + spec2.Name = mockSpec2 + ts.specs = append(ts.specs, ts.AddSpec(mockSpec2, spec2).Spec(mockSpec2)) + + // add two providers and stake them both on the two specs + _, provider := ts.AddAccount(common.PROVIDER, 0, testBalance) + _, provider2 := ts.AddAccount(common.PROVIDER, 1, testBalance) + err = ts.StakeProvider(provider, ts.specs[0], testStake) + require.NoError(ts.T, err) + err = ts.StakeProvider(provider, ts.specs[1], testStake) + require.NoError(ts.T, err) + err = ts.StakeProvider(provider2, ts.specs[0], testStake) + require.NoError(ts.T, err) + err = ts.StakeProvider(provider2, ts.specs[1], testStake) + require.NoError(ts.T, err) + + ts.AdvanceEpoch() // apply pairing + + // reset time to the start of the month + startOfMonth := time.Date(ts.Ctx.BlockTime().Year(), ts.Ctx.BlockTime().Month(), 1, 0, 0, 0, 0, ts.Ctx.BlockTime().Location()) + ts.Ctx = ts.Ctx.WithBlockTime(startOfMonth) + ts.GoCtx = sdk.WrapSDKContext(ts.Ctx) + + if fundIprpcPool { + duration := uint64(1) + err = ts.Keepers.BankKeeper.AddToBalance(consumerAcc.Addr, iprpcFunds.MulInt(sdk.NewIntFromUint64(duration))) + require.NoError(ts.T, err) + balanceBeforeFund := ts.GetBalances(consumerAcc.Addr) + _, err = ts.TxRewardsFundIprpc(consumer, mockSpec2, duration, iprpcFunds) + require.NoError(ts.T, err) + expectedBalanceAfterFund := balanceBeforeFund.Sub(iprpcFunds.MulInt(math.NewIntFromUint64(duration))...) + require.True(ts.T, ts.GetBalances(consumerAcc.Addr).IsEqual(expectedBalanceAfterFund)) + ts.AdvanceMonths(1).AdvanceEpoch() // fund only fund for next month, so advance a month + } +} + // deductParticipationFees calculates the validators and community participation // fees and returns the providers reward after deducting them func (ts *tester) DeductParticipationFees(reward math.Int) (updatedReward math.Int, valParticipation math.Int, communityParticipation math.Int) { diff --git a/x/rewards/keeper/iprpc.go b/x/rewards/keeper/iprpc.go index 5a25ce96ad..028f2b6f4c 100644 --- a/x/rewards/keeper/iprpc.go +++ b/x/rewards/keeper/iprpc.go @@ -55,7 +55,7 @@ func (k Keeper) FundIprpc(ctx sdk.Context, creator string, duration uint64, fund } // add spec funds to next month IPRPC reward object - k.addSpecFunds(ctx, spec, fund, duration) + k.addSpecFunds(ctx, spec, fund, duration, true) return nil } @@ -64,7 +64,7 @@ func (k Keeper) FundIprpc(ctx sdk.Context, creator string, duration uint64, fund // so the IPRPC rewards transfer to the next month func (k Keeper) handleNoIprpcRewardToProviders(ctx sdk.Context, iprpcFunds []types.Specfund) { for _, fund := range iprpcFunds { - k.addSpecFunds(ctx, fund.Spec, fund.Fund, 1) + k.addSpecFunds(ctx, fund.Spec, fund.Fund, 1, false) } details := map[string]string{ @@ -93,8 +93,14 @@ func (k Keeper) countIprpcCu(specCuMap map[string]types.SpecCuType, iprpcCu uint // AddSpecFunds adds funds for a specific spec for of months. // This function is used by the fund-iprpc TX. -func (k Keeper) addSpecFunds(ctx sdk.Context, spec string, fund sdk.Coins, duration uint64) { - startID := k.GetIprpcRewardsCurrentId(ctx) + 1 // fund IPRPC only from the next month for months +// use fromNextMonth=true for normal IPRPC fund (should always start from next month) +// use fromNextMonth=false for IPRPC reward transfer for next month (when no providers are eligible for IPRPC rewards) +func (k Keeper) addSpecFunds(ctx sdk.Context, spec string, fund sdk.Coins, duration uint64, fromNextMonth bool) { + startID := k.GetIprpcRewardsCurrentId(ctx) + if fromNextMonth { + startID++ // fund IPRPC only from the next month for months + } + for i := startID; i < startID+duration; i++ { iprpcReward, found := k.GetIprpcReward(ctx, i) if found { diff --git a/x/rewards/keeper/iprpc_data_test.go b/x/rewards/keeper/iprpc_data_test.go index 330cb09879..8d949565b1 100644 --- a/x/rewards/keeper/iprpc_data_test.go +++ b/x/rewards/keeper/iprpc_data_test.go @@ -109,10 +109,10 @@ func TestIprpcDataValidation(t *testing.T) { for _, tt := range template { t.Run(tt.name, func(t *testing.T) { - _, err := ts.TxRewardsSetIprpcDataProposal(ts.Ctx, tt.authority, tt.cost, tt.subs) + _, err := ts.TxRewardsSetIprpcDataProposal(tt.authority, tt.cost, tt.subs) if tt.success { require.NoError(t, err) - res, err := ts.QueryShowIprpcData() + res, err := ts.QueryRewardsShowIprpcData() require.NoError(t, err) require.True(t, tt.cost.IsEqual(res.MinCost)) require.Equal(t, tt.subs, res.IprpcSubscriptions) diff --git a/x/rewards/keeper/iprpc_test.go b/x/rewards/keeper/iprpc_test.go new file mode 100644 index 0000000000..07486ddaf6 --- /dev/null +++ b/x/rewards/keeper/iprpc_test.go @@ -0,0 +1,717 @@ +package keeper_test + +import ( + "testing" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + "github.com/lavanet/lava/testutil/common" + "github.com/lavanet/lava/utils/sigs" + rewardstypes "github.com/lavanet/lava/x/rewards/types" + "github.com/stretchr/testify/require" +) + +// TestFundIprpcTX tests the FundIprpc TX functionality in funding the IPRPC pool +// Scenarios: +// 1. fund IPRPC with different periods (1m,3m,12m) and different denominations (also combinations) +// -> pool balance and iprpc reward should be as expected +func TestFundIprpcTX(t *testing.T) { + ts := newTester(t, true) + ts.setupForIprpcTests(false) + + consumerAcc, consumer := ts.GetAccount(common.CONSUMER, 0) + err := ts.Keepers.BankKeeper.AddToBalance(consumerAcc.Addr, iprpcFunds.MulInt(math.NewInt(12))) + require.NoError(ts.T, err) + + type fundIprpcData struct { + spec string + duration uint64 + fund sdk.Coins + } + + // we fund as follows (to all we add the min IPRPC price. the description below is the funds that go to the pool): + // - 10ulava, 1 month, mockspec + // - 50uibc, 1 month, mockspec + // - 90ulava + 30uibc, 3 months, mockspec2 + // - 130uibc, 3 months, mockspec + // - 10ulava + 120uibc, 12 months, mockspec2 + fundIprpcTXsData := []fundIprpcData{ + {spec: ts.specs[0].Index, duration: 1, fund: sdk.NewCoins( + sdk.NewCoin(ts.BondDenom(), math.NewInt(10+minIprpcCost.Amount.Int64())), + )}, + {spec: ts.specs[0].Index, duration: 1, fund: sdk.NewCoins( + sdk.NewCoin(ts.BondDenom(), math.NewInt(minIprpcCost.Amount.Int64())), + sdk.NewCoin(ibcDenom, math.NewInt(50)), + )}, + {spec: ts.specs[1].Index, duration: 3, fund: sdk.NewCoins( + sdk.NewCoin(ts.BondDenom(), math.NewInt(90+minIprpcCost.Amount.Int64())), + sdk.NewCoin(ibcDenom, math.NewInt(30)), + )}, + {spec: ts.specs[0].Index, duration: 3, fund: sdk.NewCoins( + sdk.NewCoin(ts.BondDenom(), math.NewInt(minIprpcCost.Amount.Int64())), + sdk.NewCoin(ibcDenom, math.NewInt(130)), + )}, + {spec: ts.specs[1].Index, duration: 12, fund: sdk.NewCoins( + sdk.NewCoin(ts.BondDenom(), math.NewInt(10+minIprpcCost.Amount.Int64())), + sdk.NewCoin(ibcDenom, math.NewInt(120)), + )}, + } + + for _, txData := range fundIprpcTXsData { + _, err = ts.TxRewardsFundIprpc(consumer, txData.spec, txData.duration, txData.fund) + require.NoError(t, err) + } + + // Expected total IPRPC pool balance (by TXs): + // 1. 10ulava + // 2. 50uibc + // 3. (90ulava + 30uibc) * 3 = 270ulava + 90uibc + // 4. 130uibc * 3 = 390uibc + // 5. (10ulava + 120uibc) * 12 = 120ulava + 1440uibc + // Total: 400ulava + 1970uibc + iprpcTotalBalance := ts.Keepers.Rewards.TotalPoolTokens(ts.Ctx, rewardstypes.IprpcPoolName) + expectedIprpcTotalBalance := sdk.NewCoins( + sdk.NewCoin(ts.BondDenom(), math.NewInt(400)), + sdk.NewCoin(ibcDenom, math.NewInt(1970)), + ) + require.True(t, expectedIprpcTotalBalance.IsEqual(iprpcTotalBalance)) + + // Expected IPRPC rewards (by months, first month is skipped): + // 1. mockspec: 10ulava + 180uibc(=50+130), mockspec2: 100ulava(=10+90) + 150uibc(=30+120) + // 2. mockspec: 130uibc, mockspec2: 100ulava(=10+90) + 150uibc(=30+120) + // 3. mockspec: 130uibc, mockspec2: 100ulava(=10+90) + 150uibc(=30+120) + // 4-12. mockspec: nothing, mockspec2: 10ulava + 120uibc + iprpcRewards := ts.Keepers.Rewards.GetAllIprpcReward(ts.Ctx) + require.Len(t, iprpcRewards, 12) + for i := range iprpcRewards { + var expectedSpecFunds []rewardstypes.Specfund + switch i { + case 0: + // first month + expectedSpecFunds = []rewardstypes.Specfund{ + { + Spec: ts.specs[0].Index, Fund: sdk.NewCoins( + sdk.NewCoin(ts.BondDenom(), math.NewInt(10)), + sdk.NewCoin(ibcDenom, math.NewInt(180)), + ), + }, + { + Spec: ts.specs[1].Index, Fund: sdk.NewCoins( + sdk.NewCoin(ts.BondDenom(), math.NewInt(100)), + sdk.NewCoin(ibcDenom, math.NewInt(150)), + ), + }, + } + case 1: + // second month + expectedSpecFunds = []rewardstypes.Specfund{ + { + Spec: ts.specs[0].Index, Fund: sdk.NewCoins( + sdk.NewCoin(ibcDenom, math.NewInt(130)), + ), + }, + { + Spec: ts.specs[1].Index, Fund: sdk.NewCoins( + sdk.NewCoin(ts.BondDenom(), math.NewInt(100)), + sdk.NewCoin(ibcDenom, math.NewInt(150)), + ), + }, + } + case 2: + // 3rd month + expectedSpecFunds = []rewardstypes.Specfund{ + { + Spec: ts.specs[0].Index, Fund: sdk.NewCoins( + sdk.NewCoin(ibcDenom, math.NewInt(130)), + ), + }, + { + Spec: ts.specs[1].Index, Fund: sdk.NewCoins( + sdk.NewCoin(ts.BondDenom(), math.NewInt(100)), + sdk.NewCoin(ibcDenom, math.NewInt(150)), + ), + }, + } + default: + // rest of months (until 12) + expectedSpecFunds = []rewardstypes.Specfund{ + { + Spec: ts.specs[1].Index, Fund: sdk.NewCoins( + sdk.NewCoin(ts.BondDenom(), math.NewInt(10)), + sdk.NewCoin(ibcDenom, math.NewInt(120)), + ), + }, + } + } + require.Equal(t, i+1, int(iprpcRewards[i].Id)) + require.ElementsMatch(t, expectedSpecFunds, iprpcRewards[i].SpecFunds) + } +} + +// TestIprpcProviderRewardQuery tests the IprpcProviderReward query functionality +// Scenarios: +// 1. two providers provide different CU for two consumers, which only one is IPRPC eligible -> query should return expected reward +// 2. advance a month, fund the pool and check the query's output again (without sending relays -> provider rewards should be empty) +func TestIprpcProviderRewardQuery(t *testing.T) { + ts := newTester(t, true) + ts.setupForIprpcTests(true) // setup funds IPRPC for mock2 spec + + // get consumers and providers (note, only c1 is IPRPC eligible) + c1Acc, _ := ts.GetAccount(common.CONSUMER, 0) + c2Acc, _ := ts.GetAccount(common.CONSUMER, 1) + _, p1 := ts.GetAccount(common.PROVIDER, 0) + _, p2 := ts.GetAccount(common.PROVIDER, 1) + + // send relays from both consumers to both providers + type relayInfo struct { + consumer sigs.Account + provider string + cu uint64 + } + relaysInfo := []relayInfo{ + {consumer: c1Acc, provider: p1, cu: 100}, + {consumer: c2Acc, provider: p1, cu: 150}, + {consumer: c1Acc, provider: p2, cu: 400}, + {consumer: c2Acc, provider: p2, cu: 450}, + } + for _, info := range relaysInfo { + msg := ts.SendRelay(info.provider, info.consumer, []string{ts.specs[1].Index}, info.cu) + _, err := ts.Servers.PairingServer.RelayPayment(ts.GoCtx, &msg) + require.NoError(t, err) + } + + // check the IprpcProviderReward query + // p1 should get 1/5 of the reward and p2 4/5 of the reward (p1 relative serviced CU is 100/500) + // note: setupForIprpcTests() funds the IPRPC pool with 1000ulava and 500uibc + type providerRewards struct { + provider string + fund sdk.Coins + } + 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))}, + } + for _, expectedProviderReward := range expectedProviderRewards { + res, err := ts.QueryRewardsIprpcProviderRewardEstimation(expectedProviderReward.provider) + require.NoError(t, err) + require.ElementsMatch(t, expectedProviderReward.fund, res.SpecFunds[0].Fund) // taking 0 index because there's a single spec + } + + // advance month to distribute monthly rewards + ts.AdvanceMonths(1) + ts.AdvanceEpoch() + + // check that rewards were distributed as expected + for _, expectedProviderReward := range expectedProviderRewards { + res2, err := ts.QueryDualstakingDelegatorRewards(expectedProviderReward.provider, 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 + } +} + +// TestIprpcSpecRewardQuery tests the IprpcSpecReward query functionality +// Scenarios: +// 0. assume IPRPC pool is funded with two denoms over different periods of vesting with two specs +// 1. query with no args should return all +// 2. query with arg should return the IPRPC rewards for the specific spec +// 3. advance a month, this month reward should transfer to next month -> query should return updated iprpc pool balance +// 4. make a provider provide service, advance a month to get his reward -> query should return updated iprpc pool balance +func TestIprpcSpecRewardQuery(t *testing.T) { + ts := newTester(t, true) + ts.setupForIprpcTests(true) // setup funds IPRPC for mock2 spec for 1 month and advances a month + + _, consumer := ts.GetAccount(common.CONSUMER, 0) + + // do another funding for mockspec and mock2 for 3 months + // Expected funds: + // first month: mock2 - 500uibc + 3000ulava, mockspec - 100000ulava + // second + third month: mock2 - 2000ulava, mockspec - 100000ulava + duration := int64(3) + _, err := ts.TxRewardsFundIprpc(consumer, ts.specs[0].Index, uint64(duration), + sdk.NewCoins(sdk.NewCoin(ts.BondDenom(), sdk.NewInt(100000).Add(minIprpcCost.Amount)))) + require.NoError(ts.T, err) + + _, err = ts.TxRewardsFundIprpc(consumer, ts.specs[1].Index, uint64(duration), + sdk.NewCoins(sdk.NewCoin(ts.BondDenom(), sdk.NewInt(2000).Add(minIprpcCost.Amount)))) + require.NoError(ts.T, err) + + expectedResults := []rewardstypes.IprpcReward{ + { + Id: 1, SpecFunds: []rewardstypes.Specfund{ + {Spec: ts.specs[1].Index, Fund: sdk.NewCoins(sdk.NewCoin(ibcDenom, sdk.NewInt(500)), + sdk.NewCoin(ts.BondDenom(), sdk.NewInt(1000)))}, + }, + }, + { + Id: 2, SpecFunds: []rewardstypes.Specfund{ + {Spec: ts.specs[0].Index, Fund: sdk.NewCoins(sdk.NewCoin(ts.BondDenom(), sdk.NewInt(100000)))}, + {Spec: ts.specs[1].Index, Fund: sdk.NewCoins(sdk.NewCoin(ts.BondDenom(), sdk.NewInt(2000)))}, + }, + }, + { + Id: 3, SpecFunds: []rewardstypes.Specfund{ + {Spec: ts.specs[0].Index, Fund: sdk.NewCoins(sdk.NewCoin(ts.BondDenom(), sdk.NewInt(100000)))}, + {Spec: ts.specs[1].Index, Fund: sdk.NewCoins(sdk.NewCoin(ts.BondDenom(), sdk.NewInt(2000)))}, + }, + }, + { + Id: 4, SpecFunds: []rewardstypes.Specfund{ + {Spec: ts.specs[0].Index, Fund: sdk.NewCoins(sdk.NewCoin(ts.BondDenom(), sdk.NewInt(100000)))}, + {Spec: ts.specs[1].Index, Fund: sdk.NewCoins(sdk.NewCoin(ts.BondDenom(), sdk.NewInt(2000)))}, + }, + }, + } + + // query with no args + res, err := ts.QueryRewardsIprpcSpecReward("") + require.NoError(t, err) + require.ElementsMatch(t, expectedResults, res.IprpcRewards) + + // query with arg = mockspec + mockspecExpectedResults := []rewardstypes.IprpcReward{ + { + Id: 2, SpecFunds: []rewardstypes.Specfund{ + {Spec: ts.specs[0].Index, Fund: sdk.NewCoins(sdk.NewCoin(ts.BondDenom(), sdk.NewInt(100000)))}, + }, + }, + { + Id: 3, SpecFunds: []rewardstypes.Specfund{ + {Spec: ts.specs[0].Index, Fund: sdk.NewCoins(sdk.NewCoin(ts.BondDenom(), sdk.NewInt(100000)))}, + }, + }, + { + Id: 4, SpecFunds: []rewardstypes.Specfund{ + {Spec: ts.specs[0].Index, Fund: sdk.NewCoins(sdk.NewCoin(ts.BondDenom(), sdk.NewInt(100000)))}, + }, + }, + } + res, err = ts.QueryRewardsIprpcSpecReward(ts.specs[0].Index) + require.NoError(t, err) + require.ElementsMatch(t, mockspecExpectedResults, res.IprpcRewards) + + // advance a month with no providers getting rewarded this month's reward should transfer to the next month + // 2nd month expected funds: mockspec - 100000ulava, mock2 - 3000ulava(=2000+1000) and 500uibc + ts.AdvanceMonths(1) + ts.AdvanceEpoch() + + afterMonthExpectedResults := expectedResults[1:] + afterMonthExpectedResults[0].SpecFunds = []rewardstypes.Specfund{ + {Spec: ts.specs[0].Index, Fund: sdk.NewCoins(sdk.NewCoin(ts.BondDenom(), sdk.NewInt(100000)))}, + {Spec: ts.specs[1].Index, Fund: sdk.NewCoins( + sdk.NewCoin(ts.BondDenom(), sdk.NewInt(3000)), + sdk.NewCoin(ibcDenom, sdk.NewInt(500)), + )}, + } + res, err = ts.QueryRewardsIprpcSpecReward("") + require.NoError(t, err) + require.Len(t, res.IprpcRewards, len(afterMonthExpectedResults)) + for i := range res.IprpcRewards { + require.Equal(t, afterMonthExpectedResults[i].Id, res.IprpcRewards[i].Id) + require.ElementsMatch(t, afterMonthExpectedResults[i].SpecFunds, res.IprpcRewards[i].SpecFunds) + } + + // make a provider provide some service to an IPRPC eligible subscription + c1Acc, _ := ts.GetAccount(common.CONSUMER, 0) + _, p1 := ts.GetAccount(common.PROVIDER, 0) + relay := ts.SendRelay(p1, c1Acc, []string{ts.specs[1].Index}, 100) + _, err = ts.Servers.PairingServer.RelayPayment(ts.GoCtx, &relay) + require.NoError(t, err) + relay = ts.SendRelay(p1, c1Acc, []string{ts.specs[0].Index}, 100) + _, err = ts.Servers.PairingServer.RelayPayment(ts.GoCtx, &relay) + require.NoError(t, err) + + // advance month to distribute monthly rewards + ts.AdvanceMonths(1) + ts.AdvanceEpoch() + + // check that the latest iprpc object has been deleted + afterProviderServiceExpectedResults := afterMonthExpectedResults[1:] + res, err = ts.QueryRewardsIprpcSpecReward("") + require.NoError(t, err) + require.ElementsMatch(t, afterProviderServiceExpectedResults, res.IprpcRewards) +} + +// TestIprpcRewardObjectsUpdate tests that the IPRPC reward objects' management works as expected: +// Scenarios: +// 0. fund iprpc pool for 2 months, current should be 0 and first iprpc reward should be with id=1 (fund is always for the next month) +// 1. there is no service to eligible subscriptions, month passes -> current shouldn't increment and there should be no IPRPC object +// 2. provider provides service for eligible subscription, month passes -> current should increment by 1 and a new IPRPC reward should be created with id=current +func TestIprpcRewardObjectsUpdate(t *testing.T) { + ts := newTester(t, true) + ts.setupForIprpcTests(false) + consumerAcc, consumer := ts.GetAccount(common.CONSUMER, 0) + + // fund iprpc pool + duration := uint64(2) + err := ts.Keepers.BankKeeper.AddToBalance(consumerAcc.Addr, iprpcFunds.MulInt(math.NewInt(2))) + require.NoError(ts.T, err) + _, err = ts.TxRewardsFundIprpc(consumer, mockSpec2, duration, iprpcFunds) + require.NoError(ts.T, err) + + // check there are 2 iprpc reward object, and the first one is with id=1 + currentIprpcRewardId := ts.Keepers.Rewards.GetIprpcRewardsCurrentId(ts.Ctx) + require.Equal(t, uint64(0), currentIprpcRewardId) + res, err := ts.QueryRewardsIprpcSpecReward(mockSpec2) + require.NoError(t, err) + require.Len(t, res.IprpcRewards, 2) + require.Equal(t, uint64(0), res.CurrentMonthId) + for i := range res.IprpcRewards { + require.Equal(t, uint64(i+1), res.IprpcRewards[i].Id) + require.True(t, iprpcFunds.Sub(minIprpcCost).IsEqual(res.IprpcRewards[i].SpecFunds[0].Fund)) + } + + // advance month to reach the first iprpc reward (first object is with id=1) + // there should still be the exact two objects as before + ts.AdvanceMonths(1) + ts.AdvanceEpoch() + currentIprpcRewardId = ts.Keepers.Rewards.GetIprpcRewardsCurrentId(ts.Ctx) + require.Equal(t, uint64(1), currentIprpcRewardId) + res, err = ts.QueryRewardsIprpcSpecReward(mockSpec2) + require.NoError(t, err) + require.Len(t, res.IprpcRewards, 2) + require.Equal(t, uint64(1), res.CurrentMonthId) + for i := range res.IprpcRewards { + require.Equal(t, uint64(i+1), res.IprpcRewards[i].Id) + require.True(t, iprpcFunds.Sub(minIprpcCost).IsEqual(res.IprpcRewards[i].SpecFunds[0].Fund)) + } + + // advance month without any provider service, there should be one IPRPC object with combined reward + ts.AdvanceMonths(1) + ts.AdvanceEpoch() + currentIprpcRewardId = ts.Keepers.Rewards.GetIprpcRewardsCurrentId(ts.Ctx) + require.Equal(t, uint64(2), currentIprpcRewardId) + res, err = ts.QueryRewardsIprpcSpecReward(mockSpec2) + require.NoError(t, err) + require.Len(t, res.IprpcRewards, 1) + require.Equal(t, uint64(2), res.CurrentMonthId) + require.True(t, iprpcFunds.Sub(minIprpcCost).MulInt(sdk.NewInt(2)).IsEqual(res.IprpcRewards[0].SpecFunds[0].Fund)) + + // make a provider service an IPRPC eligible consumer and advance a month + // there should be no iprpc rewards objects + c1Acc, _ := ts.GetAccount(common.CONSUMER, 0) + _, p1 := ts.GetAccount(common.PROVIDER, 0) + relay := ts.SendRelay(p1, c1Acc, []string{ts.specs[1].Index}, 100) + _, err = ts.Servers.PairingServer.RelayPayment(ts.GoCtx, &relay) + require.NoError(t, err) + ts.AdvanceMonths(1) + ts.AdvanceEpoch() + res, err = ts.QueryRewardsIprpcSpecReward(mockSpec2) + require.NoError(t, err) + require.Len(t, res.IprpcRewards, 0) + require.Equal(t, uint64(3), res.CurrentMonthId) +} + +// TestFundIprpcTwice tests the following scenario: +// IPRPC is funded for two months, advance month and fund again +// during this month, let provider serve and advance month again -> reward should be as the original funding +// advance again and serve -> reward should be from both funds (funding only starts from the next month) +func TestFundIprpcTwice(t *testing.T) { + ts := newTester(t, true) + ts.setupForIprpcTests(false) + consumerAcc, consumer := ts.GetAccount(common.CONSUMER, 0) + _, p1 := ts.GetAccount(common.PROVIDER, 0) + + // fund iprpc pool + err := ts.Keepers.BankKeeper.AddToBalance(consumerAcc.Addr, iprpcFunds.MulInt(math.NewInt(2))) + require.NoError(ts.T, err) + _, err = ts.TxRewardsFundIprpc(consumer, mockSpec2, 2, iprpcFunds) + require.NoError(ts.T, err) + + // advance month and fund again + ts.AdvanceMonths(1).AdvanceEpoch() + err = ts.Keepers.BankKeeper.AddToBalance(consumerAcc.Addr, iprpcFunds.MulInt(math.NewInt(2))) + require.NoError(ts.T, err) + _, err = ts.TxRewardsFundIprpc(consumer, mockSpec2, 2, iprpcFunds) + require.NoError(ts.T, err) + + // make a provider service an IPRPC eligible consumer and advance month + relay := ts.SendRelay(p1, consumerAcc, []string{ts.specs[1].Index}, 100) + _, err = ts.Servers.PairingServer.RelayPayment(ts.GoCtx, &relay) + ts.AdvanceEpoch() + require.NoError(t, err) + ts.AdvanceMonths(1).AdvanceEpoch() + + // check rewards - should be only from first funding (=iprpcFunds) + res, err := ts.QueryDualstakingDelegatorRewards(p1, p1, mockSpec2) + require.NoError(t, err) + require.True(t, iprpcFunds.Sub(minIprpcCost).IsEqual(res.Rewards[0].Amount)) + + // make a provider service an IPRPC eligible consumer and advance month again + relay = ts.SendRelay(p1, consumerAcc, []string{ts.specs[1].Index}, 100) + _, err = ts.Servers.PairingServer.RelayPayment(ts.GoCtx, &relay) + ts.AdvanceEpoch() + require.NoError(t, err) + ts.AdvanceMonths(1).AdvanceEpoch() + + // check rewards - should be only from first + second funding (=iprpcFunds*3) + res, err = ts.QueryDualstakingDelegatorRewards(p1, p1, mockSpec2) + require.NoError(t, err) + require.True(t, iprpcFunds.Sub(minIprpcCost).MulInt(math.NewInt(3)).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 +// Scenarios: +// 1. fund TX with the minimum cost available -> TX success +// 2. assume min cost = 100ulava, fund TX with 50ulava and 200ibc -> TX fails (ibc "has enough funds") +// 3. fund TX without the minimum cost available -> TX fails +// 4. fund TX with the minimum cost but creator doesn't have enough balance for the funding -> TX fails +func TestIprpcMinCost(t *testing.T) { + ts := newTester(t, true) + ts.setupForIprpcTests(false) + consumerAcc, consumer := ts.GetAccount(common.CONSUMER, 0) + err := ts.Keepers.BankKeeper.AddToBalance(consumerAcc.Addr, sdk.NewCoins(sdk.NewCoin(ibcDenom, sdk.NewInt(500)))) + + _, poorConsumer := ts.AddAccount(common.CONSUMER, 1, minIprpcCost.Amount.Int64()-10) + + testCases := []struct { + name string + creator string + fund sdk.Coins + success bool + }{ + { + name: "Happy flow - creator with enough funds and above min iprpc cost", + creator: consumer, + fund: sdk.NewCoins(minIprpcCost.AddAmount(sdk.NewInt(10))), + success: true, + }, + { + name: "fund without min iprpc cost", + creator: consumer, + fund: sdk.NewCoins(minIprpcCost.SubAmount(sdk.NewInt(10))), + success: false, + }, + { + name: "fund with other denom above min iprpc cost", + creator: consumer, + fund: sdk.NewCoins(sdk.NewCoin(ibcDenom, minIprpcCost.Amount.AddRaw(10))), + success: false, + }, + { + name: "insufficient balance for fund", + creator: poorConsumer, + fund: sdk.NewCoins(minIprpcCost.AddAmount(sdk.NewInt(10))), + success: false, + }, + } + + for _, tt := range testCases { + t.Run(tt.name, func(t *testing.T) { + _, err = ts.TxRewardsFundIprpc(tt.creator, mockSpec2, 1, tt.fund) + if tt.success { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} + +// TestIprpcEligibleSubscriptions tests that IPRPC CU is counted only if serviced an eligible subscription +// Scenarios: +// 0. assume two providers: p1, p2 and two consumers: c1, c2. Only c1 is IPRPC eligible +// 1. p1 provides service for both consumers, p2 provides service for c1 -> IPRPC reward should divide equally between p1 and p2 +// 2. both providers provide service for c2 -> No IPRPC rewards should be given +func TestIprpcEligibleSubscriptions(t *testing.T) { + ts := newTester(t, true) + ts.setupForIprpcTests(true) // setup creates consumers and providers and funds IPRPC pool for mock2 spec + + c1Acc, c1 := ts.GetAccount(common.CONSUMER, 0) + c2Acc, _ := ts.GetAccount(common.CONSUMER, 1) + _, p1 := ts.GetAccount(common.PROVIDER, 0) + _, p2 := ts.GetAccount(common.PROVIDER, 1) + + // p1 provides service for both consumers, p2 provides service for c1 + msg := ts.SendRelay(p1, c1Acc, []string{mockSpec2}, 100) + _, err := ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) + require.NoError(t, err) + + msg = ts.SendRelay(p1, c2Acc, []string{mockSpec2}, 100) + _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) + require.NoError(t, err) + + msg = ts.SendRelay(p2, c1Acc, []string{mockSpec2}, 100) + _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) + require.NoError(t, err) + + // check expected reward for each provider, it should be equal (the service for c1 was equal) + res1, err := ts.QueryRewardsIprpcProviderRewardEstimation(p1) + require.NoError(t, err) + res2, err := ts.QueryRewardsIprpcProviderRewardEstimation(p2) + require.NoError(t, err) + require.True(t, res1.SpecFunds[0].Fund.IsEqual(res2.SpecFunds[0].Fund)) + require.True(t, iprpcFunds.Sub(minIprpcCost).QuoInt(sdk.NewInt(2)).IsEqual(res1.SpecFunds[0].Fund)) + + // fund the pool again (advance month to apply) + _, err = ts.TxRewardsFundIprpc(c1, mockSpec2, 1, sdk.NewCoins(minIprpcCost.AddAmount(sdk.NewInt(10)))) + require.NoError(ts.T, err) + ts.AdvanceMonths(1).AdvanceEpoch() + + // provide service only for c2 + msg = ts.SendRelay(p1, c2Acc, []string{mockSpec2}, 100) + _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) + require.NoError(t, err) + + msg = ts.SendRelay(p2, c2Acc, []string{mockSpec2}, 100) + _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) + require.NoError(t, err) + + // check none of the providers should get rewards + res1, err = ts.QueryRewardsIprpcProviderRewardEstimation(p1) + require.NoError(t, err) + res2, err = ts.QueryRewardsIprpcProviderRewardEstimation(p2) + require.NoError(t, err) + require.Len(t, res1.SpecFunds, 0) + require.Len(t, res2.SpecFunds, 0) + + // advance another month and see there are still no rewards + ts.AdvanceMonths(1).AdvanceEpoch() + res1, err = ts.QueryRewardsIprpcProviderRewardEstimation(p1) + require.NoError(t, err) + res2, err = ts.QueryRewardsIprpcProviderRewardEstimation(p2) + require.NoError(t, err) + require.Len(t, res1.SpecFunds, 0) + require.Len(t, res2.SpecFunds, 0) +} + +// TestMultipleIprpcSpec checks that rewards are distributed correctly when multiple specs are configured in the IPRPC pool +// Scenarios: +// 0. IPRPC pool is funded for two specs for different periods and different denom (some are the same) +// 1. two providers provide service for consumer on 3 specs, two of them are the IPRPC ones -> they get rewarded relative to their serviced CU on each spec +func TestMultipleIprpcSpec(t *testing.T) { + ts := newTester(t, true) + ts.setupForIprpcTests(false) // creates consumers and providers staked on two stakes + + c1Acc, c1 := ts.GetAccount(common.CONSUMER, 0) + _, p1 := ts.GetAccount(common.PROVIDER, 0) + _, p2 := ts.GetAccount(common.PROVIDER, 1) + + // add another spec and stake the providers + mockSpec3 := "mock3" + spec3 := common.CreateMockSpec() + spec3.Index = mockSpec3 + spec3.Name = mockSpec3 + ts.specs = append(ts.specs, ts.AddSpec(mockSpec3, spec3).Spec(mockSpec3)) + err := ts.StakeProvider(p1, ts.specs[2], testStake) + require.NoError(ts.T, err) + err = ts.StakeProvider(p2, ts.specs[2], testStake) + require.NoError(ts.T, err) + + // fund iprpc pool for mock2 spec for 1 months + duration := uint64(1) + mock2Fund := sdk.NewCoin(ts.BondDenom(), sdk.NewInt(1700)) + _, err = ts.TxRewardsFundIprpc(c1, mockSpec2, duration, sdk.NewCoins(mock2Fund.Add(minIprpcCost))) + require.NoError(t, err) + + // fund iprpc pool for mock3 spec for 3 months + duration = uint64(3) + mock3Fund := sdk.NewCoin(ts.BondDenom(), sdk.NewInt(400)) + _, err = ts.TxRewardsFundIprpc(c1, mockSpec3, duration, sdk.NewCoins(mock3Fund.Add(minIprpcCost))) + require.NoError(t, err) + + // advance month and epoch to apply pairing and iprpc fund + ts.AdvanceMonths(1) + ts.AdvanceEpoch() + + // make both providers service the consumer on 3 specs, only 2 are funded by IPRPC + nonIprpcSpec := ts.specs[0].Index + type relayData struct { + provider string + spec string + cu uint64 + } + relaysData := []relayData{ + {provider: p1, spec: nonIprpcSpec, cu: 100}, + {provider: p1, spec: mockSpec2, cu: 200}, + {provider: p1, spec: mockSpec3, cu: 300}, + {provider: p2, spec: nonIprpcSpec, cu: 700}, + {provider: p2, spec: mockSpec2, cu: 200}, + {provider: p2, spec: mockSpec3, cu: 300}, + } + for _, rd := range relaysData { + msg := ts.SendRelay(rd.provider, c1Acc, []string{rd.spec}, rd.cu) + _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) + require.NoError(t, err) + } + + // p1 total CU: 600, p2 total CU: 1200 -> if the rewards were divided by total CU (wrong) the rewards ratio should've been 1:2 + // p1 total iprpc CU: 500, p2 total iprpc CU: 500 -> if the rewards were divided by total iprpc CU the rewards should be equal + res1, err := ts.QueryRewardsIprpcProviderRewardEstimation(p1) + require.NoError(t, err) + res2, err := ts.QueryRewardsIprpcProviderRewardEstimation(p2) + require.NoError(t, err) + require.Equal(t, len(res1.SpecFunds), len(res2.SpecFunds)) + responses := []*rewardstypes.QueryIprpcProviderRewardEstimationResponse{res1, res2} + for _, res := range responses { + for _, sf := range res.SpecFunds { + switch sf.Spec { + case mockSpec2: + expectedReward := sdk.NewCoins(mock2Fund).QuoInt(sdk.NewInt(2)) + require.True(t, expectedReward.IsEqual(sf.Fund)) + case mockSpec3: + expectedReward := sdk.NewCoins(mock3Fund).QuoInt(sdk.NewInt(2)) + require.True(t, expectedReward.IsEqual(sf.Fund)) + } + } + } +} + +// 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 +// 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 +func TestIprpcRewardWithZeroSubRewards(t *testing.T) { + ts := newTester(t, true) + ts.setupForIprpcTests(true) // create a consumer and buys subscription + funds iprpc + + c1Acc, _ := ts.GetAccount(common.CONSUMER, 0) + _, p1 := ts.GetAccount(common.PROVIDER, 0) + _, p2 := ts.GetAccount(common.PROVIDER, 1) + + // make community participation percentage to be 100% to make the provider not get rewarded for its service later + distParams := distributiontypes.DefaultParams() + distParams.CommunityTax = sdk.OneDec() + err := ts.Keepers.Distribution.SetParams(ts.Ctx, distParams) + require.NoError(t, err) + + // make providers service the IPRPC eligible consumer + msg := ts.SendRelay(p1, c1Acc, []string{mockSpec2}, 100) + _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) + require.NoError(t, err) + + msg = ts.SendRelay(p2, c1Acc, []string{mockSpec2}, 400) + _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) + require.NoError(t, err) + + // advance month to trigger monthly iprpc reward + blocksToSave to trigger sub rewards + ts.AdvanceMonths(1) + ts.AdvanceEpoch() + ts.AdvanceBlocks(ts.BlocksToSave() + 1) + + // check provider rewards (should be only expected IPRPC rewards) + p1ExpectedReward := iprpcFunds.Sub(minIprpcCost).QuoInt(sdk.NewInt(5)) + res1, err := ts.QueryDualstakingDelegatorRewards(p1, p1, mockSpec2) + require.NoError(t, err) + require.True(t, p1ExpectedReward.IsEqual(res1.Rewards[0].Amount)) + + p2ExpectedReward := p1ExpectedReward.MulInt(sdk.NewInt(4)) + res2, err := ts.QueryDualstakingDelegatorRewards(p2, p2, mockSpec2) + require.NoError(t, err) + require.True(t, p2ExpectedReward.IsEqual(res2.Rewards[0].Amount)) +} + +// TestMinIprpcCostForSeveralMonths checks that if a user sends fund=1.1*minIprpcCost with duration=2 +// the TX succeeds (checks that the min iprpc cost check that per month there is enough funds) +func TestMinIprpcCostForSeveralMonths(t *testing.T) { + ts := newTester(t, true) + ts.setupForIprpcTests(false) + consumerAcc, consumer := ts.GetAccount(common.CONSUMER, 0) + + // fund iprpc pool + err := ts.Keepers.BankKeeper.AddToBalance(consumerAcc.Addr, iprpcFunds.MulInt(math.NewInt(3))) + require.NoError(ts.T, err) + _, err = ts.TxRewardsFundIprpc(consumer, mockSpec2, 2, iprpcFunds.MulInt(math.NewInt(110)).QuoInt(math.NewInt(100))) + require.NoError(ts.T, err) +} diff --git a/x/rewards/keeper/pool_test.go b/x/rewards/keeper/pool_test.go index f1fccf4c2c..ab18224d7a 100644 --- a/x/rewards/keeper/pool_test.go +++ b/x/rewards/keeper/pool_test.go @@ -37,8 +37,6 @@ import ( // 1. The allocation pool has the expected allocated funds minus one block reward // 2. The distribution pool has the expected monthly quota minus one block reward // 3. The fee collector has one block reward -// -// the validator got rewards func TestRewardsModuleSetup(t *testing.T) { ts := newTester(t, false) lifetime := int64(types.RewardsAllocationPoolsLifetime) @@ -64,6 +62,8 @@ func TestRewardsModuleSetup(t *testing.T) { require.Equal(t, allocationPoolBalance*(lifetime-1)/lifetime, pool.Balance.AmountOf(ts.BondDenom()).Int64()) case string(types.ValidatorsRewardsDistributionPoolName): require.Equal(t, (allocationPoolBalance/lifetime)-blockReward, pool.Balance.AmountOf(ts.BondDenom()).Int64()) + case string(types.IprpcPoolName): + require.True(t, pool.Balance.Empty()) } } diff --git a/x/rewards/keeper/providers.go b/x/rewards/keeper/providers.go index cc22684c6b..0d7cfc62a1 100644 --- a/x/rewards/keeper/providers.go +++ b/x/rewards/keeper/providers.go @@ -60,7 +60,7 @@ func (k Keeper) distributeMonthlyBonusRewards(ctx sdk.Context) { specCuMap := map[string]types.SpecCuType{} // spec -> specCu for _, spec := range specs { // all providers basepays and the total basepay of the spec - basepays, totalbasepay := k.specProvidersBasePay(ctx, spec.ChainID) + basepays, totalbasepay := k.specProvidersBasePay(ctx, spec.ChainID, true) if len(basepays) == 0 { continue } @@ -167,8 +167,14 @@ func (k Keeper) specEmissionParts(ctx sdk.Context) (emissions []types.SpecEmissi return emissions } -func (k Keeper) specProvidersBasePay(ctx sdk.Context, chainID string) ([]types.BasePayWithIndex, math.Int) { - basepays := k.popAllBasePayForChain(ctx, chainID) +func (k Keeper) specProvidersBasePay(ctx sdk.Context, chainID string, pop bool) ([]types.BasePayWithIndex, math.Int) { + var basepays []types.BasePayWithIndex + if pop { + basepays = k.popAllBasePayForChain(ctx, chainID) + } else { + basepays = k.getAllBasePayForChain(ctx, chainID, "") // getting all basepays with chainID (for all providers) + } + totalBasePay := math.ZeroInt() for _, basepay := range basepays { totalBasePay = totalBasePay.Add(basepay.Total) diff --git a/x/rewards/keeper/providers_test.go b/x/rewards/keeper/providers_test.go index c2ed44c47d..abbeba4e41 100644 --- a/x/rewards/keeper/providers_test.go +++ b/x/rewards/keeper/providers_test.go @@ -18,7 +18,7 @@ func TestZeroProvidersRewards(t *testing.T) { ts := newTester(t, true) providerAcc, _ := ts.AddAccount(common.PROVIDER, 1, testBalance) - err := ts.StakeProvider(providerAcc.Addr.String(), ts.spec, testBalance) + err := ts.StakeProvider(providerAcc.Addr.String(), ts.specs[0], testBalance) require.NoError(t, err) ts.AdvanceEpoch() @@ -51,7 +51,7 @@ func TestBasicBoostProvidersRewards(t *testing.T) { ts := newTester(t, true) providerAcc, _ := ts.AddAccount(common.PROVIDER, 1, testBalance) - err := ts.StakeProvider(providerAcc.Addr.String(), ts.spec, testBalance) + err := ts.StakeProvider(providerAcc.Addr.String(), ts.specs[0], testBalance) require.NoError(t, err) ts.AdvanceEpoch() @@ -62,7 +62,7 @@ func TestBasicBoostProvidersRewards(t *testing.T) { baserewards := uint64(100) // the rewards by the subscription will be limited by LIMIT_TOKEN_PER_CU - msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.spec.Index}, baserewards) + msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.specs[0].Index}, baserewards) _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) @@ -96,7 +96,7 @@ func TestSpecAllocationProvidersRewards(t *testing.T) { ts := newTester(t, true) providerAcc, _ := ts.AddAccount(common.PROVIDER, 1, testBalance) - err := ts.StakeProvider(providerAcc.Addr.String(), ts.spec, testBalance) + err := ts.StakeProvider(providerAcc.Addr.String(), ts.specs[0], testBalance) require.NoError(t, err) ts.AdvanceEpoch() @@ -105,7 +105,7 @@ func TestSpecAllocationProvidersRewards(t *testing.T) { _, err = ts.TxSubscriptionBuy(consumerAcc.Addr.String(), consumerAcc.Addr.String(), ts.plan.Index, 1, false, false) require.NoError(t, err) - msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.spec.Index}, ts.plan.Price.Amount.Uint64()) + msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.specs[0].Index}, ts.plan.Price.Amount.Uint64()) _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) @@ -140,7 +140,7 @@ func TestProvidersDiminishingRewards(t *testing.T) { ts := newTester(t, true) providerAcc, _ := ts.AddAccount(common.PROVIDER, 1, testBalance) - err := ts.StakeProvider(providerAcc.Addr.String(), ts.spec, testBalance) + err := ts.StakeProvider(providerAcc.Addr.String(), ts.specs[0], testBalance) require.NoError(t, err) ts.AdvanceEpoch() @@ -150,7 +150,7 @@ func TestProvidersDiminishingRewards(t *testing.T) { _, err = ts.TxSubscriptionBuy(consumerAcc.Addr.String(), consumerAcc.Addr.String(), ts.plan.Index, 1, false, false) require.NoError(t, err) - msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.spec.Index}, ts.plan.Price.Amount.Uint64()) + msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.specs[0].Index}, ts.plan.Price.Amount.Uint64()) _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) } @@ -189,7 +189,7 @@ func TestProvidersEndRewards(t *testing.T) { ts := newTester(t, true) providerAcc, _ := ts.AddAccount(common.PROVIDER, 1, testBalance) - err := ts.StakeProvider(providerAcc.Addr.String(), ts.spec, testBalance) + err := ts.StakeProvider(providerAcc.Addr.String(), ts.specs[0], testBalance) require.NoError(t, err) ts.AdvanceEpoch() @@ -199,7 +199,7 @@ func TestProvidersEndRewards(t *testing.T) { _, err = ts.TxSubscriptionBuy(consumerAcc.Addr.String(), consumerAcc.Addr.String(), ts.plan.Index, 1, false, false) require.NoError(t, err) - msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.spec.Index}, ts.plan.Price.Amount.Uint64()) + msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.specs[0].Index}, ts.plan.Price.Amount.Uint64()) _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) } @@ -233,14 +233,14 @@ func TestProvidersEndRewards(t *testing.T) { // this means that no matter how much rewards the providers in this spec will get, they will get 0 bonus rewards func Test2SpecsZeroShares(t *testing.T) { ts := newTester(t, true) - spec2 := ts.spec + spec2 := ts.specs[0] spec2.Index = "mock2" spec2.Name = spec2.Index spec2.Shares = 0 ts.AddSpec(spec2.Index, spec2) providerAcc, _ := ts.AddAccount(common.PROVIDER, 1, 2*testBalance) - err := ts.StakeProvider(providerAcc.Addr.String(), ts.spec, testBalance) + err := ts.StakeProvider(providerAcc.Addr.String(), ts.specs[0], testBalance) require.NoError(t, err) err = ts.StakeProvider(providerAcc.Addr.String(), spec2, testBalance) @@ -252,7 +252,7 @@ func Test2SpecsZeroShares(t *testing.T) { _, err = ts.TxSubscriptionBuy(consumerAcc.Addr.String(), consumerAcc.Addr.String(), ts.plan.Index, 1, false, false) require.NoError(t, err) - msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.spec.Index}, ts.plan.Price.Amount.Uint64()) + msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.specs[0].Index}, ts.plan.Price.Amount.Uint64()) _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) @@ -287,7 +287,7 @@ func Test2SpecsZeroShares(t *testing.T) { require.NoError(t, err) require.Len(t, res.Rewards, 1) require.Equal(t, distBalance.QuoRaw(int64(ts.Keepers.Rewards.MaxRewardBoost(ts.Ctx))), res.Rewards[0].Amount.AmountOf(ts.BondDenom())) - require.Equal(t, res.Rewards[0].ChainId, ts.spec.Index) + require.Equal(t, res.Rewards[0].ChainId, ts.specs[0].Index) _, err = ts.TxDualstakingClaimRewards(providerAcc.Addr.String(), providerAcc.Addr.String()) require.NoError(t, err) } @@ -297,14 +297,14 @@ func Test2SpecsZeroShares(t *testing.T) { // the bonus for the provider with double the shares should be double than the other provider func Test2SpecsDoubleShares(t *testing.T) { ts := newTester(t, true) - spec2 := ts.spec + spec2 := ts.specs[0] spec2.Index = "mock2" spec2.Name = spec2.Index spec2.Shares *= 2 ts.AddSpec(spec2.Index, spec2) providerAcc, _ := ts.AddAccount(common.PROVIDER, 1, 2*testBalance) - err := ts.StakeProvider(providerAcc.Addr.String(), ts.spec, testBalance) + err := ts.StakeProvider(providerAcc.Addr.String(), ts.specs[0], testBalance) require.NoError(t, err) err = ts.StakeProvider(providerAcc.Addr.String(), spec2, testBalance) @@ -316,7 +316,7 @@ func Test2SpecsDoubleShares(t *testing.T) { _, err = ts.TxSubscriptionBuy(consumerAcc.Addr.String(), consumerAcc.Addr.String(), ts.plan.Index, 1, false, false) require.NoError(t, err) - msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.spec.Index}, ts.plan.Price.Amount.Uint64()) + msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.specs[0].Index}, ts.plan.Price.Amount.Uint64()) _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) @@ -360,15 +360,15 @@ func TestBonusRewards3Providers(t *testing.T) { ts := newTester(t, true) providerAcc1, _ := ts.AddAccount(common.PROVIDER, 1, 2*testBalance) - err := ts.StakeProvider(providerAcc1.Addr.String(), ts.spec, testBalance) + err := ts.StakeProvider(providerAcc1.Addr.String(), ts.specs[0], testBalance) require.NoError(t, err) providerAcc2, _ := ts.AddAccount(common.PROVIDER, 2, 2*testBalance) - err = ts.StakeProvider(providerAcc2.Addr.String(), ts.spec, 2*testBalance) + err = ts.StakeProvider(providerAcc2.Addr.String(), ts.specs[0], 2*testBalance) require.NoError(t, err) providerAcc3, _ := ts.AddAccount(common.PROVIDER, 3, 3*testBalance) - err = ts.StakeProvider(providerAcc3.Addr.String(), ts.spec, 3*testBalance) + err = ts.StakeProvider(providerAcc3.Addr.String(), ts.specs[0], 3*testBalance) require.NoError(t, err) ts.AdvanceEpoch() @@ -377,15 +377,15 @@ func TestBonusRewards3Providers(t *testing.T) { _, err = ts.TxSubscriptionBuy(consumerAcc.Addr.String(), consumerAcc.Addr.String(), ts.plan.Index, 1, false, false) require.NoError(t, err) - msg := ts.SendRelay(providerAcc1.Addr.String(), consumerAcc, []string{ts.spec.Index}, ts.plan.Price.Amount.Uint64()/2) + msg := ts.SendRelay(providerAcc1.Addr.String(), consumerAcc, []string{ts.specs[0].Index}, ts.plan.Price.Amount.Uint64()/2) _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) - msg = ts.SendRelay(providerAcc2.Addr.String(), consumerAcc, []string{ts.spec.Index}, ts.plan.Price.Amount.Uint64()) + msg = ts.SendRelay(providerAcc2.Addr.String(), consumerAcc, []string{ts.specs[0].Index}, ts.plan.Price.Amount.Uint64()) _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) - msg = ts.SendRelay(providerAcc3.Addr.String(), consumerAcc, []string{ts.spec.Index}, ts.plan.Price.Amount.Uint64()*2) + msg = ts.SendRelay(providerAcc3.Addr.String(), consumerAcc, []string{ts.specs[0].Index}, ts.plan.Price.Amount.Uint64()*2) _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) @@ -464,7 +464,7 @@ func TestValidatorsAndCommunityParticipation(t *testing.T) { // create provider+comsumer, send relay and send relay payment TX providerAcc, _ := ts.AddAccount(common.PROVIDER, 1, testBalance) - err = ts.StakeProvider(providerAcc.Addr.String(), ts.spec, testBalance) + err = ts.StakeProvider(providerAcc.Addr.String(), ts.specs[0], testBalance) require.NoError(t, err) ts.AdvanceEpoch() @@ -475,7 +475,7 @@ func TestValidatorsAndCommunityParticipation(t *testing.T) { baserewards := uint64(100) // the rewards by the subscription will be limited by LIMIT_TOKEN_PER_CU - msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.spec.Index}, baserewards) + msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.specs[0].Index}, baserewards) _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) @@ -509,7 +509,7 @@ func TestValidatorsAndCommunityParticipation(t *testing.T) { func TestBonusReward49months(t *testing.T) { ts := newTester(t, true) providerAcc, _ := ts.AddAccount(common.PROVIDER, 1, testBalance) - err := ts.StakeProvider(providerAcc.Addr.String(), ts.spec, testBalance) + err := ts.StakeProvider(providerAcc.Addr.String(), ts.specs[0], testBalance) require.NoError(t, err) ts.AdvanceEpoch() @@ -525,7 +525,7 @@ func TestBonusReward49months(t *testing.T) { baserewards := uint64(100) // the rewards by the subscription will be limited by LIMIT_TOKEN_PER_CU - msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.spec.Index}, baserewards) + msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.specs[0].Index}, baserewards) _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) @@ -559,7 +559,7 @@ func TestBonusRewardsEquall5Providers(t *testing.T) { for i := 0; i < count; i++ { providerAcc, _ := ts.AddAccount(common.PROVIDER, 1, testBalance) - err := ts.StakeProvider(providerAcc.Addr.String(), ts.spec, testBalance) + err := ts.StakeProvider(providerAcc.Addr.String(), ts.specs[0], testBalance) providerAccs = append(providerAccs, providerAcc) require.NoError(t, err) @@ -574,7 +574,7 @@ func TestBonusRewardsEquall5Providers(t *testing.T) { for _, providerAcc := range providerAccs { for _, consAcc := range consAccs { - msg := ts.SendRelay(providerAcc.Addr.String(), consAcc, []string{ts.spec.Index}, ts.plan.Price.Amount.Uint64()/uint64(count)/1000) + msg := ts.SendRelay(providerAcc.Addr.String(), consAcc, []string{ts.specs[0].Index}, ts.plan.Price.Amount.Uint64()/uint64(count)/1000) _, err := ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) } @@ -622,7 +622,7 @@ func TestBonusRewards5Providers(t *testing.T) { for i := 0; i < count; i++ { providerAcc, _ := ts.AddAccount(common.PROVIDER, 1, testBalance) - err := ts.StakeProvider(providerAcc.Addr.String(), ts.spec, testBalance) + err := ts.StakeProvider(providerAcc.Addr.String(), ts.specs[0], testBalance) providerAccs = append(providerAccs, providerAcc) require.NoError(t, err) @@ -635,13 +635,13 @@ func TestBonusRewards5Providers(t *testing.T) { for i := 1; i < 10; i++ { ts.AdvanceEpoch() - msg := ts.SendRelay(providerAccs[0].Addr.String(), consAccs[0], []string{ts.spec.Index}, ts.plan.Price.Amount.Uint64()/100) + msg := ts.SendRelay(providerAccs[0].Addr.String(), consAccs[0], []string{ts.specs[0].Index}, ts.plan.Price.Amount.Uint64()/100) _, err := ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) for _, providerAcc := range providerAccs[1:] { for _, consAcc := range consAccs[1:] { - msg := ts.SendRelay(providerAcc.Addr.String(), consAcc, []string{ts.spec.Index}, ts.plan.Price.Amount.Uint64()/uint64(count)/100) + msg := ts.SendRelay(providerAcc.Addr.String(), consAcc, []string{ts.specs[0].Index}, ts.plan.Price.Amount.Uint64()/uint64(count)/100) _, err := ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) } @@ -708,7 +708,7 @@ func TestCommunityTaxOne(t *testing.T) { // create provider+comsumer, send relay and send relay payment TX providerAcc, _ := ts.AddAccount(common.PROVIDER, 1, testBalance) - err = ts.StakeProvider(providerAcc.Addr.String(), ts.spec, testBalance) + err = ts.StakeProvider(providerAcc.Addr.String(), ts.specs[0], testBalance) require.NoError(t, err) ts.AdvanceEpoch() @@ -719,7 +719,7 @@ func TestCommunityTaxOne(t *testing.T) { baserewards := uint64(100) // the rewards by the subscription will be limited by LIMIT_TOKEN_PER_CU - msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.spec.Index}, baserewards) + msg := ts.SendRelay(providerAcc.Addr.String(), consumerAcc, []string{ts.specs[0].Index}, baserewards) _, err = ts.TxPairingRelayPayment(msg.Creator, msg.Relays...) require.NoError(t, err) diff --git a/x/rewards/types/iprpc.pb.go b/x/rewards/types/iprpc.pb.go index 123a2982d6..7349489ce8 100644 --- a/x/rewards/types/iprpc.pb.go +++ b/x/rewards/types/iprpc.pb.go @@ -25,7 +25,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// list object that holds the +// object that holds the list for iprpc funcs for a specific month id type IprpcReward struct { Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` SpecFunds []Specfund `protobuf:"bytes,2,rep,name=spec_funds,json=specFunds,proto3" json:"spec_funds"` diff --git a/x/rewards/types/query.pb.go b/x/rewards/types/query.pb.go index ff126b98e2..dfd1109e68 100644 --- a/x/rewards/types/query.pb.go +++ b/x/rewards/types/query.pb.go @@ -604,6 +604,202 @@ func (m *QueryProviderRewardResponse) GetRewards() []RewardInfo { return nil } +// QueryIprpcProviderRewardEstimationRequest is request type for the Query/IprpcProviderRewardEstimation RPC method. +type QueryIprpcProviderRewardEstimationRequest struct { + Provider string `protobuf:"bytes,1,opt,name=provider,proto3" json:"provider,omitempty"` +} + +func (m *QueryIprpcProviderRewardEstimationRequest) Reset() { + *m = QueryIprpcProviderRewardEstimationRequest{} +} +func (m *QueryIprpcProviderRewardEstimationRequest) String() string { + return proto.CompactTextString(m) +} +func (*QueryIprpcProviderRewardEstimationRequest) ProtoMessage() {} +func (*QueryIprpcProviderRewardEstimationRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_15bce9a904340007, []int{12} +} +func (m *QueryIprpcProviderRewardEstimationRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIprpcProviderRewardEstimationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIprpcProviderRewardEstimationRequest.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 *QueryIprpcProviderRewardEstimationRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIprpcProviderRewardEstimationRequest.Merge(m, src) +} +func (m *QueryIprpcProviderRewardEstimationRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryIprpcProviderRewardEstimationRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIprpcProviderRewardEstimationRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIprpcProviderRewardEstimationRequest proto.InternalMessageInfo + +func (m *QueryIprpcProviderRewardEstimationRequest) GetProvider() string { + if m != nil { + return m.Provider + } + return "" +} + +// QueryIprpcProviderRewardEstimationResponse is response type for the Query/IprpcProviderRewardEstimation RPC method. +type QueryIprpcProviderRewardEstimationResponse struct { + SpecFunds []Specfund `protobuf:"bytes,1,rep,name=spec_funds,json=specFunds,proto3" json:"spec_funds"` +} + +func (m *QueryIprpcProviderRewardEstimationResponse) Reset() { + *m = QueryIprpcProviderRewardEstimationResponse{} +} +func (m *QueryIprpcProviderRewardEstimationResponse) String() string { + return proto.CompactTextString(m) +} +func (*QueryIprpcProviderRewardEstimationResponse) ProtoMessage() {} +func (*QueryIprpcProviderRewardEstimationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_15bce9a904340007, []int{13} +} +func (m *QueryIprpcProviderRewardEstimationResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIprpcProviderRewardEstimationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIprpcProviderRewardEstimationResponse.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 *QueryIprpcProviderRewardEstimationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIprpcProviderRewardEstimationResponse.Merge(m, src) +} +func (m *QueryIprpcProviderRewardEstimationResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryIprpcProviderRewardEstimationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIprpcProviderRewardEstimationResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIprpcProviderRewardEstimationResponse proto.InternalMessageInfo + +func (m *QueryIprpcProviderRewardEstimationResponse) GetSpecFunds() []Specfund { + if m != nil { + return m.SpecFunds + } + return nil +} + +// QueryIprpcSpecRewardRequest is request type for the Query/IprpcSpecReward RPC method. +type QueryIprpcSpecRewardRequest struct { + Spec string `protobuf:"bytes,1,opt,name=spec,proto3" json:"spec,omitempty"` +} + +func (m *QueryIprpcSpecRewardRequest) Reset() { *m = QueryIprpcSpecRewardRequest{} } +func (m *QueryIprpcSpecRewardRequest) String() string { return proto.CompactTextString(m) } +func (*QueryIprpcSpecRewardRequest) ProtoMessage() {} +func (*QueryIprpcSpecRewardRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_15bce9a904340007, []int{14} +} +func (m *QueryIprpcSpecRewardRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIprpcSpecRewardRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIprpcSpecRewardRequest.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 *QueryIprpcSpecRewardRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIprpcSpecRewardRequest.Merge(m, src) +} +func (m *QueryIprpcSpecRewardRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryIprpcSpecRewardRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIprpcSpecRewardRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIprpcSpecRewardRequest proto.InternalMessageInfo + +func (m *QueryIprpcSpecRewardRequest) GetSpec() string { + if m != nil { + return m.Spec + } + return "" +} + +// QueryIprpcSpecRewardResponse is response type for the Query/IprpcSpecReward RPC method. +type QueryIprpcSpecRewardResponse struct { + IprpcRewards []IprpcReward `protobuf:"bytes,1,rep,name=iprpc_rewards,json=iprpcRewards,proto3" json:"iprpc_rewards"` + CurrentMonthId uint64 `protobuf:"varint,2,opt,name=current_month_id,json=currentMonthId,proto3" json:"current_month_id,omitempty"` +} + +func (m *QueryIprpcSpecRewardResponse) Reset() { *m = QueryIprpcSpecRewardResponse{} } +func (m *QueryIprpcSpecRewardResponse) String() string { return proto.CompactTextString(m) } +func (*QueryIprpcSpecRewardResponse) ProtoMessage() {} +func (*QueryIprpcSpecRewardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_15bce9a904340007, []int{15} +} +func (m *QueryIprpcSpecRewardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIprpcSpecRewardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIprpcSpecRewardResponse.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 *QueryIprpcSpecRewardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIprpcSpecRewardResponse.Merge(m, src) +} +func (m *QueryIprpcSpecRewardResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryIprpcSpecRewardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIprpcSpecRewardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIprpcSpecRewardResponse proto.InternalMessageInfo + +func (m *QueryIprpcSpecRewardResponse) GetIprpcRewards() []IprpcReward { + if m != nil { + return m.IprpcRewards + } + return nil +} + +func (m *QueryIprpcSpecRewardResponse) GetCurrentMonthId() uint64 { + if m != nil { + return m.CurrentMonthId + } + return 0 +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "lavanet.lava.rewards.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "lavanet.lava.rewards.QueryParamsResponse") @@ -617,64 +813,81 @@ func init() { proto.RegisterType((*QueryProviderRewardRequest)(nil), "lavanet.lava.rewards.QueryProviderRewardRequest") proto.RegisterType((*RewardInfo)(nil), "lavanet.lava.rewards.RewardInfo") proto.RegisterType((*QueryProviderRewardResponse)(nil), "lavanet.lava.rewards.QueryProviderRewardResponse") + proto.RegisterType((*QueryIprpcProviderRewardEstimationRequest)(nil), "lavanet.lava.rewards.QueryIprpcProviderRewardEstimationRequest") + proto.RegisterType((*QueryIprpcProviderRewardEstimationResponse)(nil), "lavanet.lava.rewards.QueryIprpcProviderRewardEstimationResponse") + proto.RegisterType((*QueryIprpcSpecRewardRequest)(nil), "lavanet.lava.rewards.QueryIprpcSpecRewardRequest") + proto.RegisterType((*QueryIprpcSpecRewardResponse)(nil), "lavanet.lava.rewards.QueryIprpcSpecRewardResponse") } func init() { proto.RegisterFile("lavanet/lava/rewards/query.proto", fileDescriptor_15bce9a904340007) } var fileDescriptor_15bce9a904340007 = []byte{ - // 833 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcd, 0x6e, 0xf3, 0x44, - 0x14, 0x8d, 0xdb, 0xe6, 0xa7, 0x53, 0xa8, 0xc4, 0xb4, 0x52, 0x13, 0xa7, 0xb8, 0xc1, 0x14, 0x35, - 0x54, 0xaa, 0xdd, 0x96, 0x05, 0x12, 0x08, 0x09, 0x52, 0x36, 0x95, 0x40, 0x6a, 0x1d, 0x56, 0x6c, - 0xac, 0x89, 0x33, 0x49, 0x46, 0xb5, 0x3d, 0xae, 0x67, 0xd2, 0x52, 0x09, 0x09, 0x09, 0xc4, 0x82, - 0x1d, 0x12, 0x1b, 0xb6, 0x48, 0xac, 0x78, 0x92, 0x2e, 0x2b, 0xb1, 0x61, 0x05, 0xa8, 0xe5, 0x09, - 0x10, 0x0f, 0x80, 0x7c, 0x67, 0x9c, 0x26, 0xaa, 0x9b, 0x2f, 0xdf, 0xb7, 0xb2, 0x3d, 0x73, 0xee, - 0xb9, 0xe7, 0xdc, 0xb9, 0x77, 0x8c, 0x5a, 0x21, 0xb9, 0x22, 0x31, 0x95, 0x6e, 0xf6, 0x74, 0x53, - 0x7a, 0x4d, 0xd2, 0xbe, 0x70, 0x2f, 0xc7, 0x34, 0xbd, 0x71, 0x92, 0x94, 0x4b, 0x8e, 0x37, 0x35, - 0xc2, 0xc9, 0x9e, 0x8e, 0x46, 0x98, 0x9b, 0x43, 0x3e, 0xe4, 0x00, 0x70, 0xb3, 0x37, 0x85, 0x35, - 0xb7, 0x87, 0x9c, 0x0f, 0x43, 0xea, 0x92, 0x84, 0xb9, 0x24, 0x8e, 0xb9, 0x24, 0x92, 0xf1, 0x58, - 0xe8, 0xdd, 0xfd, 0x80, 0x8b, 0x88, 0x0b, 0xb7, 0x47, 0x04, 0x55, 0x29, 0xdc, 0xab, 0xa3, 0x1e, - 0x95, 0xe4, 0xc8, 0x4d, 0xc8, 0x90, 0xc5, 0x00, 0xd6, 0xd8, 0xb7, 0x0a, 0x75, 0x25, 0x24, 0x25, - 0x51, 0x4e, 0x67, 0x4d, 0xd3, 0xe5, 0x44, 0x01, 0x67, 0x9a, 0xc2, 0xde, 0x44, 0xf8, 0x3c, 0x4b, - 0x72, 0x06, 0x41, 0x1e, 0xbd, 0x1c, 0x53, 0x21, 0xed, 0x73, 0xb4, 0x31, 0xb3, 0x2a, 0x12, 0x1e, - 0x0b, 0x8a, 0x3f, 0x40, 0x15, 0x45, 0x5e, 0x37, 0x5a, 0x46, 0x7b, 0xed, 0x78, 0xdb, 0x29, 0xb2, - 0xed, 0xa8, 0xa8, 0xce, 0xca, 0xed, 0x9f, 0x3b, 0x25, 0x4f, 0x47, 0xd8, 0x1b, 0xe8, 0x0d, 0x45, - 0xc9, 0x79, 0x38, 0xc9, 0xf3, 0xbd, 0x81, 0x6a, 0xd9, 0xc2, 0x69, 0x3c, 0xe0, 0x18, 0xa3, 0x95, - 0x98, 0x44, 0x14, 0xb8, 0x57, 0x3d, 0x78, 0xc7, 0x14, 0x55, 0x7b, 0x24, 0x24, 0x71, 0x40, 0xeb, - 0x4b, 0xad, 0xe5, 0xf6, 0xda, 0x71, 0xc3, 0x51, 0x86, 0x9c, 0xcc, 0x90, 0xa3, 0x0d, 0x39, 0x27, - 0x9c, 0xc5, 0x9d, 0xc3, 0x2c, 0xdf, 0x6f, 0x7f, 0xed, 0xb4, 0x87, 0x4c, 0x8e, 0xc6, 0x3d, 0x27, - 0xe0, 0x91, 0xab, 0xdd, 0xab, 0xc7, 0x81, 0xe8, 0x5f, 0xb8, 0xf2, 0x26, 0xa1, 0x02, 0x02, 0x84, - 0x97, 0x73, 0xdb, 0xff, 0x1a, 0x79, 0x19, 0x94, 0xba, 0x89, 0xdf, 0x72, 0x92, 0x2d, 0xd4, 0x0d, - 0xc8, 0x6d, 0x3d, 0x63, 0x57, 0x1b, 0xd0, 0x86, 0x55, 0x08, 0xde, 0x45, 0xeb, 0x92, 0x45, 0xd4, - 0x97, 0xdc, 0x4f, 0xe9, 0x80, 0x85, 0x61, 0x7d, 0xa9, 0x65, 0xb4, 0x97, 0xbd, 0xd7, 0xb2, 0xd5, - 0x2f, 0xb8, 0x07, 0x6b, 0xf8, 0x43, 0x64, 0x52, 0x21, 0x59, 0x44, 0x24, 0xed, 0xfb, 0xbd, 0x90, - 0x07, 0x17, 0x62, 0x2a, 0x62, 0x19, 0x22, 0xb6, 0x26, 0x88, 0x0e, 0x00, 0x26, 0xc1, 0x1f, 0xa1, - 0x26, 0x09, 0x43, 0x1e, 0x40, 0x4b, 0xf8, 0x59, 0x5a, 0x3f, 0xe2, 0xb1, 0x1c, 0x09, 0x3f, 0xa4, - 0x03, 0x59, 0x5f, 0x81, 0xe8, 0xfa, 0x23, 0x24, 0x13, 0xfa, 0x39, 0x00, 0x3e, 0xa3, 0x03, 0x69, - 0x37, 0xd0, 0x16, 0x78, 0x06, 0x56, 0x0f, 0xcc, 0xe4, 0xe7, 0xd2, 0x45, 0xf5, 0xa7, 0x5b, 0xba, - 0x28, 0xef, 0xa3, 0x8a, 0x72, 0xae, 0x9b, 0x60, 0xce, 0x89, 0xe8, 0x0e, 0x50, 0x70, 0xbb, 0x89, - 0x1a, 0x40, 0xda, 0x1d, 0xf1, 0xeb, 0xd3, 0x24, 0x4d, 0x82, 0x4f, 0x89, 0x24, 0x79, 0xc6, 0x1f, - 0x0c, 0x64, 0x16, 0xed, 0x4e, 0x4e, 0xa2, 0x16, 0xb1, 0xd8, 0x0f, 0xb8, 0x90, 0x8b, 0xa6, 0xad, - 0x46, 0x2c, 0x3e, 0xe1, 0x42, 0x62, 0x17, 0x6d, 0xb0, 0x8c, 0xd0, 0x17, 0xe3, 0x9e, 0x08, 0x52, - 0x96, 0xc0, 0xb8, 0x41, 0x3f, 0xad, 0x7a, 0x18, 0xb6, 0xba, 0xd3, 0x3b, 0x76, 0x57, 0x4b, 0x39, - 0x4b, 0xf9, 0x15, 0xeb, 0xd3, 0x74, 0xa6, 0x36, 0xb8, 0x81, 0x6a, 0xc1, 0x88, 0xb0, 0xd8, 0x67, - 0x7d, 0xdd, 0xaa, 0x55, 0xf8, 0x3e, 0xed, 0x63, 0x13, 0xd5, 0x12, 0x1d, 0x03, 0xa7, 0xbd, 0xea, - 0x4d, 0xbe, 0xed, 0xaf, 0x11, 0x52, 0x3c, 0xd0, 0xeb, 0xaf, 0x46, 0x92, 0xd5, 0x9e, 0x44, 0x7c, - 0x1c, 0x4b, 0x68, 0x8d, 0x45, 0x6a, 0xaf, 0xe0, 0xb6, 0x8f, 0x9a, 0x85, 0x96, 0x74, 0x79, 0x3f, - 0x46, 0x55, 0xdd, 0xcd, 0xba, 0xd5, 0x5b, 0xc5, 0xad, 0xfe, 0xe8, 0x20, 0x2f, 0xb2, 0xde, 0x39, - 0xfe, 0xaf, 0x8c, 0xca, 0x90, 0x01, 0x7f, 0x67, 0xa0, 0x8a, 0xba, 0x01, 0x70, 0xbb, 0x98, 0xe5, - 0xe9, 0x85, 0x63, 0xbe, 0xbb, 0x00, 0x52, 0x69, 0xb5, 0x77, 0xbf, 0xfd, 0xfd, 0x9f, 0x9f, 0x96, - 0x2c, 0xbc, 0xed, 0xce, 0xb9, 0xfd, 0xf0, 0x37, 0xa8, 0x0c, 0xb3, 0x8c, 0xf7, 0xe6, 0x31, 0x4f, - 0xdd, 0x45, 0x66, 0xfb, 0xc5, 0x40, 0xad, 0xe0, 0x6d, 0x50, 0xf0, 0x26, 0x6e, 0x3e, 0xa3, 0x00, - 0xf2, 0xfe, 0x6c, 0xa0, 0xb5, 0xa9, 0xf1, 0xc1, 0x07, 0x73, 0xe8, 0x9f, 0x4e, 0xa0, 0xe9, 0x2c, - 0x0a, 0xd7, 0x9a, 0xf6, 0x41, 0xd3, 0x2e, 0xb6, 0x8b, 0x35, 0xc1, 0xd5, 0xe2, 0xab, 0x2f, 0xfc, - 0x8b, 0x81, 0x5e, 0x9f, 0x19, 0x33, 0xec, 0xce, 0xc9, 0x56, 0x34, 0xae, 0xe6, 0xe1, 0xe2, 0x01, - 0x5a, 0xe0, 0x01, 0x08, 0xdc, 0xc3, 0xef, 0x14, 0x0b, 0x14, 0x23, 0x7e, 0xed, 0xab, 0x31, 0xed, - 0x67, 0x8a, 0x7e, 0x35, 0xd0, 0xfa, 0x6c, 0xb3, 0xe2, 0x79, 0x39, 0x0b, 0x47, 0xd5, 0x3c, 0x7a, - 0x89, 0x88, 0xc5, 0x64, 0xe6, 0x93, 0xa8, 0x4b, 0xd9, 0xf9, 0xe4, 0xf6, 0xde, 0x32, 0xee, 0xee, - 0x2d, 0xe3, 0xef, 0x7b, 0xcb, 0xf8, 0xf1, 0xc1, 0x2a, 0xdd, 0x3d, 0x58, 0xa5, 0x3f, 0x1e, 0xac, - 0xd2, 0x97, 0x7b, 0x53, 0x7f, 0xa1, 0x19, 0xaa, 0xaf, 0x26, 0x64, 0xf0, 0x2b, 0xea, 0x55, 0xe0, - 0x47, 0xfc, 0xde, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x09, 0x8e, 0xb1, 0xb0, 0x65, 0x08, 0x00, + // 1041 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcf, 0x6f, 0xdc, 0x44, + 0x14, 0x8e, 0xf3, 0x3b, 0x2f, 0x6d, 0x80, 0x49, 0xa4, 0x6e, 0x9c, 0x74, 0x9b, 0x9a, 0xa0, 0x6c, + 0x23, 0xc5, 0x4e, 0x82, 0x54, 0x10, 0x08, 0x28, 0x09, 0x3f, 0x14, 0xa9, 0x48, 0xad, 0x97, 0x13, + 0x17, 0x6b, 0xd6, 0x3b, 0xbb, 0x6b, 0xd5, 0xf6, 0x38, 0x9e, 0xd9, 0x84, 0x0a, 0x2a, 0x24, 0x10, + 0x07, 0x24, 0x0e, 0x48, 0x48, 0x88, 0x2b, 0x12, 0x27, 0x4e, 0xfc, 0x19, 0x3d, 0x56, 0xe2, 0xc2, + 0x09, 0x50, 0xc2, 0x5f, 0xc0, 0x5f, 0x80, 0xe6, 0xcd, 0x78, 0xb3, 0x9b, 0x38, 0x9b, 0x6d, 0x4f, + 0x6b, 0xcf, 0x7c, 0xef, 0x7d, 0xdf, 0xf7, 0xe6, 0xcd, 0x5b, 0xc3, 0x5a, 0x4c, 0x8f, 0x68, 0xca, + 0xa4, 0xa7, 0x7e, 0xbd, 0x9c, 0x1d, 0xd3, 0xbc, 0x29, 0xbc, 0xc3, 0x2e, 0xcb, 0x1f, 0xbb, 0x59, + 0xce, 0x25, 0x27, 0x4b, 0x06, 0xe1, 0xaa, 0x5f, 0xd7, 0x20, 0xec, 0xa5, 0x36, 0x6f, 0x73, 0x04, + 0x78, 0xea, 0x49, 0x63, 0xed, 0xd5, 0x36, 0xe7, 0xed, 0x98, 0x79, 0x34, 0x8b, 0x3c, 0x9a, 0xa6, + 0x5c, 0x52, 0x19, 0xf1, 0x54, 0x98, 0xdd, 0xcd, 0x90, 0x8b, 0x84, 0x0b, 0xaf, 0x41, 0x05, 0xd3, + 0x14, 0xde, 0xd1, 0x4e, 0x83, 0x49, 0xba, 0xe3, 0x65, 0xb4, 0x1d, 0xa5, 0x08, 0x36, 0xd8, 0xdb, + 0xa5, 0xba, 0x32, 0x9a, 0xd3, 0xa4, 0x48, 0x57, 0x2e, 0x3d, 0xca, 0xf2, 0x2c, 0x34, 0x88, 0x6a, + 0x3f, 0x61, 0x41, 0x15, 0xf2, 0xc8, 0x90, 0x38, 0x4b, 0x40, 0x1e, 0x2a, 0x19, 0x0f, 0x30, 0xad, + 0xcf, 0x0e, 0xbb, 0x4c, 0x48, 0xe7, 0x21, 0x2c, 0x0e, 0xac, 0x8a, 0x8c, 0xa7, 0x82, 0x91, 0xb7, + 0x60, 0x5a, 0xd3, 0x57, 0xac, 0x35, 0xab, 0x36, 0xbf, 0xbb, 0xea, 0x96, 0x15, 0xc6, 0xd5, 0x51, + 0x7b, 0x93, 0x4f, 0xff, 0xba, 0x35, 0xe6, 0x9b, 0x08, 0x67, 0x11, 0x5e, 0xd1, 0x29, 0x39, 0x8f, + 0x7b, 0x3c, 0xdf, 0x5a, 0x30, 0xab, 0x16, 0x0e, 0xd2, 0x16, 0x27, 0x04, 0x26, 0x53, 0x9a, 0x30, + 0xcc, 0x3d, 0xe7, 0xe3, 0x33, 0x61, 0x30, 0xd3, 0xa0, 0x31, 0x4d, 0x43, 0x56, 0x19, 0x5f, 0x9b, + 0xa8, 0xcd, 0xef, 0x2e, 0xbb, 0xda, 0x90, 0xab, 0x0c, 0xb9, 0xc6, 0x90, 0xbb, 0xcf, 0xa3, 0x74, + 0x6f, 0x5b, 0xf1, 0xfd, 0xf6, 0xf7, 0xad, 0x5a, 0x3b, 0x92, 0x9d, 0x6e, 0xc3, 0x0d, 0x79, 0xe2, + 0x19, 0xf7, 0xfa, 0x67, 0x4b, 0x34, 0x1f, 0x79, 0xf2, 0x71, 0xc6, 0x04, 0x06, 0x08, 0xbf, 0xc8, + 0xed, 0xfc, 0x67, 0x15, 0x65, 0xd0, 0xea, 0x7a, 0x7e, 0xa7, 0x32, 0xb5, 0x50, 0xb1, 0x90, 0xbb, + 0x7a, 0x89, 0x5d, 0x63, 0xc0, 0x18, 0xd6, 0x21, 0x64, 0x1d, 0x16, 0x64, 0x94, 0xb0, 0x40, 0xf2, + 0x20, 0x67, 0xad, 0x28, 0x8e, 0x2b, 0xe3, 0x6b, 0x56, 0x6d, 0xc2, 0xbf, 0xa6, 0x56, 0x3f, 0xe5, + 0x3e, 0xae, 0x91, 0xb7, 0xc1, 0x66, 0x42, 0x46, 0x09, 0x95, 0xac, 0x19, 0x34, 0x62, 0x1e, 0x3e, + 0x12, 0x7d, 0x11, 0x13, 0x18, 0x71, 0xa3, 0x87, 0xd8, 0x43, 0x40, 0x2f, 0xf8, 0x1d, 0x58, 0xa1, + 0x71, 0xcc, 0x43, 0x6c, 0x9a, 0x40, 0xd1, 0x06, 0x09, 0x4f, 0x65, 0x47, 0x04, 0x31, 0x6b, 0xc9, + 0xca, 0x24, 0x46, 0x57, 0xce, 0x20, 0x4a, 0xe8, 0x27, 0x08, 0xb8, 0xcf, 0x5a, 0xd2, 0x59, 0x86, + 0x1b, 0xe8, 0x19, 0xb3, 0xfa, 0x68, 0xa6, 0x38, 0x97, 0x3a, 0x54, 0x2e, 0x6e, 0x99, 0xa2, 0xbc, + 0x01, 0xd3, 0xda, 0xb9, 0x69, 0x82, 0x21, 0x27, 0x62, 0x3a, 0x40, 0xc3, 0x9d, 0x15, 0x58, 0xc6, + 0xa4, 0xf5, 0x0e, 0x3f, 0x3e, 0x50, 0x2d, 0xfa, 0x01, 0x95, 0xb4, 0x60, 0xfc, 0xce, 0x02, 0xbb, + 0x6c, 0xb7, 0x77, 0x12, 0xb3, 0x49, 0x94, 0x06, 0x21, 0x17, 0x72, 0x54, 0xda, 0x99, 0x24, 0x4a, + 0xf7, 0xb9, 0x90, 0xc4, 0x83, 0x45, 0xbc, 0x11, 0x81, 0xe8, 0x36, 0x44, 0x98, 0x47, 0x19, 0x5e, + 0x48, 0xec, 0xa7, 0x39, 0x9f, 0xe0, 0x56, 0xbd, 0x7f, 0xc7, 0xa9, 0x1b, 0x29, 0x0f, 0x72, 0x7e, + 0x14, 0x35, 0x59, 0x3e, 0x50, 0x1b, 0xb2, 0x0c, 0xb3, 0x61, 0x87, 0x46, 0x69, 0x10, 0x35, 0x4d, + 0xab, 0xce, 0xe0, 0xfb, 0x41, 0x93, 0xd8, 0x30, 0x9b, 0x99, 0x18, 0x3c, 0xed, 0x39, 0xbf, 0xf7, + 0xee, 0x7c, 0x09, 0xa0, 0xf3, 0x60, 0xaf, 0xbf, 0x58, 0x12, 0x55, 0x7b, 0x9a, 0xf0, 0x6e, 0x2a, + 0xb1, 0x35, 0x46, 0xa9, 0xbd, 0x86, 0x3b, 0x01, 0xac, 0x94, 0x5a, 0x32, 0xe5, 0xbd, 0x07, 0x33, + 0xa6, 0x9b, 0x4d, 0xab, 0xaf, 0x95, 0xb7, 0xfa, 0x99, 0x83, 0xa2, 0xc8, 0x66, 0xc7, 0xf9, 0x18, + 0xee, 0x20, 0x01, 0x1e, 0xdd, 0x20, 0xcb, 0x87, 0xba, 0x7d, 0x23, 0x9e, 0x16, 0x25, 0xec, 0xb7, + 0x68, 0x9d, 0xab, 0xd3, 0x21, 0x6c, 0x8e, 0x92, 0xc8, 0x08, 0xdf, 0x07, 0x10, 0x19, 0x0b, 0x83, + 0x56, 0x37, 0x6d, 0x5e, 0x71, 0x4d, 0xeb, 0x19, 0x0b, 0x15, 0xcc, 0x28, 0x9f, 0x53, 0x71, 0x1f, + 0xa9, 0x30, 0x67, 0xc7, 0x14, 0x07, 0x29, 0x15, 0x6c, 0xf0, 0xc0, 0x09, 0x4c, 0x2a, 0x6c, 0x31, + 0x97, 0xd4, 0xb3, 0xf3, 0x93, 0x05, 0xab, 0xe5, 0x31, 0x46, 0xd8, 0x7d, 0xb8, 0xae, 0x9b, 0x6e, + 0xb0, 0xae, 0xb7, 0xcb, 0xb5, 0x61, 0x16, 0x9d, 0xc1, 0xc8, 0xbb, 0x16, 0x9d, 0x2d, 0x09, 0x52, + 0x83, 0x97, 0xc3, 0x6e, 0x9e, 0xb3, 0x54, 0xea, 0x1b, 0xae, 0xda, 0x46, 0xf5, 0xc6, 0xa4, 0xbf, + 0x60, 0xd6, 0xf1, 0x5e, 0x1f, 0x34, 0x77, 0xbf, 0x9f, 0x83, 0x29, 0x14, 0x46, 0xbe, 0xb1, 0x60, + 0x5a, 0x4f, 0x62, 0x52, 0x2b, 0x67, 0xbd, 0x38, 0xf8, 0xed, 0x3b, 0x23, 0x20, 0xb5, 0x43, 0x67, + 0xfd, 0xeb, 0x3f, 0xfe, 0xfd, 0x71, 0xbc, 0x4a, 0x56, 0xbd, 0x21, 0xff, 0x53, 0xe4, 0x2b, 0x98, + 0xc2, 0x99, 0x4a, 0x36, 0x86, 0x65, 0xee, 0xfb, 0x4f, 0xb0, 0x6b, 0x57, 0x03, 0x8d, 0x82, 0x57, + 0x51, 0xc1, 0x4d, 0xb2, 0x72, 0x89, 0x02, 0xe4, 0xfd, 0xd9, 0x82, 0xf9, 0xbe, 0x31, 0x46, 0xb6, + 0x86, 0xa4, 0xbf, 0x38, 0x09, 0x6d, 0x77, 0x54, 0xb8, 0xd1, 0xb4, 0x89, 0x9a, 0xd6, 0x89, 0x53, + 0xae, 0x09, 0x47, 0xbc, 0xe9, 0x09, 0xf2, 0x8b, 0x05, 0xd7, 0x07, 0xc6, 0x1d, 0xf1, 0x86, 0xb0, + 0x95, 0x8d, 0x4d, 0x7b, 0x7b, 0xf4, 0x00, 0x23, 0x70, 0x0b, 0x05, 0x6e, 0x90, 0xd7, 0xca, 0x05, + 0x8a, 0x0e, 0x3f, 0x0e, 0x74, 0xe7, 0x36, 0x95, 0xa2, 0x5f, 0x2d, 0x58, 0x18, 0xbc, 0x85, 0x64, + 0x18, 0x67, 0xe9, 0xc8, 0xb4, 0x77, 0x9e, 0x23, 0x62, 0x34, 0x99, 0xc5, 0xb8, 0x28, 0x4a, 0x79, + 0x62, 0xc1, 0xcd, 0xa1, 0x13, 0x83, 0xbc, 0x37, 0x44, 0xc3, 0x28, 0x43, 0xcb, 0xbe, 0xf7, 0xe2, + 0x09, 0x8c, 0xa7, 0x77, 0xd1, 0xd3, 0x9b, 0xe4, 0xae, 0x77, 0xf9, 0x67, 0x5b, 0x70, 0xce, 0x99, + 0xf7, 0x45, 0xb1, 0xf0, 0x84, 0xfc, 0x6e, 0xc1, 0x4b, 0xe7, 0xe6, 0x0d, 0xd9, 0xb9, 0x4a, 0xd5, + 0x85, 0x79, 0x66, 0xef, 0x3e, 0x4f, 0x88, 0x91, 0x7e, 0x17, 0xa5, 0x6f, 0x13, 0x77, 0x98, 0x74, + 0x9c, 0xc4, 0x85, 0x6c, 0xf5, 0xf2, 0x64, 0xef, 0xfd, 0xa7, 0x27, 0x55, 0xeb, 0xd9, 0x49, 0xd5, + 0xfa, 0xe7, 0xa4, 0x6a, 0xfd, 0x70, 0x5a, 0x1d, 0x7b, 0x76, 0x5a, 0x1d, 0xfb, 0xf3, 0xb4, 0x3a, + 0xf6, 0xd9, 0x46, 0xdf, 0x57, 0xda, 0x40, 0xce, 0xcf, 0x7b, 0x59, 0xf1, 0x53, 0xad, 0x31, 0x8d, + 0x1f, 0xaa, 0xaf, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x0e, 0xc7, 0x33, 0xa7, 0x0b, 0x00, 0x00, } @@ -700,6 +913,10 @@ type QueryClient interface { ShowIprpcData(ctx context.Context, in *QueryShowIprpcDataRequest, opts ...grpc.CallOption) (*QueryShowIprpcDataResponse, error) // ProviderReward queries for the providers reward for their services ProviderReward(ctx context.Context, in *QueryProviderRewardRequest, opts ...grpc.CallOption) (*QueryProviderRewardResponse, error) + // IprpcProviderRewardEstimation queries for a provider's current IPRPC reward (relative to its serviced CU) + IprpcProviderRewardEstimation(ctx context.Context, in *QueryIprpcProviderRewardEstimationRequest, opts ...grpc.CallOption) (*QueryIprpcProviderRewardEstimationResponse, error) + // IprpcSpecReward queries for a spec's IPRPC reward + IprpcSpecReward(ctx context.Context, in *QueryIprpcSpecRewardRequest, opts ...grpc.CallOption) (*QueryIprpcSpecRewardResponse, error) } type queryClient struct { @@ -755,6 +972,24 @@ func (c *queryClient) ProviderReward(ctx context.Context, in *QueryProviderRewar return out, nil } +func (c *queryClient) IprpcProviderRewardEstimation(ctx context.Context, in *QueryIprpcProviderRewardEstimationRequest, opts ...grpc.CallOption) (*QueryIprpcProviderRewardEstimationResponse, error) { + out := new(QueryIprpcProviderRewardEstimationResponse) + err := c.cc.Invoke(ctx, "/lavanet.lava.rewards.Query/IprpcProviderRewardEstimation", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) IprpcSpecReward(ctx context.Context, in *QueryIprpcSpecRewardRequest, opts ...grpc.CallOption) (*QueryIprpcSpecRewardResponse, error) { + out := new(QueryIprpcSpecRewardResponse) + err := c.cc.Invoke(ctx, "/lavanet.lava.rewards.Query/IprpcSpecReward", 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. @@ -767,6 +1002,10 @@ type QueryServer interface { ShowIprpcData(context.Context, *QueryShowIprpcDataRequest) (*QueryShowIprpcDataResponse, error) // ProviderReward queries for the providers reward for their services ProviderReward(context.Context, *QueryProviderRewardRequest) (*QueryProviderRewardResponse, error) + // IprpcProviderRewardEstimation queries for a provider's current IPRPC reward (relative to its serviced CU) + IprpcProviderRewardEstimation(context.Context, *QueryIprpcProviderRewardEstimationRequest) (*QueryIprpcProviderRewardEstimationResponse, error) + // IprpcSpecReward queries for a spec's IPRPC reward + IprpcSpecReward(context.Context, *QueryIprpcSpecRewardRequest) (*QueryIprpcSpecRewardResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -788,6 +1027,12 @@ func (*UnimplementedQueryServer) ShowIprpcData(ctx context.Context, req *QuerySh func (*UnimplementedQueryServer) ProviderReward(ctx context.Context, req *QueryProviderRewardRequest) (*QueryProviderRewardResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ProviderReward not implemented") } +func (*UnimplementedQueryServer) IprpcProviderRewardEstimation(ctx context.Context, req *QueryIprpcProviderRewardEstimationRequest) (*QueryIprpcProviderRewardEstimationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IprpcProviderRewardEstimation not implemented") +} +func (*UnimplementedQueryServer) IprpcSpecReward(ctx context.Context, req *QueryIprpcSpecRewardRequest) (*QueryIprpcSpecRewardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IprpcSpecReward not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -883,6 +1128,42 @@ func _Query_ProviderReward_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _Query_IprpcProviderRewardEstimation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryIprpcProviderRewardEstimationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).IprpcProviderRewardEstimation(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lavanet.lava.rewards.Query/IprpcProviderRewardEstimation", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).IprpcProviderRewardEstimation(ctx, req.(*QueryIprpcProviderRewardEstimationRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_IprpcSpecReward_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryIprpcSpecRewardRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).IprpcSpecReward(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lavanet.lava.rewards.Query/IprpcSpecReward", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).IprpcSpecReward(ctx, req.(*QueryIprpcSpecRewardRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "lavanet.lava.rewards.Query", HandlerType: (*QueryServer)(nil), @@ -907,6 +1188,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ProviderReward", Handler: _Query_ProviderReward_Handler, }, + { + MethodName: "IprpcProviderRewardEstimation", + Handler: _Query_IprpcProviderRewardEstimation_Handler, + }, + { + MethodName: "IprpcSpecReward", + Handler: _Query_IprpcSpecReward_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "lavanet/lava/rewards/query.proto", @@ -1329,76 +1618,215 @@ func (m *QueryProviderRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *QueryIprpcProviderRewardEstimationRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n + +func (m *QueryIprpcProviderRewardEstimationRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryIprpcProviderRewardEstimationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n + if len(m.Provider) > 0 { + i -= len(m.Provider) + copy(dAtA[i:], m.Provider) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Provider))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *QueryPoolsRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryIprpcProviderRewardEstimationResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *PoolInfo) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryIprpcProviderRewardEstimationResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIprpcProviderRewardEstimationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if len(m.Balance) > 0 { - for _, e := range m.Balance { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.SpecFunds) > 0 { + for iNdEx := len(m.SpecFunds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SpecFunds[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } } - return n + return len(dAtA) - i, nil } -func (m *QueryPoolsResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryIprpcSpecRewardRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - if len(m.Pools) > 0 { - for _, e := range m.Pools { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } + return dAtA[:n], nil +} + +func (m *QueryIprpcSpecRewardRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIprpcSpecRewardRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Spec) > 0 { + i -= len(m.Spec) + copy(dAtA[i:], m.Spec) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Spec))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryIprpcSpecRewardResponse) 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 *QueryIprpcSpecRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIprpcSpecRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CurrentMonthId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.CurrentMonthId)) + i-- + dAtA[i] = 0x10 + } + if len(m.IprpcRewards) > 0 { + for iNdEx := len(m.IprpcRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.IprpcRewards[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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryPoolsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *PoolInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.Balance) > 0 { + for _, e := range m.Balance { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryPoolsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Pools) > 0 { + for _, e := range m.Pools { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } } if m.TimeToRefill != 0 { n += 1 + sovQuery(uint64(m.TimeToRefill)) @@ -1509,6 +1937,65 @@ func (m *QueryProviderRewardResponse) Size() (n int) { return n } +func (m *QueryIprpcProviderRewardEstimationRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Provider) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryIprpcProviderRewardEstimationResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.SpecFunds) > 0 { + for _, e := range m.SpecFunds { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryIprpcSpecRewardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Spec) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryIprpcSpecRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.IprpcRewards) > 0 { + for _, e := range m.IprpcRewards { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.CurrentMonthId != 0 { + n += 1 + sovQuery(uint64(m.CurrentMonthId)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2598,6 +3085,357 @@ func (m *QueryProviderRewardResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryIprpcProviderRewardEstimationRequest) 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: QueryIprpcProviderRewardEstimationRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIprpcProviderRewardEstimationRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Provider", 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.Provider = 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 *QueryIprpcProviderRewardEstimationResponse) 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: QueryIprpcProviderRewardEstimationResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIprpcProviderRewardEstimationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpecFunds", 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.SpecFunds = append(m.SpecFunds, Specfund{}) + if err := m.SpecFunds[len(m.SpecFunds)-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 (m *QueryIprpcSpecRewardRequest) 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: QueryIprpcSpecRewardRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIprpcSpecRewardRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Spec", 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.Spec = 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 *QueryIprpcSpecRewardResponse) 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: QueryIprpcSpecRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIprpcSpecRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IprpcRewards", 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.IprpcRewards = append(m.IprpcRewards, IprpcReward{}) + if err := m.IprpcRewards[len(m.IprpcRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentMonthId", wireType) + } + m.CurrentMonthId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentMonthId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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/rewards/types/query.pb.gw.go b/x/rewards/types/query.pb.gw.go index 8e0c4b1485..94fe230994 100644 --- a/x/rewards/types/query.pb.gw.go +++ b/x/rewards/types/query.pb.gw.go @@ -141,6 +141,114 @@ func local_request_Query_ProviderReward_0(ctx context.Context, marshaler runtime } +func request_Query_IprpcProviderRewardEstimation_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIprpcProviderRewardEstimationRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["provider"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "provider") + } + + protoReq.Provider, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider", err) + } + + msg, err := client.IprpcProviderRewardEstimation(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_IprpcProviderRewardEstimation_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIprpcProviderRewardEstimationRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["provider"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "provider") + } + + protoReq.Provider, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider", err) + } + + msg, err := server.IprpcProviderRewardEstimation(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_IprpcSpecReward_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIprpcSpecRewardRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["spec"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "spec") + } + + protoReq.Spec, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "spec", err) + } + + msg, err := client.IprpcSpecReward(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_IprpcSpecReward_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIprpcSpecRewardRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["spec"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "spec") + } + + protoReq.Spec, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "spec", err) + } + + msg, err := server.IprpcSpecReward(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. @@ -262,6 +370,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_IprpcProviderRewardEstimation_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_IprpcProviderRewardEstimation_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_IprpcProviderRewardEstimation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_IprpcSpecReward_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_IprpcSpecReward_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_IprpcSpecReward_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -403,6 +557,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_IprpcProviderRewardEstimation_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_IprpcProviderRewardEstimation_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_IprpcProviderRewardEstimation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_IprpcSpecReward_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_IprpcSpecReward_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_IprpcSpecReward_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -416,6 +610,10 @@ var ( pattern_Query_ShowIprpcData_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"lavanet", "lava", "rewards", "show_iprpc_data"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_ProviderReward_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"lavanet", "lava", "rewards", "provider_reward"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_IprpcProviderRewardEstimation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"lavanet", "lava", "rewards", "iprpc_provider_reward", "provider"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_IprpcSpecReward_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"lavanet", "lava", "rewards", "iprpc_spec_reward", "spec"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -428,4 +626,8 @@ var ( forward_Query_ShowIprpcData_0 = runtime.ForwardResponseMessage forward_Query_ProviderReward_0 = runtime.ForwardResponseMessage + + forward_Query_IprpcProviderRewardEstimation_0 = runtime.ForwardResponseMessage + + forward_Query_IprpcSpecReward_0 = runtime.ForwardResponseMessage ) diff --git a/x/subscription/client/cli/query_list.go b/x/subscription/client/cli/query_list.go index c60b5f03c3..6311b55f74 100644 --- a/x/subscription/client/cli/query_list.go +++ b/x/subscription/client/cli/query_list.go @@ -17,7 +17,7 @@ func CmdList() *cobra.Command { Short: "Query all current subscriptions", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, err := client.GetClientTxContext(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err } diff --git a/x/subscription/client/cli/query_list_projects.go b/x/subscription/client/cli/query_list_projects.go index 543ce42a08..b25ff1f3a8 100644 --- a/x/subscription/client/cli/query_list_projects.go +++ b/x/subscription/client/cli/query_list_projects.go @@ -19,7 +19,7 @@ func CmdListProjects() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) (err error) { reqSubscription := args[0] - clientCtx, err := client.GetClientTxContext(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err } diff --git a/x/subscription/client/cli/query_next_to_month_expiry.go b/x/subscription/client/cli/query_next_to_month_expiry.go index a8b99c110e..50a0143b30 100644 --- a/x/subscription/client/cli/query_next_to_month_expiry.go +++ b/x/subscription/client/cli/query_next_to_month_expiry.go @@ -17,7 +17,7 @@ func CmdNextToMonthExpiry() *cobra.Command { Short: "Query the subscriptions with the closest month expiry", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, err := client.GetClientTxContext(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err }