x/Slashing: gRPC query service (#6597)

* Add grpc methods - slashing

* Add slashing grpc queries

* Add tests

* Remove duplicate declarations

* Add signing infos

* Update query test

* Use suite for grpc tests

* Update godoc

Co-authored-by: Alexander Bezobchuk <alexanderbez@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>
This commit is contained in:
SaReN
2020-07-06 21:54:25 +00:00
committed by GitHub
co-authored by Alexander Bezobchuk Federico Kunze mergify[bot]
parent 3c76084bf5
commit a0daec2d94
7 changed files with 2096 additions and 53 deletions
+52
View File
@@ -0,0 +1,52 @@
syntax = "proto3";
package cosmos.slashing;
import "cosmos/query/pagination.proto";
import "gogoproto/gogo.proto";
import "cosmos/slashing/slashing.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types";
// Query provides defines the gRPC querier service
service Query {
// Params queries the parameters of slashing module
rpc Params (QueryParamsRequest) returns (QueryParamsResponse){}
// SigningInfo queries the signing info of given cons address
rpc SigningInfo (QuerySigningInfoRequest) returns (QuerySigningInfoResponse) {}
// SigningInfos queries signing info of all validators
rpc SigningInfos (QuerySigningInfosRequest) returns (QuerySigningInfosResponse) {}
}
// QueryParamsRequest is the request type for the Query/Parameters RPC method
message QueryParamsRequest{}
// QueryParamsResponse is the response type for the Query/Parameters RPC method
message QueryParamsResponse{
cosmos.slashing.Params params = 1[(gogoproto.nullable) = false];
}
// QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC method
message QuerySigningInfoRequest{
// cons_address is the address to query signing info of
bytes cons_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ConsAddress"];
}
// QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC method
message QuerySigningInfoResponse{
// val_signing_info is the signing info of requested val cons address
cosmos.slashing.ValidatorSigningInfo val_signing_info = 1[(gogoproto.nullable)= false];
}
// QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC method
message QuerySigningInfosRequest{
cosmos.query.PageRequest req = 1;
}
// QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC method
message QuerySigningInfosResponse{
// info is the signing info of all validators
repeated cosmos.slashing.ValidatorSigningInfo info = 1[(gogoproto.nullable)= false];
cosmos.query.PageResponse res =2;
}
+23
View File
@@ -5,6 +5,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types";
option (gogoproto.equal_all) = true;
import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
// MsgUnjail - struct for unjailing jailed validator
@@ -40,3 +41,25 @@ message ValidatorSigningInfo {
// missed blocks counter (to avoid scanning the array every time)
int64 missed_blocks_counter = 6 [(gogoproto.moretags) = "yaml:\"missed_blocks_counter\""];
}
// Params - used for initializing default parameter for slashing at genesis
message Params{
int64 signed_blocks_window = 1 [(gogoproto.jsontag) = "json:\"signed_blocks_window\"",
(gogoproto.moretags) = "yaml:\"signed_blocks_window\""];
bytes min_signed_per_window = 2 [(gogoproto.jsontag) = "json:\"min_signed_per_window\"",
(gogoproto.moretags) = "yaml:\"min_signed_per_window\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false];
google.protobuf.Duration downtime_jail_duration = 3 [(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "json:\"downtime_jail_duration\"",
(gogoproto.moretags) = "yaml:\"downtime_jail_duration\""];
bytes slash_fraction_double_sign = 4 [(gogoproto.jsontag) = "json:\"slash_fraction_double_sign\"",
(gogoproto.moretags) = "yaml:\"slash_fraction_double_sign\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false];
bytes slash_fraction_downtime = 5 [(gogoproto.jsontag) = "json:\"slash_fraction_downtime\"",
(gogoproto.moretags) = "yaml:\"slash_fraction_downtime\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false];
}