From 5e05483a8e86385507b6a82a918f2bda5f6788cd Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Mon, 18 Dec 2023 11:28:21 +0100 Subject: [PATCH 01/15] Add new grpc query --- packages/std/src/query/mod.rs | 17 ++++++++++++++++- packages/std/src/testing/mock.rs | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/std/src/query/mod.rs b/packages/std/src/query/mod.rs index a6e0219c11..636bb0f8d4 100644 --- a/packages/std/src/query/mod.rs +++ b/packages/std/src/query/mod.rs @@ -2,7 +2,6 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::prelude::*; -#[cfg(feature = "stargate")] use crate::Binary; use crate::Empty; @@ -63,6 +62,22 @@ pub enum QueryRequest { #[cfg(feature = "stargate")] Ibc(IbcQuery), Wasm(WasmQuery), + Grpc(GrpcQuery), +} + +/// Queries the chain using a grpc query. +/// This allows to query information that is not exposed in our API. +/// The chain needs to whitelist the supported queries. +/// The drawback of this query is that you have to handle the protobuf encoding and decoding yourself. +/// +/// The returned data is protobuf encoded. The protobuf type depends on the query. +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct GrpcQuery { + /// The fully qualified service path used for routing, + /// eg. "custom/cosmos_sdk.x.bank.v1.Query/QueryBalance" + path: String, + /// The expected protobuf message type (not any), binary encoded + data: Binary, } /// A trait that is required to avoid conflicts with other query types like BankQuery and WasmQuery diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index dd3395daf0..cb7e839268 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -605,6 +605,9 @@ impl MockQuerier { QueryRequest::Stargate { .. } => SystemResult::Err(SystemError::UnsupportedRequest { kind: "Stargate".to_string(), }), + QueryRequest::Grpc(_) => SystemResult::Err(SystemError::UnsupportedRequest { + kind: "GRPC".to_string(), + }), #[cfg(feature = "stargate")] QueryRequest::Ibc(msg) => self.ibc.query(msg), } From 2e15e769c9fa03fef755e7eeb3f7f0ddf40bf50d Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Mon, 18 Dec 2023 13:43:56 +0100 Subject: [PATCH 02/15] Update schemas --- contracts/reflect/schema/raw/query.json | 34 +++++++++++++++++++++++++ contracts/reflect/schema/reflect.json | 34 +++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/contracts/reflect/schema/raw/query.json b/contracts/reflect/schema/raw/query.json index ef21990549..069537b99e 100644 --- a/contracts/reflect/schema/raw/query.json +++ b/contracts/reflect/schema/raw/query.json @@ -324,6 +324,28 @@ } ] }, + "GrpcQuery": { + "description": "Queries the chain using a grpc query. This allows to query information that is not exposed in our API. The chain needs to whitelist the supported queries. The drawback of this query is that you have to handle the protobuf encoding and decoding yourself.\n\nThe returned data is protobuf encoded. The protobuf type depends on the query.", + "type": "object", + "required": [ + "data", + "path" + ], + "properties": { + "data": { + "description": "The expected protobuf message type (not any), binary encoded", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "path": { + "description": "The fully qualified service path used for routing, eg. \"custom/cosmos_sdk.x.bank.v1.Query/QueryBalance\"", + "type": "string" + } + } + }, "IbcQuery": { "description": "These are queries to the various IBC modules to see the state of the contract's IBC connection. These will return errors if the contract is not \"ibc enabled\"", "oneOf": [ @@ -522,6 +544,18 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "grpc" + ], + "properties": { + "grpc": { + "$ref": "#/definitions/GrpcQuery" + } + }, + "additionalProperties": false } ] }, diff --git a/contracts/reflect/schema/reflect.json b/contracts/reflect/schema/reflect.json index 05e8c7d4be..decd37cca7 100644 --- a/contracts/reflect/schema/reflect.json +++ b/contracts/reflect/schema/reflect.json @@ -1327,6 +1327,28 @@ } ] }, + "GrpcQuery": { + "description": "Queries the chain using a grpc query. This allows to query information that is not exposed in our API. The chain needs to whitelist the supported queries. The drawback of this query is that you have to handle the protobuf encoding and decoding yourself.\n\nThe returned data is protobuf encoded. The protobuf type depends on the query.", + "type": "object", + "required": [ + "data", + "path" + ], + "properties": { + "data": { + "description": "The expected protobuf message type (not any), binary encoded", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "path": { + "description": "The fully qualified service path used for routing, eg. \"custom/cosmos_sdk.x.bank.v1.Query/QueryBalance\"", + "type": "string" + } + } + }, "IbcQuery": { "description": "These are queries to the various IBC modules to see the state of the contract's IBC connection. These will return errors if the contract is not \"ibc enabled\"", "oneOf": [ @@ -1525,6 +1547,18 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "grpc" + ], + "properties": { + "grpc": { + "$ref": "#/definitions/GrpcQuery" + } + }, + "additionalProperties": false } ] }, From 34a55a625c524863efa808220622757b76e3b8ef Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Tue, 19 Dec 2023 12:24:45 +0100 Subject: [PATCH 03/15] Link to protobuf Any type Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com> --- packages/std/src/query/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/std/src/query/mod.rs b/packages/std/src/query/mod.rs index 636bb0f8d4..892e4cf7eb 100644 --- a/packages/std/src/query/mod.rs +++ b/packages/std/src/query/mod.rs @@ -76,7 +76,7 @@ pub struct GrpcQuery { /// The fully qualified service path used for routing, /// eg. "custom/cosmos_sdk.x.bank.v1.Query/QueryBalance" path: String, - /// The expected protobuf message type (not any), binary encoded + /// The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded data: Binary, } From e36093c7c27e0cd4ac9a0e810309fc5a5f1ed0bf Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Tue, 19 Dec 2023 12:25:15 +0100 Subject: [PATCH 04/15] Improve wording Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com> --- packages/std/src/query/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/std/src/query/mod.rs b/packages/std/src/query/mod.rs index 892e4cf7eb..73e97a3640 100644 --- a/packages/std/src/query/mod.rs +++ b/packages/std/src/query/mod.rs @@ -67,7 +67,7 @@ pub enum QueryRequest { /// Queries the chain using a grpc query. /// This allows to query information that is not exposed in our API. -/// The chain needs to whitelist the supported queries. +/// The chain needs to allowlist the supported queries. /// The drawback of this query is that you have to handle the protobuf encoding and decoding yourself. /// /// The returned data is protobuf encoded. The protobuf type depends on the query. From 498d9d3d02596dd03b14430d461fad40707ebe92 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Tue, 19 Dec 2023 13:04:24 +0100 Subject: [PATCH 05/15] Deprecate Stargate query --- packages/std/src/query/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/std/src/query/mod.rs b/packages/std/src/query/mod.rs index 73e97a3640..ae57447c41 100644 --- a/packages/std/src/query/mod.rs +++ b/packages/std/src/query/mod.rs @@ -52,6 +52,7 @@ pub enum QueryRequest { /// 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. #[cfg(feature = "stargate")] + #[deprecated = "Please use the GrpcQuery instead"] Stargate { /// this is the fully qualified service path used for routing, /// eg. custom/cosmos_sdk.x.bank.v1.Query/QueryBalance From dea14925625726e30eac23280eae6ab995abba15 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Tue, 19 Dec 2023 13:04:58 +0100 Subject: [PATCH 06/15] Add GrpcQuery to QueryRequest conversion --- packages/std/src/query/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/std/src/query/mod.rs b/packages/std/src/query/mod.rs index ae57447c41..3a23e8ad29 100644 --- a/packages/std/src/query/mod.rs +++ b/packages/std/src/query/mod.rs @@ -131,6 +131,12 @@ impl From for QueryRequest { } } +impl From for QueryRequest { + fn from(msg: GrpcQuery) -> Self { + QueryRequest::Grpc(msg) + } +} + #[cfg(feature = "stargate")] impl From for QueryRequest { fn from(msg: IbcQuery) -> Self { From 22a8bd1aec71548baffc94af5f644e410da0ab45 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Tue, 19 Dec 2023 13:59:35 +0100 Subject: [PATCH 07/15] Improve grpc query docs --- packages/std/src/query/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/std/src/query/mod.rs b/packages/std/src/query/mod.rs index 3a23e8ad29..19597c501f 100644 --- a/packages/std/src/query/mod.rs +++ b/packages/std/src/query/mod.rs @@ -72,10 +72,14 @@ pub enum QueryRequest { /// The drawback of this query is that you have to handle the protobuf encoding and decoding yourself. /// /// The returned data is protobuf encoded. The protobuf type depends on the query. +/// +/// To find the path, as well as the request and response types, +/// you can query the chain's gRPC endpoint using a tool like +/// [grpcurl](https://github.com/fullstorydev/grpcurl). #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct GrpcQuery { - /// The fully qualified service path used for routing, - /// eg. "custom/cosmos_sdk.x.bank.v1.Query/QueryBalance" + /// The fully qualified endpoint path used for routing, + /// eg. "cosmos.authz.v1beta1.Query.Grants" path: String, /// The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded data: Binary, From 752c8306ef9cb2f7d0077142b3eeac32ce290c7b Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Tue, 19 Dec 2023 15:09:23 +0100 Subject: [PATCH 08/15] Fix deprecation warnings --- packages/std/src/query/mod.rs | 3 +++ packages/std/src/testing/mock.rs | 1 + 2 files changed, 4 insertions(+) diff --git a/packages/std/src/query/mod.rs b/packages/std/src/query/mod.rs index 19597c501f..a3cd4b2681 100644 --- a/packages/std/src/query/mod.rs +++ b/packages/std/src/query/mod.rs @@ -1,3 +1,6 @@ +// needed because the derive macros on QueryRequest use the deprecated `Stargate` variant +#![allow(deprecated)] + use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index cb7e839268..abe163649e 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -602,6 +602,7 @@ impl MockQuerier { } QueryRequest::Wasm(msg) => self.wasm.query(msg), #[cfg(feature = "stargate")] + #[allow(deprecated)] QueryRequest::Stargate { .. } => SystemResult::Err(SystemError::UnsupportedRequest { kind: "Stargate".to_string(), }), From a8725fa4ddb945047a1ba6d0baaeea7076e74ce9 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 20 Dec 2023 13:48:32 +0100 Subject: [PATCH 09/15] Fix stargate and grpc query docs --- packages/std/src/query/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/std/src/query/mod.rs b/packages/std/src/query/mod.rs index a3cd4b2681..a10e798402 100644 --- a/packages/std/src/query/mod.rs +++ b/packages/std/src/query/mod.rs @@ -58,7 +58,7 @@ pub enum QueryRequest { #[deprecated = "Please use the GrpcQuery instead"] Stargate { /// this is the fully qualified service path used for routing, - /// eg. custom/cosmos_sdk.x.bank.v1.Query/QueryBalance + /// eg. "/cosmos_sdk.x.bank.v1.Query/QueryBalance" path: String, /// this is the expected protobuf message type (not any), binary encoded data: Binary, @@ -81,8 +81,9 @@ pub enum QueryRequest { /// [grpcurl](https://github.com/fullstorydev/grpcurl). #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct GrpcQuery { - /// The fully qualified endpoint path used for routing, - /// eg. "cosmos.authz.v1beta1.Query.Grants" + /// The fully qualified endpoint path used for routing. + /// It follows the format `/service_path/method_name`, + /// eg. "/cosmos.authz.v1beta1.Query/Grants" path: String, /// The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded data: Binary, From e1aa326e25b0c5a40098d59a4aa2ec8a47b98fe9 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 20 Dec 2023 15:58:52 +0100 Subject: [PATCH 10/15] Update schemas --- contracts/reflect/schema/raw/query.json | 9 +++++---- contracts/reflect/schema/reflect.json | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/contracts/reflect/schema/raw/query.json b/contracts/reflect/schema/raw/query.json index 069537b99e..4191afab52 100644 --- a/contracts/reflect/schema/raw/query.json +++ b/contracts/reflect/schema/raw/query.json @@ -325,7 +325,7 @@ ] }, "GrpcQuery": { - "description": "Queries the chain using a grpc query. This allows to query information that is not exposed in our API. The chain needs to whitelist the supported queries. The drawback of this query is that you have to handle the protobuf encoding and decoding yourself.\n\nThe returned data is protobuf encoded. The protobuf type depends on the query.", + "description": "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 drawback of this query is that you have to handle the protobuf encoding and decoding yourself.\n\nThe returned data is protobuf encoded. The protobuf type depends on the query.\n\nTo find the path, as well as the request and response types, you can query the chain's gRPC endpoint using a tool like [grpcurl](https://github.com/fullstorydev/grpcurl).", "type": "object", "required": [ "data", @@ -333,7 +333,7 @@ ], "properties": { "data": { - "description": "The expected protobuf message type (not any), binary encoded", + "description": "The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded", "allOf": [ { "$ref": "#/definitions/Binary" @@ -341,7 +341,7 @@ ] }, "path": { - "description": "The fully qualified service path used for routing, eg. \"custom/cosmos_sdk.x.bank.v1.Query/QueryBalance\"", + "description": "The fully qualified endpoint path used for routing. It follows the format `/service_path/method_name`, eg. \"/cosmos.authz.v1beta1.Query/Grants\"", "type": "string" } } @@ -492,6 +492,7 @@ }, { "description": "A Stargate query 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.", + "deprecated": true, "type": "object", "required": [ "stargate" @@ -513,7 +514,7 @@ ] }, "path": { - "description": "this is the fully qualified service path used for routing, eg. custom/cosmos_sdk.x.bank.v1.Query/QueryBalance", + "description": "this is the fully qualified service path used for routing, eg. \"/cosmos_sdk.x.bank.v1.Query/QueryBalance\"", "type": "string" } } diff --git a/contracts/reflect/schema/reflect.json b/contracts/reflect/schema/reflect.json index decd37cca7..9877aa1a42 100644 --- a/contracts/reflect/schema/reflect.json +++ b/contracts/reflect/schema/reflect.json @@ -1328,7 +1328,7 @@ ] }, "GrpcQuery": { - "description": "Queries the chain using a grpc query. This allows to query information that is not exposed in our API. The chain needs to whitelist the supported queries. The drawback of this query is that you have to handle the protobuf encoding and decoding yourself.\n\nThe returned data is protobuf encoded. The protobuf type depends on the query.", + "description": "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 drawback of this query is that you have to handle the protobuf encoding and decoding yourself.\n\nThe returned data is protobuf encoded. The protobuf type depends on the query.\n\nTo find the path, as well as the request and response types, you can query the chain's gRPC endpoint using a tool like [grpcurl](https://github.com/fullstorydev/grpcurl).", "type": "object", "required": [ "data", @@ -1336,7 +1336,7 @@ ], "properties": { "data": { - "description": "The expected protobuf message type (not any), binary encoded", + "description": "The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded", "allOf": [ { "$ref": "#/definitions/Binary" @@ -1344,7 +1344,7 @@ ] }, "path": { - "description": "The fully qualified service path used for routing, eg. \"custom/cosmos_sdk.x.bank.v1.Query/QueryBalance\"", + "description": "The fully qualified endpoint path used for routing. It follows the format `/service_path/method_name`, eg. \"/cosmos.authz.v1beta1.Query/Grants\"", "type": "string" } } @@ -1495,6 +1495,7 @@ }, { "description": "A Stargate query 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.", + "deprecated": true, "type": "object", "required": [ "stargate" @@ -1516,7 +1517,7 @@ ] }, "path": { - "description": "this is the fully qualified service path used for routing, eg. custom/cosmos_sdk.x.bank.v1.Query/QueryBalance", + "description": "this is the fully qualified service path used for routing, eg. \"/cosmos_sdk.x.bank.v1.Query/QueryBalance\"", "type": "string" } } From 677b09607bc1423ce07bf106a9c3b281c84b6019 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 20 Dec 2023 16:21:51 +0100 Subject: [PATCH 11/15] Feature-gate grpc query --- docs/CAPABILITIES-BUILT-IN.md | 4 ++-- packages/std/Cargo.toml | 2 +- packages/std/src/query/mod.rs | 2 ++ packages/std/src/testing/mock.rs | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/CAPABILITIES-BUILT-IN.md b/docs/CAPABILITIES-BUILT-IN.md index 1d1313618d..b9c43bf19e 100644 --- a/docs/CAPABILITIES-BUILT-IN.md +++ b/docs/CAPABILITIES-BUILT-IN.md @@ -23,5 +23,5 @@ might define others. `DistributionQuery::DelegationTotalRewards` and `DistributionQuery::DelegatorValidators` queries. Only chains running CosmWasm `1.4.0` or higher support this. -- `cosmwasm_2_0` enables `CosmosMsg::Any`. Only chains running CosmWasm `2.0.0` - or higher support this. +- `cosmwasm_2_0` enables `CosmosMsg::Any` and `QueryRequest::Grpc`. Only chains + running CosmWasm `2.0.0` or higher support this. diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 6dfdce060b..0e89233675 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -47,7 +47,7 @@ cosmwasm_1_3 = ["cosmwasm_1_2"] # It requires the host blockchain to run CosmWasm `1.4.0` or higher. cosmwasm_1_4 = ["cosmwasm_1_3"] # This enables functionality that is only available on 2.0 chains. -# It adds `CosmosMsg::Any`, replacing `CosmosMsg::Stargate`. +# It adds `CosmosMsg::Any`, replacing `CosmosMsg::Stargate`. It also adds `QueryRequest::Grpc`. cosmwasm_2_0 = ["cosmwasm_1_4"] [dependencies] diff --git a/packages/std/src/query/mod.rs b/packages/std/src/query/mod.rs index a10e798402..ded13c2d7f 100644 --- a/packages/std/src/query/mod.rs +++ b/packages/std/src/query/mod.rs @@ -66,6 +66,7 @@ pub enum QueryRequest { #[cfg(feature = "stargate")] Ibc(IbcQuery), Wasm(WasmQuery), + #[cfg(feature = "cosmwasm_2_0")] Grpc(GrpcQuery), } @@ -139,6 +140,7 @@ impl From for QueryRequest { } } +#[cfg(feature = "cosmwasm_2_0")] impl From for QueryRequest { fn from(msg: GrpcQuery) -> Self { QueryRequest::Grpc(msg) diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index abe163649e..b3bf55f28f 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -606,6 +606,7 @@ impl MockQuerier { QueryRequest::Stargate { .. } => SystemResult::Err(SystemError::UnsupportedRequest { kind: "Stargate".to_string(), }), + #[cfg(feature = "cosmwasm_2_0")] QueryRequest::Grpc(_) => SystemResult::Err(SystemError::UnsupportedRequest { kind: "GRPC".to_string(), }), From 4f0a8ed92a7d8903eaf6251333d5bd87cc50b398 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 20 Dec 2023 16:27:34 +0100 Subject: [PATCH 12/15] Add changelog entry for grpc query --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cb05008d7..a50e5c53fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,8 @@ and this project adheres to - cosmwasm-std: Make `IbcReceiveResponse::acknowledgement` optional and add `IbcReceiveResponse::without_ack` constructor. ([#1892]) - cosmwasm-std: Add `std` feature and make it a default feature. ([#1971]) +- cosmwasm-std: Add `QueryRequest::Grpc` and deprecate `QueryRequest::Stargate`. + ([#1973]) [#1874]: https://github.com/CosmWasm/cosmwasm/pull/1874 [#1876]: https://github.com/CosmWasm/cosmwasm/pull/1876 @@ -91,6 +93,7 @@ and this project adheres to [#1949]: https://github.com/CosmWasm/cosmwasm/pull/1949 [#1967]: https://github.com/CosmWasm/cosmwasm/pull/1967 [#1971]: https://github.com/CosmWasm/cosmwasm/pull/1971 +[#1973]: https://github.com/CosmWasm/cosmwasm/pull/1973 ### Removed From 9662f73ece4ed2044f353025ba8eaefc33c67f05 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 20 Dec 2023 16:32:45 +0100 Subject: [PATCH 13/15] Update schemas --- contracts/reflect/schema/raw/query.json | 34 ------------------------- contracts/reflect/schema/reflect.json | 34 ------------------------- 2 files changed, 68 deletions(-) diff --git a/contracts/reflect/schema/raw/query.json b/contracts/reflect/schema/raw/query.json index 4191afab52..7c37f35326 100644 --- a/contracts/reflect/schema/raw/query.json +++ b/contracts/reflect/schema/raw/query.json @@ -324,28 +324,6 @@ } ] }, - "GrpcQuery": { - "description": "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 drawback of this query is that you have to handle the protobuf encoding and decoding yourself.\n\nThe returned data is protobuf encoded. The protobuf type depends on the query.\n\nTo find the path, as well as the request and response types, you can query the chain's gRPC endpoint using a tool like [grpcurl](https://github.com/fullstorydev/grpcurl).", - "type": "object", - "required": [ - "data", - "path" - ], - "properties": { - "data": { - "description": "The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "path": { - "description": "The fully qualified endpoint path used for routing. It follows the format `/service_path/method_name`, eg. \"/cosmos.authz.v1beta1.Query/Grants\"", - "type": "string" - } - } - }, "IbcQuery": { "description": "These are queries to the various IBC modules to see the state of the contract's IBC connection. These will return errors if the contract is not \"ibc enabled\"", "oneOf": [ @@ -545,18 +523,6 @@ } }, "additionalProperties": false - }, - { - "type": "object", - "required": [ - "grpc" - ], - "properties": { - "grpc": { - "$ref": "#/definitions/GrpcQuery" - } - }, - "additionalProperties": false } ] }, diff --git a/contracts/reflect/schema/reflect.json b/contracts/reflect/schema/reflect.json index 9877aa1a42..aaf5d1dea0 100644 --- a/contracts/reflect/schema/reflect.json +++ b/contracts/reflect/schema/reflect.json @@ -1327,28 +1327,6 @@ } ] }, - "GrpcQuery": { - "description": "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 drawback of this query is that you have to handle the protobuf encoding and decoding yourself.\n\nThe returned data is protobuf encoded. The protobuf type depends on the query.\n\nTo find the path, as well as the request and response types, you can query the chain's gRPC endpoint using a tool like [grpcurl](https://github.com/fullstorydev/grpcurl).", - "type": "object", - "required": [ - "data", - "path" - ], - "properties": { - "data": { - "description": "The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "path": { - "description": "The fully qualified endpoint path used for routing. It follows the format `/service_path/method_name`, eg. \"/cosmos.authz.v1beta1.Query/Grants\"", - "type": "string" - } - } - }, "IbcQuery": { "description": "These are queries to the various IBC modules to see the state of the contract's IBC connection. These will return errors if the contract is not \"ibc enabled\"", "oneOf": [ @@ -1548,18 +1526,6 @@ } }, "additionalProperties": false - }, - { - "type": "object", - "required": [ - "grpc" - ], - "properties": { - "grpc": { - "$ref": "#/definitions/GrpcQuery" - } - }, - "additionalProperties": false } ] }, From 9d9131bef2fec9c3907ba3108a15169b80774726 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 20 Dec 2023 18:58:51 +0100 Subject: [PATCH 14/15] Make grpc query fields public --- packages/std/src/query/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/std/src/query/mod.rs b/packages/std/src/query/mod.rs index ded13c2d7f..8082fdd44d 100644 --- a/packages/std/src/query/mod.rs +++ b/packages/std/src/query/mod.rs @@ -85,9 +85,9 @@ pub struct GrpcQuery { /// The fully qualified endpoint path used for routing. /// It follows the format `/service_path/method_name`, /// eg. "/cosmos.authz.v1beta1.Query/Grants" - path: String, + pub path: String, /// The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded - data: Binary, + pub data: Binary, } /// A trait that is required to avoid conflicts with other query types like BankQuery and WasmQuery From 2d8baa9895f1304150faa2c9c02777bde56e2c4e Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 20 Dec 2023 19:00:19 +0100 Subject: [PATCH 15/15] Add migrating entry for grpc query --- MIGRATING.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/MIGRATING.md b/MIGRATING.md index d1dc8c6099..e13975ac2e 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -189,6 +189,23 @@ major releases of `cosmwasm`. Note that you can also view the +}; ``` +- If you were using `QueryRequest::Stargate`, you might want to enable the + `cosmwasm_2_0` cargo feature and migrate to `QueryRequest::Grpc` instead. + While the stargate query sometimes returns protobuf encoded data and sometimes + JSON encoded data, depending on the chain, the gRPC query always returns + protobuf encoded data. + + ```diff + -deps.querier.query(&QueryRequest::Stargate { + - path: "/service.Path/ServiceMethod".to_string(), + - data: Binary::new(b"DATA"), + -})?; + +deps.querier.query(&QueryRequest::Grpc(GrpcQuery { + + path: "/service.Path/ServiceMethod".to_string(), + + data: Binary::new(b"DATA"), + +}))?; + ``` + ## 1.4.x -> 1.5.0 - Update `cosmwasm-*` dependencies in Cargo.toml (skip the ones you don't use):