x/distribution: gRPC query service (#6600)

* WIP: adding grpc

* added grpc for query withdraw address

* Fix outstanding rewards query

* added inteerface registry

* added gRPC for delegation rewards

* added remaining commands

* lint issue

* added tests

* added test for community pool

* fixed error

* added test for delegator validators

* updated to use test suite

* updated tests

* more test checks added

* updated tests

* Add sdk wrap

* removed pagination for outstanding rewards

* fixed distr tests issue

* fixed slashes issue

* migrated tests to table driven tests

* docs updated

* review changes

* review changes

* review changes

* Update x/distribution/keeper/grpc_query.go

Co-authored-by: sahith-narahari <sahithnarahari@gmail.com>
Co-authored-by: anilCSE <anil@vitwit.com>
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
atheeshp
2020-07-13 20:01:16 +00:00
committed by GitHub
co-authored by sahith-narahari anilCSE Alexander Bezobchuk Federico Kunze
parent 7678f8a913
commit be111ef036
9 changed files with 5374 additions and 77 deletions
@@ -179,3 +179,17 @@ message DelegatorStartingInfo {
uint64 height = 3
[(gogoproto.moretags) = "yaml:\"creation_height\"", (gogoproto.jsontag) = "creation_height"];
}
// DelegationDelegatorReward defines the properties
// of a delegator's delegation reward.
message DelegationDelegatorReward {
bytes validator_address = 1 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress",
(gogoproto.moretags) = "yaml:\"validator_address\""
];
repeated cosmos.DecCoin reward = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
(gogoproto.nullable) = false
];
}
+141
View File
@@ -0,0 +1,141 @@
syntax = "proto3";
package cosmos.distribution;
import "cosmos/query/pagination.proto";
import "gogoproto/gogo.proto";
import "cosmos/cosmos.proto";
import "cosmos/distribution/distribution.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types";
// Query defines the gRPC querier service for distribution module
service Query {
// Params queries params of distribution module
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {}
// ValidatorOutstandingRewards queries rewards of a validator address
rpc ValidatorOutstandingRewards(QueryValidatorOutstandingRewardsRequest) returns (QueryValidatorOutstandingRewardsResponse) {}
// ValidatorCommission queries accumulated commission for a validator
rpc ValidatorCommission (QueryValidatorCommissionRequest) returns (QueryValidatorCommissionResponse) {}
// ValidatorSlashes queries slash events of a validator
rpc ValidatorSlashes (QueryValidatorSlashesRequest) returns (QueryValidatorSlashesResponse) {}
// DelegationRewards the total rewards accrued by a delegation
rpc DelegationRewards (QueryDelegationRewardsRequest) returns (QueryDelegationRewardsResponse) {}
// DelegationTotalRewards the total rewards accrued by a each validator
rpc DelegationTotalRewards (QueryDelegationTotalRewardsRequest) returns (QueryDelegationTotalRewardsResponse) {}
// DelegatorValidators queries the validators of a delegator
rpc DelegatorValidators (QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) {}
// DelegatorWithdrawAddress queries withdraw address of a delegator
rpc DelegatorWithdrawAddress (QueryDelegatorWithdrawAddressRequest) returns (QueryDelegatorWithdrawAddressResponse) {}
// CommunityPool queries the community pool coins
rpc CommunityPool (QueryCommunityPoolRequest) returns (QueryCommunityPoolResponse) {}
}
// QueryParamsRequest is the request type for the Query/Params RPC method
message QueryParamsRequest { }
// QueryParamsResponse is the response type for the Query/Params RPC method
message QueryParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}
// QueryValidatorOutstandingRewardsRequest is the request type for the Query/ValidatorOutstandingRewards RPC method
message QueryValidatorOutstandingRewardsRequest {
bytes validator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"];
}
// QueryValidatorOutstandingRewardsResponse is the response type for the Query/ValidatorOutstandingRewards RPC method
message QueryValidatorOutstandingRewardsResponse {
ValidatorOutstandingRewards rewards = 1 [(gogoproto.nullable) = false];
}
// QueryValidatorCommissionRequest is the request type for the Query/ValidatorCommission RPC method
message QueryValidatorCommissionRequest {
bytes validator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"];
}
// QueryValidatorCommissionResponse is the response type for the Query/ValidatorCommission RPC method
message QueryValidatorCommissionResponse {
ValidatorAccumulatedCommission commission = 1 [(gogoproto.nullable) = false];
}
// QueryValidatorSlashesRequest is the request type for the Query/ValidatorSlashes RPC method
message QueryValidatorSlashesRequest {
bytes validator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"];
uint64 starting_height = 2;
uint64 ending_height = 3;
cosmos.query.PageRequest req = 4;
}
// QueryValidatorSlashesResponse is the response type for the Query/ValidatorSlashes RPC method
message QueryValidatorSlashesResponse {
repeated ValidatorSlashEvent slashes = 1 [(gogoproto.nullable) = false];
cosmos.query.PageResponse res = 2;
}
// QueryDelegationRewardsRequest is the request type for the Query/DelegationRewards RPC method
message QueryDelegationRewardsRequest {
bytes delegator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
bytes validator_address = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"];
}
// QueryDelegationRewardsResponse is the response type for the Query/DelegationRewards RPC method
message QueryDelegationRewardsResponse {
repeated cosmos.DecCoin rewards = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"
];
}
// QueryDelegationTotalRewardsRequest is the request type for the Query/DelegationTotalRewards RPC method
message QueryDelegationTotalRewardsRequest {
bytes delegator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
// QueryDelegationTotalRewardsResponse is the response type for the Query/DelegationTotalRewards RPC method
message QueryDelegationTotalRewardsResponse {
repeated DelegationDelegatorReward rewards = 1 [(gogoproto.nullable) = false];
repeated cosmos.DecCoin total = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"
];
}
// QueryDelegatorValidatorsRequest is the request type for the Query/DelegatorValidators RPC method
message QueryDelegatorValidatorsRequest {
bytes delegator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
// QueryDelegatorValidatorsResponse is the response type for the Query/DelegatorValidators RPC method
message QueryDelegatorValidatorsResponse {
repeated bytes validators = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"];
}
// QueryDelegatorWithdrawAddressRequest is the request type for the Query/DelegatorWithdrawAddress RPC method
message QueryDelegatorWithdrawAddressRequest {
bytes delegator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
// QueryDelegatorWithdrawAddressResponse is the response type for the Query/DelegatorWithdrawAddress RPC method
message QueryDelegatorWithdrawAddressResponse {
bytes withdraw_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
}
// QueryCommunityPoolRequest is the request type for the Query/CommunityPool RPC method
message QueryCommunityPoolRequest {}
// QueryCommunityPoolResponse is the response type for the Query/CommunityPool RPC method
message QueryCommunityPoolResponse {
repeated cosmos.DecCoin pool = 1 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
(gogoproto.nullable) = false
];
}