Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added query for provider parameters (backport #1605) #1612

Merged
merged 4 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added query for current values of all provider parameters
([\#1605](https://github.com/cosmos/interchain-security/pull/1605))
16 changes: 15 additions & 1 deletion proto/interchain_security/ccv/provider/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ service Query {
returns (QueryAllPairsValConAddrByConsumerChainIDResponse) {
option (google.api.http).get =
"/interchain_security/ccv/provider/consumer_chain_id";
}
}

// QueryParams returns all current values of provider parameters
rpc QueryParams(QueryParamsRequest)
returns (QueryParamsResponse) {
option (google.api.http).get =
"/interchain_security/ccv/provider/params";
}
}

message QueryConsumerGenesisRequest { string chain_id = 1; }
Expand Down Expand Up @@ -235,3 +242,10 @@ message PairValConAddrProviderAndConsumer {
string consumer_address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
tendermint.crypto.PublicKey consumer_key = 3;
}

message QueryParamsRequest {}

message QueryParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}

36 changes: 35 additions & 1 deletion x/ccv/provider/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewQueryCmd() *cobra.Command {
cmd.AddCommand(CmdRegisteredConsumerRewardDenoms())
cmd.AddCommand(CmdProposedConsumerChains())
cmd.AddCommand(CmdAllPairsValConAddrByConsumerChainID())

cmd.AddCommand(CmdProviderParameters())
return cmd
}

Expand Down Expand Up @@ -412,3 +412,37 @@ func CmdAllPairsValConAddrByConsumerChainID() *cobra.Command {

return cmd
}

// Command to query provider parameters
func CmdProviderParameters() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "Query provider parameters information",
Long: strings.TrimSpace(
fmt.Sprintf(`Query parameter values of provider.
Example:
$ %s query provider params
`, version.AppName),
),
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.QueryParams(cmd.Context(),
&types.QueryParamsRequest{})
if err != nil {
return err
}

return clientCtx.PrintProto(&res.Params)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
8 changes: 8 additions & 0 deletions x/ccv/provider/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,11 @@ func (k Keeper) QueryAllPairsValConAddrByConsumerChainID(goCtx context.Context,
PairValConAddr: pairValConAddrs,
}, nil
}

// QueryParams returns all parameters and current values of provider
func (k Keeper) QueryParams(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
params := k.GetParams(ctx)

return &types.QueryParamsResponse{Params: params}, nil
}
214 changes: 108 additions & 106 deletions x/ccv/provider/types/provider.pb.go

Large diffs are not rendered by default.

531 changes: 440 additions & 91 deletions x/ccv/provider/types/query.pb.go

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions x/ccv/provider/types/query.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

132 changes: 53 additions & 79 deletions x/ccv/types/shared_consumer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading