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

Add GrpcQuery #510

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions docs/MIGRATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
two `VM` instances operate on the same directory in parallel. This was
unsupported before already but now leads to an error early on. When doing
parallel testing, use a different directory for each instance.
- `QueryRequest.Grpc` was added. It is similar to `QueryRequest.Stargate` but
unlike that, it should always return protobuf encoded responses on all chains.
- `VM.StoreCode` now returns a `uint64` containing the gas cost in CosmWasm gas
and takes a gas limit as argument. This was previously calculated in wasmd.
The change brings consistency with the other functions that cause gas usage.
Expand Down
26 changes: 21 additions & 5 deletions types/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ type QueryRequest struct {
Staking *StakingQuery `json:"staking,omitempty"`
Distribution *DistributionQuery `json:"distribution,omitempty"`
Stargate *StargateQuery `json:"stargate,omitempty"`
Grpc *GrpcQuery `json:"grpc,omitempty"`
chipshort marked this conversation as resolved.
Show resolved Hide resolved
Wasm *WasmQuery `json:"wasm,omitempty"`
}

Expand Down Expand Up @@ -435,14 +436,29 @@ type BondedDenomResponse struct {

// StargateQuery is encoded the same way as abci_query, with path and protobuf encoded request data.
// The format is defined in [ADR-21](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-021-protobuf-query-encoding.md).
// The response is protobuf encoded data directly without a JSON response wrapper.
// The caller is responsible for compiling the proper protobuf definitions for both requests and responses.
// The response is supposed to always be protobuf encoded data, but is JSON encoded on some chains.
// The caller is responsible for compiling the proper type definitions for both requests and responses.
type StargateQuery struct {
// this is the fully qualified service path used for routing,
// eg. custom/cosmos_sdk.x.bank.v1.Query/QueryBalance
// The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded
Data []byte `json:"data"`
// The fully qualified endpoint path used for routing.
// It follows the format `/service_path/method_name`,
// eg. "/cosmos.authz.v1beta1.Query/Grants"
Path string `json:"path"`
// this is the expected protobuf message type (not any), binary encoded
}

// GrpcQuery queries the chain using a grpc query.
// This allows to query information that is not exposed in our API.
// The chain needs to allowlist the supported queries.
//
// The returned data is protobuf encoded. The protobuf type depends on the query.
type GrpcQuery struct {
// The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded
Data []byte `json:"data"`
// The fully qualified endpoint path used for routing.
// It follows the format `/service_path/method_name`,
// eg. "/cosmos.authz.v1beta1.Query/Grants"
Path string `json:"path"`
}

type WasmQuery struct {
Expand Down
Loading