Skip to content

Commit

Permalink
fix: fix queries' API REST endpoint path (#2196)
Browse files Browse the repository at this point in the history
* clean uw files

* doc

* Revert "doc"

This reverts commit efc2718.

* Revert "clean uw files"

This reverts commit 5773cf3.

* remove deprecated REST endpoints

* update REST endpoint

* fix broken UT by previous PR (#2195)
  • Loading branch information
sainoe committed Aug 30, 2024
1 parent 45c5fce commit b874510
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 1,343 deletions.
58 changes: 12 additions & 46 deletions proto/interchain_security/ccv/provider/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ service Query {
rpc QueryConsumerGenesis(QueryConsumerGenesisRequest)
returns (QueryConsumerGenesisResponse) {
option (google.api.http) = {
// [DEPRECATED] use the {consumer_id} endpoint instead.
get: "/interchain_security/ccv/provider/consumer_genesis/{chain_id}";
additional_bindings {
get: "/interchain_security/ccv/provider/consumer_genesis/{consumer_id}";
}
get: "/interchain_security/ccv/provider/consumer_genesis/{consumer_id}";
};
}

Expand Down Expand Up @@ -74,11 +70,7 @@ service Query {
QueryAllPairsValConAddrByConsumerChainIDRequest)
returns (QueryAllPairsValConAddrByConsumerChainIDResponse) {
option (google.api.http) = {
// [DEPRECATED] use the {consumer_id} endpoint instead.
get: "/interchain_security/ccv/provider/{chain_id}";
additional_bindings {
get: "/interchain_security/ccv/provider/{consumer_id}";
}
get: "/interchain_security/ccv/provider/address_pairs/{consumer_id}";
};
}

Expand All @@ -95,11 +87,7 @@ service Query {
QueryConsumerChainOptedInValidatorsRequest)
returns (QueryConsumerChainOptedInValidatorsResponse) {
option (google.api.http) = {
// [DEPRECATED] use the {consumer_id} endpoint instead.
get: "/interchain_security/ccv/provider/opted_in_validators/{chain_id}";
additional_bindings {
get: "/interchain_security/ccv/provider/opted_in_validators/{consumer_id}";
}
get: "/interchain_security/ccv/provider/opted_in_validators/{consumer_id}";
};
}

Expand All @@ -118,11 +106,7 @@ service Query {
QueryValidatorConsumerCommissionRateRequest)
returns (QueryValidatorConsumerCommissionRateResponse) {
option (google.api.http) = {
// [DEPRECATED] use the {consumer_id} endpoint instead.
get: "/interchain_security/ccv/provider/consumer_commission_rate/{chain_id}/{provider_address}";
additional_bindings {
get: "/interchain_security/ccv/provider/consumer_commission_rate/{consumer_id}/{provider_address}";
}
};
}

Expand All @@ -132,11 +116,7 @@ service Query {
rpc QueryConsumerValidators(QueryConsumerValidatorsRequest)
returns (QueryConsumerValidatorsResponse) {
option (google.api.http) = {
// [DEPRECATED] use the {consumer_id} endpoint instead.
get: "/interchain_security/ccv/provider/consumer_validators/{chain_id}";
additional_bindings {
get: "/interchain_security/ccv/provider/consumer_validators/{consumer_id}";
}
};
}

Expand Down Expand Up @@ -166,9 +146,7 @@ service Query {
}

message QueryConsumerGenesisRequest {
// [DEPRECATED] use `consumer_id` instead
string chain_id = 1 [deprecated = true];
string consumer_id = 2;
string consumer_id = 1;
}

message QueryConsumerGenesisResponse {
Expand Down Expand Up @@ -218,12 +196,10 @@ message Chain {
message QueryValidatorConsumerAddrRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// [DEPRECATED] use `consumer_id` instead
string chain_id = 1 [deprecated = true];
// The consensus address of the validator on the provider chain
string provider_address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string provider_address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
// The id of the consumer chain
string consumer_id = 3;
string consumer_id = 2;
}

message QueryValidatorConsumerAddrResponse {
Expand All @@ -234,12 +210,10 @@ message QueryValidatorConsumerAddrResponse {
message QueryValidatorProviderAddrRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// [DEPRECATED] use `consumer_id` instead
string chain_id = 1 [deprecated = true];
// The consensus address of the validator on the consumer chain
string consumer_address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string consumer_address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
// The id of the consumer chain
string consumer_id = 3;
string consumer_id = 2;
}

message QueryValidatorProviderAddrResponse {
Expand Down Expand Up @@ -268,10 +242,8 @@ message QueryRegisteredConsumerRewardDenomsResponse {
}

message QueryAllPairsValConAddrByConsumerChainIDRequest {
// [DEPRECATED] use `consumer_id` instead
string chain_id = 1 [deprecated = true];
// The id of the consumer chain
string consumer_id = 2;
string consumer_id = 1;
}

message QueryAllPairsValConAddrByConsumerChainIDResponse {
Expand All @@ -293,9 +265,7 @@ message QueryParamsResponse {
}

message QueryConsumerChainOptedInValidatorsRequest {
// [DEPRECATED] use `consumer_id` instead
string chain_id = 1 [deprecated = true];
string consumer_id = 2;
string consumer_id = 1;
}

message QueryConsumerChainOptedInValidatorsResponse {
Expand All @@ -304,9 +274,7 @@ message QueryConsumerChainOptedInValidatorsResponse {
}

message QueryConsumerValidatorsRequest {
// [DEPRECATED] use `consumer_id` instead
string chain_id = 1 [deprecated = true];
string consumer_id = 2;
string consumer_id = 1;
}

message QueryConsumerValidatorsValidator {
Expand Down Expand Up @@ -368,11 +336,9 @@ message QueryConsumerChainsValidatorHasToValidateResponse {
}

message QueryValidatorConsumerCommissionRateRequest {
// [DEPRECATED] use `consumer_id` instead
string chain_id = 1 [deprecated = true];
string consumer_id = 1;
// The consensus address of the validator on the provider chain
string provider_address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string consumer_id = 3;
}

message QueryValidatorConsumerCommissionRateResponse {
Expand Down
15 changes: 1 addition & 14 deletions x/ccv/provider/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ func (k Keeper) QueryConsumerGenesis(c context.Context, req *types.QueryConsumer

if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
} else if req.ChainId != "" {
return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.")
}

consumerId := req.ConsumerId
Expand Down Expand Up @@ -163,8 +161,6 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai
func (k Keeper) QueryValidatorConsumerAddr(goCtx context.Context, req *types.QueryValidatorConsumerAddrRequest) (*types.QueryValidatorConsumerAddrResponse, error) {
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
} else if req.ChainId != "" {
return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.")
}

ctx := sdk.UnwrapSDKContext(goCtx)
Expand Down Expand Up @@ -198,8 +194,6 @@ func (k Keeper) QueryValidatorConsumerAddr(goCtx context.Context, req *types.Que
func (k Keeper) QueryValidatorProviderAddr(goCtx context.Context, req *types.QueryValidatorProviderAddrRequest) (*types.QueryValidatorProviderAddrResponse, error) {
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
} else if req.ChainId != "" {
return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.")
}

ctx := sdk.UnwrapSDKContext(goCtx)
Expand Down Expand Up @@ -255,8 +249,6 @@ func (k Keeper) QueryRegisteredConsumerRewardDenoms(goCtx context.Context, req *
func (k Keeper) QueryAllPairsValConAddrByConsumerChainID(goCtx context.Context, req *types.QueryAllPairsValConAddrByConsumerChainIDRequest) (*types.QueryAllPairsValConAddrByConsumerChainIDResponse, error) {
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
} else if req.ChainId != "" {
return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.")
}

consumerId := req.ConsumerId
Expand Down Expand Up @@ -302,8 +294,6 @@ func (k Keeper) QueryParams(goCtx context.Context, req *types.QueryParamsRequest
func (k Keeper) QueryConsumerChainOptedInValidators(goCtx context.Context, req *types.QueryConsumerChainOptedInValidatorsRequest) (*types.QueryConsumerChainOptedInValidatorsResponse, error) {
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
} else if req.ChainId != "" {
return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.")
}

consumerId := req.ConsumerId
Expand Down Expand Up @@ -331,9 +321,8 @@ func (k Keeper) QueryConsumerChainOptedInValidators(goCtx context.Context, req *
func (k Keeper) QueryConsumerValidators(goCtx context.Context, req *types.QueryConsumerValidatorsRequest) (*types.QueryConsumerValidatorsResponse, error) {
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
} else if req.ChainId != "" {
return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.")
}

consumerId := req.ConsumerId
if err := types.ValidateConsumerId(consumerId); err != nil {
return nil, status.Error(codes.InvalidArgument, errorsmod.Wrap(types.ErrInvalidConsumerId, consumerId).Error())
Expand Down Expand Up @@ -524,8 +513,6 @@ func (k Keeper) hasToValidate(
func (k Keeper) QueryValidatorConsumerCommissionRate(goCtx context.Context, req *types.QueryValidatorConsumerCommissionRateRequest) (*types.QueryValidatorConsumerCommissionRateResponse, error) {
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
} else if req.ChainId != "" {
return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.")
}

consumerId := req.ConsumerId
Expand Down
6 changes: 3 additions & 3 deletions x/ccv/provider/types/legacy_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ func TestMsgUpdateConsumerValidateBasic(t *testing.T) {
Top_N: 50,
ValidatorsPowerCap: 100,
ValidatorSetCap: 34,
Allowlist: []string{"addr1"},
Allowlist: []string{"cosmosvalcons1arwg2sh5fd2wq4mwl6d05pyz4nrwls2mayg36j"},
Denylist: nil,
MinStake: 0,
AllowInactiveVals: false,
Expand Down Expand Up @@ -591,8 +591,8 @@ func TestMsgUpdateConsumerValidateBasic(t *testing.T) {
Top_N: 54,
ValidatorsPowerCap: 92,
ValidatorSetCap: 0,
Allowlist: []string{"addr1"},
Denylist: []string{"addr2", "addr3"},
Allowlist: []string{"cosmosvalcons1arwg2sh5fd2wq4mwl6d05pyz4nrwls2mayg36j"},
Denylist: []string{"cosmosvalcons1arwg2sh5fd2wq4mwl6d05pyz4nrwls2mayg36j", "cosmosvalcons1arwg2sh5fd2wq4mwl6d05pyz4nrwls2mayg36j"},
MinStake: 0,
AllowInactiveVals: false,
},
Expand Down
Loading

0 comments on commit b874510

Please sign in to comment.