-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x/staking: gRPC query Service (#6490)
* Add types for staking grpc * Update module.go * Update staking query types * Add grpc query methods * Add delegation response to proto * Add queriers for delegations * Add queriers for unbonding * Add queriers for redelegations * Add cases for redelegations * Add test for grpc validators * Update staking types to proto * Update staking query proto * Add tests for grpc * Add tests for grpc pool, parameters * Fix lint issues * Add grpc redelegation tests * Add more tests * Add docs for query proto * Add docs for query types * Modify redel querier * Add debugging statements * Revert debugging * Fix proto lint errors * Add wrapper for keeper * Embed keeper in querier * Add more tests * Add tests for validator unbondings * Add redel tests * fix queryRedelegationsFromSrcValidator * Fix Redelegation tests * update godoc * Update args * Update tests with suite * Fix lint * Remove redundant types * Refactor tests * fix test * refactor query proto * Fix tests * address review comments * lint staking proto * add godoc * Update tests to table driven tests * add debugging * Fix grpc tests * address comments * address whitespace suggestions * Add more tests * add tests for invalid redels * update error messages * address review suggestions * add tests * move suite to keeper_test Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
b9f86dd
commit 5656e86
Showing
19 changed files
with
10,156 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
syntax = "proto3"; | ||
package cosmos.staking; | ||
|
||
import "cosmos/query/pagination.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "cosmos/staking/staking.proto"; | ||
|
||
option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; | ||
|
||
// Query defines the gRPC querier service | ||
service Query { | ||
// Validators queries all validators that match the given status | ||
rpc Validators (QueryValidatorsRequest) returns (QueryValidatorsResponse) {} | ||
|
||
// Validator queries validator info for given validator addr | ||
rpc Validator (QueryValidatorRequest) returns (QueryValidatorResponse) {} | ||
|
||
// ValidatorDelegations queries delegate info for given validator | ||
rpc ValidatorDelegations (QueryValidatorDelegationsRequest) returns (QueryValidatorDelegationsResponse) {} | ||
|
||
// ValidatorUnbondingDelegations queries unbonding delegations of a validator | ||
rpc ValidatorUnbondingDelegations (QueryValidatorUnbondingDelegationsRequest) returns (QueryValidatorUnbondingDelegationsResponse) {} | ||
|
||
// Delegation queries delegate info for given validator delegator pair | ||
rpc Delegation (QueryDelegationRequest) returns (QueryDelegationResponse) {} | ||
|
||
// UnbondingDelegation queries unbonding info for give validator delegator pair | ||
rpc UnbondingDelegation (QueryUnbondingDelegationRequest) returns (QueryUnbondingDelegationResponse) {} | ||
|
||
// DelegatorDelegations queries all delegations of a give delegator address | ||
rpc DelegatorDelegations (QueryDelegatorDelegationsRequest) returns (QueryDelegatorDelegationsResponse) {} | ||
|
||
// DelegatorUnbondingDelegations queries all unbonding delegations of a give delegator address | ||
rpc DelegatorUnbondingDelegations (QueryDelegatorUnbondingDelegationsRequest) returns (QueryDelegatorUnbondingDelegationsResponse) {} | ||
|
||
// Redelegations queries redelegations of given address | ||
rpc Redelegations (QueryRedelegationsRequest) returns (QueryRedelegationsResponse) {} | ||
|
||
// DelegatorValidators queries all validator info for given delegator address | ||
rpc DelegatorValidators (QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) {} | ||
|
||
// DelegatorValidator queries validator info for given delegator validator pair | ||
rpc DelegatorValidator (QueryDelegatorValidatorRequest) returns (QueryDelegatorValidatorResponse) {} | ||
|
||
// HistoricalInfo queries the historical info for given height | ||
rpc HistoricalInfo (QueryHistoricalInfoRequest) returns (QueryHistoricalInfoResponse) {} | ||
|
||
// Pool queries the pool info | ||
rpc Pool (QueryPoolRequest) returns (QueryPoolResponse) {} | ||
|
||
// Parameters queries the staking parameters | ||
rpc Params (QueryParamsRequest) returns (QueryParamsResponse) {} | ||
} | ||
|
||
// QueryValidatorsRequest is request type for Query/Validators RPC method | ||
message QueryValidatorsRequest{ | ||
string status = 1; | ||
|
||
cosmos.query.PageRequest req = 2; | ||
} | ||
|
||
// QueryValidatorsResponse is response type for the Query/Validators RPC method | ||
message QueryValidatorsResponse { | ||
repeated cosmos.staking.Validator validators = 1 [(gogoproto.nullable) = false]; | ||
|
||
cosmos.query.PageResponse res = 2; | ||
} | ||
|
||
// QueryValidatorRequest is response type for the Query/Validator RPC method | ||
message QueryValidatorRequest { | ||
bytes validator_addr = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"]; | ||
} | ||
|
||
// QueryValidatorResponse is response type for the Query/Validator RPC method | ||
message QueryValidatorResponse { | ||
Validator validator = 1 [(gogoproto.nullable) = false]; | ||
} | ||
|
||
// QueryValidatorDelegationsRequest is request type for the Query/ValidatorDelegations RPC method | ||
message QueryValidatorDelegationsRequest { | ||
bytes validator_addr = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"]; | ||
|
||
cosmos.query.PageRequest req = 2; | ||
} | ||
|
||
// QueryValidatorDelegationsRequest is response type for the Query/ValidatorDelegations RPC method | ||
message QueryValidatorDelegationsResponse { | ||
repeated DelegationResponse delegation_responses = 1 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "DelegationResponses"]; | ||
|
||
cosmos.query.PageResponse res = 2; | ||
} | ||
|
||
// QueryValidatorUnbondingDelegationsRequest is required type for the Query/ValidatorUnbondingDelegations RPC method | ||
message QueryValidatorUnbondingDelegationsRequest { | ||
bytes validator_addr = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"]; | ||
|
||
cosmos.query.PageRequest req = 2; | ||
} | ||
|
||
// QueryValidatorUnbondingDelegationsResponse is response type for the Query/ValidatorUnbondingDelegations RPC method | ||
message QueryValidatorUnbondingDelegationsResponse { | ||
repeated UnbondingDelegation unbonding_responses = 1 [(gogoproto.nullable) = false]; | ||
|
||
cosmos.query.PageResponse res = 2; | ||
} | ||
|
||
// QueryDelegationRequest is request type for the Query/Delegation RPC method | ||
message QueryDelegationRequest { | ||
bytes delegator_addr = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; | ||
|
||
bytes validator_addr = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"]; | ||
} | ||
|
||
// QueryDelegationResponse is response type for the Query/Delegation RPC method | ||
message QueryDelegationResponse { | ||
DelegationResponse delegation_response = 1 [(gogoproto.casttype) = "DelegationResponse"]; | ||
} | ||
|
||
// QueryUnbondingDelegationRequest is request type for the Query/UnbondingDelegation RPC method | ||
message QueryUnbondingDelegationRequest { | ||
bytes delegator_addr = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; | ||
|
||
bytes validator_addr = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"]; | ||
} | ||
|
||
// QueryDelegationResponse is response type for the Query/UnbondingDelegation RPC method | ||
message QueryUnbondingDelegationResponse { | ||
UnbondingDelegation unbond =1 [(gogoproto.nullable) = false]; | ||
} | ||
|
||
// QueryDelegatorDelegationsRequest is request type for the Query/DelegatorDelegations RPC method | ||
message QueryDelegatorDelegationsRequest { | ||
bytes delegator_addr = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; | ||
|
||
cosmos.query.PageRequest req = 2; | ||
} | ||
|
||
// QueryDelegatorDelegationsResponse is response type for the Query/DelegatorDelegations RPC method | ||
message QueryDelegatorDelegationsResponse { | ||
repeated DelegationResponse delegation_responses = 1 [(gogoproto.nullable) = false]; | ||
|
||
cosmos.query.PageResponse res = 2; | ||
} | ||
|
||
// QueryDelegatorUnbondingDelegationsRequest is request type for the Query/DelegatorUnbondingDelegations RPC method | ||
message QueryDelegatorUnbondingDelegationsRequest { | ||
bytes delegator_addr = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; | ||
|
||
cosmos.query.PageRequest req = 2; | ||
} | ||
// QueryUnbondingDelegatorDelegationsResponse is response type for the Query/UnbondingDelegatorDelegations RPC method | ||
message QueryDelegatorUnbondingDelegationsResponse { | ||
repeated UnbondingDelegation unbonding_responses = 1 [(gogoproto.nullable) = false]; | ||
|
||
cosmos.query.PageResponse res = 2; | ||
} | ||
|
||
// QueryRedelegationsRequest is request type for the Query/Redelegations RPC method | ||
message QueryRedelegationsRequest { | ||
bytes delegator_addr = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; | ||
|
||
bytes src_validator_addr = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"]; | ||
|
||
bytes dst_validator_addr = 3 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"]; | ||
|
||
cosmos.query.PageRequest req = 4; | ||
} | ||
|
||
// QueryRedelegationsResponse is response type for the Query/Redelegations RPC method | ||
message QueryRedelegationsResponse { | ||
repeated RedelegationResponse redelegation_responses = 1 [(gogoproto.nullable) = false]; | ||
|
||
cosmos.query.PageResponse res = 2; | ||
} | ||
|
||
// QueryDelegatorValidatorsRequest is request type for the Query/DelegatorValidators RPC method | ||
message QueryDelegatorValidatorsRequest { | ||
bytes delegator_addr = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; | ||
|
||
cosmos.query.PageRequest req = 2; | ||
} | ||
|
||
// QueryDelegatorValidatorsResponse is response type for the Query/DelegatorValidators RPC method | ||
message QueryDelegatorValidatorsResponse { | ||
repeated Validator validators = 1 [(gogoproto.nullable) = false]; | ||
|
||
cosmos.query.PageResponse res = 2; | ||
} | ||
|
||
// QueryDelegatorValidatorRequest is request type for the Query/DelegatorValidator RPC method | ||
message QueryDelegatorValidatorRequest { | ||
bytes delegator_addr = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; | ||
|
||
bytes validator_addr = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"]; | ||
} | ||
|
||
// QueryDelegatorValidatorResponse response type for the Query/DelegatorValidator RPC method | ||
message QueryDelegatorValidatorResponse { | ||
Validator validator = 1 [(gogoproto.nullable) = false]; | ||
} | ||
|
||
// QueryHistoricalInfoRequest is request type for the Query/HistoricalInfo RPC method | ||
message QueryHistoricalInfoRequest { | ||
int64 height = 1; | ||
} | ||
|
||
// QueryHistoricalInfoResponse is response type for the Query/HistoricalInfo RPC method | ||
message QueryHistoricalInfoResponse { | ||
HistoricalInfo hist = 1; | ||
} | ||
|
||
// QueryPoolRequest is request type for the Query/Pool RPC method | ||
message QueryPoolRequest { } | ||
|
||
// QueryPoolResponse is response type for the Query/Pool RPC method | ||
message QueryPoolResponse { | ||
Pool pool = 1 [(gogoproto.nullable) = false]; | ||
} | ||
|
||
// QueryParametersRequest is request type for the Query/Parameters RPC method | ||
message QueryParamsRequest { } | ||
|
||
// QueryParametersResponse is response type for the Query/Parameters RPC method | ||
message QueryParamsResponse { | ||
Params params = 1 [(gogoproto.nullable) = false]; | ||
|
||
cosmos.query.PageResponse res = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.