From 40b6c561caaeaa8eb3a5f8a0a9bc0e7d3ce072fa Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 16 Oct 2024 18:15:09 +0800 Subject: [PATCH] Problem: ibc query is outdated in swagger (#1640) * Problem: ibc query is outdated in swagger * persist-credentials * Revert "persist-credentials" This reverts commit 320d9e982baaf9b061dd0ade676c04bd1ce4e50f. --- client/docs/swagger-ui/swagger.yaml | 387 ++++++++++++++++++ .../interchain_accounts/host/v1/host.proto | 11 + .../interchain_accounts/host/v1/tx.proto | 25 ++ .../ibc/applications/transfer/v1/authz.proto | 4 +- .../proto/ibc/core/client/v1/query.proto | 35 ++ .../proto/ibc/core/connection/v1/tx.proto | 22 +- 6 files changed, 471 insertions(+), 13 deletions(-) diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 6969e77e22..c5f9adf0dc 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -44391,6 +44391,299 @@ paths: } tags: - Query + /ibc/core/client/v1/verify_membership: + post: + summary: >- + VerifyMembership queries an IBC light client for proof verification of a + value at a given key path. + operationId: VerifyMembership + responses: + '200': + description: A successful response. + schema: + type: object + properties: + success: + type: boolean + description: boolean indicating success or failure of proof verification. + title: >- + QueryVerifyMembershipResponse is the response type for the + Query/VerifyMembership RPC method + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: body + in: body + required: true + schema: + type: object + properties: + client_id: + type: string + description: client unique identifier. + proof: + type: string + format: byte + description: the proof to be verified by the client. + proof_height: + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height + while keeping + + RevisionNumber the same. However some consensus algorithms may + choose to + + reset the height in certain conditions e.g. hard forks, + state-machine + + breaking changes In these cases, the RevisionNumber is + incremented so that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + title: >- + Height is a monotonically increasing data type + + that can be compared against another Height for the purposes + of updating and + + freezing clients + merkle_path: + description: the commitment key path. + type: object + properties: + key_path: + type: array + items: + type: string + title: >- + MerklePath is the path used to verify commitment proofs, which + can be an + + arbitrary structured object (defined by a commitment type). + + MerklePath is represented from root-to-leaf + value: + type: string + format: byte + description: the value which is proven. + time_delay: + type: string + format: uint64 + title: optional time delay + block_delay: + type: string + format: uint64 + title: optional block delay + title: >- + QueryVerifyMembershipRequest is the request type for the + Query/VerifyMembership RPC method + tags: + - Query /ibc/apps/fee/v1/channels/{channel_id}/ports/{port_id}/fee_enabled: get: summary: >- @@ -75479,6 +75772,100 @@ definitions: description: |- QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState RPC method. + ibc.core.client.v1.QueryVerifyMembershipRequest: + type: object + properties: + client_id: + type: string + description: client unique identifier. + proof: + type: string + format: byte + description: the proof to be verified by the client. + proof_height: + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping + + RevisionNumber the same. However some consensus algorithms may choose + to + + reset the height in certain conditions e.g. hard forks, state-machine + + breaking changes In these cases, the RevisionNumber is incremented so + that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + title: >- + Height is a monotonically increasing data type + + that can be compared against another Height for the purposes of + updating and + + freezing clients + merkle_path: + description: the commitment key path. + type: object + properties: + key_path: + type: array + items: + type: string + title: >- + MerklePath is the path used to verify commitment proofs, which can be + an + + arbitrary structured object (defined by a commitment type). + + MerklePath is represented from root-to-leaf + value: + type: string + format: byte + description: the value which is proven. + time_delay: + type: string + format: uint64 + title: optional time delay + block_delay: + type: string + format: uint64 + title: optional block delay + title: >- + QueryVerifyMembershipRequest is the request type for the + Query/VerifyMembership RPC method + ibc.core.client.v1.QueryVerifyMembershipResponse: + type: object + properties: + success: + type: boolean + description: boolean indicating success or failure of proof verification. + title: >- + QueryVerifyMembershipResponse is the response type for the + Query/VerifyMembership RPC method + ibc.core.commitment.v1.MerklePath: + type: object + properties: + key_path: + type: array + items: + type: string + title: |- + MerklePath is the path used to verify commitment proofs, which can be an + arbitrary structured object (defined by a commitment type). + MerklePath is represented from root-to-leaf ibc.applications.fee.v1.Fee: type: object properties: diff --git a/third_party/proto/ibc/applications/interchain_accounts/host/v1/host.proto b/third_party/proto/ibc/applications/interchain_accounts/host/v1/host.proto index f036857113..9165f36e79 100644 --- a/third_party/proto/ibc/applications/interchain_accounts/host/v1/host.proto +++ b/third_party/proto/ibc/applications/interchain_accounts/host/v1/host.proto @@ -12,3 +12,14 @@ message Params { // allow_messages defines a list of sdk message typeURLs allowed to be executed on a host chain. repeated string allow_messages = 2; } + +// QueryRequest defines the parameters for a particular query request +// by an interchain account. +message QueryRequest { + // path defines the path of the query request as defined by ADR-021. + // https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-021-protobuf-query-encoding.md#custom-query-registration-and-routing + string path = 1; + // data defines the payload of the query request as defined by ADR-021. + // https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-021-protobuf-query-encoding.md#custom-query-registration-and-routing + bytes data = 2; +} diff --git a/third_party/proto/ibc/applications/interchain_accounts/host/v1/tx.proto b/third_party/proto/ibc/applications/interchain_accounts/host/v1/tx.proto index 5a8073bc93..22e8c9b356 100644 --- a/third_party/proto/ibc/applications/interchain_accounts/host/v1/tx.proto +++ b/third_party/proto/ibc/applications/interchain_accounts/host/v1/tx.proto @@ -14,6 +14,9 @@ service Msg { // UpdateParams defines a rpc handler for MsgUpdateParams. rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + + // ModuleQuerySafe defines a rpc handler for MsgModuleQuerySafe. + rpc ModuleQuerySafe(MsgModuleQuerySafe) returns (MsgModuleQuerySafeResponse); } // MsgUpdateParams defines the payload for Msg/UpdateParams @@ -33,3 +36,25 @@ message MsgUpdateParams { // MsgUpdateParamsResponse defines the response for Msg/UpdateParams message MsgUpdateParamsResponse {} + +// MsgModuleQuerySafe defines the payload for Msg/ModuleQuerySafe +message MsgModuleQuerySafe { + option (cosmos.msg.v1.signer) = "signer"; + + option (gogoproto.goproto_getters) = false; + + // signer address + string signer = 1; + + // requests defines the module safe queries to execute. + repeated QueryRequest requests = 2; +} + +// MsgModuleQuerySafeResponse defines the response for Msg/ModuleQuerySafe +message MsgModuleQuerySafeResponse { + // height at which the responses were queried + uint64 height = 1; + + // protobuf encoded responses for each query + repeated bytes responses = 2; +} diff --git a/third_party/proto/ibc/applications/transfer/v1/authz.proto b/third_party/proto/ibc/applications/transfer/v1/authz.proto index e7561b0708..5c4b71d347 100644 --- a/third_party/proto/ibc/applications/transfer/v1/authz.proto +++ b/third_party/proto/ibc/applications/transfer/v1/authz.proto @@ -19,8 +19,8 @@ message Allocation { [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; // allow list of receivers, an empty allow list permits any receiver address repeated string allow_list = 4; - // allow list of packet data keys, an empty list prohibits all packet data keys; - // a list only with "*" permits any packet data key + // allow list of memo strings, an empty list prohibits all memo strings; + // a list only with "*" permits any memo string repeated string allowed_packet_data = 5; } diff --git a/third_party/proto/ibc/core/client/v1/query.proto b/third_party/proto/ibc/core/client/v1/query.proto index 0032306ec9..10377d9717 100644 --- a/third_party/proto/ibc/core/client/v1/query.proto +++ b/third_party/proto/ibc/core/client/v1/query.proto @@ -5,7 +5,9 @@ package ibc.core.client.v1; option go_package = "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"; import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos/query/v1/query.proto"; import "ibc/core/client/v1/client.proto"; +import "ibc/core/commitment/v1/commitment.proto"; import "google/protobuf/any.proto"; import "google/api/annotations.proto"; import "gogoproto/gogo.proto"; @@ -60,6 +62,15 @@ service Query { rpc UpgradedConsensusState(QueryUpgradedConsensusStateRequest) returns (QueryUpgradedConsensusStateResponse) { option (google.api.http).get = "/ibc/core/client/v1/upgraded_consensus_states"; } + + // VerifyMembership queries an IBC light client for proof verification of a value at a given key path. + rpc VerifyMembership(QueryVerifyMembershipRequest) returns (QueryVerifyMembershipResponse) { + option (cosmos.query.v1.module_query_safe) = true; + option (google.api.http) = { + post: "/ibc/core/client/v1/verify_membership" + body: "*" + }; + } } // QueryClientStateRequest is the request type for the Query/ClientState RPC @@ -205,3 +216,27 @@ message QueryUpgradedConsensusStateResponse { // Consensus state associated with the request identifier google.protobuf.Any upgraded_consensus_state = 1; } + +// QueryVerifyMembershipRequest is the request type for the Query/VerifyMembership RPC method +message QueryVerifyMembershipRequest { + // client unique identifier. + string client_id = 1; + // the proof to be verified by the client. + bytes proof = 2; + // the height of the commitment root at which the proof is verified. + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; + // the commitment key path. + ibc.core.commitment.v1.MerklePath merkle_path = 4 [(gogoproto.nullable) = false]; + // the value which is proven. + bytes value = 5; + // optional time delay + uint64 time_delay = 6; + // optional block delay + uint64 block_delay = 7; +} + +// QueryVerifyMembershipResponse is the response type for the Query/VerifyMembership RPC method +message QueryVerifyMembershipResponse { + // boolean indicating success or failure of proof verification. + bool success = 1; +} \ No newline at end of file diff --git a/third_party/proto/ibc/core/connection/v1/tx.proto b/third_party/proto/ibc/core/connection/v1/tx.proto index 3ba8ff4566..648cb4bac1 100644 --- a/third_party/proto/ibc/core/connection/v1/tx.proto +++ b/third_party/proto/ibc/core/connection/v1/tx.proto @@ -60,7 +60,7 @@ message MsgConnectionOpenTry { string client_id = 1; // Deprecated: this field is unused. Crossing hellos are no longer supported in core IBC. string previous_connection_id = 2 [deprecated = true]; - google.protobuf.Any client_state = 3; + google.protobuf.Any client_state = 3 [deprecated = true]; Counterparty counterparty = 4 [(gogoproto.nullable) = false]; uint64 delay_period = 5; repeated Version counterparty_versions = 6; @@ -69,13 +69,13 @@ message MsgConnectionOpenTry { // INIT` bytes proof_init = 8; // proof of client state included in message - bytes proof_client = 9; + bytes proof_client = 9 [deprecated = true]; // proof of client consensus state - bytes proof_consensus = 10; - ibc.core.client.v1.Height consensus_height = 11 [(gogoproto.nullable) = false]; + bytes proof_consensus = 10 [deprecated = true]; + ibc.core.client.v1.Height consensus_height = 11 [deprecated = true, (gogoproto.nullable) = false]; string signer = 12; // optional proof data for host state machines that are unable to introspect their own consensus state - bytes host_consensus_state_proof = 13; + bytes host_consensus_state_proof = 13 [deprecated = true]; } // MsgConnectionOpenTryResponse defines the Msg/ConnectionOpenTry response type. @@ -91,19 +91,19 @@ message MsgConnectionOpenAck { string connection_id = 1; string counterparty_connection_id = 2; Version version = 3; - google.protobuf.Any client_state = 4; + google.protobuf.Any client_state = 4 [deprecated = true]; ibc.core.client.v1.Height proof_height = 5 [(gogoproto.nullable) = false]; // proof of the initialization the connection on Chain B: `UNITIALIZED -> // TRYOPEN` bytes proof_try = 6; // proof of client state included in message - bytes proof_client = 7; + bytes proof_client = 7 [deprecated = true]; // proof of client consensus state - bytes proof_consensus = 8; - ibc.core.client.v1.Height consensus_height = 9 [(gogoproto.nullable) = false]; + bytes proof_consensus = 8 [deprecated = true]; + ibc.core.client.v1.Height consensus_height = 9 [deprecated = true, (gogoproto.nullable) = false]; string signer = 10; // optional proof data for host state machines that are unable to introspect their own consensus state - bytes host_consensus_state_proof = 11; + bytes host_consensus_state_proof = 11 [deprecated = true]; } // MsgConnectionOpenAckResponse defines the Msg/ConnectionOpenAck response type. @@ -143,4 +143,4 @@ message MsgUpdateParams { } // MsgUpdateParamsResponse defines the MsgUpdateParams response type. -message MsgUpdateParamsResponse {} \ No newline at end of file +message MsgUpdateParamsResponse {}