From f7b24e1fe72aae226c8d14baea469a62f3dc3757 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Wed, 26 Feb 2025 17:51:20 +0100 Subject: [PATCH] feat: remove channel upgradability (#8008) * feat: remove channel upgradability * lint * basic migration setup * feat: remove channel upgradeability * fix docs * register v10 migration in app module * error on upgrading channels + code review fixes --- docs/client/swagger-ui/swagger.yaml | 2654 +---- docs/docs/01-ibc/06-channel-upgrades.md | 413 - .../{07-proposals.md => 06-proposals.md} | 0 .../01-ibc/{08-relayer.md => 07-relayer.md} | 0 .../{09-proto-docs.md => 08-proto-docs.md} | 0 .../01-ibc/{10-roadmap.md => 09-roadmap.md} | 0 ...oubleshooting.md => 10-troubleshooting.md} | 0 ...best-practices.md => 11-best-practices.md} | 0 ...4-permissioning.md => 12-permissioning.md} | 0 .../02-interchain-accounts/01-overview.md | 2 +- .../01-developer-guide/08-proposals.md | 2 +- docs/docs/05-migrations/02-sdk-to-v1.md | 2 +- docs/docs/05-migrations/12-v8-to-v8_1.md | 2 +- docs/docusaurus.config.js | 17 - .../channel-upgradability-requirements.md | 178 - docs/tutorials/00-intro.md | 10 - .../tutorials/02-channel-upgrades/01-intro.md | 38 - .../02-channel-upgrades/02-setup-env.md | 75 - .../02-channel-upgrades/03-run-chains.md | 110 - .../04-open-transfer-channel.md | 167 - .../02-channel-upgrades/05-upgrade-channel.md | 213 - .../06-incentivize-packet.md | 105 - .../02-channel-upgrades/_category_.json | 5 - .../interchain_accounts/localhost_test.go | 2 +- .../interchain_accounts/upgrades_test.go | 218 - e2e/testsuite/query/queries.go | 12 - e2e/testsuite/testsuite.go | 23 - e2e/testsuite/tx.go | 13 - .../controller/ibc_middleware.go | 78 - .../controller/ibc_middleware_test.go | 313 - .../controller/keeper/handshake_test.go | 372 - .../27-interchain-accounts/host/ibc_module.go | 24 - .../host/ibc_module_test.go | 122 - .../host/keeper/handshake.go | 73 - .../host/keeper/handshake_test.go | 200 - .../host/keeper/keeper.go | 9 - modules/apps/callbacks/ibc_middleware.go | 43 - modules/apps/transfer/ibc_module.go | 41 - modules/apps/transfer/ibc_module_test.go | 211 - modules/core/03-connection/keeper/verify.go | 66 - .../core/03-connection/keeper/verify_test.go | 148 - modules/core/04-channel/client/cli/cli.go | 21 - modules/core/04-channel/client/cli/query.go | 93 - modules/core/04-channel/client/cli/tx.go | 175 - modules/core/04-channel/client/utils/utils.go | 86 - modules/core/04-channel/genesis.go | 7 - modules/core/04-channel/keeper/events.go | 167 - modules/core/04-channel/keeper/export_test.go | 20 - modules/core/04-channel/keeper/grpc_query.go | 74 - .../core/04-channel/keeper/grpc_query_test.go | 223 +- modules/core/04-channel/keeper/handshake.go | 23 +- .../core/04-channel/keeper/handshake_test.go | 53 +- modules/core/04-channel/keeper/keeper.go | 238 - modules/core/04-channel/keeper/keeper_test.go | 482 - modules/core/04-channel/keeper/migrations.go | 16 +- .../core/04-channel/keeper/migrations_test.go | 34 - modules/core/04-channel/keeper/packet.go | 54 +- modules/core/04-channel/keeper/packet_test.go | 267 - modules/core/04-channel/keeper/timeout.go | 33 +- .../core/04-channel/keeper/timeout_test.go | 232 +- modules/core/04-channel/keeper/upgrade.go | 1053 -- .../core/04-channel/keeper/upgrade_test.go | 2779 ----- .../04-channel/migrations/v10/channel.pb.go | 2964 ++++++ .../migrations/v10/expected_keepers.go | 14 + .../core/04-channel/migrations/v10/store.go | 123 + .../04-channel/migrations/v10/store_test.go | 232 + .../{types => migrations/v10}/upgrade.pb.go | 2 +- modules/core/04-channel/module.go | 5 - modules/core/04-channel/types/channel.go | 17 +- modules/core/04-channel/types/channel.pb.go | 364 +- modules/core/04-channel/types/codec.go | 9 - modules/core/04-channel/types/codec_test.go | 45 - modules/core/04-channel/types/events.go | 29 +- .../core/04-channel/types/expected_keepers.go | 18 - modules/core/04-channel/types/genesis.go | 3 - modules/core/04-channel/types/genesis.pb.go | 113 +- modules/core/04-channel/types/genesis_test.go | 3 - modules/core/04-channel/types/keys.go | 3 - modules/core/04-channel/types/msgs.go | 424 +- modules/core/04-channel/types/msgs_test.go | 876 +- modules/core/04-channel/types/params.go | 37 - modules/core/04-channel/types/query.go | 18 - modules/core/04-channel/types/query.pb.go | 1638 +-- modules/core/04-channel/types/query.pb.gw.go | 311 - modules/core/04-channel/types/tx.pb.go | 9131 ++++------------- modules/core/04-channel/types/upgrade.go | 128 - modules/core/04-channel/types/upgrade_test.go | 262 - modules/core/05-port/types/module.go | 51 - modules/core/24-host/channel_keys.go | 23 +- modules/core/24-host/packet_keys.go | 6 - modules/core/ante/ante_test.go | 2 +- modules/core/client/cli/cli.go | 1 - modules/core/genesis_test.go | 2 - modules/core/integration_test.go | 98 - modules/core/keeper/msg_server.go | 354 +- modules/core/keeper/msg_server_test.go | 1898 +--- modules/core/module.go | 14 +- proto/ibc/core/channel/v1/channel.proto | 24 +- proto/ibc/core/channel/v1/genesis.proto | 1 - proto/ibc/core/channel/v1/query.proto | 57 - proto/ibc/core/channel/v1/tx.proto | 212 - proto/ibc/core/channel/v1/upgrade.proto | 43 - testing/config.go | 7 +- testing/endpoint.go | 250 - testing/mock/ibc_module.go | 35 - testing/solomachine.go | 2 - 106 files changed, 6263 insertions(+), 25677 deletions(-) delete mode 100644 docs/docs/01-ibc/06-channel-upgrades.md rename docs/docs/01-ibc/{07-proposals.md => 06-proposals.md} (100%) rename docs/docs/01-ibc/{08-relayer.md => 07-relayer.md} (100%) rename docs/docs/01-ibc/{09-proto-docs.md => 08-proto-docs.md} (100%) rename docs/docs/01-ibc/{10-roadmap.md => 09-roadmap.md} (100%) rename docs/docs/01-ibc/{11-troubleshooting.md => 10-troubleshooting.md} (100%) rename docs/docs/01-ibc/{13-best-practices.md => 11-best-practices.md} (100%) rename docs/docs/01-ibc/{14-permissioning.md => 12-permissioning.md} (100%) delete mode 100644 docs/requirements/channel-upgradability-requirements.md delete mode 100644 docs/tutorials/00-intro.md delete mode 100644 docs/tutorials/02-channel-upgrades/01-intro.md delete mode 100644 docs/tutorials/02-channel-upgrades/02-setup-env.md delete mode 100644 docs/tutorials/02-channel-upgrades/03-run-chains.md delete mode 100644 docs/tutorials/02-channel-upgrades/04-open-transfer-channel.md delete mode 100644 docs/tutorials/02-channel-upgrades/05-upgrade-channel.md delete mode 100644 docs/tutorials/02-channel-upgrades/06-incentivize-packet.md delete mode 100644 docs/tutorials/02-channel-upgrades/_category_.json delete mode 100644 e2e/tests/interchain_accounts/upgrades_test.go delete mode 100644 modules/core/04-channel/client/cli/tx.go delete mode 100644 modules/core/04-channel/keeper/migrations_test.go delete mode 100644 modules/core/04-channel/keeper/upgrade.go delete mode 100644 modules/core/04-channel/keeper/upgrade_test.go create mode 100644 modules/core/04-channel/migrations/v10/channel.pb.go create mode 100644 modules/core/04-channel/migrations/v10/expected_keepers.go create mode 100644 modules/core/04-channel/migrations/v10/store.go create mode 100644 modules/core/04-channel/migrations/v10/store_test.go rename modules/core/04-channel/{types => migrations/v10}/upgrade.pb.go (99%) delete mode 100644 modules/core/04-channel/types/params.go delete mode 100644 modules/core/04-channel/types/upgrade.go delete mode 100644 modules/core/04-channel/types/upgrade_test.go delete mode 100644 modules/core/integration_test.go delete mode 100644 proto/ibc/core/channel/v1/upgrade.proto diff --git a/docs/client/swagger-ui/swagger.yaml b/docs/client/swagger-ui/swagger.yaml index b84e56c765f..34714825ef2 100644 --- a/docs/client/swagger-ui/swagger.yaml +++ b/docs/client/swagger-ui/swagger.yaml @@ -6546,15 +6546,12 @@ paths: - STATE_TRYOPEN - STATE_OPEN - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE default: STATE_UNINITIALIZED_UNSPECIFIED description: >- State defines if a channel is in one of the following states: - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or - UNINITIALIZED. + CLOSED, INIT, TRYOPEN, OPEN, or UNINITIALIZED. - STATE_UNINITIALIZED_UNSPECIFIED: Default State - STATE_INIT: A channel has just started the opening handshake. @@ -6563,8 +6560,6 @@ paths: ready to send and receive packets. - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. ordering: title: whether the channel is ordered or unordered type: string @@ -6611,15 +6606,6 @@ paths: channel_id: type: string title: channel identifier - upgrade_sequence: - type: string - format: uint64 - title: >- - upgrade sequence indicates the latest upgrade attempt - performed by this channel - - the value of 0 indicates the channel has never been - upgraded description: >- IdentifiedChannel defines a channel with additional port and channel @@ -6970,15 +6956,12 @@ paths: - STATE_TRYOPEN - STATE_OPEN - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE default: STATE_UNINITIALIZED_UNSPECIFIED description: >- State defines if a channel is in one of the following states: - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or - UNINITIALIZED. + CLOSED, INIT, TRYOPEN, OPEN, or UNINITIALIZED. - STATE_UNINITIALIZED_UNSPECIFIED: Default State - STATE_INIT: A channel has just started the opening handshake. @@ -6987,8 +6970,6 @@ paths: ready to send and receive packets. - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. ordering: title: whether the channel is ordered or unordered type: string @@ -7028,15 +7009,6 @@ paths: title: >- opaque channel version, which is agreed upon during the handshake - upgrade_sequence: - type: string - format: uint64 - title: >- - upgrade sequence indicates the latest upgrade attempt - performed by this channel - - the value of 0 indicates the channel has never been - upgraded description: >- Channel defines pipeline for exactly-once packet delivery between specific @@ -10875,129 +10847,129 @@ paths: format: uint64 tags: - Query - /ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/upgrade: + /ibc/core/channel/v1/connections/{connection}/channels: get: - summary: Upgrade returns the upgrade for a given port and channel id. - operationId: Upgrade + summary: |- + ConnectionChannels queries all the channels associated with a connection + end. + operationId: ConnectionChannels responses: '200': description: A successful response. schema: type: object properties: - upgrade: - type: object - properties: - fields: - type: object - properties: - ordering: - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: >- - - ORDER_NONE_UNSPECIFIED: zero-value for channel - ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - title: Order defines if a channel is ORDERED or UNORDERED - connection_hops: - type: array - items: - type: string - version: - type: string - description: >- - UpgradeFields are the fields in a channel end which may be - changed - - during a channel upgrade. - timeout: - type: object - properties: - height: - title: >- - block height after which the packet or upgrade times - out - 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 - + channels: + type: array + items: + type: object + properties: + state: + title: current state of the channel end + type: string + enum: + - STATE_UNINITIALIZED_UNSPECIFIED + - STATE_INIT + - STATE_TRYOPEN + - STATE_OPEN + - STATE_CLOSED + default: STATE_UNINITIALIZED_UNSPECIFIED + description: >- + State defines if a channel is in one of the following + states: - Please note that json tags for generated Go code are - overridden to explicitly exclude the omitempty - jsontag. + CLOSED, INIT, TRYOPEN, OPEN, or UNINITIALIZED. - This enforces the Go json marshaller to always emit - zero values for both revision_number and - revision_height. - timestamp: + - STATE_UNINITIALIZED_UNSPECIFIED: Default State + - STATE_INIT: A channel has just started the opening handshake. + - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. + - STATE_OPEN: A channel has completed the handshake. Open channels are + ready to send and receive packets. + - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive + packets. + ordering: + title: whether the channel is ordered or unordered + type: string + enum: + - ORDER_NONE_UNSPECIFIED + - ORDER_UNORDERED + - ORDER_ORDERED + default: ORDER_NONE_UNSPECIFIED + description: >- + - ORDER_NONE_UNSPECIFIED: zero-value for channel + ordering + - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in + which they were sent. + - ORDER_ORDERED: packets are delivered exactly in the order which they were sent + counterparty: + title: counterparty channel end + type: object + properties: + port_id: + type: string + description: >- + port on the counterparty chain which owns the other + end of the channel. + channel_id: + type: string + title: channel end on the counterparty chain + connection_hops: + type: array + items: type: string - format: uint64 - title: >- - block timestamp (in nanoseconds) after which the - packet or upgrade times out - description: >- - Timeout defines an execution deadline structure for - 04-channel handlers. + title: >- + list of connection identifiers, in order, along which + packets sent on - This includes packet lifecycle handlers as well as the - upgrade handshake handlers. + this channel will travel + version: + type: string + title: >- + opaque channel version, which is agreed upon during the + handshake + port_id: + type: string + title: port identifier + channel_id: + type: string + title: channel identifier + description: >- + IdentifiedChannel defines a channel with additional port and + channel - A valid Timeout contains either one or both of a timestamp - and block height (sequence). - next_sequence_send: + identifier fields. + description: list of channels associated with a connection. + pagination: + title: pagination response + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: type: string format: uint64 - description: >- - Upgrade is a verifiable type which contains the relevant - information - - for an attempted upgrade. It provides the proposed changes to - the channel + title: >- + total is total number of results available if + PageRequest.count_total - end, the timeout for this upgrade attempt and the next packet - sequence + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the - which allows the counterparty to efficiently know the highest - sequence it has received. + corresponding request message has used PageRequest. - The next sequence send is used for pruning and upgrading from - unordered to ordered channels. - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + height: + title: query block height type: object properties: revision_number: @@ -11032,9 +11004,9 @@ paths: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - title: >- - QueryUpgradeResponse is the response type for the - QueryUpgradeResponse RPC method + title: |- + QueryConnectionChannelsResponse is the Response type for the + Query/QueryConnectionChannels RPC method default: description: An unexpected error response. schema: @@ -11230,44 +11202,83 @@ paths: "value": "1.212s" } parameters: - - name: channel_id + - name: connection + description: connection unique identifier in: path required: true type: string - - name: port_id - in: path - required: true + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean tags: - Query - /ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/upgrade_error: + /ibc/core/channel/v2/clients/{client_id}/next_sequence_send: get: - summary: UpgradeError returns the error receipt if the upgrade handshake failed. - operationId: UpgradeError + summary: NextSequenceSend returns the next send sequence for a given channel. + operationId: NextSequenceSendV2 responses: '200': description: A successful response. schema: type: object properties: - error_receipt: - type: object - properties: - sequence: - type: string - format: uint64 - title: the channel upgrade sequence - message: - type: string - title: the error message detailing the cause of failure - description: >- - ErrorReceipt defines a type which encapsulates the upgrade - sequence and error associated with the - - upgrade handshake failure. When a channel upgrade handshake is - aborted both chains are expected to increment to the - - next sequence. + next_sequence_send: + type: string + format: uint64 + title: next sequence send number proof: type: string format: byte @@ -11309,8 +11320,8 @@ paths: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. title: >- - QueryUpgradeErrorResponse is the response type for the - Query/QueryUpgradeError RPC method + QueryNextSequenceSendResponse is the response type for the + Query/QueryNextSequenceSend RPC method default: description: An unexpected error response. schema: @@ -11506,122 +11517,51 @@ paths: "value": "1.212s" } parameters: - - name: channel_id - in: path - required: true - type: string - - name: port_id + - name: client_id + description: client unique identifier in: path required: true type: string tags: - Query - /ibc/core/channel/v1/connections/{connection}/channels: + /ibc/core/channel/v2/clients/{client_id}/packet_acknowledgements: get: - summary: |- - ConnectionChannels queries all the channels associated with a connection - end. - operationId: ConnectionChannels + summary: >- + PacketAcknowledgements returns all packet acknowledgements associated + with a channel. + operationId: PacketAcknowledgementsV2 responses: '200': description: A successful response. schema: type: object properties: - channels: + acknowledgements: type: array items: type: object properties: - state: - title: current state of the channel end + client_id: type: string - enum: - - STATE_UNINITIALIZED_UNSPECIFIED - - STATE_INIT - - STATE_TRYOPEN - - STATE_OPEN - - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE - default: STATE_UNINITIALIZED_UNSPECIFIED - description: >- - State defines if a channel is in one of the following - states: - - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or - UNINITIALIZED. - - - STATE_UNINITIALIZED_UNSPECIFIED: Default State - - STATE_INIT: A channel has just started the opening handshake. - - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. - - STATE_OPEN: A channel has completed the handshake. Open channels are - ready to send and receive packets. - - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive - packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. - ordering: - title: whether the channel is ordered or unordered - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: >- - - ORDER_NONE_UNSPECIFIED: zero-value for channel - ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - counterparty: - title: counterparty channel end - type: object - properties: - port_id: - type: string - description: >- - port on the counterparty chain which owns the other - end of the channel. - channel_id: - type: string - title: channel end on the counterparty chain - connection_hops: - type: array - items: - type: string - title: >- - list of connection identifiers, in order, along which - packets sent on - - this channel will travel - version: - type: string - title: >- - opaque channel version, which is agreed upon during the - handshake - port_id: - type: string - title: port identifier - channel_id: - type: string - title: channel identifier - upgrade_sequence: + description: client unique identifier. + sequence: type: string format: uint64 - title: >- - upgrade sequence indicates the latest upgrade attempt - performed by this channel - - the value of 0 indicates the channel has never been - upgraded + description: packet sequence. + data: + type: string + format: byte + description: embedded data that represents packet state. description: >- - IdentifiedChannel defines a channel with additional port and - channel + PacketState defines the generic type necessary to retrieve + and store - identifier fields. - description: list of channels associated with a connection. + packet commitments, acknowledgements, and receipts. + + Caller is responsible for knowing the context necessary to + interpret this + + state as a commitment, acknowledgement, or a receipt. pagination: title: pagination response type: object @@ -11688,8 +11628,8 @@ paths: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. title: |- - QueryConnectionChannelsResponse is the Response type for the - Query/QueryConnectionChannels RPC method + QueryPacketAcknowledgemetsResponse is the request type for the + Query/QueryPacketAcknowledgements RPC method default: description: An unexpected error response. schema: @@ -11885,8 +11825,8 @@ paths: "value": "1.212s" } parameters: - - name: connection - description: connection unique identifier + - name: client_id + description: client unique identifier in: path required: true type: string @@ -11946,83 +11886,74 @@ paths: in: query required: false type: boolean + - name: packet_commitment_sequences + description: list of packet sequences. + in: query + required: false + type: array + items: + type: string + format: uint64 + collectionFormat: multi tags: - Query - /ibc/core/channel/v1/params: + /ibc/core/channel/v2/clients/{client_id}/packet_acks/{sequence}: get: - summary: ChannelParams queries all parameters of the ibc channel submodule. - operationId: ChannelParams + summary: PacketAcknowledgement queries a stored acknowledgement commitment hash. + operationId: PacketAcknowledgementV2 responses: '200': description: A successful response. schema: type: object properties: - params: - description: params defines the parameters of the module. + acknowledgement: + type: string + format: byte + title: acknowledgement associated with the request fields + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved type: object properties: - upgrade_timeout: - type: object - properties: - height: - title: >- - block height after which the packet or upgrade times - out - 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 + 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 - breaking changes In these cases, the RevisionNumber is - incremented so that + RevisionNumber the same. However some consensus algorithms may + choose to - height continues to be monitonically increasing even - as the RevisionHeight + reset the height in certain conditions e.g. hard forks, + state-machine - gets reset + breaking changes In these cases, the RevisionNumber is + incremented so that + height continues to be monitonically increasing even as the + RevisionHeight - Please note that json tags for generated Go code are - overridden to explicitly exclude the omitempty - jsontag. + gets reset - This enforces the Go json marshaller to always emit - zero values for both revision_number and - revision_height. - timestamp: - type: string - format: uint64 - title: >- - block timestamp (in nanoseconds) after which the - packet or upgrade times out - description: >- - Timeout defines an execution deadline structure for - 04-channel handlers. - This includes packet lifecycle handlers as well as the - upgrade handshake handlers. + Please note that json tags for generated Go code are + overridden to explicitly exclude the omitempty jsontag. - A valid Timeout contains either one or both of a timestamp - and block height (sequence). + This enforces the Go json marshaller to always emit zero + values for both revision_number and revision_height. description: >- - QueryChannelParamsResponse is the response type for the - Query/ChannelParams RPC method. + QueryPacketAcknowledgementResponse is the response type for the + Query/PacketAcknowledgement RPC method. default: description: An unexpected error response. schema: @@ -12217,28 +12148,80 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + parameters: + - name: client_id + description: client unique identifier + in: path + required: true + type: string + - name: sequence + description: packet sequence + in: path + required: true + type: string + format: uint64 tags: - Query - /ibc/core/channel/v2/clients/{client_id}/next_sequence_send: + /ibc/core/channel/v2/clients/{client_id}/packet_commitments: get: - summary: NextSequenceSend returns the next send sequence for a given channel. - operationId: NextSequenceSendV2 + summary: PacketCommitments queries a stored packet commitment hash. + operationId: PacketCommitmentsV2 responses: '200': description: A successful response. schema: type: object properties: - next_sequence_send: - type: string - format: uint64 - title: next sequence send number - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved + commitments: + type: array + items: + type: object + properties: + client_id: + type: string + description: client unique identifier. + sequence: + type: string + format: uint64 + description: packet sequence. + data: + type: string + format: byte + description: embedded data that represents packet state. + description: >- + PacketState defines the generic type necessary to retrieve + and store + + packet commitments, acknowledgements, and receipts. + + Caller is responsible for knowing the context necessary to + interpret this + + state as a commitment, acknowledgement, or a receipt. + description: >- + collection of packet commitments for the requested channel + identifier. + pagination: + description: pagination response. + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + height: + description: query block height. type: object properties: revision_number: @@ -12249,33 +12232,16 @@ paths: 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 - Please note that json tags for generated Go code are - overridden to explicitly exclude the omitempty jsontag. + that can be compared against another Height for the purposes + of updating and - This enforces the Go json marshaller to always emit zero - values for both revision_number and revision_height. - title: >- - QueryNextSequenceSendResponse is the response type for the - Query/QueryNextSequenceSend RPC method + freezing clients + description: >- + QueryPacketCommitmentResponse is the response type for the + Query/PacketCommitment RPC method. default: description: An unexpected error response. schema: @@ -12476,75 +12442,82 @@ paths: in: path required: true type: string + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean tags: - Query - /ibc/core/channel/v2/clients/{client_id}/packet_acknowledgements: + /ibc/core/channel/v2/clients/{client_id}/packet_commitments/{packet_ack_sequences}/unreceived_acks: get: summary: >- - PacketAcknowledgements returns all packet acknowledgements associated - with a channel. - operationId: PacketAcknowledgementsV2 + UnreceivedAcks returns all the unreceived IBC acknowledgements + associated with a channel and sequences. + operationId: UnreceivedAcksV2 responses: '200': description: A successful response. schema: type: object properties: - acknowledgements: + sequences: type: array items: - type: object - properties: - client_id: - type: string - description: client unique identifier. - sequence: - type: string - format: uint64 - description: packet sequence. - data: - type: string - format: byte - description: embedded data that represents packet state. - description: >- - PacketState defines the generic type necessary to retrieve - and store - - packet commitments, acknowledgements, and receipts. - - Caller is responsible for knowing the context necessary to - interpret this - - state as a commitment, acknowledgement, or a receipt. - pagination: - title: pagination response - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: >- - PageResponse is to be embedded in gRPC response messages where - the - - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } + type: string + format: uint64 + title: list of unreceived acknowledgement sequences height: title: query block height type: object @@ -12582,8 +12555,8 @@ paths: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. title: |- - QueryPacketAcknowledgemetsResponse is the request type for the - Query/QueryPacketAcknowledgements RPC method + QueryUnreceivedAcksResponse is the response type for the + Query/UnreceivedAcks RPC method default: description: An unexpected error response. schema: @@ -12784,93 +12757,38 @@ paths: in: path required: true type: string - - name: pagination.key - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - in: query - required: false - type: string - format: byte - - name: pagination.offset - description: >- - offset is a numeric offset that can be used when key is unavailable. - - It is less efficient than using key. Only one of offset or key - should - - be set. - in: query - required: false - type: string - format: uint64 - - name: pagination.limit - description: >- - limit is the total number of results to be returned in the result - page. - - If left empty it will default to a value to be set by each app. - in: query - required: false - type: string - format: uint64 - - name: pagination.count_total - description: >- - count_total is set to true to indicate that the result set should - include - - a count of the total number of items available for pagination in - UIs. - - count_total is only respected when offset is used. It is ignored - when key - - is set. - in: query - required: false - type: boolean - - name: pagination.reverse - description: >- - reverse is set to true if results are to be returned in the - descending order. - - - Since: cosmos-sdk 0.43 - in: query - required: false - type: boolean - - name: packet_commitment_sequences - description: list of packet sequences. - in: query - required: false + - name: packet_ack_sequences + description: list of acknowledgement sequences + in: path + required: true type: array items: type: string format: uint64 - collectionFormat: multi + collectionFormat: csv + minItems: 1 tags: - Query - /ibc/core/channel/v2/clients/{client_id}/packet_acks/{sequence}: + /ibc/core/channel/v2/clients/{client_id}/packet_commitments/{sequences}/unreceived_packets: get: - summary: PacketAcknowledgement queries a stored acknowledgement commitment hash. - operationId: PacketAcknowledgementV2 + summary: >- + UnreceivedPackets returns all the unreceived IBC packets associated with + a channel and sequences. + operationId: UnreceivedPacketsV2 responses: '200': description: A successful response. schema: type: object properties: - acknowledgement: - type: string - format: byte - title: acknowledgement associated with the request fields - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved + sequences: + type: array + items: + type: string + format: uint64 + title: list of unreceived packet sequences + height: + title: query block height type: object properties: revision_number: @@ -12905,9 +12823,9 @@ paths: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - description: >- - QueryPacketAcknowledgementResponse is the response type for the - Query/PacketAcknowledgement RPC method. + title: >- + QueryUnreceivedPacketsResponse is the response type for the + Query/UnreceivedPacketCommitments RPC method default: description: An unexpected error response. schema: @@ -13108,74 +13026,38 @@ paths: in: path required: true type: string - - name: sequence - description: packet sequence + - name: sequences + description: list of packet sequences in: path required: true - type: string - format: uint64 + type: array + items: + type: string + format: uint64 + collectionFormat: csv + minItems: 1 tags: - Query - /ibc/core/channel/v2/clients/{client_id}/packet_commitments: + /ibc/core/channel/v2/clients/{client_id}/packet_commitments/{sequence}: get: - summary: PacketCommitments queries a stored packet commitment hash. - operationId: PacketCommitmentsV2 + summary: PacketCommitment queries a stored packet commitment hash. + operationId: PacketCommitmentV2 responses: '200': description: A successful response. schema: type: object properties: - commitments: - type: array - items: - type: object - properties: - client_id: - type: string - description: client unique identifier. - sequence: - type: string - format: uint64 - description: packet sequence. - data: - type: string - format: byte - description: embedded data that represents packet state. - description: >- - PacketState defines the generic type necessary to retrieve - and store - - packet commitments, acknowledgements, and receipts. - - Caller is responsible for knowing the context necessary to - interpret this - - state as a commitment, acknowledgement, or a receipt. - description: >- - collection of packet commitments for the requested channel - identifier. - pagination: - description: pagination response. - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - height: - description: query block height. + commitment: + type: string + format: byte + title: packet associated with the request fields + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved type: object properties: revision_number: @@ -13186,13 +13068,30 @@ paths: type: string format: uint64 title: the height within the given revision - title: >- - Height is a monotonically increasing data type + description: >- + Normally the RevisionHeight is incremented at each height + while keeping - that can be compared against another Height for the purposes - of updating and + RevisionNumber the same. However some consensus algorithms may + choose to - freezing clients + 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 + + + Please note that json tags for generated Go code are + overridden to explicitly exclude the omitempty jsontag. + + This enforces the Go json marshaller to always emit zero + values for both revision_number and revision_height. description: >- QueryPacketCommitmentResponse is the response type for the Query/PacketCommitment RPC method. @@ -13396,84 +13295,33 @@ paths: in: path required: true type: string - - name: pagination.key - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - in: query - required: false - type: string - format: byte - - name: pagination.offset - description: >- - offset is a numeric offset that can be used when key is unavailable. - - It is less efficient than using key. Only one of offset or key - should - - be set. - in: query - required: false - type: string - format: uint64 - - name: pagination.limit - description: >- - limit is the total number of results to be returned in the result - page. - - If left empty it will default to a value to be set by each app. - in: query - required: false + - name: sequence + description: packet sequence + in: path + required: true type: string format: uint64 - - name: pagination.count_total - description: >- - count_total is set to true to indicate that the result set should - include - - a count of the total number of items available for pagination in - UIs. - - count_total is only respected when offset is used. It is ignored - when key - - is set. - in: query - required: false - type: boolean - - name: pagination.reverse - description: >- - reverse is set to true if results are to be returned in the - descending order. - - - Since: cosmos-sdk 0.43 - in: query - required: false - type: boolean tags: - Query - /ibc/core/channel/v2/clients/{client_id}/packet_commitments/{packet_ack_sequences}/unreceived_acks: + /ibc/core/channel/v2/clients/{client_id}/packet_receipts/{sequence}: get: - summary: >- - UnreceivedAcks returns all the unreceived IBC acknowledgements - associated with a channel and sequences. - operationId: UnreceivedAcksV2 + summary: PacketReceipt queries a stored packet receipt. + operationId: PacketReceiptV2 responses: '200': description: A successful response. schema: type: object properties: - sequences: - type: array - items: - type: string - format: uint64 - title: list of unreceived acknowledgement sequences - height: - title: query block height + received: + type: boolean + title: success flag for if receipt exists + proof: + type: string + format: byte + title: merkle proof of existence or absence + proof_height: + title: height at which the proof was retrieved type: object properties: revision_number: @@ -13508,9 +13356,9 @@ paths: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - title: |- - QueryUnreceivedAcksResponse is the response type for the - Query/UnreceivedAcks RPC method + description: >- + QueryPacketReceiptResponse is the response type for the + Query/PacketReceipt RPC method. default: description: An unexpected error response. schema: @@ -13711,855 +13559,53 @@ paths: in: path required: true type: string - - name: packet_ack_sequences - description: list of acknowledgement sequences + - name: sequence + description: packet sequence in: path required: true - type: array - items: - type: string - format: uint64 - collectionFormat: csv - minItems: 1 + type: string + format: uint64 tags: - Query - /ibc/core/channel/v2/clients/{client_id}/packet_commitments/{sequences}/unreceived_packets: + /ibc/lightclients/wasm/v1/checksums: get: - summary: >- - UnreceivedPackets returns all the unreceived IBC packets associated with - a channel and sequences. - operationId: UnreceivedPacketsV2 + summary: Get all Wasm checksums + operationId: Checksums responses: '200': description: A successful response. schema: type: object properties: - sequences: + checksums: type: array items: type: string - format: uint64 - title: list of unreceived packet sequences - height: - title: query block height + description: >- + checksums is a list of the hex encoded checksums of all wasm + codes stored. + pagination: + description: pagination defines the pagination in the response. type: object properties: - revision_number: + next_key: type: string - format: uint64 - title: the revision that the client is currently on - revision_height: + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: 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 - - - Please note that json tags for generated Go code are - overridden to explicitly exclude the omitempty jsontag. + title: >- + total is total number of results available if + PageRequest.count_total - This enforces the Go json marshaller to always emit zero - values for both revision_number and revision_height. - title: >- - QueryUnreceivedPacketsResponse is the response type for the - Query/UnreceivedPacketCommitments 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: client_id - description: client unique identifier - in: path - required: true - type: string - - name: sequences - description: list of packet sequences - in: path - required: true - type: array - items: - type: string - format: uint64 - collectionFormat: csv - minItems: 1 - tags: - - Query - /ibc/core/channel/v2/clients/{client_id}/packet_commitments/{sequence}: - get: - summary: PacketCommitment queries a stored packet commitment hash. - operationId: PacketCommitmentV2 - responses: - '200': - description: A successful response. - schema: - type: object - properties: - commitment: - type: string - format: byte - title: packet associated with the request fields - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved - 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 - - - Please note that json tags for generated Go code are - overridden to explicitly exclude the omitempty jsontag. - - This enforces the Go json marshaller to always emit zero - values for both revision_number and revision_height. - description: >- - QueryPacketCommitmentResponse is the response type for the - Query/PacketCommitment 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: client_id - description: client unique identifier - in: path - required: true - type: string - - name: sequence - description: packet sequence - in: path - required: true - type: string - format: uint64 - tags: - - Query - /ibc/core/channel/v2/clients/{client_id}/packet_receipts/{sequence}: - get: - summary: PacketReceipt queries a stored packet receipt. - operationId: PacketReceiptV2 - responses: - '200': - description: A successful response. - schema: - type: object - properties: - received: - type: boolean - title: success flag for if receipt exists - proof: - type: string - format: byte - title: merkle proof of existence or absence - proof_height: - title: height at which the proof was retrieved - 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 - - - Please note that json tags for generated Go code are - overridden to explicitly exclude the omitempty jsontag. - - This enforces the Go json marshaller to always emit zero - values for both revision_number and revision_height. - description: >- - QueryPacketReceiptResponse is the response type for the - Query/PacketReceipt 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: client_id - description: client unique identifier - in: path - required: true - type: string - - name: sequence - description: packet sequence - in: path - required: true - type: string - format: uint64 - tags: - - Query - /ibc/lightclients/wasm/v1/checksums: - get: - summary: Get all Wasm checksums - operationId: Checksums - responses: - '200': - description: A successful response. - schema: - type: object - properties: - checksums: - type: array - items: - type: string - description: >- - checksums is a list of the hex encoded checksums of all wasm - codes stored. - pagination: - description: pagination defines the pagination in the response. - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: >- - QueryChecksumsResponse is the response type for the - Query/Checksums RPC method. + was set, its value is undefined otherwise + description: >- + QueryChecksumsResponse is the response type for the + Query/Checksums RPC method. default: description: An unexpected error response. schema: @@ -18429,12 +17475,10 @@ definitions: - STATE_TRYOPEN - STATE_OPEN - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE default: STATE_UNINITIALIZED_UNSPECIFIED description: |- State defines if a channel is in one of the following states: - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or UNINITIALIZED. + CLOSED, INIT, TRYOPEN, OPEN, or UNINITIALIZED. - STATE_UNINITIALIZED_UNSPECIFIED: Default State - STATE_INIT: A channel has just started the opening handshake. @@ -18443,8 +17487,6 @@ definitions: ready to send and receive packets. - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. ordering: title: whether the channel is ordered or unordered type: string @@ -18480,14 +17522,6 @@ definitions: version: type: string title: opaque channel version, which is agreed upon during the handshake - upgrade_sequence: - type: string - format: uint64 - title: >- - upgrade sequence indicates the latest upgrade attempt performed by - this channel - - the value of 0 indicates the channel has never been upgraded description: |- Channel defines pipeline for exactly-once packet delivery between specific modules on separate blockchains, which has at least one end capable of @@ -18504,24 +17538,6 @@ definitions: type: string title: channel end on the counterparty chain title: Counterparty defines a channel end counterparty - ibc.core.channel.v1.ErrorReceipt: - type: object - properties: - sequence: - type: string - format: uint64 - title: the channel upgrade sequence - message: - type: string - title: the error message detailing the cause of failure - description: >- - ErrorReceipt defines a type which encapsulates the upgrade sequence and - error associated with the - - upgrade handshake failure. When a channel upgrade handshake is aborted - both chains are expected to increment to the - - next sequence. ibc.core.channel.v1.IdentifiedChannel: type: object properties: @@ -18534,12 +17550,10 @@ definitions: - STATE_TRYOPEN - STATE_OPEN - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE default: STATE_UNINITIALIZED_UNSPECIFIED description: |- State defines if a channel is in one of the following states: - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or UNINITIALIZED. + CLOSED, INIT, TRYOPEN, OPEN, or UNINITIALIZED. - STATE_UNINITIALIZED_UNSPECIFIED: Default State - STATE_INIT: A channel has just started the opening handshake. @@ -18548,8 +17562,6 @@ definitions: ready to send and receive packets. - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. ordering: title: whether the channel is ordered or unordered type: string @@ -18591,14 +17603,6 @@ definitions: channel_id: type: string title: channel identifier - upgrade_sequence: - type: string - format: uint64 - title: >- - upgrade sequence indicates the latest upgrade attempt performed by - this channel - - the value of 0 indicates the channel has never been upgraded description: |- IdentifiedChannel defines a channel with additional port and channel identifier fields. @@ -18637,64 +17641,6 @@ definitions: packet commitments, acknowledgements, and receipts. Caller is responsible for knowing the context necessary to interpret this state as a commitment, acknowledgement, or a receipt. - ibc.core.channel.v1.Params: - type: object - properties: - upgrade_timeout: - type: object - properties: - height: - title: block height after which the packet or upgrade times out - 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 - - - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. - - This enforces the Go json marshaller to always emit zero values - for both revision_number and revision_height. - timestamp: - type: string - format: uint64 - title: >- - block timestamp (in nanoseconds) after which the packet or upgrade - times out - description: >- - Timeout defines an execution deadline structure for 04-channel - handlers. - - This includes packet lifecycle handlers as well as the upgrade - handshake handlers. - - A valid Timeout contains either one or both of a timestamp and block - height (sequence). - description: Params defines the set of IBC channel parameters. ibc.core.channel.v1.QueryChannelClientStateResponse: type: object properties: @@ -19134,70 +18080,6 @@ definitions: title: |- QueryChannelClientStateResponse is the Response type for the Query/QueryChannelClientState RPC method - ibc.core.channel.v1.QueryChannelParamsResponse: - type: object - properties: - params: - description: params defines the parameters of the module. - type: object - properties: - upgrade_timeout: - type: object - properties: - height: - title: block height after which the packet or upgrade times out - 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 - - - Please note that json tags for generated Go code are - overridden to explicitly exclude the omitempty jsontag. - - This enforces the Go json marshaller to always emit zero - values for both revision_number and revision_height. - timestamp: - type: string - format: uint64 - title: >- - block timestamp (in nanoseconds) after which the packet or - upgrade times out - description: >- - Timeout defines an execution deadline structure for 04-channel - handlers. - - This includes packet lifecycle handlers as well as the upgrade - handshake handlers. - - A valid Timeout contains either one or both of a timestamp and - block height (sequence). - description: >- - QueryChannelParamsResponse is the response type for the - Query/ChannelParams RPC method. ibc.core.channel.v1.QueryChannelResponse: type: object properties: @@ -19214,14 +18096,10 @@ definitions: - STATE_TRYOPEN - STATE_OPEN - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE default: STATE_UNINITIALIZED_UNSPECIFIED - description: >- + description: |- State defines if a channel is in one of the following states: - - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or - UNINITIALIZED. + CLOSED, INIT, TRYOPEN, OPEN, or UNINITIALIZED. - STATE_UNINITIALIZED_UNSPECIFIED: Default State - STATE_INIT: A channel has just started the opening handshake. @@ -19230,8 +18108,6 @@ definitions: ready to send and receive packets. - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. ordering: title: whether the channel is ordered or unordered type: string @@ -19269,14 +18145,6 @@ definitions: version: type: string title: opaque channel version, which is agreed upon during the handshake - upgrade_sequence: - type: string - format: uint64 - title: >- - upgrade sequence indicates the latest upgrade attempt performed by - this channel - - the value of 0 indicates the channel has never been upgraded description: >- Channel defines pipeline for exactly-once packet delivery between specific @@ -19347,14 +18215,10 @@ definitions: - STATE_TRYOPEN - STATE_OPEN - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE default: STATE_UNINITIALIZED_UNSPECIFIED - description: >- + description: |- State defines if a channel is in one of the following states: - - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or - UNINITIALIZED. + CLOSED, INIT, TRYOPEN, OPEN, or UNINITIALIZED. - STATE_UNINITIALIZED_UNSPECIFIED: Default State - STATE_INIT: A channel has just started the opening handshake. @@ -19363,8 +18227,6 @@ definitions: ready to send and receive packets. - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. ordering: title: whether the channel is ordered or unordered type: string @@ -19410,14 +18272,6 @@ definitions: channel_id: type: string title: channel identifier - upgrade_sequence: - type: string - format: uint64 - title: >- - upgrade sequence indicates the latest upgrade attempt performed - by this channel - - the value of 0 indicates the channel has never been upgraded description: |- IdentifiedChannel defines a channel with additional port and channel identifier fields. @@ -19504,14 +18358,10 @@ definitions: - STATE_TRYOPEN - STATE_OPEN - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE default: STATE_UNINITIALIZED_UNSPECIFIED - description: >- + description: |- State defines if a channel is in one of the following states: - - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or - UNINITIALIZED. + CLOSED, INIT, TRYOPEN, OPEN, or UNINITIALIZED. - STATE_UNINITIALIZED_UNSPECIFIED: Default State - STATE_INIT: A channel has just started the opening handshake. @@ -19520,8 +18370,6 @@ definitions: ready to send and receive packets. - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. ordering: title: whether the channel is ordered or unordered type: string @@ -19567,14 +18415,6 @@ definitions: channel_id: type: string title: channel identifier - upgrade_sequence: - type: string - format: uint64 - title: >- - upgrade sequence indicates the latest upgrade attempt performed - by this channel - - the value of 0 indicates the channel has never been upgraded description: |- IdentifiedChannel defines a channel with additional port and channel identifier fields. @@ -20035,118 +18875,20 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. title: |- - QueryPacketCommitmentsResponse is the request type for the - Query/QueryPacketCommitments RPC method - ibc.core.channel.v1.QueryPacketReceiptResponse: - type: object - properties: - received: - type: boolean - title: success flag for if receipt exists - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved - 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 - - - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. - - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - title: >- - QueryPacketReceiptResponse defines the client query response for a packet - - receipt which also includes a proof, and the height from which the proof - was - - retrieved - ibc.core.channel.v1.QueryUnreceivedAcksResponse: - type: object - properties: - sequences: - type: array - items: - type: string - format: uint64 - title: list of unreceived acknowledgement sequences - height: - title: query block 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 - - - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. - - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - title: |- - QueryUnreceivedAcksResponse is the response type for the - Query/UnreceivedAcks RPC method - ibc.core.channel.v1.QueryUnreceivedPacketsResponse: + QueryPacketCommitmentsResponse is the request type for the + Query/QueryPacketCommitments RPC method + ibc.core.channel.v1.QueryPacketReceiptResponse: type: object properties: - sequences: - type: array - items: - type: string - format: uint64 - title: list of unreceived packet sequences - height: - title: query block height + received: + type: boolean + title: success flag for if receipt exists + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved type: object properties: revision_number: @@ -20180,36 +18922,24 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - title: |- - QueryUnreceivedPacketsResponse is the response type for the - Query/UnreceivedPacketCommitments RPC method - ibc.core.channel.v1.QueryUpgradeErrorResponse: - type: object - properties: - error_receipt: - type: object - properties: - sequence: - type: string - format: uint64 - title: the channel upgrade sequence - message: - type: string - title: the error message detailing the cause of failure - description: >- - ErrorReceipt defines a type which encapsulates the upgrade sequence - and error associated with the + title: >- + QueryPacketReceiptResponse defines the client query response for a packet - upgrade handshake failure. When a channel upgrade handshake is aborted - both chains are expected to increment to the + receipt which also includes a proof, and the height from which the proof + was - next sequence. - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved + retrieved + ibc.core.channel.v1.QueryUnreceivedAcksResponse: + type: object + properties: + sequences: + type: array + items: + type: string + format: uint64 + title: list of unreceived acknowledgement sequences + height: + title: query block height type: object properties: revision_number: @@ -20243,116 +18973,20 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - title: >- - QueryUpgradeErrorResponse is the response type for the - Query/QueryUpgradeError RPC method - ibc.core.channel.v1.QueryUpgradeResponse: + title: |- + QueryUnreceivedAcksResponse is the response type for the + Query/UnreceivedAcks RPC method + ibc.core.channel.v1.QueryUnreceivedPacketsResponse: type: object properties: - upgrade: - type: object - properties: - fields: - type: object - properties: - ordering: - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - title: Order defines if a channel is ORDERED or UNORDERED - connection_hops: - type: array - items: - type: string - version: - type: string - description: |- - UpgradeFields are the fields in a channel end which may be changed - during a channel upgrade. - timeout: - type: object - properties: - height: - title: block height after which the packet or upgrade times out - 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 - - - Please note that json tags for generated Go code are - overridden to explicitly exclude the omitempty jsontag. - - This enforces the Go json marshaller to always emit zero - values for both revision_number and revision_height. - timestamp: - type: string - format: uint64 - title: >- - block timestamp (in nanoseconds) after which the packet or - upgrade times out - description: >- - Timeout defines an execution deadline structure for 04-channel - handlers. - - This includes packet lifecycle handlers as well as the upgrade - handshake handlers. - - A valid Timeout contains either one or both of a timestamp and - block height (sequence). - next_sequence_send: - type: string - format: uint64 - description: >- - Upgrade is a verifiable type which contains the relevant information - - for an attempted upgrade. It provides the proposed changes to the - channel - - end, the timeout for this upgrade attempt and the next packet sequence - - which allows the counterparty to efficiently know the highest sequence - it has received. - - The next sequence send is used for pruning and upgrading from - unordered to ordered channels. - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved + sequences: + type: array + items: + type: string + format: uint64 + title: list of unreceived packet sequences + height: + title: query block height type: object properties: revision_number: @@ -20386,9 +19020,9 @@ definitions: This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. - title: >- - QueryUpgradeResponse is the response type for the QueryUpgradeResponse RPC - method + title: |- + QueryUnreceivedPacketsResponse is the response type for the + Query/UnreceivedPacketCommitments RPC method ibc.core.channel.v1.State: type: string enum: @@ -20397,12 +19031,10 @@ definitions: - STATE_TRYOPEN - STATE_OPEN - STATE_CLOSED - - STATE_FLUSHING - - STATE_FLUSHCOMPLETE default: STATE_UNINITIALIZED_UNSPECIFIED description: |- State defines if a channel is in one of the following states: - CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or UNINITIALIZED. + CLOSED, INIT, TRYOPEN, OPEN, or UNINITIALIZED. - STATE_UNINITIALIZED_UNSPECIFIED: Default State - STATE_INIT: A channel has just started the opening handshake. @@ -20411,182 +19043,6 @@ definitions: ready to send and receive packets. - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive packets. - - STATE_FLUSHING: A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - - STATE_FLUSHCOMPLETE: A channel has just completed flushing any in-flight packets. - ibc.core.channel.v1.Timeout: - type: object - properties: - height: - title: block height after which the packet or upgrade times out - 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 - - - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. - - This enforces the Go json marshaller to always emit zero values for - both revision_number and revision_height. - timestamp: - type: string - format: uint64 - title: >- - block timestamp (in nanoseconds) after which the packet or upgrade - times out - description: >- - Timeout defines an execution deadline structure for 04-channel handlers. - - This includes packet lifecycle handlers as well as the upgrade handshake - handlers. - - A valid Timeout contains either one or both of a timestamp and block - height (sequence). - ibc.core.channel.v1.Upgrade: - type: object - properties: - fields: - type: object - properties: - ordering: - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - title: Order defines if a channel is ORDERED or UNORDERED - connection_hops: - type: array - items: - type: string - version: - type: string - description: |- - UpgradeFields are the fields in a channel end which may be changed - during a channel upgrade. - timeout: - type: object - properties: - height: - title: block height after which the packet or upgrade times out - 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 - - - Please note that json tags for generated Go code are overridden to - explicitly exclude the omitempty jsontag. - - This enforces the Go json marshaller to always emit zero values - for both revision_number and revision_height. - timestamp: - type: string - format: uint64 - title: >- - block timestamp (in nanoseconds) after which the packet or upgrade - times out - description: >- - Timeout defines an execution deadline structure for 04-channel - handlers. - - This includes packet lifecycle handlers as well as the upgrade - handshake handlers. - - A valid Timeout contains either one or both of a timestamp and block - height (sequence). - next_sequence_send: - type: string - format: uint64 - description: >- - Upgrade is a verifiable type which contains the relevant information - - for an attempted upgrade. It provides the proposed changes to the channel - - end, the timeout for this upgrade attempt and the next packet sequence - - which allows the counterparty to efficiently know the highest sequence it - has received. - - The next sequence send is used for pruning and upgrading from unordered to - ordered channels. - ibc.core.channel.v1.UpgradeFields: - type: object - properties: - ordering: - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - title: Order defines if a channel is ORDERED or UNORDERED - connection_hops: - type: array - items: - type: string - version: - type: string - description: |- - UpgradeFields are the fields in a channel end which may be changed - during a channel upgrade. ibc.core.channel.v2.PacketState: type: object properties: diff --git a/docs/docs/01-ibc/06-channel-upgrades.md b/docs/docs/01-ibc/06-channel-upgrades.md deleted file mode 100644 index 02249a00b65..00000000000 --- a/docs/docs/01-ibc/06-channel-upgrades.md +++ /dev/null @@ -1,413 +0,0 @@ ---- -title: Channel Upgrades -sidebar_label: Channel Upgrades -sidebar_position: 6 -slug: /ibc/channel-upgrades ---- - -# Channel Upgrades - -:::note Synopsis -Learn how to upgrade existing IBC channels. -::: - -Channel upgradability is an IBC-level protocol that allows chains to leverage new application and channel features without having to create new channels or perform a network-wide upgrade. - -Prior to this feature, developers who wanted to update an application module or add a middleware to their application flow would need to create a new channel in order to use the updated application feature/middleware, resulting in a loss of the accumulated state/liquidity, token fungibility (as the channel ID is encoded in the IBC denom), and any other larger network effects of losing usage of the existing channel from relayers monitoring, etc. - -With channel upgradability, applications will be able to implement features such as but not limited to: potentially adding [denom metadata to tokens](https://github.com/cosmos/ibc/discussions/719), or utilizing the [fee middleware](https://github.com/cosmos/ibc/tree/main/spec/app/ics-029-fee-payment), all while maintaining the channels on which they currently operate. - -This document outlines the channel upgrade feature, and the multiple steps used in the upgrade process. - -## Channel Upgrade Handshake - -Channel upgrades will be achieved using a handshake process that is designed to be similar to the standard connection/channel opening handshake. - -```go -type Channel struct { - // current state of the channel end - State State `protobuf:"varint,1,opt,name=state,proto3,enum=ibc.core.channel.v1.State" json:"state,omitempty"` - // whether the channel is ordered or unordered - Ordering Order `protobuf:"varint,2,opt,name=ordering,proto3,enum=ibc.core.channel.v1.Order" json:"ordering,omitempty"` - // counterparty channel end - Counterparty Counterparty `protobuf:"bytes,3,opt,name=counterparty,proto3" json:"counterparty"` - // list of connection identifiers, in order, along which packets sent on - // this channel will travel - ConnectionHops []string `protobuf:"bytes,4,rep,name=connection_hops,json=connectionHops,proto3" json:"connection_hops,omitempty"` - // opaque channel version, which is agreed upon during the handshake - Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"` - // upgrade sequence indicates the latest upgrade attempt performed by this channel - // the value of 0 indicates the channel has never been upgraded - UpgradeSequence uint64 `protobuf:"varint,6,opt,name=upgrade_sequence,json=upgradeSequence,proto3" json:"upgrade_sequence,omitempty"` -} -``` - -The version, connection hops, and channel ordering are fields in this channel struct which can be changed. For example, the fee middleware can be added to an application module by updating the version string [shown here](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/apps/29-fee/types/metadata.pb.go#L29). However, although connection hops can change in a channel upgrade, both sides must still be each other's counterparty. This is enforced by the upgrade protocol and upgrade attempts which try to alter an expected counterparty will fail. - -On a high level, successful handshake process for channel upgrades works as follows: - -1. The chain initiating the upgrade process will propose an upgrade. -2. If the counterparty agrees with the proposal, it will block sends and begin flushing any in-flight packets on its channel end. This flushing process will be covered in more detail below. -3. Upon successful completion of the previous step, the initiating chain will also block packet sends and begin flushing any in-flight packets on its channel end. -4. Once both channel ends have completed flushing packets within the upgrade timeout window, both channel ends can be opened and upgraded to the new channel fields. - -Each handshake step will be documented below in greater detail. - -## Initializing a Channel Upgrade - -A channel upgrade is initialised by submitting the `MsgChannelUpgradeInit` message, which can be submitted only by the chain itself upon governance authorization. It is possible to upgrade the channel ordering, the channel connection hops, and the channel version, which can be found in the `UpgradeFields`. - -```go -type MsgChannelUpgradeInit struct { - PortId string - ChannelId string - Fields UpgradeFields - Signer string -} -``` - -As part of the handling of the `MsgChannelUpgradeInit` message, the application's `OnChanUpgradeInit` callback will be triggered as well. - -After this message is handled successfully, the channel's upgrade sequence will be incremented. This upgrade sequence will serve as a nonce for the upgrade process to provide replay protection. - -:::warning -Initiating an upgrade in the same block as opening a channel may potentially prevent the counterparty channel from also opening. -::: - -### Governance gating on `ChanUpgradeInit` - -The message signer for `MsgChannelUpgradeInit` must be the address which has been designated as the `authority` of the `IBCKeeper`. If this proposal passes, the counterparty's channel will upgrade by default. - -If chains want to initiate the upgrade of many channels, they will need to submit a governance proposal with multiple `MsgChannelUpgradeInit` messages, one for each channel they would like to upgrade, again with message signer as the designated `authority` of the `IBCKeeper`. The `upgrade-channels` CLI command can be used to submit a proposal that initiates the upgrade of multiple channels; see section [Upgrading channels with the CLI](#upgrading-channels-with-the-cli) below for more information. - -## Channel State and Packet Flushing - -`FLUSHING` and `FLUSHCOMPLETE` are additional channel states which have been added to enable the upgrade feature. - -These states may consist of: - -```go -const ( - // Default State - UNINITIALIZED State = 0 - // A channel has just started the opening handshake. - INIT State = 1 - // A channel has acknowledged the handshake step on the counterparty chain. - TRYOPEN State = 2 - // A channel has completed the handshake. Open channels are - // ready to send and receive packets. - OPEN State = 3 - // A channel has been closed and can no longer be used to send or receive - // packets. - CLOSED State = 4 - // A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - FLUSHING State = 5 - // A channel has just completed flushing any in-flight packets. - FLUSHCOMPLETE State = 6 -) -``` - -These are found in `State` on the `Channel` struct: - -```go -type Channel struct { - // current state of the channel end - State State `protobuf:"varint,1,opt,name=state,proto3,enum=ibc.core.channel.v1.State" json:"state,omitempty"` - // whether the channel is ordered or unordered - Ordering Order `protobuf:"varint,2,opt,name=ordering,proto3,enum=ibc.core.channel.v1.Order" json:"ordering,omitempty"` - // counterparty channel end - Counterparty Counterparty `protobuf:"bytes,3,opt,name=counterparty,proto3" json:"counterparty"` - // list of connection identifiers, in order, along which packets sent on - // this channel will travel - ConnectionHops []string `protobuf:"bytes,4,rep,name=connection_hops,json=connectionHops,proto3" json:"connection_hops,omitempty"` - // opaque channel version, which is agreed upon during the handshake - Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"` - // upgrade sequence indicates the latest upgrade attempt performed by this channel - // the value of 0 indicates the channel has never been upgraded - UpgradeSequence uint64 `protobuf:"varint,6,opt,name=upgrade_sequence,json=upgradeSequence,proto3" json:"upgrade_sequence,omitempty"` -} -``` - -`startFlushing` is the specific method which is called in `ChanUpgradeTry` and `ChanUpgradeAck` to update the state on the channel end. This will set the timeout on the upgrade and update the channel state to `FLUSHING` which will block the upgrade from continuing until all in-flight packets have been flushed. - -This will also set the upgrade timeout for the counterparty (i.e. the timeout before which the counterparty chain must move from `FLUSHING` to `FLUSHCOMPLETE`; if it doesn't then the chain will cancel the upgrade and write an error receipt). The timeout is a relative time duration in nanoseconds that can be changed with `MsgUpdateParams` and by default is 10 minutes. - -The state will change to `FLUSHCOMPLETE` once there are no in-flight packets left and the channel end is ready to move to `OPEN`. This flush state will also have an impact on how a channel upgrade can be cancelled, as detailed below. - -All other parameters will remain the same during the upgrade handshake until the upgrade handshake completes. When the channel is reset to `OPEN` on a successful upgrade handshake, the relevant fields on the channel end will be switched over to the `UpgradeFields` specified in the upgrade. - -:::note - -When transitioning a channel from UNORDERED to ORDERED, new packet sends from the channel end which upgrades first will be incapable of being timed out until the counterparty has finished upgrading. - -::: - -:::warning - -Due to the addition of new channel states, packets can still be received and processed in both `FLUSHING` and `FLUSHCOMPLETE` states. -Packets can also be acknowledged in the `FLUSHING` state. Acknowledging will **not** be possible when the channel is in the `FLUSHCOMPLETE` state, since all packets sent from that channel end have been flushed. -Application developers should consider these new states when implementing application logic that relies on the channel state. -It is still only possible to send packets when the channel is in the `OPEN` state, but sending is disallowed when the channel enters `FLUSHING` and `FLUSHCOMPLETE`. When the channel reopens, sending will be possible again. - -::: - -## Cancelling a Channel Upgrade - -Channel upgrade cancellation is performed by submitting a `MsgChannelUpgradeCancel` message. - -It is possible for the authority to cancel an in-progress channel upgrade if the following are true: - -- The signer is the authority -- The channel state has not reached FLUSHCOMPLETE -- If the channel state has reached FLUSHCOMPLETE, an existence proof of an `ErrorReceipt` on the counterparty chain is provided at our upgrade sequence or greater - -It is possible for a relayer to cancel an in-progress channel upgrade if the following are true: - -- An existence proof of an `ErrorReceipt` on the counterparty chain is provided at our upgrade sequence or greater - -> Note: if the signer is the authority, e.g. the `gov` address, no `ErrorReceipt` or proof is required if the current channel state is not in FLUSHCOMPLETE. -> These can be left empty in the `MsgChannelUpgradeCancel` message in that case. - -Upon cancelling a channel upgrade, an `ErrorReceipt` will be written with the channel's current upgrade sequence, and -the channel will move back to `OPEN` state keeping its original parameters. - -It will then be possible to re-initiate an upgrade by sending a `MsgChannelOpenInit` message. - -:::warning - -Performing sequentially an upgrade cancellation, upgrade initialization, and another upgrade cancellation in a single block while the counterparty is in `FLUSHCOMPLETE` will lead to corrupted state. -The counterparty will be unable to cancel its upgrade attempt and will require a manual migration. -When the counterparty is in `FLUSHCOMPLETE`, it requires a proof that the counterparty cancelled its current upgrade attempt. -When this cancellation is succeeded by an initialization and cancellation in the same block, it results in the proof of cancellation existing only for the next upgrade attempt, not the current. - -::: - -## Timing Out a Channel Upgrade - -Timing out an outstanding channel upgrade may be necessary during the flushing packet stage of the channel upgrade process. As stated above, with `ChanUpgradeTry` or `ChanUpgradeAck`, the channel state has been changed from `OPEN` to `FLUSHING`, so no new packets will be allowed to be sent over this channel while flushing. If upgrades cannot be performed in a timely manner (due to unforeseen flushing issues), upgrade timeouts allow the channel to avoid blocking packet sends indefinitely. If flushing exceeds the time limit set in the `UpgradeTimeout` channel `Params`, the upgrade process will need to be timed out to abort the upgrade attempt and resume normal channel processing. - -Channel upgrades require setting a valid timeout value in the channel `Params` before submitting a `MsgChannelUpgradeTry` or `MsgChannelUpgradeAck` message (by default, 10 minutes): - -```go -type Params struct { - UpgradeTimeout Timeout -} -``` - -A valid Timeout contains either one or both of a timestamp and block height (sequence). - -```go -type Timeout struct { - // block height after which the packet or upgrade times out - Height types.Height - // block timestamp (in nanoseconds) after which the packet or upgrade times out - Timestamp uint64 -} -``` - -This timeout will then be set as a field on the `Upgrade` struct itself when flushing is started. - -```go -type Upgrade struct { - Fields UpgradeFields - Timeout Timeout - NextSequenceSend uint64 -} -``` - -If the timeout has been exceeded during flushing, a chain can then submit the `MsgChannelUpgradeTimeout` to timeout the channel upgrade process: - -```go -type MsgChannelUpgradeTimeout struct { - PortId string - ChannelId string - CounterpartyChannel Channel - ProofChannel []byte - ProofHeight types.Height - Signer string -} -``` - -An `ErrorReceipt` will be written with the channel's current upgrade sequence, and the channel will move back to `OPEN` state keeping its original parameters. - -Note that timing out a channel upgrade will end the upgrade process, and a new `MsgChannelUpgradeInit` will have to be submitted via governance in order to restart the upgrade process. - -## Pruning Acknowledgements - -Acknowledgements can be pruned by broadcasting the `MsgPruneAcknowledgements` message. - -> Note: It is only possible to prune acknowledgements after a channel has been upgraded, so pruning will fail -> if the channel has not yet been upgraded. - -```protobuf -// MsgPruneAcknowledgements defines the request type for the PruneAcknowledgements rpc. -message MsgPruneAcknowledgements { - option (cosmos.msg.v1.signer) = "signer"; - option (gogoproto.goproto_getters) = false; - - string port_id = 1; - string channel_id = 2; - uint64 limit = 3; - string signer = 4; -} -``` - -The `port_id` and `channel_id` specify the port and channel to act on, and the `limit` specifies the upper bound for the number -of acknowledgements and packet receipts to prune. - -### CLI Usage - -Acknowledgements can be pruned via the cli with the `prune-acknowledgements` command. - -```bash -simd tx ibc channel prune-acknowledgements [port] [channel] [limit] -``` - -## IBC App Recommendations - -IBC application callbacks should be primarily used to validate data fields and do compatibility checks. Application developers -should be aware that callbacks will be invoked before any core ibc state changes are written. - -`OnChanUpgradeInit` should validate the proposed version, order, and connection hops, and should return the application version to upgrade to. - -`OnChanUpgradeTry` should validate the proposed version (provided by the counterparty), order, and connection hops. The desired upgrade version should be returned. - -`OnChanUpgradeAck` should validate the version proposed by the counterparty. - -`OnChanUpgradeOpen` should perform any logic associated with changing of the channel fields. - -> IBC applications should not attempt to process any packet data under the new conditions until after `OnChanUpgradeOpen` -> has been executed, as up until this point it is still possible for the upgrade handshake to fail and for the channel -> to remain in the pre-upgraded state. - -## Upgrade an existing transfer application stack to use 29-fee middleware - -### Wire up the transfer stack and middleware in app.go - -In app.go, the existing transfer stack must be wrapped with the fee middleware. - -```golang - -import ( - // ... - ibcfee "github.com/cosmos/ibc-go/v10/modules/apps/29-fee" - ibctransferkeeper "github.com/cosmos/ibc-go/v10/modules/apps/transfer/keeper" - transfer "github.com/cosmos/ibc-go/v10/modules/apps/transfer" - porttypes "github.com/cosmos/ibc-go/v10/modules/core/05-port/types" - // ... -) - -type App struct { - // ... - TransferKeeper ibctransferkeeper.Keeper - IBCFeeKeeper ibcfeekeeper.Keeper - // .. -} - -// ... - -app.IBCFeeKeeper = ibcfeekeeper.NewKeeper( - appCodec, keys[ibcfeetypes.StoreKey], - app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware - app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, -) - -// Create Transfer Keeper and pass IBCFeeKeeper as expected Channel and PortKeeper -// since fee middleware will wrap the IBCKeeper for underlying application. -app.TransferKeeper = ibctransferkeeper.NewKeeper( - appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), - app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware - app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper, - app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), -) - - -ibcRouter := porttypes.NewRouter() - -// create IBC module from bottom to top of stack -var transferStack porttypes.IBCModule -transferStack = transfer.NewIBCModule(app.TransferKeeper) -transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper) - -// Add transfer stack to IBC Router -ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack) -``` - -### Submit a governance proposal to execute a MsgChannelUpgradeInit message - -> This process can be performed with the new CLI that has been added -> outlined [here](#upgrading-channels-with-the-cli). - -Only the configured authority for the ibc module is able to initiate a channel upgrade by submitting a `MsgChannelUpgradeInit` message. - -Execute a governance proposal specifying the relevant fields to perform a channel upgrade. - -Update the following json sample, and copy the contents into `proposal.json`. - -```json -{ - "title": "Channel upgrade init", - "summary": "Channel upgrade init", - "messages": [ - { - "@type": "/ibc.core.channel.v1.MsgChannelUpgradeInit", - "signer": "", - "port_id": "transfer", - "channel_id": "channel-...", - "fields": { - "ordering": "ORDER_UNORDERED", - "connection_hops": ["connection-0"], - "version": "{\"fee_version\":\"ics29-1\",\"app_version\":\"ics20-1\"}" - } - } - ], - "metadata": "", - "deposit": "10stake" -} -``` - -> Note: ensure the correct fields.version is specified. This is the new version that the channels will be upgraded to. - -### Submit the proposal - -```shell -simd tx submit-proposal proposal.json --from -``` - -## Upgrading channels with the CLI - -A new cli has been added which enables either - - submitting a governance proposal which contains a `MsgChannelUpgradeInit` for every channel to be upgraded. - - generating a `proposal.json` file which contains the proposal contents to be edited/submitted at a later date. - -The following example, would submit a governance proposal with the specified deposit, title and summary which would -contain a `MsgChannelUpgradeInit` for all `OPEN` channels whose port matches the regular expression `transfer`. - -> Note: by adding the `--json` flag, the command would instead output the contents of the proposal which could be -> stored in a `proposal.json` file to be edited and submitted at a later date. - -```bash -simd tx ibc channel upgrade-channels "{\"fee_version\":\"ics29-1\",\"app_version\":\"ics20-1\"}" \ - --deposit "10stake" \ - --title "Channel Upgrades Governance Proposal" \ - --summary "Upgrade all transfer channels to be fee enabled" \ - --port-pattern "transfer" -``` - -It is also possible to explicitly list a comma separated string of channel IDs. It is important to note that the -regular expression matching specified by `--port-pattern` (which defaults to `transfer`) still applies. - -For example the following command would generate the contents of a `proposal.json` file which would attempt to upgrade -channels with a port ID of `transfer` and a channelID of `channel-0`, `channel-1` or `channel-2`. - -```bash -simd tx ibc channel upgrade-channels "{\"fee_version\":\"ics29-1\",\"app_version\":\"ics20-1\"}" \ - --deposit "10stake" \ - --title "Channel Upgrades Governance Proposal" \ - --summary "Upgrade all transfer channels to be fee enabled" \ - --port-pattern "transfer" \ - --channel-ids "channel-0,channel-1,channel-2" \ - --json -``` diff --git a/docs/docs/01-ibc/07-proposals.md b/docs/docs/01-ibc/06-proposals.md similarity index 100% rename from docs/docs/01-ibc/07-proposals.md rename to docs/docs/01-ibc/06-proposals.md diff --git a/docs/docs/01-ibc/08-relayer.md b/docs/docs/01-ibc/07-relayer.md similarity index 100% rename from docs/docs/01-ibc/08-relayer.md rename to docs/docs/01-ibc/07-relayer.md diff --git a/docs/docs/01-ibc/09-proto-docs.md b/docs/docs/01-ibc/08-proto-docs.md similarity index 100% rename from docs/docs/01-ibc/09-proto-docs.md rename to docs/docs/01-ibc/08-proto-docs.md diff --git a/docs/docs/01-ibc/10-roadmap.md b/docs/docs/01-ibc/09-roadmap.md similarity index 100% rename from docs/docs/01-ibc/10-roadmap.md rename to docs/docs/01-ibc/09-roadmap.md diff --git a/docs/docs/01-ibc/11-troubleshooting.md b/docs/docs/01-ibc/10-troubleshooting.md similarity index 100% rename from docs/docs/01-ibc/11-troubleshooting.md rename to docs/docs/01-ibc/10-troubleshooting.md diff --git a/docs/docs/01-ibc/13-best-practices.md b/docs/docs/01-ibc/11-best-practices.md similarity index 100% rename from docs/docs/01-ibc/13-best-practices.md rename to docs/docs/01-ibc/11-best-practices.md diff --git a/docs/docs/01-ibc/14-permissioning.md b/docs/docs/01-ibc/12-permissioning.md similarity index 100% rename from docs/docs/01-ibc/14-permissioning.md rename to docs/docs/01-ibc/12-permissioning.md diff --git a/docs/docs/02-apps/02-interchain-accounts/01-overview.md b/docs/docs/02-apps/02-interchain-accounts/01-overview.md index d09654230b9..8626ad0d1a2 100644 --- a/docs/docs/02-apps/02-interchain-accounts/01-overview.md +++ b/docs/docs/02-apps/02-interchain-accounts/01-overview.md @@ -45,4 +45,4 @@ This means that the host and controller modules cannot close channels, but they In the event of a channel closing (due to a packet timeout in an ordered channel, for example), the interchain account associated with that channel can become accessible again if a new channel is created with a (JSON-formatted) version string that encodes the exact same `Metadata` information of the previous channel. The channel can be reopened using either [`MsgRegisterInterchainAccount`](./05-messages.md#msgregisterinterchainaccount) or `MsgChannelOpenInit`. If `MsgRegisterInterchainAccount` is used, then it is possible to leave the `version` field of the message empty, since it will be filled in by the controller submodule. If `MsgChannelOpenInit` is used, then the `version` field must be provided with the correct JSON-encoded `Metadata` string. See section [Understanding Active Channels](./09-active-channels.md#understanding-active-channels) for more information. -When reopening a channel with the default controller submodule, the ordering of the channel cannot be changed. In order to change the ordering of the channel, the channel has to go through a [channel upgrade handshake](../../01-ibc/06-channel-upgrades.md) or reopen the channel with a custom controller implementation. +When reopening a channel with the default controller submodule, the ordering of the channel cannot be changed. diff --git a/docs/docs/03-light-clients/01-developer-guide/08-proposals.md b/docs/docs/03-light-clients/01-developer-guide/08-proposals.md index 1015901ba73..3e2cd6731d4 100644 --- a/docs/docs/03-light-clients/01-developer-guide/08-proposals.md +++ b/docs/docs/03-light-clients/01-developer-guide/08-proposals.md @@ -8,7 +8,7 @@ slug: /ibc/light-clients/proposals # Handling proposals -It is possible to update the client with the state of the substitute client through a governance proposal. [This type of governance proposal](../../01-ibc/07-proposals.md) is typically used to recover an expired or frozen client, as it can recover the entire state and therefore all existing channels built on top of the client. `RecoverClient` should be implemented to handle the proposal. +It is possible to update the client with the state of the substitute client through a governance proposal. [This type of governance proposal](../../01-ibc/06-proposals.md) is typically used to recover an expired or frozen client, as it can recover the entire state and therefore all existing channels built on top of the client. `RecoverClient` should be implemented to handle the proposal. ## Implementing `RecoverClient` diff --git a/docs/docs/05-migrations/02-sdk-to-v1.md b/docs/docs/05-migrations/02-sdk-to-v1.md index 88022435f64..e24c0f62bb6 100644 --- a/docs/docs/05-migrations/02-sdk-to-v1.md +++ b/docs/docs/05-migrations/02-sdk-to-v1.md @@ -112,7 +112,7 @@ app.IBCKeeper = ibckeeper.NewKeeper( ### UpdateClientProposal -The `UpdateClient` has been modified to take in two client-identifiers and one initial height. Please see the [documentation](../01-ibc/07-proposals.md) for more information. +The `UpdateClient` has been modified to take in two client-identifiers and one initial height. Please see the [documentation](../01-ibc/06-proposals.md) for more information. ### UpgradeProposal diff --git a/docs/docs/05-migrations/12-v8-to-v8_1.md b/docs/docs/05-migrations/12-v8-to-v8_1.md index 17ddfbe295f..9b99eefdded 100644 --- a/docs/docs/05-migrations/12-v8-to-v8_1.md +++ b/docs/docs/05-migrations/12-v8-to-v8_1.md @@ -23,7 +23,7 @@ There are four sections based on the four potential user groups of this document ### `04-channel` params migration -Self-managed [params](https://github.com/cosmos/ibc-go/blob/v8.1.0/proto/ibc/core/channel/v1/channel.proto#L183-L187) have been added for `04-channel` module. The params include the `upgrade_timeout` that is used in channel upgradability to specify the interval of time during which the counterparty chain must flush all in-flight packets on its end and move to `FLUSH_COMPLETE` state (see [Channel Upgrades](../01-ibc/06-channel-upgrades.md#) for more information). An [automatic migration handler](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/module.go#L162-L166) is configured in the `04-channel` module that sets the default params (with a default upgrade timeout of 10 minutes). The module has a corresponding [`MsgUpdateParams` message](https://github.com/cosmos/ibc-go/blob/v8.1.0/proto/ibc/core/channel/v1/tx.proto#L435-L447) with a `Params` field which can be specified in full to update the module's `Params`. +Self-managed [params](https://github.com/cosmos/ibc-go/blob/v8.1.0/proto/ibc/core/channel/v1/channel.proto#L183-L187) have been added for `04-channel` module. The params include the `upgrade_timeout` that is used in channel upgradability to specify the interval of time during which the counterparty chain must flush all in-flight packets on its end and move to `FLUSH_COMPLETE` state). An [automatic migration handler](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/module.go#L162-L166) is configured in the `04-channel` module that sets the default params (with a default upgrade timeout of 10 minutes). The module has a corresponding [`MsgUpdateParams` message](https://github.com/cosmos/ibc-go/blob/v8.1.0/proto/ibc/core/channel/v1/tx.proto#L435-L447) with a `Params` field which can be specified in full to update the module's `Params`. ### Fee migration diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index b1e8c9e0ff9..baf2aed6448 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -119,13 +119,6 @@ const config = { docsPluginId: "adrs", label: "Architecture Decision Records", }, - { - type: "doc", - position: "left", - docId: "intro", - docsPluginId: "tutorials", - label: "Tutorials", - }, { type: "docsVersionDropdown", position: "right", @@ -275,16 +268,6 @@ const config = { exclude: ["**/*.template.md"], }, ], - [ - "@docusaurus/plugin-content-docs", - { - id: "tutorials", - path: "tutorials", - routeBasePath: "tutorials", - sidebarPath: require.resolve("./sidebars.js"), - exclude: ["**/*.template.md"], - }, - ], [ "@docusaurus/plugin-content-docs", { diff --git a/docs/requirements/channel-upgradability-requirements.md b/docs/requirements/channel-upgradability-requirements.md deleted file mode 100644 index fb1829e15ab..00000000000 --- a/docs/requirements/channel-upgradability-requirements.md +++ /dev/null @@ -1,178 +0,0 @@ -# Business requirements - -Rather than create a new channel to expand upon the capabilities of an existing channel, channel upgradability enables new features and capabilities to be added to existing channels. - -## Problem - -Currently, once a channel is opened and the channel handshake is complete, you cannot change or renegotiate the semantics of that channel. This means that if you wanted to make a change to a channel affecting the semantics on both channel ends, you would need to open a new channel, meaning all previous state in the prior channel would be lost. This is particularly important for channels using the ICS 20 (fungible token transfer) application module because tokens are not fungible between channels. - -Upgrading a channel enables upgrading the application module claiming the channel, where the upgrade requires a new packet data structure or adding a middleware at both channel ends. Currently it is possible to make changes to one end of a channel that does not require the counterparty to make changes, for example adding rate limiting middleware. Channel upgradability is solving the problem when changes need to be agreed upon on both sides of the channel. - -## Objectives - -To enable existing channels to upgrade the application module claiming the channel or add middleware to both ends of an existing channel whilst retaining the state of the channel. - -## Scope - -A new `ChannelEnd` interface is defined after a channel upgrade, the scope of these upgrades is detailed in the table below. - -| Features | Release | -| --------- | ------- | -| Performing a channel upgrade results in an application module changing from v1 to v2, claiming the same `channelID` and `portID` | v8.1 | -| Performing a channel upgrade results in a channel with the same `channelID` and `portID` changing the channel ordering | v8.1 | -| Performing a channel upgrade results in a channel with the same `channelID` and `portID` having a new channel version, where the change is needed on both `ChannelEnd`s, for example additional middleware added to the application stack on both sides of the channel, or a change to the packet data or acknowledgement structure | v8.1 | -| Performing a channel upgrade results in a channel with the same `channelID` and `portID` modifying the `connectionHops` | v8.1 | - -# User requirements - -## Use cases - -- Upgrading an existing application module from v1 to v2, e.g. new features could be added to the existing ICS 20 application module which would result in a new version of the module, e.g. enabling multiple coin types to be sent in a single packet. -- Adding middleware on both sides of an existing channel, e.g. relayer incentivisation middleware, ICS 29, requires middleware to be added to both ends of a channel to incentivise the `recvPacket`, `acknowledgePacket` and `timeoutPacket`. - -### Upgrade parameters - -The parameters of a channel that can be modified during a channel upgrade are: - -- channel version -- channel ordering -- connection hops - -These must be specified for each channel ID and port ID selected for the upgrade. If an upgradable parameter is omitted, then it is assumed the parameter must stay the same after the upgrade. - -#### Examples - -| port ID, channel ID | version | ordering | hops | use case | -| ------------------- | ------- | -------- | ---- | -------- | -| (`transfer`, `channel-0`) & (`transfer`, `channel-1`)| `ics20-2` | | | Upgrading ics20 to v2 for 2 channels | -| (`icacontroller-cosmos13fx6...`, `channel-2`)| | `UNORDERED` | | Upgrading single ICA controller channel to be unordered | -| (`transfer`, `channel-1`) | `{"fee_version":"ics29-1", "app_version":"ics20-1"}`| | | Upgrade single transfer channel to have ics-29 enabled | -| (`icacontroller-cosmos89y4...`, `channel-7`) | `{"fee_version":"ics29-1", "app_version":"ics27-1"}` | | | Upgrade an ICA controller channel to have ics-29 enabled | - -### Upgrade Flow - -Upgrades can be proposed only in a **permissioned** manner: upgrade initiation is approved by governance or groups proposal and `MsgChannelUpgradeInit` is automatically submitted on proposal passing. A permissioned mechanism may also optionally be implemented for the counterparty chain such that governance would need to allow (or prohibit, in the case of using a deny list) upgrades for channels in specific connections. Assuming that the proposed upgrade parameters are identical on both chains, then the following upgrade initiation combinations are possible: - -- Chain A's governance proposal to initiate the upgrade of (`transfer`, `channel-0`) is accepted and `MsgChannelUpgradeInit` is executed. Chain B's governance proposal to allow upgrades for channels in connection `connection-0` is accepted. When the on-chain parameter with the list of allowed connections is updated, then a relayer can submit `MsgChannelUpgradeTry` on chain B for the counterparty channel (`transfer`, `channel-0`) in `connection-0`. -- Governance of both chain A and chain B submit proposal to initiate the upgrade of (`transfer`, `channel-0`) on chain A and the counterparty channel (`transfer`, `channel-0`) on chain B. The proposal passes and `MsgChannelUpgradeInit` is executed on both chains. This is a crossing hello scenario. A relayer can then continue the handshake submitting `MsgChannelUpgradeTry` on either chain A or chain B. - -A normal flow and crossing hello flow are described in more detail below. For the sake of simplicity, the samples below make the following assumptions: - -1. The relayer can construct correct messages. -2. There exists a transfer channel between chain A and chain B, with channel ID `channel-0` on both ends. -3. The channel is upgraded to use fee incentivization (i.e. stack fee middleware on top of the transfer application). Both chains' binary has wired up the fee middleware. - -Further exception flows can be explored if some of the assumptions above do not apply. For example: if chain B's binary has not wired up the fee middleware and `MsgChannelUpgradeTry` is submitted, the upgrade will be aborted and a cancellation message can be submitted to chain A to restore the channel to its previous state. Or if each chain approves a different channel version, then the upgrade will abort during the negotiation. - -### Normal flow - -A normal flow for upgrades: - -1. Governance proposal with `MsgChannelUpgradeInit` proposing to upgrade channel version to `{"fee_version":"ics29-1","app_version":"ics20-1"}` is submitted on chain A. -2. Governance proposal passes and `MsgChannelUpgradeInit` executes successfully on chain A. -3. Governance of chain B updates the list of allowed connections for channel upgrades, so that `channel-0` is allowed to be upgraded permissionlessly. -4. Relayer submits `MsgChannelUpgradeTry` on chain B proposing to upgrade channel version to `{"fee_version":"ics29-1","app_version":"ics20-1"}`. -5. Execution of `MsgChannelUpgradeTry` succeeds on chain B. Chain B specifies a timeout for chain A before which all packets on its side should be flushed. -6. Relayer starts flushing in-flight packets from chain B to chain A. -7. Relayer detects successful execution of `MsgChannelUpgradeTry` and submits `MsgChannelUpgradeAck` on chain A. -8. Execution of `MsgChannelUpgradeAck` succeeds on chain A. Chain A specifies a timeout for chain B before which all packets on its side should be flushed. -9. Relayer starts flushing in-flight packets from chain A to chain B. -10. Relayer completes packet lifecycle for in-flight packets from chain B to chain A. -11. Relayer completes packet lifecycle for in-flight packets from chain A to chain B. -12. Relayer submits `MsgChannelUpgradeConfirm` on chain B. -13. Execution of `MsgChannelUpgradeConfirm` succeeds on chain B. -14. Relayer submits `MsgChannelUpgradeOpen` on chain A. -15. Execution of `MsgChannelUpgradeOpen` succeeds on chain A. - -Sample exception flows: - -- Relayer submits `MsgChannelUpgradeTry` for a channel whose connection is not in the list of allowed connection. Then the message is rejected, but the channel state on the proposing chain does not need to be reverted. -- Relayer submits `MsgChannelUpgradeTry` with different upgrade parameters to the parameters accepted on the proposing chain. Then the message is rejected, but the channel state on the proposing chain does not need to be reverted. -- During packet flushing if the timeout specified by the counterparty is reached, then the channel will be restored to its initial state, an error receipt will be written and the upgrade will be aborted. - -### Crossing hello flow - -The crossing hello flow for upgrades happens when a governance proposal on both chains passes and executes `MsgChannelUpgradeInit` with the same upgrade parameters for channel ends that are the counterparty of each other: - -1. Governance proposal with `MsgChannelUpgradeInit` proposing to upgrade channel version to `{"fee_version":"ics29-1","app_version":"ics20-1"}` is submitted on chain A. -2. Governance proposal passes and `MsgChannelUpgradeInit` executes successfully on chain A. -3. Governance proposal with `MsgChannelUpgradeInit` proposing to upgrade channel version to `{"fee_version":"ics29-1","app_version":"ics20-1"}` is submitted on chain B. -4. Governance proposal passes and `MsgChannelUpgradeInit` executes successfully on chain B. -5. Relayer detects execution of `MsgChannelUpgradeInit` on chain A and submits `MsgChannelUpgradeTry` on chain B proposing to upgrade channel version to `{"fee_version":"ics29-1","app_version":"ics20-1"}`. Since chain B has already executed `MsgChannelUpgradeInit`, we are in a crossing hello scenario. -6. Execution of `MsgChannelUpgradeTry` succeeds on chain B. Chain B specifies a timeout for chain A before which all packets on its side should be flushed. -7. Relayer starts flushing in-flight packets from chain B to chain A. -8. Relayer detects successful execution of `MsgChannelUpgradeTry` and submits `MsgChannelUpgradeAck` on chain A. -9. Execution of `MsgChannelUpgradeAck` succeeds on chain A. Chain A specifies a timeout for chain B before which all packets on its side should be flushed. -10. Relayer starts flushing in-flight packets from chain A to chain B. -11. Relayer completes packet lifecycle for in-flight packets from chain B to chain A. -12. Relayer completes packet lifecycle for in-flight packets from chain A to chain B. -13. Relayer submits `MsgChannelUpgradeConfirm` on chain B. -14. Execution of `MsgChannelUpgradeConfirm` succeeds on chain B. -15. Relayer submits `MsgChannelUpgradeOpen` on chain A. -16. Execution of `MsgChannelUpgradeOpen` succeeds on chain A. - -Sample exception flows: - -- If two different relayers detect execution of `MsgChannelUpgradeInit` on both chain A and chain B and they submit `MsgChannelUpgradeTry` on the counterparty, then the handshake will finish `MsgChannelUpgradeOpen` after both chains execute `MsgChannelUpgradeAck` and all in-flight packets have been flushed (i.e. it is not needed to execute `MsgChannelUpgradeConfirm`). - -# Functional requirements - -## Assumptions and dependencies - -- Functional relayer infrastructure is required to perform a channel upgrade. -- Chains wishing to successfully upgrade a channel must be using a minimum ibc-go version of v8.1. -- Chains proposing an upgrade must have the middleware or application module intended to be used in the channel upgrade configured. - -## Features - -### 1 - Configuration - -| ID | Description | Verification | Status | -| -- | ----------- | ------------ | ------ | -| 1.01 | An on-chain parameter keeps a list of all connection IDs (e.g. [`connection-0`, `connection-1`]) for which channels are allowed to be upgraded for an upgrade proposed on a counterparty chain | TBD | `Deferred` | -| 1.02 | The on-chain parameter of connection IDs can only be updated by an authorized actor (e.g. governance) | TBD | `Deferred` | - -### 2 - Initiation - -| ID | Description | Verification | Status | -| -- | ----------- | ------------ | ------ | -| 2.01 | An upgrade initiated by an authorized actor (e.g. governance) is always allowed | [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/keeper/msg_server_test.go#L952-L969) | `Verified` | -| 2.02 | A chain can configure a channel upgrade to be initiated automatically after a successful governance proposal | Provided by Cosmos SDK `x/gov` | `Verified` | -| 2.03 | After permission is granted for channels in a given connection to be upgraded, any relayer can continue the upgrade proposed on a counterparty chain | Only `MsgChannelUpgradeInit` is permissioned |`Verified` | -| 2.04 | A channel upgrade will be initiated when both `ChannelEnd`s are in the `OPEN` state | Acceptance tests in [`ChanUpgradeInit`](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/upgrade_test.go#L63-L69) and [`ChanUpgradeTry`](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/upgrade_test.go#L167-L173)| `Verified` | -| 2.05 | In the case of a crossing hello, a channel upgrade can be initiated when the counterparty has also executed the `ChanUpgradeInit` datagram with compatible parameters in the case of a crossing hello | [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/upgrade_test.go#L141-L148) | `Verified` | - -### 3 - Upgrade Handshake - -| ID | Description | Verification | Status | -| -- | ----------- | ------------ | ------ | -| 3.01 | The upgrade proposing chain's channel state will remain `OPEN` after successful or unsuccessful execution of the `ChanUpgradeInit` datagram | [Channel state does not change in `WriteUpgradeInitChannel`](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/upgrade.go#L66) | `Verified` | -| 3.02 | If the counterparty chain accepts the upgrade its channel state will go from `OPEN` to `FLUSHING` after successful execution of the `ChanUpgradeTry` datagram, initiated by a relayer | [Move to `FLUSHING` in `startFlushing`](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/upgrade.go#L219) | `Verified` | -| 3.03 | A relayer must initiate the `ChanUpgradeAck` datagram on the upgrade proposing chain, on successful execution the channel state will go from `OPEN` to `FLUSHING`| [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/upgrade_test.go#L826) | `Verified` | -| 3.04 | The `ChanUpgradeAck` datagram informs the chain of the timeout period specified by the counterparty for the upgrade process to complete | [Stored in `WriteUpgradeAckChannel`](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/upgrade.go#L380) | `Verified` | -| 3.05 | When channel is in `FLUSHING` state, no new packets are allowed to be sent | [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/packet_test.go#L232-L247) | `Verified` | -| 3.06 | When channel is in `FLUSHING` state, it is only allowed to receive packets with sequence number smaller or equal than the sequence number of the last packet sent on the counterparty when the channel moved to `FLUSHING` state | [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/packet_test.go#L406-L427) | `Verified` | -| 3.07 | When channel is in `FLUSHING` state and packets are acknowledged or timed out, if the counterparty-specified timeout is reached, then the channel will be restored to its initial state, an error receipt will be written and the upgrade will be aborted | [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/packet_test.go#L978-L1028) | `Verified` | -| 3.08 | Once in-flight packets have been flushed, the channel state shall change from `FLUSHING` to `FLUSHCOMPLETE` | [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/packet_test.go#L924-L977) | `Verified` | -| 3.09 | A relayer must initiate the `ChanUpgradeConfirm` datagram on the counterparty to inform of the timeout period specified by the counterparty for the upgrade process to complete | [Stored in `WriteUpgradeConfirmChannel`](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/upgrade.go#L480) | `Verified` | -| 3.10 | Successful execution of the `ChanUpgradeConfirm` datagram when the channel state is `FLUSHCOMPLETE` changes the channel state to `OPEN` | [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/keeper/msg_server_test.go#L1557-L1596) | `Verified` | -| 3.11 | If the channel state is `FLUSHING` when the `ChanUpgradeConfirm` datagram is called, `ChanUpgradeOpen` is later called to change the state to `OPEN` | [Move to `OPEN` in `WriteUpgradeOpenChannel`](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/upgrade.go#L627) | `Verified` | -| 3.12 | When both channel ends are in the `FLUSHCOMPLETE` state, a relayer can submit the `ChanUpgradeOpen` datagram to move the channel state to `OPEN` | [Move to `OPEN` in `WriteUpgradeOpenChannel`](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/upgrade.go#L627) | `Verified` | -| 3.13 | The counterparty chain may reject a proposed channel upgrade and the original channel on the proposing chain will be restored | [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/upgrade_test.go#L215-L229) | `Verified` | -| 3.14 | If an upgrade handshake is unsuccessful, the original channel will be restored | [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/upgrade_test.go#L2512-L2516) | `Verified` | -| 3.15 | A relayer can submit the `ChanUpgradeCancel` to cancel an upgrade which will successfully execute if the counterparty wrote an `ErrorReceipt`| [There must be an error receipt proof](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/upgrade.go#L652-L655) | `Verified` | -| 3.16 | If the `ChanUpgradeCancel` datagram is submitted by an authorized actor (e.g. governance) then the upgrade will be canceled without requiring the counterparty to write an `ErrorReceipt`| [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/keeper/msg_server_test.go#L2192-L2241) | `Verified` | -| 3.17 | An upgrade should be timed out if the chain has not completed flushing all pending packets within the timeout specified by the counterparty | [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/packet_test.go#L978-L1028) | `Verified` | - -# External interface requirements - -| ID | Description | Verification | Status | -| -- | ----------- | ------------ | ------ | -| 4.01 | There should be a gRPC query to retrieve the upgrade fields and timeout stored for a given port ID and channel ID | [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/grpc_query_test.go#L1849-L1854) | `Verified` | -| 4.02 | There should be a gRPC query to retrieve the upgrade error receipt stored for a given port ID and channel ID | [Acceptance test](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/grpc_query_test.go#L1755-L1769) | `Verified` | - -# Non-functional requirements - -| ID | Description | Verification | Status | -| -- | ----------- | ------------ | ------ | -| 5.01 | A malicious actor should not be able to compromise the liveness of a channel | Verified during security audit | `Verified` | diff --git a/docs/tutorials/00-intro.md b/docs/tutorials/00-intro.md deleted file mode 100644 index c56bf04dc98..00000000000 --- a/docs/tutorials/00-intro.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: IBC-Go Tutorials -sidebar_label: IBC-Go Tutorials -sidebar_position: 0 -slug: /intro ---- - -# IBC-Go Tutorials - -Welcome to IBC-Go Tutorials. This is a collection of tutorials that will help you get started with IBC-Go. diff --git a/docs/tutorials/02-channel-upgrades/01-intro.md b/docs/tutorials/02-channel-upgrades/01-intro.md deleted file mode 100644 index 83adb299946..00000000000 --- a/docs/tutorials/02-channel-upgrades/01-intro.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: Introduction -sidebar_label: Introduction -sidebar_position: 1 -slug: /channel-upgrades/intro ---- - -import HighlightTag from '@site/src/components/HighlightTag'; -import HighlightBox from '@site/src/components/HighlightBox'; - -# Introduction - - - -This is a tutorial for upgrading an existing ICS 20 transfer channel to wrap it with the ICS 29 Fee Middleware. - - - -- Basic Knowledge of Cosmos SDK. - - If you are new to Cosmos SDK, we recommend you to go through the first two categories of the [Developer Portal](https://tutorials.cosmos.network/academy/1-what-is-cosmos/). -- Basic Knowledge of [the Fee Middleware module](https://ibc.cosmos.network/main/middleware/ics29-fee/overview). -- Basic knowledge of [channel upgrades](https://ibc.cosmos.network/main/ibc/channel-upgrades). - - - -## Scope - -This tutorial will cover the process of upgrading an existing ICS 20 transfer channel to add packet incentivization using the Fee Middleware. - - - -In this tutorial, you will: - -- Run two IBC-enabled blockchains locally. -- Open an ICS 20 transfer channel using the Hermes relayer. -- Upgrade the ICS 20 transfer channel to add ICS-29 Fee Middleware. - - diff --git a/docs/tutorials/02-channel-upgrades/02-setup-env.md b/docs/tutorials/02-channel-upgrades/02-setup-env.md deleted file mode 100644 index d4047f617db..00000000000 --- a/docs/tutorials/02-channel-upgrades/02-setup-env.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -title: Set Up Your Work Environment -sidebar_label: Set Up Your Work Environment -sidebar_position: 2 -slug: /channel-upgrades/setup-env ---- - -import HighlightBox from '@site/src/components/HighlightBox'; - -# Set up your work environment - -On this page, you can find helpful links to set up your work environment. - - - -In this section, you can find all you need to install: - -- [jq](https://jqlang.github.io/jq/) -- [gm](https://github.com/informalsystems/gm/) -- [ibc-go simd](https://github.com/cosmos/ibc-go/) -- [Hermes v1.9.0](https://hermes.informal.systems/) - - - -## jq - -Install `jq` following the instructions on [its website](https://jqlang.github.io/jq/download/). Test if it is installed by running the following command: - -```bash -jq --version -``` - -At the moment of writing this tutorial, the version of `jq` used was 1.6. - -## gm - -The [gaiad manager](https://github.com/informalsystems/gm) (`gm`) is a configurable command-line tool (CLI) that helps manage local gaiad networks. It can be used to easily and quickly run a local setup of multiple blockchains. Follow the installation steps [here](https://github.com/informalsystems/gm#how-to-run). - -## ibc-go simd - -Download the simd binary from the [v8.1.0 release](https://github.com/cosmos/ibc-go/releases/tag/v8.1.0). This chain binary has the Fee Middleware already wired up and wrapping the ICS 20 transfer application. If you want to know how to wire up the Fee Middleware, please read the wiring section from the Fee Middleware tutorial. - -## Hermes - -Install Hermes relayer version `v1.9.0` via cargo following the instructions on the [Hermes website](https://hermes.informal.systems/quick-start/installation.html#install-via-cargo) or by using the command below. - -```bash -cargo install ibc-relayer-cli --version 1.9.0 --bin hermes --locked -``` - -Test if Hermes is installed by running the following command: - -```bash -hermes version -``` - -# Folder structure - -This tutorial assumes the following folder structure: - -```text -testing -├── bin -│ ├── chain1 -│ │ ├── simd -│ │ └── proposal.json -│ └── chain2 -│ └── simd -├── gm -└── hermes - ├── hermes - └── config.toml -``` - -`simd` if the chain binary that will be used to run 2 blockchains (`chain1` and `chain2`). THe folder `gm` will contain the data folders for both blockchains. diff --git a/docs/tutorials/02-channel-upgrades/03-run-chains.md b/docs/tutorials/02-channel-upgrades/03-run-chains.md deleted file mode 100644 index 7f4c2b09e6d..00000000000 --- a/docs/tutorials/02-channel-upgrades/03-run-chains.md +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: Run 2 Cosmos SDK Blockchains Locally -sidebar_label: Run 2 Cosmos SDK Blockchains Locally -sidebar_position: 3 -slug: /channel-upgrades/run-chains ---- - -# Run 2 Cosmos SDK blockchains locally - -The gm tool uses a [configuration file](https://github.com/informalsystems/gm/blob/master/gm.toml). This tutorial uses the following configuration file for gm: - -```yaml title="gm.toml" -[global] -add_to_hermes=true -home_dir="~/testing/gm" - -[global.hermes] -binary="~/testing/hermes/hermes" -config="~/testing/hermes/config.toml" - -[chain1] - gaiad_binary="~/testing/bin/chain1/simd" - ports_start_at=27000 - -[chain2] - gaiad_binary="~/testing/bin/chain2/simd" - ports_start_at=27010 -``` - -The configuration file needs to be placed in `$HOME/.gm`. This configuration file sets up 2 blockchains (`chain1` and `chain2`), each with 2 accounts (1 validator, 1 wallet). The ports where the CometBFT RPC interface for each chain is 27000 for `chain1` and 27010 for `chain2`. - -In order to shorten the voting period of governance proposal, we are going to change some of the `x/gov` module parameters in the `genesis.json` file, so that we can complete the upgrade faster. These are the changes needed in the `genesis.json` of `chain1`: - -```json title="genesis.json" -"gov": { - "starting_proposal_id": "1", - "deposits": [], - "votes": [], - "proposals": [], - "deposit_params": null, - "voting_params": null, - "tally_params": null, - "params": { - "min_deposit": [ - { - "denom": "stake", -// minus-diff-line -- "amount": "10000000" -// plus-diff-line -+ "amount": "100" - } - ], - "max_deposit_period": "172800s", -// minus-diff-line -- "voting_period": "172800s", -// plus-diff-line -+ "voting_period": "180s", - "quorum": "0.334000000000000000", -// minus-diff-line -- "threshold": "0.500000000000000000", -// plus-diff-line -+ "threshold": "0.300000000000000000", - "veto_threshold": "0.334000000000000000", - "min_initial_deposit_ratio": "0.000000000000000000", - "proposal_cancel_ratio": "0.500000000000000000", - "proposal_cancel_dest": "", - "expedited_voting_period": "86400s", - "expedited_threshold": "0.667000000000000000", - "expedited_min_deposit": [ - { - "denom": "stake", - "amount": "50000000" - } - ], - "burn_vote_quorum": false, - "burn_proposal_deposit_prevote": false, - "burn_vote_veto": true, - "min_deposit_ratio": "0.010000000000000000" - }, - "constitution": "" -} -``` - -We start both blockchains by running the following command: - -```bash -gm start -``` - -For convenience, we are going to store a few account addresses as variables in the current shell environment. Execute the following commands to store the relayer addresses on chains `chain1` and `chain2`, respectively: - -```bash -export RLY_CHAIN1=$(simd keys show wallet -a \ ---keyring-backend test \ ---home ../../gm/chain1) && echo $RLY_CHAIN1; -export RLY_CHAIN2=$(simd keys show wallet -a \ ---keyring-backend test \ ---home ../../gm/chain2) && echo $RLY_CHAIN2; -``` - -And execute also the following commands to store the validator account addresses on chains `chain1` and `chain2` that we will use throughout this tutorial: - -```bash -export VALIDATOR_CHAIN1=$(simd keys show validator -a \ ---keyring-backend test \ ---home ../../gm/chain1) && echo $VALIDATOR_CHAIN1; -export VALIDATOR_CHAIN2=$(simd keys show validator -a \ ---keyring-backend test \ ---home ../../gm/chain2) && echo $VALIDATOR_CHAIN2; -``` diff --git a/docs/tutorials/02-channel-upgrades/04-open-transfer-channel.md b/docs/tutorials/02-channel-upgrades/04-open-transfer-channel.md deleted file mode 100644 index 77636dcbd71..00000000000 --- a/docs/tutorials/02-channel-upgrades/04-open-transfer-channel.md +++ /dev/null @@ -1,167 +0,0 @@ ---- -title: Open transfer channel -sidebar_label: Open transfer channel -sidebar_position: 4 -slug: /channel-upgrades/open-channel ---- - -# Open an ICS 20 transfer channel - -The relayer needs to submit transactions on both blockchains, so we run the following command to add the keys for the accounts on `chain1` and `chain2` that the relayer can use to submit transactions: - -```bash -gm hermes keys -``` - -The relayer also needs a [configuration file](https://github.com/informalsystems/hermes/blob/master/config.toml). In this tutorial we will have the configuration file in the same folder as the relayer binary and specify it using the `--config` flag in each command. - -You can generate a default configuration by running: - -```bash -gm hermes config -``` - -This tutorial has been completed with the following configuration file: - -```yaml -[global] -log_level = 'trace' - -[telemetry] -enabled = true -host = '127.0.0.1' -port = 3001 - -# Specify the mode to be used by the relayer. [Required] -[mode] - -# Specify the client mode. -[mode.clients] - -# Whether or not to enable the client workers. [Required] -enabled = true - -# Whether or not to enable periodic refresh of clients. [Default: true] -# Note: Even if this is disabled, clients will be refreshed automatically if -# there is activity on a connection or channel they are involved with. -refresh = true - -# Whether or not to enable misbehaviour detection for clients. [Default: false] -misbehaviour = true - -# Specify the connections mode. -[mode.connections] - -# Whether or not to enable the connection workers for handshake completion. [Required] -enabled = true - -[mode.channels] -enabled = true - -# Specify the packets mode. -[mode.packets] - -# Whether or not to enable the packet workers. [Required] -enabled = true - -clear_interval = 1 - -[[chains]] -id = 'chain1' -type = 'CosmosSdk' -rpc_addr = 'http://localhost:27000' -grpc_addr = 'http://localhost:27002' -event_source = { mode = 'push', url = 'ws://127.0.0.1:27000/websocket', batch_delay = '500ms' } -rpc_timeout = '15s' -account_prefix = 'cosmos' -key_name = 'wallet' -store_prefix = 'ibc' -gas_price = { price = 0.001, denom = 'stake' } -max_gas = 1000000 -clock_drift = '5s' -trusting_period = '14days' -trust_threshold = { numerator = '1', denominator = '3' } - -[[chains]] -id = 'chain2' -type = 'CosmosSdk' -rpc_addr = 'http://localhost:27010' -grpc_addr = 'http://localhost:27012' -event_source = { mode = 'push', url = 'ws://127.0.0.1:27010/websocket', batch_delay = '500ms' } -rpc_timeout = '15s' -account_prefix = 'cosmos' -key_name = 'wallet' -store_prefix = 'ibc' -gas_price = { price = 0.001, denom = 'stake' } -max_gas = 1000000 -clock_drift = '5s' -trusting_period = '14days' -trust_threshold = { numerator = '1', denominator = '3' } -``` - -With both blockchains running, we can run the following command in hermes to establish a connection and an ICS 20 transfer channel: - -```bash -hermes --config config.toml create channel --a-chain chain1 \ ---b-chain chain2 \ ---a-port transfer \ ---b-port transfer \ ---new-client-connection -``` - -When both the connection and channel handshakes complete, the output on the console looks like this: - -```bash -SUCCESS Channel { - ordering: Unordered, - a_side: ChannelSide { - chain: BaseChainHandle { - chain_id: ChainId { - id: "chain1", - version: 0, - }, - runtime_sender: Sender { .. }, - }, - client_id: ClientId( - "07-tendermint-0", - ), - connection_id: ConnectionId( - "connection-0", - ), - port_id: PortId( - "transfer", - ), - channel_id: Some( - ChannelId( - "channel-0", - ), - ), - version: None, - }, - b_side: ChannelSide { - chain: BaseChainHandle { - chain_id: ChainId { - id: "chain2", - version: 0, - }, - runtime_sender: Sender { .. }, - }, - client_id: ClientId( - "07-tendermint-0", - ), - connection_id: ConnectionId( - "connection-0", - ), - port_id: PortId( - "transfer", - ), - channel_id: Some( - ChannelId( - "channel-0", - ), - ), - version: None, - }, - connection_delay: 0ns, -} -``` diff --git a/docs/tutorials/02-channel-upgrades/05-upgrade-channel.md b/docs/tutorials/02-channel-upgrades/05-upgrade-channel.md deleted file mode 100644 index d9addbacc10..00000000000 --- a/docs/tutorials/02-channel-upgrades/05-upgrade-channel.md +++ /dev/null @@ -1,213 +0,0 @@ ---- -title: Upgrade channel -sidebar_label: Upgrade channel -sidebar_position: 5 -slug: /channel-upgrades/upgrade-channel ---- - -# Upgrade the ICS 20 transfer channel - -## Start the relayer - -We start the relayer: - -```bash -hermes --config config.toml start -``` - -## Initiate the upgrade - -The [initiation of the upgrade process is authority-gated](https://ibc.cosmos.network/main/ibc/channel-upgrades#governance-gating-on-chanupgradeinit), and thus the upgrade will begin when a governance proposal passes. There a couple of ways in which the initiation can be triggered. - -### With `upgrade-channels` CLI - -We have a [CLI command](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/client/cli/tx.go#L62) that streamlines the submission of the governance proposal to initiate the upgrade. By default the CLI will upgrade all channels on `transfer` port with the provided channel version string. Both the port and the channels to be upgraded can be customized with CLI flags. To keep it simple, and since we only have one ICS20 channel, for this example the CLI command would look like the following: - -```bash -simd tx ibc channel upgrade-channels "{\"fee_version\":\"ics29-1\",\"app_version\":\"ics20-1\"}" --deposit 10stake -``` - -After the governance proposal is submitted, the user can vote for it and wait that it passes, but these steps are shown in more detail in the next section. - -### With `submit-proposal` CLI - -And alternative way of submitting the proposal is using `x/gov` module's CLI command. The contents of the governance proposal are: - -```json title=proposal.json -{ - "title": "Channel upgrade init", - "summary": "Channel upgrade init", - "messages": [ - { - "@type": "/ibc.core.channel.v1.MsgChannelUpgradeInit", - "signer": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", - "port_id": "transfer", - "channel_id": "channel-0", - "fields": { - "ordering": "ORDER_UNORDERED", - "connection_hops": ["connection-0"], - "version": "{\"fee_version\":\"ics29-1\",\"app_version\":\"ics20-1\"}" - } - } - ], - "metadata": "AQ==", - "deposit": "100005stake" -} -``` - -where `cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn` is the address of the governance module on `chain1`. You can retrieve the account of the governance module running the following command: - -```bash -simd query auth module-account gov --node http://localhost:27000 -``` - -The upgrade will modify the channel version to include the fee version. We submit the proposal: - -```bash -simd tx gov submit-proposal ./proposal_upgrade_channel.json \ ---from $VALIDATOR_CHAIN1 \ ---chain-id chain1 \ ---keyring-backend test \ ---home ../../gm/chain1 \ ---node http://localhost:27000 -``` - -Now we vote for the proposal: - -```bash -simd tx gov vote 1 yes \ ---from $VALIDATOR_CHAIN1 \ ---chain-id chain1 \ ---keyring-backend test \ ---home ../../gm/chain1 \ ---node http://localhost:27000 -``` - -And we wait for the voting period to end (approximately 3 minutes). Once it ends we can check that the proposal has passed (i.e. the status has changed from `PROPOSAL_STATUS_VOTING_PERIOD` to `PROPOSAL_STATUS_PASSED`): - -```bash -simd q gov proposals --node http://localhost:27000 -``` - -```yaml -pagination: - total: "1" -proposals: -- deposit_end_time: "2024-01-27T21:29:52.430508Z" - final_tally_result: - abstain_count: "0" - no_count: "0" - no_with_veto_count: "0" - yes_count: "1000000" - id: "1" - messages: - - type: /ibc.core.channel.v1.MsgChannelUpgradeInit - value: - channel_id: channel-0 - fields: {} - port_id: transfer - signer: cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn - metadata: AQ== - proposer: cosmos1vdy5fp0jy2l2ees870a7mls357v7uad6ufzcyz - status: 3 - submit_time: "2024-01-25T21:29:52.430508Z" - summary: Channel upgrade init - title: Channel upgrade init - total_deposit: - - amount: "100005" - denom: stake - voting_end_time: "2024-01-25T21:32:52.430508Z" - voting_start_time: "2024-01-25T21:29:52.430508Z" -``` - -Now we wait for the relayer to complete the upgrade handshake. - -## Check upgrade completed - -Once the handshake has completed we verify that the channel has successfully upgraded: - -```bash -simd q ibc channel channels --node http://localhost:27000 -``` - -```yaml -channels: -- channel_id: channel-0 - connection_hops: - - connection-0 - counterparty: - channel_id: channel-0 - port_id: transfer - ordering: ORDER_UNORDERED - port_id: transfer - state: STATE_OPEN - upgrade_sequence: "1" - version: '{"fee_version":"ics29-1","app_version":"ics20-1"}' -height: - revision_height: "135" - revision_number: "0" -pagination: - next_key: null - total: "0" -``` - -The channel version on `chain1` is what we expect. - -```bash -simd q ibc-fee channels --node http://localhost:27000 -``` - -```yaml -fee_enabled_channels: -- channel_id: channel-0 - port_id: transfer -pagination: - next_key: null - total: "0" -``` - -As we expect there is one incentivized channel. - -```bash -simd q ibc channel channels --node http://localhost:27010 -``` - -```yaml -channels: -- channel_id: channel-0 - connection_hops: - - connection-0 - counterparty: - channel_id: channel-0 - port_id: transfer - ordering: ORDER_UNORDERED - port_id: transfer - state: STATE_OPEN - upgrade_sequence: "1" - version: '{"fee_version":"ics29-1","app_version":"ics20-1"}' -height: - revision_height: "138" - revision_number: "0" -pagination: - next_key: null - total: "0" -``` - -The channel version on `chain2` is also what we expect. - -```bash -simd q ibc-fee channels --node http://localhost:27010 -``` - -```yaml -fee_enabled_channels: -- channel_id: channel-0 - port_id: transfer -pagination: - next_key: null - total: "0" -``` - -As we expect there is one incentivized channel as well on `chain2`. - -From now ICS 20 packets sent on this channel can be incentivized. diff --git a/docs/tutorials/02-channel-upgrades/06-incentivize-packet.md b/docs/tutorials/02-channel-upgrades/06-incentivize-packet.md deleted file mode 100644 index ef766ad6e2e..00000000000 --- a/docs/tutorials/02-channel-upgrades/06-incentivize-packet.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -title: Incentivize packet -sidebar_label: Incentivize packet -sidebar_position: 6 -slug: /channel-upgrades/incentivize-packet ---- - -# Incentivize an ICS 20 transfer packet - -## Register the counterparty payee - -All incentivization fees are paid to accounts on the chain from where the IBC packets originate. To ensure that the relayer that delivers the `MsgRecvPacket` on the destination chain is correctly compensated, the counterparty payee address (i.e. the account address of the relayer on the source chain) needs to be registered on the destination chain. Throughout this tutorial the source chain is `chain1` and the destination chain is `chain2`, therefore we need to register the account address of the relayer on chain `chain1` (`RLY_CHAIN1`) on chain `chain2` (where the relayer has the account address `RLY_CHAIN2`): - -```bash -simd tx ibc-fee register-counterparty-payee transfer channel-0 $RLY_CHAIN2 $RLY_CHAIN1 \ ---from $RLY_CHAIN2 \ ---chain-id chain2 \ ---keyring-backend test \ ---home ../../gm/chain2 \ ---node http://localhost:27010 -``` - -Once the above command succeeds, then we can verify which counterparty payee is registered on chain `chain2` for account `RLY_CHAIN2`: - -```bash -simd q ibc-fee counterparty-payee channel-0 $RLY_CHAIN2 --node http://localhost:27010 -``` - -```yaml -counterparty_payee: cosmos1vdy5fp0jy2l2ees870a7mls357v7uad6ufzcyz -``` - -We see that the counterparty payee address matches what we expected (i.e. the `RLY_CHAIN1` address). In this tutorial we are going to send only one packet from chain `chain1` to chain `chain2`, so we only need to register the counterparty payee on chain `chain2`. In real life circumstances relayers relay packets on both directions (i.e. from chain `chain1` to `chain2` and also vice-versa), and thus relayers should register as well on chain `chain1` the counterparty payee address to be compensated for delivering the `MsgRecvPacket` on chain `chain1`. - -## Multi-message transaction with single `MsgPayPacketFee` message - -We first generate (not execute) an IBC transfer transaction (again `1000samoleans` from `VALIDATOR_CHAIN1` to `VALIDATOR_CHAIN2`): - -```bash -simd tx ibc-transfer transfer transfer channel-0 $VALIDATOR_CHAIN2 1000samoleans \ ---from $VALIDATOR_CHAIN1 \ ---chain-id chain1 \ ---keyring-backend test \ ---home ../../gm/chain1 \ ---node tcp://localhost:27000 \ ---generate-only > transfer.json -``` - -Then we prepend a `MsgPayPacketFee`, sign the transaction and broadcast it. Please note that `jq` is used to manipulate the transaction JSON file, making it a multi-message transaction. In practice, this multi-message transaction would be built using a gRPC or web client, for example, a web-based wallet application could fulfill this role. Note also that the `signer` field uses the address of `VALIDATOR_CHAIN1`. - -` -jq '.body.messages |= [{"@type":"/ibc.applications.fee.v1.MsgPayPacketFee","fee": {"recv_fee": [{"denom": "samoleans", "amount": "50"}], "ack_fee": [{"denom": "samoleans", "amount": "25"}], "timeout_fee": [{"denom": "samoleans", "amount": "10"}]}, "source_port_id": "transfer", "source_channel_id": "channel-0", "signer": "cosmos18phmkrpnn6gmpzscf6hnf5zpv06sygxc6f2v92" }] + .' transfer.json > incentivized_transfer.json -` - -```bash -simd tx sign incentivized_transfer.json \ ---from $VALIDATOR_CHAIN1 \ ---chain-id chain1 \ ---keyring-backend test \ ---home ../../gm/chain1 \ ---node tcp://localhost:27000 > signed.json -``` - -```bash -simd tx broadcast signed.json \ ---home ../../gm/chain1 \ ---node tcp://localhost:27000 -``` - -We wait for the relayer to relay the packet, and then we query the balance of account `VALIDATOR_CHAIN2` on chain `chain2` and see that it has indeed received an equivalent amount of vouchers for the `1000samoleans` sent by `VALIDATOR_CHAIN1`: - -```yaml -simd q bank balances $VALIDATOR_CHAIN2 --node http://localhost:27010 -``` - -```bash -balances: -- amount: "1000" - denom: ibc/27A6394C3F9FF9C9DCF5DFFADF9BB5FE9A37C7E92B006199894CF1824DF9AC7C -- amount: "100000000" - denom: samoleans -- amount: "99000000" - denom: stake -pagination: - total: "3" -``` - -We check as well the balance for account `VALIDATOR_CHAIN1` on chain `chain1`: - -```bash -simd q bank balances $WALLET_1 --node http://localhost:16657 -``` - -```yaml -./simd q bank balances $VALIDATOR_CHAIN1 --node http://localhost:27000 -balances: -- amount: "99998925" - denom: samoleans -- amount: "99000000" - denom: stake -pagination: - total: "2" -``` - -An amount of `1075samoleans` has been deducted, which is what we expected: `1000samoleans` have been transferred to `VALIDATOR_CHAIN2` and `75stake` have been paid for the receive and acknowledgment fees. The timeout fee has been refunded to `VALIDATOR_CHAIN1` and the relayer address `RLY_CHAIN1` should have gained `75samoleans` for submitting the `MsgRecvPacket` and the `MsgAcknowledgement` messages. diff --git a/docs/tutorials/02-channel-upgrades/_category_.json b/docs/tutorials/02-channel-upgrades/_category_.json deleted file mode 100644 index a43d5906845..00000000000 --- a/docs/tutorials/02-channel-upgrades/_category_.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "label": "Channel Upgrades", - "position": 2, - "link": null -} diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index 8e5c8e407cf..9b5f5b3583d 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -334,7 +334,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan t.Run("close interchain accounts host channel end", func(t *testing.T) { // Pass in zero for counterpartyUpgradeSequence given that channel has not undergone any upgrades. - msgCloseConfirm := channeltypes.NewMsgChannelCloseConfirm(icatypes.HostPortID, msgChanOpenTryRes.ChannelId, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress(), 0) + msgCloseConfirm := channeltypes.NewMsgChannelCloseConfirm(icatypes.HostPortID, msgChanOpenTryRes.ChannelId, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress()) txResp := s.BroadcastMessages(ctx, chainA, rlyWallet, msgCloseConfirm) s.AssertTxSuccess(txResp) diff --git a/e2e/tests/interchain_accounts/upgrades_test.go b/e2e/tests/interchain_accounts/upgrades_test.go deleted file mode 100644 index 4dc8a99a7f0..00000000000 --- a/e2e/tests/interchain_accounts/upgrades_test.go +++ /dev/null @@ -1,218 +0,0 @@ -//go:build !test_e2e - -package interchainaccounts - -import ( - "context" - "testing" - "time" - - "github.com/cosmos/gogoproto/proto" - "github.com/strangelove-ventures/interchaintest/v8" - "github.com/strangelove-ventures/interchaintest/v8/ibc" - test "github.com/strangelove-ventures/interchaintest/v8/testutil" - testifysuite "github.com/stretchr/testify/suite" - - sdkmath "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - - "github.com/cosmos/ibc-go/e2e/testsuite" - "github.com/cosmos/ibc-go/e2e/testsuite/query" - "github.com/cosmos/ibc-go/e2e/testvalues" - controllertypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/controller/types" - icatypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/types" - channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/v10/testing" -) - -// compatibility:from_version: v8.4.0 -func TestInterchainAccountsChannelUpgradesTestSuite(t *testing.T) { - testifysuite.Run(t, new(InterchainAccountsChannelUpgradesTestSuite)) -} - -type InterchainAccountsChannelUpgradesTestSuite struct { - testsuite.E2ETestSuite -} - -// TestMsgSendTx_SuccessfulTransfer_AfterUpgradingOrdertoUnordered tests upgrading an ICA channel to -// unordered and sends a message to the host afterwards. -func (s *InterchainAccountsChannelUpgradesTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterUpgradingOrdertoUnordered() { - t := s.T() - ctx := context.TODO() - - testName := t.Name() - relayer := s.CreateDefaultPaths(testName) - - chainA, chainB := s.GetChains() - - // setup 2 accounts: controller account on chain A, a second chain B account. - // host account will be created when the ICA is registered - controllerAccount := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) - controllerAddress := controllerAccount.FormattedAddress() - chainBAccount := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) - - var ( - portID string - hostAccount string - - initialChannelID = "channel-1" - ) - - t.Run("register interchain account", func(t *testing.T) { - var err error - // explicitly set the version string because we don't want to use incentivized channels. - version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) - msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) - - txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) - s.AssertTxSuccess(txResp) - portID, err = icatypes.NewControllerPortID(controllerAddress) - s.Require().NoError(err) - }) - - t.Run("start relayer", func(t *testing.T) { - s.StartRelayer(relayer, testName) - }) - - t.Run("verify interchain account", func(t *testing.T) { - var err error - hostAccount, err = query.InterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) - s.Require().NoError(err) - s.Require().NotEmpty(hostAccount) - - _, err = query.Channel(ctx, chainA, portID, initialChannelID) - s.Require().NoError(err) - }) - - t.Run("fund interchain account wallet", func(t *testing.T) { - // fund the host account so it has some $$ to send - err := chainB.SendFunds(ctx, interchaintest.FaucetAccountKeyName, ibc.WalletAmount{ - Address: hostAccount, - Amount: sdkmath.NewInt(testvalues.StartingTokenAmount), - Denom: chainB.Config().Denom, - }) - s.Require().NoError(err) - }) - - t.Run("broadcast MsgSendTx", func(t *testing.T) { - // assemble bank transfer message from host account to user account on host chain - msgSend := &banktypes.MsgSend{ - FromAddress: hostAccount, - ToAddress: chainBAccount.FormattedAddress(), - Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)), - } - - cdc := testsuite.Codec() - - bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{msgSend}, icatypes.EncodingProtobuf) - s.Require().NoError(err) - - packetData := icatypes.InterchainAccountPacketData{ - Type: icatypes.EXECUTE_TX, - Data: bz, - Memo: "e2e", - } - - msgSendTx := controllertypes.NewMsgSendTx(controllerAddress, ibctesting.FirstConnectionID, uint64(5*time.Minute), packetData) - - resp := s.BroadcastMessages( - ctx, - chainA, - controllerAccount, - msgSendTx, - ) - - s.AssertTxSuccess(resp) - s.AssertPacketRelayed(ctx, chainA, portID, initialChannelID, 1) - }) - - t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) - s.Require().NoError(err) - - expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount - s.Require().Equal(expected, balance.Int64()) - }) - - channel, err := query.Channel(ctx, chainA, portID, initialChannelID) - s.Require().NoError(err) - - // upgrade the channel ordering to UNORDERED - upgradeFields := channeltypes.NewUpgradeFields(channeltypes.UNORDERED, channel.ConnectionHops, channel.Version) - - t.Run("execute gov proposal to initiate channel upgrade", func(t *testing.T) { - govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chainA) - s.Require().NoError(err) - s.Require().NotNil(govModuleAddress) - - msg := channeltypes.NewMsgChannelUpgradeInit(portID, initialChannelID, upgradeFields, govModuleAddress.String()) - s.ExecuteAndPassGovV1Proposal(ctx, msg, chainA, controllerAccount) - }) - - t.Run("verify channel A upgraded and is now unordered", func(t *testing.T) { - var channel channeltypes.Channel - waitErr := test.WaitForCondition(time.Minute*2, time.Second*5, func() (bool, error) { - channel, err = query.Channel(ctx, chainA, portID, initialChannelID) - if err != nil { - return false, err - } - return channel.Ordering == channeltypes.UNORDERED, nil - }) - s.Require().NoErrorf(waitErr, "channel was not upgraded: expected %s got %s", channeltypes.UNORDERED, channel.Ordering) - }) - - t.Run("verify channel B upgraded and is now unordered", func(t *testing.T) { - var channel channeltypes.Channel - waitErr := test.WaitForCondition(time.Minute*2, time.Second*5, func() (bool, error) { - channel, err = query.Channel(ctx, chainB, icatypes.HostPortID, initialChannelID) - if err != nil { - return false, err - } - return channel.Ordering == channeltypes.UNORDERED, nil - }) - s.Require().NoErrorf(waitErr, "channel was not upgraded: expected %s got %s", channeltypes.UNORDERED, channel.Ordering) - }) - - t.Run("broadcast MsgSendTx", func(t *testing.T) { - // assemble bank transfer message from host account to user account on host chain - msgSend := &banktypes.MsgSend{ - FromAddress: hostAccount, - ToAddress: chainBAccount.FormattedAddress(), - Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)), - } - - cdc := testsuite.Codec() - - bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{msgSend}, icatypes.EncodingProtobuf) - s.Require().NoError(err) - - packetData := icatypes.InterchainAccountPacketData{ - Type: icatypes.EXECUTE_TX, - Data: bz, - Memo: "e2e", - } - - msgSendTx := controllertypes.NewMsgSendTx(controllerAddress, ibctesting.FirstConnectionID, uint64(5*time.Minute), packetData) - - resp := s.BroadcastMessages( - ctx, - chainA, - controllerAccount, - msgSendTx, - ) - - s.AssertTxSuccess(resp) - s.AssertPacketRelayed(ctx, chainA, portID, initialChannelID, 2) - }) - - t.Run("verify tokens transferred", func(t *testing.T) { - balance, err := query.Balance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) - s.Require().NoError(err) - - expected := 2*testvalues.IBCTransferAmount + testvalues.StartingTokenAmount - s.Require().Equal(expected, balance.Int64()) - }) -} diff --git a/e2e/testsuite/query/queries.go b/e2e/testsuite/query/queries.go index faa8599bae1..2a95be36b30 100644 --- a/e2e/testsuite/query/queries.go +++ b/e2e/testsuite/query/queries.go @@ -148,18 +148,6 @@ func PacketAcknowledgements(ctx context.Context, chain ibc.Chain, portID, channe return res.Acknowledgements, nil } -// UpgradeError queries the upgrade error on the given chain for the provided channel. -func UpgradeError(ctx context.Context, chain ibc.Chain, portID, channelID string) (channeltypes.ErrorReceipt, error) { - res, err := GRPCQuery[channeltypes.QueryUpgradeErrorResponse](ctx, chain, &channeltypes.QueryUpgradeErrorRequest{ - PortId: portID, - ChannelId: channelID, - }) - if err != nil { - return channeltypes.ErrorReceipt{}, err - } - return res.ErrorReceipt, nil -} - // InterchainAccount queries the interchain account for the given owner and connectionID. func InterchainAccount(ctx context.Context, chain ibc.Chain, address, connectionID string) (string, error) { res, err := GRPCQuery[controllertypes.QueryInterchainAccountResponse](ctx, chain, &controllertypes.QueryInterchainAccountRequest{ diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index 4d58fc883ec..7578635e5d2 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -23,7 +23,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/ibc-go/e2e/internal/directories" "github.com/cosmos/ibc-go/e2e/relayer" @@ -680,28 +679,6 @@ func (s *E2ETestSuite) GetTimeoutHeight(ctx context.Context, chain ibc.Chain) cl return clienttypes.NewHeight(clienttypes.ParseChainID(chain.Config().ChainID), uint64(height)+1000) } -// SetUpgradeTimeoutParam creates and submits a governance proposal to execute the message to update 04-channel params with a timeout of 1s -func (s *E2ETestSuite) SetUpgradeTimeoutParam(ctx context.Context, chain ibc.Chain, wallet ibc.Wallet) { - const timeoutDelta = 1000000000 // use 1 second as relative timeout to force upgrade timeout on the counterparty - govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chain) - s.Require().NoError(err) - s.Require().NotNil(govModuleAddress) - - upgradeTimeout := channeltypes.NewTimeout(channeltypes.DefaultTimeout.Height, timeoutDelta) - msg := channeltypes.NewMsgUpdateChannelParams(govModuleAddress.String(), channeltypes.NewParams(upgradeTimeout)) - s.ExecuteAndPassGovV1Proposal(ctx, msg, chain, wallet) -} - -// InitiateChannelUpgrade creates and submits a governance proposal to execute the message to initiate a channel upgrade -func (s *E2ETestSuite) InitiateChannelUpgrade(ctx context.Context, chain ibc.Chain, wallet ibc.Wallet, portID, channelID string, upgradeFields channeltypes.UpgradeFields) { - govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chain) - s.Require().NoError(err) - s.Require().NotNil(govModuleAddress) - - msg := channeltypes.NewMsgChannelUpgradeInit(portID, channelID, upgradeFields, govModuleAddress.String()) - s.ExecuteAndPassGovV1Proposal(ctx, msg, chain, wallet) -} - // GetIBCToken returns the denomination of the full token denom sent to the receiving channel func GetIBCToken(fullTokenDenom string, portID, channelID string) transfertypes.Denom { return transfertypes.ExtractDenomFromPath(fmt.Sprintf("%s/%s/%s", portID, channelID, fullTokenDenom)) diff --git a/e2e/testsuite/tx.go b/e2e/testsuite/tx.go index f03e97bb89e..2e9daf423d0 100644 --- a/e2e/testsuite/tx.go +++ b/e2e/testsuite/tx.go @@ -31,7 +31,6 @@ import ( "github.com/cosmos/ibc-go/e2e/testsuite/sanitize" "github.com/cosmos/ibc-go/e2e/testvalues" clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" ) // BroadcastMessages broadcasts the provided messages to the given chain and signs them on behalf of the provided user. @@ -292,18 +291,6 @@ func (s *E2ETestSuite) Transfer(ctx context.Context, chain ibc.Chain, user ibc.W return s.BroadcastMessages(ctx, chain, user, msg) } -// PruneAcknowledgements broadcasts a MsgPruneAcknowledgements message. -func (s *E2ETestSuite) PruneAcknowledgements( - ctx context.Context, - chain ibc.Chain, - user ibc.Wallet, - portID, channelID string, - limit uint64, -) sdk.TxResponse { - msg := channeltypes.NewMsgPruneAcknowledgements(portID, channelID, limit, user.FormattedAddress()) - return s.BroadcastMessages(ctx, chain, user, msg) -} - // QueryTxsByEvents runs the QueryTxsByEvents command on the given chain. // https://github.com/cosmos/cosmos-sdk/blob/65ab2530cc654fd9e252b124ed24cbaa18023b2b/x/auth/client/cli/query.go#L33 func (*E2ETestSuite) QueryTxsByEvents( diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware.go index b2b91157cf7..ff5c22579d6 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware.go @@ -20,7 +20,6 @@ import ( var ( _ porttypes.Middleware = (*IBCMiddleware)(nil) _ porttypes.PacketDataUnmarshaler = (*IBCMiddleware)(nil) - _ porttypes.UpgradableModule = (*IBCMiddleware)(nil) ) // IBCMiddleware implements the ICS26 callbacks for the controller middleware given the @@ -237,83 +236,6 @@ func (im IBCMiddleware) OnTimeoutPacket( return nil } -// OnChanUpgradeInit implements the IBCModule interface -func (im IBCMiddleware) OnChanUpgradeInit(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, proposedVersion string) (string, error) { - if !im.keeper.GetParams(ctx).ControllerEnabled { - return "", types.ErrControllerSubModuleDisabled - } - - proposedVersion, err := im.keeper.OnChanUpgradeInit(ctx, portID, channelID, proposedOrder, proposedConnectionHops, proposedVersion) - if err != nil { - return "", err - } - - connectionID, err := im.keeper.GetConnectionID(ctx, portID, channelID) - if err != nil { - return "", err - } - - if im.app != nil && im.keeper.IsMiddlewareEnabled(ctx, portID, connectionID) { - // Only cast to UpgradableModule if the application is set. - cbs, ok := im.app.(porttypes.UpgradableModule) - if !ok { - return "", errorsmod.Wrap(porttypes.ErrInvalidRoute, "upgrade route not found to module in application callstack") - } - return cbs.OnChanUpgradeInit(ctx, portID, channelID, proposedOrder, proposedConnectionHops, proposedVersion) - } - - return proposedVersion, nil -} - -// OnChanUpgradeTry implements the IBCModule interface -func (IBCMiddleware) OnChanUpgradeTry(_ sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, counterpartyVersion string) (string, error) { - return "", errorsmod.Wrap(icatypes.ErrInvalidChannelFlow, "channel upgrade handshake must be initiated by controller chain") -} - -// OnChanUpgradeAck implements the IBCModule interface -func (im IBCMiddleware) OnChanUpgradeAck(ctx sdk.Context, portID, channelID, counterpartyVersion string) error { - if !im.keeper.GetParams(ctx).ControllerEnabled { - return types.ErrControllerSubModuleDisabled - } - - if err := im.keeper.OnChanUpgradeAck(ctx, portID, channelID, counterpartyVersion); err != nil { - return err - } - - connectionID, err := im.keeper.GetConnectionID(ctx, portID, channelID) - if err != nil { - return err - } - - if im.app != nil && im.keeper.IsMiddlewareEnabled(ctx, portID, connectionID) { - // Only cast to UpgradableModule if the application is set. - cbs, ok := im.app.(porttypes.UpgradableModule) - if !ok { - return errorsmod.Wrap(porttypes.ErrInvalidRoute, "upgrade route not found to module in application callstack") - } - return cbs.OnChanUpgradeAck(ctx, portID, channelID, counterpartyVersion) - } - - return nil -} - -// OnChanUpgradeOpen implements the IBCModule interface -func (im IBCMiddleware) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, proposedVersion string) { - connectionID, err := im.keeper.GetConnectionID(ctx, portID, channelID) - if err != nil { - panic(err) - } - - if im.app != nil && im.keeper.IsMiddlewareEnabled(ctx, portID, connectionID) { - // Only cast to UpgradableModule if the application is set. - cbs, ok := im.app.(porttypes.UpgradableModule) - if !ok { - panic(errorsmod.Wrap(porttypes.ErrInvalidRoute, "upgrade route not found to module in application callstack")) - } - cbs.OnChanUpgradeOpen(ctx, portID, channelID, proposedOrder, proposedConnectionHops, proposedVersion) - } -} - // SendPacket implements the ICS4 Wrapper interface func (IBCMiddleware) SendPacket( ctx sdk.Context, diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index 8d8d4dbe3da..0f590ce9a11 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -7,8 +7,6 @@ import ( testifysuite "github.com/stretchr/testify/suite" - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/controller" @@ -21,7 +19,6 @@ import ( host "github.com/cosmos/ibc-go/v10/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v10/modules/core/errors" ibctesting "github.com/cosmos/ibc-go/v10/testing" - ibcmock "github.com/cosmos/ibc-go/v10/testing/mock" ) const invalidVersion = "invalid|version" @@ -741,316 +738,6 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { } } -func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeInit() { - var ( - path *ibctesting.Path - isNilApp bool - version string - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", func() {}, nil, - }, - { - "success: nil underlying app", - func() { - isNilApp = true - }, - nil, - }, - { - "controller submodule disabled", func() { - suite.chainA.GetSimApp().ICAControllerKeeper.SetParams(suite.chainA.GetContext(), types.NewParams(false)) - }, types.ErrControllerSubModuleDisabled, - }, - { - "ICA OnChanUpgradeInit fails - invalid version", func() { - version = invalidVersion - }, ibcerrors.ErrInvalidType, - }, - { - "ICA auth module callback fails", func() { - suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanUpgradeInit = func(ctx sdk.Context, portID, channelID string, order channeltypes.Order, connectionHops []string, version string) (string, error) { - return "", ibcmock.MockApplicationCallbackError - } - }, ibcmock.MockApplicationCallbackError, - }, - { - "middleware disabled", func() { - suite.chainA.GetSimApp().ICAControllerKeeper.DeleteMiddlewareEnabled(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ConnectionID) - suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanUpgradeInit = func(ctx sdk.Context, portID, channelID string, order channeltypes.Order, connectionHops []string, version string) (string, error) { - return "", ibcmock.MockApplicationCallbackError - } - }, nil, - }, - } - - for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - isNilApp = false - - path = NewICAPath(suite.chainA, suite.chainB, ordering) - path.SetupConnections() - - err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress) - suite.Require().NoError(err) - - version = icatypes.NewDefaultMetadataString(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) - - tc.malleate() // malleate mutates test data - - app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) - suite.Require().True(ok) - cbs, ok := app.(porttypes.UpgradableModule) - suite.Require().True(ok) - - if isNilApp { - cbs = controller.NewIBCMiddleware(suite.chainA.GetSimApp().ICAControllerKeeper) - } - - version, err = cbs.OnChanUpgradeInit( - suite.chainA.GetContext(), - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - ordering, - []string{path.EndpointA.ConnectionID}, - version, - ) - - if tc.expError == nil { - suite.Require().NoError(err) - } else { - suite.Require().ErrorIs(err, tc.expError) - suite.Require().Empty(version) - } - }) - } - } -} - -// OnChanUpgradeTry callback returns error on controller chains -func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeTry() { - for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { - suite.SetupTest() // reset - path := NewICAPath(suite.chainA, suite.chainB, ordering) - path.SetupConnections() - - err := SetupICAPath(path, TestOwnerAddress) - suite.Require().NoError(err) - - // call application callback directly - app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) - suite.Require().True(ok) - cbs, ok := app.(porttypes.UpgradableModule) - suite.Require().True(ok) - - version, err := cbs.OnChanUpgradeTry( - suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, - path.EndpointA.ChannelConfig.Order, []string{path.EndpointA.ConnectionID}, path.EndpointB.ChannelConfig.Version, - ) - suite.Require().Error(err) - suite.Require().ErrorIs(err, icatypes.ErrInvalidChannelFlow) - suite.Require().Equal("", version) - } -} - -func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeAck() { - var ( - path *ibctesting.Path - isNilApp bool - counterpartyVersion string - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", func() {}, nil, - }, - { - "success: nil underlying app", - func() { - isNilApp = true - }, - nil, - }, - { - "controller submodule disabled", func() { - suite.chainA.GetSimApp().ICAControllerKeeper.SetParams(suite.chainA.GetContext(), types.NewParams(false)) - }, types.ErrControllerSubModuleDisabled, - }, - { - "ICA OnChanUpgradeAck fails - invalid version", func() { - counterpartyVersion = invalidVersion - }, ibcerrors.ErrInvalidType, - }, - { - "ICA auth module callback fails", func() { - suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanUpgradeAck = func(ctx sdk.Context, portID, channelID string, counterpartyVersion string) error { - return ibcmock.MockApplicationCallbackError - } - }, ibcmock.MockApplicationCallbackError, - }, - { - "middleware disabled", func() { - suite.chainA.GetSimApp().ICAControllerKeeper.DeleteMiddlewareEnabled(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ConnectionID) - suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanUpgradeAck = func(ctx sdk.Context, portID, channelID string, counterpartyVersion string) error { - return ibcmock.MockApplicationCallbackError - } - }, nil, - }, - } - - for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - isNilApp = false - - path = NewICAPath(suite.chainA, suite.chainB, ordering) - path.SetupConnections() - - err := SetupICAPath(path, TestOwnerAddress) - suite.Require().NoError(err) - - counterpartyVersion = path.EndpointB.GetChannel().Version - - tc.malleate() // malleate mutates test data - - app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) - suite.Require().True(ok) - cbs, ok := app.(porttypes.UpgradableModule) - suite.Require().True(ok) - - if isNilApp { - cbs = controller.NewIBCMiddleware(suite.chainA.GetSimApp().ICAControllerKeeper) - } - - err = cbs.OnChanUpgradeAck( - suite.chainA.GetContext(), - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - counterpartyVersion, - ) - - if tc.expError == nil { - suite.Require().NoError(err) - } else { - suite.Require().ErrorIs(err, tc.expError) - } - }) - } - } -} - -func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeOpen() { - var ( - path *ibctesting.Path - isNilApp bool - counterpartyVersion string - ) - - testCases := []struct { - name string - malleate func() - expPanic error - }{ - { - "success", func() {}, nil, - }, - { - "success: nil app", func() { - isNilApp = true - }, nil, - }, - { - "middleware disabled", func() { - suite.chainA.GetSimApp().ICAControllerKeeper.DeleteMiddlewareEnabled(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ConnectionID) - suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanUpgradeAck = func(ctx sdk.Context, portID, channelID string, counterpartyVersion string) error { - return ibcmock.MockApplicationCallbackError - } - }, - nil, - }, - { - "failure: upgrade route not found", - func() {}, - errorsmod.Wrap(porttypes.ErrInvalidRoute, "upgrade route not found to module in application callstack"), - }, - { - "failure: connection not found", - func() { - path.EndpointA.ChannelID = "invalid-channel" - }, - errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", TestPortID, "invalid-channel"), - }, - } - - for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - isNilApp = false - - path = NewICAPath(suite.chainA, suite.chainB, ordering) - path.SetupConnections() - - err := SetupICAPath(path, TestOwnerAddress) - suite.Require().NoError(err) - - counterpartyVersion = path.EndpointB.GetChannel().Version - - tc.malleate() // malleate mutates test data - - app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) - suite.Require().True(ok) - cbs, ok := app.(porttypes.UpgradableModule) - suite.Require().True(ok) - - upgradeOpenCb := func(cbs porttypes.UpgradableModule) { - cbs.OnChanUpgradeOpen( - suite.chainA.GetContext(), - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - ordering, - []string{path.EndpointA.ConnectionID}, - counterpartyVersion, - ) - } - - if tc.expPanic != nil { - mockModule := ibcmock.NewAppModule() - mockApp := ibcmock.NewIBCApp(path.EndpointA.ChannelConfig.PortID) - cbs = controller.NewIBCMiddlewareWithAuth(ibcmock.NewBlockUpgradeMiddleware(&mockModule, mockApp), suite.chainA.GetSimApp().ICAControllerKeeper) - - suite.Require().PanicsWithError(tc.expPanic.Error(), func() { upgradeOpenCb(cbs) }) - } else { - if isNilApp { - cbs = controller.NewIBCMiddleware(suite.chainA.GetSimApp().ICAControllerKeeper) - } - - upgradeOpenCb(cbs) - } - }) - } - } -} - func (suite *InterchainAccountsTestSuite) TestSingleHostMultipleControllers() { var ( pathAToB *ibctesting.Path diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index 83344acb5e8..b3976c7e2a1 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -8,10 +8,6 @@ import ( ibctesting "github.com/cosmos/ibc-go/v10/testing" ) -const ( - differentConnectionID = "connection-100" -) - func (suite *KeeperTestSuite) TestOnChanOpenInit() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { var ( @@ -239,23 +235,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { }, icatypes.ErrActiveChannelAlreadySet, }, - { - "channel is already active (FLUSHING state)", - func() { - suite.chainA.GetSimApp().ICAControllerKeeper.SetActiveChannelID(suite.chainA.GetContext(), ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - - counterparty := channeltypes.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - channel := channeltypes.Channel{ - State: channeltypes.FLUSHING, - Ordering: ordering, - Counterparty: counterparty, - ConnectionHops: []string{path.EndpointA.ConnectionID}, - Version: TestVersion, - } - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel) - }, - icatypes.ErrActiveChannelAlreadySet, - }, } for _, tc := range testCases { @@ -513,354 +492,3 @@ func (suite *KeeperTestSuite) TestOnChanCloseConfirm() { } } } - -func (suite *KeeperTestSuite) TestOnChanUpgradeInit() { - const ( - invalidVersion = "invalid-version" - ) - - var ( - path *ibctesting.Path - metadata icatypes.Metadata - version string - order channeltypes.Order - ) - - // updateMetadata is a helper function which modifies the metadata stored in the channel version - // and marshals it into a string to pass to OnChanUpgradeInit as the version string. - updateMetadata := func(modificationFn func(*icatypes.Metadata)) { - metadata, err := icatypes.MetadataFromVersion(path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version) - suite.Require().NoError(err) - modificationFn(&metadata) - version = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) - } - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - name: "success: change order", - malleate: func() { - order = channeltypes.UNORDERED - }, - expError: nil, - }, - { - name: "failure: connectionID not found", - malleate: func() { - // channelID is provided via the endpoint channelID - path.EndpointA.ChannelID = "invalid channel" - }, - expError: channeltypes.ErrChannelNotFound, - }, - { - name: "failure: invalid proposed connectionHops", - malleate: func() { - // connection hops is provided via endpoint connectionID - path.EndpointA.ConnectionID = differentConnectionID - }, - expError: channeltypes.ErrInvalidUpgrade, - }, - { - name: "failure: empty version", - malleate: func() { - version = "" - }, - expError: icatypes.ErrInvalidVersion, - }, - { - name: "failure: cannot decode version string", - malleate: func() { - version = invalidVersion - }, - expError: ibcerrors.ErrInvalidType, - }, - { - name: "failure: cannot decode self version string", - malleate: func() { - path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { channel.Version = invalidVersion }) - }, - expError: ibcerrors.ErrInvalidType, - }, - { - name: "failure: failed controller metadata validation, invalid encoding", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.Encoding = "invalid-encoding" - }) - }, - expError: icatypes.ErrInvalidCodec, - }, - { - name: "failure: failed controller metadata validation, invalid tx type", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.TxType = "invalid-tx-type" - }) - }, - expError: icatypes.ErrUnknownDataType, - }, - { - name: "failure: failed controller metadata validation, invalid interchain account version", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.Version = "invalid-interchain-account-version" - }) - }, - expError: icatypes.ErrInvalidVersion, - }, - { - name: "failure: interchain account address changed", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.Address = TestOwnerAddress // use valid address - }) - }, - expError: icatypes.ErrInvalidAccountAddress, - }, - { - name: "failure: controller connection ID has changed", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.ControllerConnectionId = differentConnectionID - }) - }, - expError: connectiontypes.ErrInvalidConnection, // the explicit checks on the controller connection identifier are unreachable - }, - { - name: "failure: host connection ID has changed", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.HostConnectionId = differentConnectionID - }) - }, - expError: connectiontypes.ErrInvalidConnection, // the explicit checks on the host connection identifier are unreachable - }, - } - - for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - path = NewICAPath(suite.chainA, suite.chainB, ordering) - path.SetupConnections() - - err := SetupICAPath(path, TestOwnerAddress) - suite.Require().NoError(err) - - currentMetadata, err := suite.chainA.GetSimApp().ICAControllerKeeper.GetAppMetadata(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().NoError(err) - - order = channeltypes.ORDERED - metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) - // use the same address as the previous metadata. - metadata.Address = currentMetadata.Address - - // this is the actual change to the version. - metadata.Encoding = icatypes.EncodingProto3JSON - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) - - version = path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version - - tc.malleate() // malleate mutates test data - - upgradeVersion, err := path.EndpointA.Chain.GetSimApp().ICAControllerKeeper.OnChanUpgradeInit( - path.EndpointA.Chain.GetContext(), - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - order, - []string{path.EndpointA.ConnectionID}, - version, - ) - - if tc.expError == nil { - suite.Require().NoError(err) - suite.Require().Equal(upgradeVersion, version) - } else { - suite.Require().ErrorIs(err, tc.expError) - } - }) - } - } -} - -func (suite *KeeperTestSuite) TestOnChanUpgradeAck() { - const ( - invalidVersion = "invalid-version" - ) - - var ( - path *ibctesting.Path - metadata icatypes.Metadata - counterpartyVersion string - ) - - // updateMetadata is a helper function which modifies the metadata stored in the channel version - // and marshals it into a string to pass to OnChanUpgradeAck as the counterpartyVersion string. - updateMetadata := func(modificationFn func(*icatypes.Metadata)) { - metadata, err := icatypes.MetadataFromVersion(path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version) - suite.Require().NoError(err) - modificationFn(&metadata) - counterpartyVersion = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) - } - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - name: "failure: empty counterparty version", - malleate: func() { - counterpartyVersion = "" - }, - expError: channeltypes.ErrInvalidChannelVersion, - }, - { - name: "failure: invalid counterparty version", - malleate: func() { - counterpartyVersion = invalidVersion - }, - expError: ibcerrors.ErrInvalidType, - }, - { - name: "failure: cannot decode self version string", - malleate: func() { - path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { channel.Version = invalidVersion }) - }, - expError: ibcerrors.ErrInvalidType, - }, - { - name: "failure: channel not found", - malleate: func() { - // channelID is provided via the endpoint channelID - path.EndpointA.ChannelID = "invalid channel" - }, - expError: ibcerrors.ErrNotFound, // GetChannel error is unreachable - }, - { - name: "failure: failed controller metadata validation, invalid encoding", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.Encoding = "invalid-encoding" - }) - }, - expError: icatypes.ErrInvalidCodec, - }, - { - name: "failure: failed controller metadata validation, invalid tx type", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.TxType = "invalid-tx-type" - }) - }, - expError: icatypes.ErrUnknownDataType, - }, - { - name: "failure: failed controller metadata validation, invalid interchain account version", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.Version = "invalid-interchain-account-version" - }) - }, - expError: icatypes.ErrInvalidVersion, - }, - { - name: "failure: interchain account address changed", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.Address = TestOwnerAddress // use valid address - }) - }, - expError: icatypes.ErrInvalidAccountAddress, - }, - { - name: "failure: controller connection ID has changed", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.ControllerConnectionId = differentConnectionID - }) - }, - expError: connectiontypes.ErrInvalidConnection, // the explicit checks on the controller identifier are unreachable - }, - { - name: "failure: host connection ID has changed", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.HostConnectionId = differentConnectionID - }) - }, - expError: connectiontypes.ErrInvalidConnection, // the explicit checks on the host identifier are unreachable - }, - } - - for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - path = NewICAPath(suite.chainA, suite.chainB, ordering) - path.SetupConnections() - - err := SetupICAPath(path, TestOwnerAddress) - suite.Require().NoError(err) - - currentMetadata, err := suite.chainA.GetSimApp().ICAControllerKeeper.GetAppMetadata(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().NoError(err) - - metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) - // use the same address as the previous metadata. - metadata.Address = currentMetadata.Address - - // this is the actual change to the version. - metadata.Encoding = icatypes.EncodingProto3JSON - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) - - err = path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - counterpartyVersion = path.EndpointB.GetChannel().Version - - tc.malleate() // malleate mutates test data - - err = suite.chainA.GetSimApp().ICAControllerKeeper.OnChanUpgradeAck( - suite.chainA.GetContext(), - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - counterpartyVersion, - ) - - if tc.expError == nil { - suite.Require().NoError(err) - suite.Require().Equal(path.EndpointA.GetChannel().Version, counterpartyVersion) - } else { - suite.Require().ErrorIs(err, tc.expError) - } - }) - } - } -} diff --git a/modules/apps/27-interchain-accounts/host/ibc_module.go b/modules/apps/27-interchain-accounts/host/ibc_module.go index 3e5b863e3c7..476752afc68 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module.go @@ -19,7 +19,6 @@ import ( var ( _ porttypes.IBCModule = (*IBCModule)(nil) _ porttypes.PacketDataUnmarshaler = (*IBCModule)(nil) - _ porttypes.UpgradableModule = (*IBCModule)(nil) ) // IBCModule implements the ICS26 interface for interchain accounts host chains @@ -157,29 +156,6 @@ func (IBCModule) OnTimeoutPacket( return errorsmod.Wrap(icatypes.ErrInvalidChannelFlow, "cannot cause a packet timeout on a host channel end, a host chain does not send a packet over the channel") } -// OnChanUpgradeInit implements the IBCModule interface -func (IBCModule) OnChanUpgradeInit(_ sdk.Context, _, _ string, _ channeltypes.Order, _ []string, _ string) (string, error) { - return "", errorsmod.Wrap(icatypes.ErrInvalidChannelFlow, "channel upgrade handshake must be initiated by controller chain") -} - -// OnChanUpgradeTry implements the IBCModule interface -func (im IBCModule) OnChanUpgradeTry(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, counterpartyVersion string) (string, error) { - if !im.keeper.GetParams(ctx).HostEnabled { - return "", types.ErrHostSubModuleDisabled - } - - return im.keeper.OnChanUpgradeTry(ctx, portID, channelID, proposedOrder, proposedConnectionHops, counterpartyVersion) -} - -// OnChanUpgradeAck implements the IBCModule interface -func (IBCModule) OnChanUpgradeAck(_ sdk.Context, _, _, _ string) error { - return errorsmod.Wrap(icatypes.ErrInvalidChannelFlow, "channel upgrade handshake must be initiated by controller chain") -} - -// OnChanUpgradeOpen implements the IBCModule interface -func (IBCModule) OnChanUpgradeOpen(_ sdk.Context, _, _ string, _ channeltypes.Order, _ []string, _ string) { -} - // UnmarshalPacketData attempts to unmarshal the provided packet data bytes // into an InterchainAccountPacketData. This function implements the optional // PacketDataUnmarshaler interface required for ADR 008 support. diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index cf3ba7e35d5..5d59bc7273c 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -19,7 +19,6 @@ import ( icatypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/types" clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" - porttypes "github.com/cosmos/ibc-go/v10/modules/core/05-port/types" host "github.com/cosmos/ibc-go/v10/modules/core/24-host" "github.com/cosmos/ibc-go/v10/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v10/testing" @@ -629,127 +628,6 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { } } -// OnChanUpgradeInit callback returns error on host chains -func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeInit() { - for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { - suite.SetupTest() // reset - - path := NewICAPath(suite.chainA, suite.chainB, ordering) - path.SetupConnections() - - err := SetupICAPath(path, TestOwnerAddress) - suite.Require().NoError(err) - - // call application callback directly - app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID) - suite.Require().True(ok) - cbs, ok := app.(porttypes.UpgradableModule) - suite.Require().True(ok) - - version, err := cbs.OnChanUpgradeInit( - suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, - path.EndpointB.ChannelConfig.Order, []string{path.EndpointB.ConnectionID}, path.EndpointB.ChannelConfig.Version, - ) - - suite.Require().Error(err) - suite.Require().ErrorIs(err, icatypes.ErrInvalidChannelFlow) - suite.Require().Equal("", version) - } -} - -func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeTry() { - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", func() {}, nil, - }, - { - "host submodule disabled", func() { - suite.chainB.GetSimApp().ICAHostKeeper.SetParams(suite.chainB.GetContext(), types.NewParams(false, []string{})) - }, types.ErrHostSubModuleDisabled, - }, - } - - for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - path := NewICAPath(suite.chainA, suite.chainB, ordering) - path.SetupConnections() - - err := SetupICAPath(path, TestOwnerAddress) - suite.Require().NoError(err) - - interchainAccountAddr, found := suite.chainB.GetSimApp().ICAHostKeeper.GetInterchainAccountAddress(suite.chainB.GetContext(), path.EndpointB.ConnectionID, path.EndpointA.ChannelConfig.PortID) - suite.Require().True(found) - - metadata := icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) - metadata.Address = interchainAccountAddr - metadata.Encoding = icatypes.EncodingProto3JSON // this is the actual change to the version - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) - - err = path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - tc.malleate() // malleate mutates test data - - app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID) - suite.Require().True(ok) - cbs, ok := app.(porttypes.UpgradableModule) - suite.Require().True(ok) - - version, err := cbs.OnChanUpgradeTry( - suite.chainB.GetContext(), - path.EndpointB.ChannelConfig.PortID, - path.EndpointB.ChannelID, - ordering, - []string{path.EndpointB.ConnectionID}, - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version, - ) - - if tc.expError == nil { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - suite.Require().Empty(version) - } - }) - } - } -} - -// OnChanUpgradeAck callback returns error on host chains -func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeAck() { - for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { - suite.SetupTest() // reset - - path := NewICAPath(suite.chainA, suite.chainB, ordering) - path.SetupConnections() - - err := SetupICAPath(path, TestOwnerAddress) - suite.Require().NoError(err) - - // call application callback directly - app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID) - suite.Require().True(ok) - cbs, ok := app.(porttypes.UpgradableModule) - suite.Require().True(ok) - - err = cbs.OnChanUpgradeAck( - suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, path.EndpointA.ChannelConfig.Version, - ) - - suite.Require().Error(err) - suite.Require().ErrorIs(err, icatypes.ErrInvalidChannelFlow) - } -} - func (suite *InterchainAccountsTestSuite) fundICAWallet(ctx sdk.Context, portID string, amount sdk.Coins) { interchainAccountAddr, found := suite.chainB.GetSimApp().ICAHostKeeper.GetInterchainAccountAddress(ctx, ibctesting.FirstConnectionID, portID) suite.Require().True(found) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake.go b/modules/apps/27-interchain-accounts/host/keeper/handshake.go index f63aaa5fc9f..9b0fef255be 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake.go @@ -2,16 +2,13 @@ package keeper import ( "fmt" - "strings" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" icatypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/types" - connectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" - porttypes "github.com/cosmos/ibc-go/v10/modules/core/05-port/types" ) // OnChanOpenTry performs basic validation of the ICA channel @@ -122,73 +119,3 @@ func (Keeper) OnChanCloseConfirm( ) error { return nil } - -// OnChanUpgradeTry performs the upgrade try step of the channel upgrade handshake. -// The upgrade try callback must verify the proposed changes to the order, connectionHops, and version. -// Within the version we have the tx type, encoding, interchain account address, host/controller connectionID's -// and the ICS27 protocol version. -// -// The following may be changed: -// - tx type (must be supported) -// - encoding (must be supported) -// - order -// -// The following may not be changed: -// - connectionHops (and subsequently host/controller connectionIDs) -// - interchain account address -// - ICS27 protocol version -func (k Keeper) OnChanUpgradeTry(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, - proposedConnectionHops []string, counterpartyVersion string, -) (string, error) { - if portID != icatypes.HostPortID { - return "", errorsmod.Wrapf(porttypes.ErrInvalidPort, "expected %s, got %s", icatypes.HostPortID, portID) - } - - // verify connection hops has not changed - connectionID, err := k.getConnectionID(ctx, portID, channelID) - if err != nil { - return "", err - } - - if len(proposedConnectionHops) != 1 || proposedConnectionHops[0] != connectionID { - return "", errorsmod.Wrapf(channeltypes.ErrInvalidUpgrade, "expected connection hops %s, got %s", []string{connectionID}, proposedConnectionHops) - } - - if strings.TrimSpace(counterpartyVersion) == "" { - return "", errorsmod.Wrap(channeltypes.ErrInvalidChannelVersion, "counterparty version cannot be empty") - } - - proposedCounterpartyMetadata, err := icatypes.MetadataFromVersion(counterpartyVersion) - if err != nil { - return "", err - } - - currentMetadata, err := k.getAppMetadata(ctx, portID, channelID) - if err != nil { - return "", err - } - - // ValidateHostMetadata will ensure the ICS27 protocol version has not changed and that the - // tx type and encoding are supported. It also validates the connection params against the counterparty metadata. - if err := icatypes.ValidateHostMetadata(ctx, k.channelKeeper, proposedConnectionHops, proposedCounterpartyMetadata); err != nil { - return "", errorsmod.Wrap(err, "invalid metadata") - } - - // the interchain account address on the host chain - // must remain the same after the upgrade. - if currentMetadata.Address != proposedCounterpartyMetadata.Address { - return "", errorsmod.Wrap(icatypes.ErrInvalidAccountAddress, "interchain account address cannot be changed") - } - - // these explicit checks on the controller connection identifier should be unreachable - if currentMetadata.ControllerConnectionId != proposedCounterpartyMetadata.ControllerConnectionId { - return "", errorsmod.Wrap(connectiontypes.ErrInvalidConnection, "proposed controller connection ID must not change") - } - - // these explicit checks on the host connection identifier should be unreachable - if currentMetadata.HostConnectionId != proposedConnectionHops[0] { - return "", errorsmod.Wrap(connectiontypes.ErrInvalidConnectionIdentifier, "proposed connection hop must not change") - } - - return counterpartyVersion, nil -} diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index bff72667984..6b9a5720430 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -9,15 +9,9 @@ import ( icatypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/types" connectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" - porttypes "github.com/cosmos/ibc-go/v10/modules/core/05-port/types" - ibcerrors "github.com/cosmos/ibc-go/v10/modules/core/errors" ibctesting "github.com/cosmos/ibc-go/v10/testing" ) -const ( - differentConnectionID = "connection-100" -) - // open and close channel is a helper function for TestOnChanOpenTry for reopening accounts func (suite *KeeperTestSuite) openAndCloseChannel(path *ibctesting.Path) { err := path.EndpointB.ChanOpenTry() @@ -254,23 +248,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { }, icatypes.ErrActiveChannelAlreadySet, }, - { - "channel is already active (FLUSHING state)", - func() { - suite.chainB.GetSimApp().ICAHostKeeper.SetActiveChannelID(suite.chainB.GetContext(), ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID, path.EndpointB.ChannelID) - - counterparty := channeltypes.NewCounterparty(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - channel := channeltypes.Channel{ - State: channeltypes.FLUSHING, - Ordering: ordering, - Counterparty: counterparty, - ConnectionHops: []string{path.EndpointB.ConnectionID}, - Version: TestVersion, - } - suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.SetChannel(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, channel) - }, - icatypes.ErrActiveChannelAlreadySet, - }, } for _, tc := range testCases { @@ -431,180 +408,3 @@ func (suite *KeeperTestSuite) TestOnChanCloseConfirm() { } } } - -func (suite *KeeperTestSuite) TestOnChanUpgradeTry() { - var ( - path *ibctesting.Path - metadata icatypes.Metadata - order channeltypes.Order - counterpartyVersion string - ) - - // updateMetadata is a helper function which modifies the metadata stored in the channel version - // and marshals it into a string to pass to OnChanUpgradeTry as the counterpartyVersion string. - updateMetadata := func(modificationFn func(*icatypes.Metadata)) { - metadata, err := icatypes.MetadataFromVersion(path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version) - suite.Require().NoError(err) - modificationFn(&metadata) - counterpartyVersion = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) - } - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - name: "success: change order", - malleate: func() { - order = channeltypes.UNORDERED - }, - expError: nil, - }, - { - name: "failure: invalid port ID", - malleate: func() { - path.EndpointB.ChannelConfig.PortID = "invalid-port-id" - }, - expError: porttypes.ErrInvalidPort, - }, - { - name: "failure: invalid proposed connectionHops", - malleate: func() { - // connection hops is provided via endpoint connectionID - path.EndpointB.ConnectionID = differentConnectionID - }, - expError: channeltypes.ErrInvalidUpgrade, - }, - { - name: "failure: empty counterparty version", - malleate: func() { - counterpartyVersion = "" - }, - expError: channeltypes.ErrInvalidChannelVersion, - }, - { - name: "failure: cannot parse metadata from counterparty version string", - malleate: func() { - counterpartyVersion = "invalid-version" - }, - expError: ibcerrors.ErrInvalidType, - }, - { - name: "failure: cannot decode version string from channel", - malleate: func() { - path.EndpointB.UpdateChannel(func(channel *channeltypes.Channel) { channel.Version = "invalid-metadata-string" }) - }, - expError: ibcerrors.ErrInvalidType, - }, - { - name: "failure: metadata encoding not supported", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.Encoding = "invalid-encoding-format" - }) - }, - expError: icatypes.ErrInvalidCodec, - }, - { - name: "failure: metadata tx type not supported", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.TxType = "invalid-tx-type" - }) - }, - expError: icatypes.ErrUnknownDataType, - }, - { - name: "failure: interchain account address has changed", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.Address = TestOwnerAddress // use valid address - }) - }, - expError: icatypes.ErrInvalidAccountAddress, - }, - { - name: "failure: controller connection ID has changed", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.ControllerConnectionId = differentConnectionID - }) - }, - expError: connectiontypes.ErrInvalidConnection, // the explicit checks on the controller connection identifier are unreachable - }, - { - name: "failure: host connection ID has changed", - malleate: func() { - updateMetadata(func(metadata *icatypes.Metadata) { - metadata.HostConnectionId = differentConnectionID - }) - }, - expError: connectiontypes.ErrInvalidConnection, // the explicit checks on the host connection identifier are unreachable - }, - { - name: "failure: channel not found", - malleate: func() { - path.EndpointB.ChannelID = "invalid-channel-id" - }, - expError: channeltypes.ErrChannelNotFound, - }, - } - - for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - path = NewICAPath(suite.chainA, suite.chainB, icatypes.EncodingProtobuf, ordering) - path.SetupConnections() - - err := SetupICAPath(path, TestOwnerAddress) - suite.Require().NoError(err) - - currentMetadata, err := suite.chainB.GetSimApp().ICAHostKeeper.GetAppMetadata(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().NoError(err) - - order = channeltypes.ORDERED - metadata = icatypes.NewDefaultMetadata(path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) - // use the same address as the previous metadata. - metadata.Address = currentMetadata.Address - // this is the actual change to the version. - metadata.Encoding = icatypes.EncodingProto3JSON - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = string(icatypes.ModuleCdc.MustMarshalJSON(&metadata)) - - err = path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - counterpartyVersion = path.EndpointA.GetChannel().Version - - tc.malleate() // malleate mutates test data - - version, err := suite.chainB.GetSimApp().ICAHostKeeper.OnChanUpgradeTry( - suite.chainB.GetContext(), - path.EndpointB.ChannelConfig.PortID, - path.EndpointB.ChannelID, - order, - []string{path.EndpointB.ConnectionID}, - counterpartyVersion, - ) - - if tc.expError == nil { - suite.Require().NoError(err) - suite.Require().Equal(path.EndpointB.GetChannel().Version, version) - } else { - suite.Require().ErrorIs(err, tc.expError) - } - }) - } - } -} diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index ac64328b222..ef1ffe5eb35 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -96,15 +96,6 @@ func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s-%s", exported.ModuleName, icatypes.ModuleName)) } -// getConnectionID returns the connection id for the given port and channelIDs. -func (k Keeper) getConnectionID(ctx sdk.Context, portID, channelID string) (string, error) { - channel, found := k.channelKeeper.GetChannel(ctx, portID, channelID) - if !found { - return "", errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - return channel.ConnectionHops[0], nil -} - // setPort sets the provided portID in state. func (k Keeper) setPort(ctx sdk.Context, portID string) { store := k.storeService.OpenKVStore(ctx) diff --git a/modules/apps/callbacks/ibc_middleware.go b/modules/apps/callbacks/ibc_middleware.go index d11872d88c9..04bea3dc277 100644 --- a/modules/apps/callbacks/ibc_middleware.go +++ b/modules/apps/callbacks/ibc_middleware.go @@ -4,8 +4,6 @@ import ( "errors" "fmt" - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/modules/apps/callbacks/internal" @@ -19,7 +17,6 @@ import ( var ( _ porttypes.Middleware = (*IBCMiddleware)(nil) _ porttypes.PacketDataUnmarshaler = (*IBCMiddleware)(nil) - _ porttypes.UpgradableModule = (*IBCMiddleware)(nil) ) // IBCMiddleware implements the ICS26 callbacks for the ibc-callbacks middleware given @@ -356,46 +353,6 @@ func (im IBCMiddleware) OnChanCloseConfirm(ctx sdk.Context, portID, channelID st return im.app.OnChanCloseConfirm(ctx, portID, channelID) } -// OnChanUpgradeInit implements the IBCModule interface -func (im IBCMiddleware) OnChanUpgradeInit(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, proposedVersion string) (string, error) { - cbs, ok := im.app.(porttypes.UpgradableModule) - if !ok { - return "", errorsmod.Wrap(porttypes.ErrInvalidRoute, "upgrade route not found to module in application callstack") - } - - return cbs.OnChanUpgradeInit(ctx, portID, channelID, proposedOrder, proposedConnectionHops, proposedVersion) -} - -// OnChanUpgradeTry implements the IBCModule interface -func (im IBCMiddleware) OnChanUpgradeTry(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, counterpartyVersion string) (string, error) { - cbs, ok := im.app.(porttypes.UpgradableModule) - if !ok { - return "", errorsmod.Wrap(porttypes.ErrInvalidRoute, "upgrade route not found to module in application callstack") - } - - return cbs.OnChanUpgradeTry(ctx, portID, channelID, proposedOrder, proposedConnectionHops, counterpartyVersion) -} - -// OnChanUpgradeAck implements the IBCModule interface -func (im IBCMiddleware) OnChanUpgradeAck(ctx sdk.Context, portID, channelID, counterpartyVersion string) error { - cbs, ok := im.app.(porttypes.UpgradableModule) - if !ok { - return errorsmod.Wrap(porttypes.ErrInvalidRoute, "upgrade route not found to module in application callstack") - } - - return cbs.OnChanUpgradeAck(ctx, portID, channelID, counterpartyVersion) -} - -// OnChanUpgradeOpen implements the IBCModule interface -func (im IBCMiddleware) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, proposedVersion string) { - cbs, ok := im.app.(porttypes.UpgradableModule) - if !ok { - panic(errorsmod.Wrap(porttypes.ErrInvalidRoute, "upgrade route not found to module in application callstack")) - } - - cbs.OnChanUpgradeOpen(ctx, portID, channelID, proposedOrder, proposedConnectionHops, proposedVersion) -} - // GetAppVersion implements the ICS4Wrapper interface. Callbacks has no version, // so the call is deferred to the underlying application. func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) { diff --git a/modules/apps/transfer/ibc_module.go b/modules/apps/transfer/ibc_module.go index 3f6fa03309a..1f4a27e1955 100644 --- a/modules/apps/transfer/ibc_module.go +++ b/modules/apps/transfer/ibc_module.go @@ -23,7 +23,6 @@ import ( var ( _ porttypes.IBCModule = (*IBCModule)(nil) _ porttypes.PacketDataUnmarshaler = (*IBCModule)(nil) - _ porttypes.UpgradableModule = (*IBCModule)(nil) ) // IBCModule implements the ICS26 interface for transfer given the transfer keeper. @@ -263,46 +262,6 @@ func (im IBCModule) OnTimeoutPacket( return nil } -// OnChanUpgradeInit implements the IBCModule interface -func (im IBCModule) OnChanUpgradeInit(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, proposedVersion string) (string, error) { - if err := ValidateTransferChannelParams(ctx, im.keeper, proposedOrder, portID, channelID); err != nil { - return "", err - } - - if !slices.Contains(types.SupportedVersions, proposedVersion) { - return "", errorsmod.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: expected one of %s, got %s", types.SupportedVersions, proposedVersion) - } - - return proposedVersion, nil -} - -// OnChanUpgradeTry implements the IBCModule interface -func (im IBCModule) OnChanUpgradeTry(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, counterpartyVersion string) (string, error) { - if err := ValidateTransferChannelParams(ctx, im.keeper, proposedOrder, portID, channelID); err != nil { - return "", err - } - - if !slices.Contains(types.SupportedVersions, counterpartyVersion) { - im.keeper.Logger(ctx).Debug("invalid counterparty version, proposing latest app version", "counterpartyVersion", counterpartyVersion, "version", types.V1) - return types.V1, nil - } - - return counterpartyVersion, nil -} - -// OnChanUpgradeAck implements the IBCModule interface -func (IBCModule) OnChanUpgradeAck(ctx sdk.Context, portID, channelID, counterpartyVersion string) error { - if !slices.Contains(types.SupportedVersions, counterpartyVersion) { - return errorsmod.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: expected one of %s, got %s", types.SupportedVersions, counterpartyVersion) - } - - return nil -} - -// OnChanUpgradeOpen implements the IBCModule interface -func (IBCModule) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, proposedVersion string) { -} - // UnmarshalPacketData attempts to unmarshal the provided packet data bytes // into a FungibleTokenPacketData. This function implements the optional // PacketDataUnmarshaler interface required for ADR 008 support. diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index 2d8f6788f2d..f9370dab5d5 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -12,7 +12,6 @@ import ( "github.com/cosmos/ibc-go/v10/modules/apps/transfer" "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" - connectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v10/modules/core/05-port/types" ibcerrors "github.com/cosmos/ibc-go/v10/modules/core/errors" @@ -38,7 +37,6 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() { }, { // connection hops is not used in the transfer application callback, - // it is already validated in the core OnChanUpgradeInit. "success: invalid connection hops", func() { path.EndpointA.ConnectionID = ibctesting.InvalidID }, nil, types.V1, @@ -441,215 +439,6 @@ func (suite *TransferTestSuite) TestOnTimeoutPacket() { } } -func (suite *TransferTestSuite) TestOnChanUpgradeInit() { - var path *ibctesting.Path - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, // successful happy path for a standalone transfer app is swapping out the underlying connection - nil, - }, - { - "invalid upgrade connection", - func() { - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.ConnectionHops = []string{"connection-100"} - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.ConnectionHops = []string{"connection-100"} - }, - connectiontypes.ErrConnectionNotFound, - }, - { - "invalid upgrade ordering", - func() { - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Ordering = channeltypes.ORDERED - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Ordering = channeltypes.ORDERED - }, - channeltypes.ErrInvalidChannelOrdering, - }, - { - "invalid upgrade version", - func() { - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibctesting.InvalidID - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibctesting.InvalidID - }, - types.ErrInvalidVersion, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewTransferPath(suite.chainA, suite.chainB) - path.Setup() - - // configure the channel upgrade to modify the underlying connection - upgradePath := ibctesting.NewPath(suite.chainA, suite.chainB) - upgradePath.SetupConnections() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.ConnectionHops = []string{upgradePath.EndpointA.ConnectionID} - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.ConnectionHops = []string{upgradePath.EndpointB.ConnectionID} - - tc.malleate() - - err := path.EndpointA.ChanUpgradeInit() - - if tc.expError == nil { - suite.Require().NoError(err) - upgrade := path.EndpointA.GetChannelUpgrade() - suite.Require().Equal(upgradePath.EndpointA.ConnectionID, upgrade.Fields.ConnectionHops[0]) - } else { - suite.Require().Error(err) - suite.Require().Contains(err.Error(), tc.expError.Error()) - } - }) - } -} - -func (suite *TransferTestSuite) TestOnChanUpgradeTry() { - var ( - counterpartyUpgrade channeltypes.Upgrade - path *ibctesting.Path - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, // successful happy path for a standalone transfer app is swapping out the underlying connection - nil, - }, - { - "success: invalid upgrade version from counterparty, we use our proposed version", - func() { - counterpartyUpgrade.Fields.Version = ibctesting.InvalidID - }, - nil, - }, - { - "invalid upgrade ordering", - func() { - counterpartyUpgrade.Fields.Ordering = channeltypes.ORDERED - }, - channeltypes.ErrInvalidChannelOrdering, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewTransferPath(suite.chainA, suite.chainB) - path.Setup() - - // configure the channel upgrade to modify the underlying connection - upgradePath := ibctesting.NewPath(suite.chainA, suite.chainB) - upgradePath.SetupConnections() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.ConnectionHops = []string{upgradePath.EndpointA.ConnectionID} - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.ConnectionHops = []string{upgradePath.EndpointB.ConnectionID} - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - counterpartyUpgrade = path.EndpointA.GetChannelUpgrade() - - tc.malleate() - - app, ok := suite.chainB.App.GetIBCKeeper().PortKeeper.Route(types.PortID) - suite.Require().True(ok) - - cbs, ok := app.(porttypes.UpgradableModule) - suite.Require().True(ok) - - version, err := cbs.OnChanUpgradeTry( - suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, - counterpartyUpgrade.Fields.Ordering, counterpartyUpgrade.Fields.ConnectionHops, counterpartyUpgrade.Fields.Version, - ) - - if tc.expError == nil { - suite.Require().NoError(err) - suite.Require().Equal(types.V1, version) - } else { - suite.Require().Error(err) - suite.Require().Contains(err.Error(), tc.expError.Error()) - } - }) - } -} - -func (suite *TransferTestSuite) TestOnChanUpgradeAck() { - var path *ibctesting.Path - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, // successful happy path for a standalone transfer app is swapping out the underlying connection - nil, - }, - { - "invalid upgrade version", - func() { - path.EndpointB.ChannelConfig.Version = ibctesting.InvalidID - }, - types.ErrInvalidVersion, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewTransferPath(suite.chainA, suite.chainB) - path.Setup() - - // configure the channel upgrade to modify the underlying connection - upgradePath := ibctesting.NewPath(suite.chainA, suite.chainB) - upgradePath.SetupConnections() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.ConnectionHops = []string{upgradePath.EndpointA.ConnectionID} - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.ConnectionHops = []string{upgradePath.EndpointB.ConnectionID} - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - tc.malleate() - - app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(types.PortID) - suite.Require().True(ok) - - cbs, ok := app.(porttypes.UpgradableModule) - suite.Require().True(ok) - - err = cbs.OnChanUpgradeAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.Version) - - if tc.expError == nil { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - suite.Require().Contains(err.Error(), tc.expError.Error()) - } - }) - } -} - func (suite *TransferTestSuite) TestPacketDataUnmarshalerInterface() { var ( sender = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() diff --git a/modules/core/03-connection/keeper/verify.go b/modules/core/03-connection/keeper/verify.go index 4f09507eadf..572d465f702 100644 --- a/modules/core/03-connection/keeper/verify.go +++ b/modules/core/03-connection/keeper/verify.go @@ -211,72 +211,6 @@ func (k *Keeper) VerifyNextSequenceRecv( return nil } -// VerifyChannelUpgradeError verifies a proof of the provided upgrade error receipt. -func (k *Keeper) VerifyChannelUpgradeError( - ctx sdk.Context, - connection types.ConnectionEnd, - height exported.Height, - proof []byte, - portID, - channelID string, - errorReceipt channeltypes.ErrorReceipt, -) error { - clientID := connection.ClientId - merklePath := commitmenttypes.NewMerklePath(host.ChannelUpgradeErrorKey(portID, channelID)) - merklePath, err := commitmenttypes.ApplyPrefix(connection.Counterparty.Prefix, merklePath) - if err != nil { - return err - } - - bz, err := k.cdc.Marshal(&errorReceipt) - if err != nil { - return err - } - - if err := k.clientKeeper.VerifyMembership( - ctx, clientID, height, - 0, 0, // skip delay period checks for non-packet processing verification - proof, merklePath, bz, - ); err != nil { - return errorsmod.Wrapf(err, "failed upgrade error receipt verification for client (%s)", clientID) - } - - return nil -} - -// VerifyChannelUpgrade verifies the proof that a particular proposed upgrade has been stored in the upgrade path. -func (k *Keeper) VerifyChannelUpgrade( - ctx sdk.Context, - connection types.ConnectionEnd, - proofHeight exported.Height, - upgradeProof []byte, - portID, - channelID string, - upgrade channeltypes.Upgrade, -) error { - clientID := connection.ClientId - merklePath := commitmenttypes.NewMerklePath(host.ChannelUpgradeKey(portID, channelID)) - merklePath, err := commitmenttypes.ApplyPrefix(connection.Counterparty.Prefix, merklePath) - if err != nil { - return err - } - - bz, err := k.cdc.Marshal(&upgrade) - if err != nil { - return err - } - - if err := k.clientKeeper.VerifyMembership( - ctx, clientID, proofHeight, - 0, 0, // skip delay period checks for non-packet processing verification - upgradeProof, merklePath, bz, - ); err != nil { - return errorsmod.Wrapf(err, "failed upgrade verification for client (%s) on channel (%s)", clientID, channelID) - } - - return nil -} - // getBlockDelay calculates the block delay period from the time delay of the connection // and the maximum expected time per block. func (k *Keeper) getBlockDelay(ctx sdk.Context, connection types.ConnectionEnd) uint64 { diff --git a/modules/core/03-connection/keeper/verify_test.go b/modules/core/03-connection/keeper/verify_test.go index 40985a0bbcf..2676bc088fe 100644 --- a/modules/core/03-connection/keeper/verify_test.go +++ b/modules/core/03-connection/keeper/verify_test.go @@ -525,154 +525,6 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() { } } -func (suite *KeeperTestSuite) TestVerifyUpgradeErrorReceipt() { - var ( - path *ibctesting.Path - upgradeError *channeltypes.UpgradeError - ) - - cases := []struct { - name string - malleate func() - expErr error - }{ - { - name: "success", - malleate: func() {}, - expErr: nil, - }, - { - name: "fails when client state is frozen", - malleate: func() { - clientState, ok := path.EndpointB.GetClientState().(*ibctm.ClientState) - suite.Require().True(ok) - clientState.FrozenHeight = clienttypes.NewHeight(0, 1) - path.EndpointB.SetClientState(clientState) - }, - expErr: errorsmod.Wrap(clienttypes.ErrClientNotActive, "client (07-tendermint-0) status is Frozen"), - }, - { - name: "verification fails when the key does not exist", - malleate: func() { - suite.chainA.DeleteKey(host.ChannelUpgradeErrorKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - suite.coordinator.CommitBlock(suite.chainA) - }, - expErr: errorsmod.Wrap(ibcerrors.ErrInvalidHeight, "failed upgrade error receipt verification for client (07-tendermint-0): client state height < proof height ({1 17} < {1 18}), please ensure the client has been updated"), - }, - { - name: "verification fails when message differs", - malleate: func() { - originalSequence := upgradeError.GetErrorReceipt().Sequence - upgradeError = channeltypes.NewUpgradeError(originalSequence, fmt.Errorf("new error")) - }, - expErr: errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "failed upgrade error receipt verification for client (07-tendermint-0): failed to verify membership proof at index 0: provided value doesn't match proof"), - }, - } - - for _, tc := range cases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - upgradeError = channeltypes.NewUpgradeError(1, channeltypes.ErrInvalidChannel) - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgradeError) - - suite.chainA.Coordinator.CommitBlock(suite.chainA) - suite.Require().NoError(path.EndpointB.UpdateClient()) - - tc.malleate() - - upgradeErrorReceiptKey := host.ChannelUpgradeErrorKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - proof, proofHeight := suite.chainA.QueryProof(upgradeErrorReceiptKey) - - err := suite.chainB.GetSimApp().IBCKeeper.ConnectionKeeper.VerifyChannelUpgradeError(suite.chainB.GetContext(), path.EndpointB.GetConnection(), proofHeight, proof, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgradeError.GetErrorReceipt()) - - if tc.expErr == nil { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expErr) - } - }) - } -} - -func (suite *KeeperTestSuite) TestVerifyUpgrade() { - var ( - path *ibctesting.Path - upgrade channeltypes.Upgrade - ) - - cases := []struct { - name string - malleate func() - expErr error - }{ - { - name: "success", - malleate: func() {}, - expErr: nil, - }, - { - name: "fails when client state is frozen", - malleate: func() { - clientState, ok := path.EndpointB.GetClientState().(*ibctm.ClientState) - suite.Require().True(ok) - clientState.FrozenHeight = clienttypes.NewHeight(0, 1) - path.EndpointB.SetClientState(clientState) - }, - expErr: errorsmod.Wrap(clienttypes.ErrClientNotActive, "client (07-tendermint-0) status is Frozen"), - }, - { - name: "fails when the upgrade field is different", - malleate: func() { - upgrade.Fields.Ordering = channeltypes.ORDERED - }, - expErr: errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "failed upgrade verification for client (07-tendermint-0) on channel (channel-7): failed to verify membership proof at index 0: provided value doesn't match proof"), - }, - } - - for _, tc := range cases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - upgrade = channeltypes.NewUpgrade( - channeltypes.NewUpgradeFields(channeltypes.UNORDERED, []string{path.EndpointA.ConnectionID}, "v1.0.0"), - channeltypes.NewTimeout(clienttypes.ZeroHeight(), 100000), - 0, - ) - - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.SetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgrade) - - suite.chainA.Coordinator.CommitBlock(suite.chainA) - suite.Require().NoError(path.EndpointB.UpdateClient()) - - tc.malleate() - - channelUpgradeKey := host.ChannelUpgradeKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - proof, proofHeight := suite.chainA.QueryProof(channelUpgradeKey) - - err := suite.chainB.GetSimApp().IBCKeeper.ConnectionKeeper.VerifyChannelUpgrade(suite.chainB.GetContext(), path.EndpointB.GetConnection(), proofHeight, proof, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgrade) - - if tc.expErr == nil { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expErr) - } - }) - } -} - func malleateHeight(height exported.Height, diff uint64) exported.Height { return clienttypes.NewHeight(height.GetRevisionNumber(), height.GetRevisionHeight()+diff) } diff --git a/modules/core/04-channel/client/cli/cli.go b/modules/core/04-channel/client/cli/cli.go index 696c8049c1a..225cfda2e04 100644 --- a/modules/core/04-channel/client/cli/cli.go +++ b/modules/core/04-channel/client/cli/cli.go @@ -31,28 +31,7 @@ func GetQueryCmd() *cobra.Command { GetCmdQueryUnreceivedAcks(), GetCmdQueryNextSequenceReceive(), GetCmdQueryNextSequenceSend(), - GetCmdQueryUpgradeError(), - GetCmdQueryUpgrade(), - GetCmdChannelParams(), ) return queryCmd } - -// NewTxCmd returns a CLI command handler for all x/ibc channel transaction commands. -func NewTxCmd() *cobra.Command { - txCmd := &cobra.Command{ - Use: types.SubModuleName, - Short: "IBC channel transaction subcommands", - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - txCmd.AddCommand( - newUpgradeChannelsTxCmd(), - newPruneAcknowledgementsTxCmd(), - ) - - return txCmd -} diff --git a/modules/core/04-channel/client/cli/query.go b/modules/core/04-channel/client/cli/query.go index 0b4017c9fd4..76205a626a4 100644 --- a/modules/core/04-channel/client/cli/query.go +++ b/modules/core/04-channel/client/cli/query.go @@ -491,96 +491,3 @@ func GetCmdQueryNextSequenceSend() *cobra.Command { return cmd } - -// GetCmdQueryUpgradeError defines the command to query for the error receipt associated with an upgrade -func GetCmdQueryUpgradeError() *cobra.Command { - cmd := &cobra.Command{ - Use: "upgrade-error [port-id] [channel-id]", - Short: "Query the upgrade error", - Long: "Query the upgrade error for a given channel", - Example: fmt.Sprintf( - "%s query %s %s upgrade-error [port-id] [channel-id]", version.AppName, ibcexported.ModuleName, types.SubModuleName, - ), - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - portID := args[0] - channelID := args[1] - prove, _ := cmd.Flags().GetBool(flags.FlagProve) - - errRes, err := utils.QueryUpgradeError(clientCtx, portID, channelID, prove) - if err != nil { - return err - } - - clientCtx = clientCtx.WithHeight(int64(errRes.ProofHeight.RevisionHeight)) - return clientCtx.PrintProto(errRes) - }, - } - cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results") - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -// GetCmdQueryUpgrade defines the command to query for the upgrade associated with a port and channel id -func GetCmdQueryUpgrade() *cobra.Command { - cmd := &cobra.Command{ - Use: "upgrade [port-id] [channel-id]", - Short: "Query the upgrade", - Long: "Query the upgrade for a given channel", - Example: fmt.Sprintf( - "%s query %s %s upgrade [port-id] [channel-id]", version.AppName, ibcexported.ModuleName, types.SubModuleName, - ), - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - portID := args[0] - channelID := args[1] - prove, _ := cmd.Flags().GetBool(flags.FlagProve) - - upgrade, err := utils.QueryUpgrade(clientCtx, portID, channelID, prove) - if err != nil { - return err - } - - clientCtx = clientCtx.WithHeight(int64(upgrade.ProofHeight.RevisionHeight)) - return clientCtx.PrintProto(upgrade) - }, - } - cmd.Flags().Bool(flags.FlagProve, false, "show proofs for the query results") - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -// GetCmdChannelParams returns the command handler for ibc channel parameter querying. -func GetCmdChannelParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "Query the current ibc channel parameters", - Long: "Query the current ibc channel parameters", - Args: cobra.NoArgs, - Example: fmt.Sprintf("%s query %s %s params", version.AppName, ibcexported.ModuleName, types.SubModuleName), - RunE: func(cmd *cobra.Command, _ []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - - res, _ := queryClient.ChannelParams(cmd.Context(), &types.QueryChannelParamsRequest{}) - return clientCtx.PrintProto(res.Params) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/modules/core/04-channel/client/cli/tx.go b/modules/core/04-channel/client/cli/tx.go deleted file mode 100644 index d1dd9a02c4c..00000000000 --- a/modules/core/04-channel/client/cli/tx.go +++ /dev/null @@ -1,175 +0,0 @@ -package cli - -import ( - "fmt" - "regexp" - "slices" - "strconv" - "strings" - - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/version" - govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli" - - "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" - ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported" -) - -const ( - flagJSON = "json" - flagPortPattern = "port-pattern" - flagExpedited = "expedited" - flagChannelIDs = "channel-ids" -) - -// newPruneAcknowledgementsTxCmd returns the command to create a new MsgPruneAcknowledgements transaction -func newPruneAcknowledgementsTxCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "prune-acknowledgements [port] [channel] [limit]", - Short: "Prune expired packet acknowledgements stored in IBC state", - Long: `Prune expired packet acknowledgements and receipts stored in IBC state. Packet ackwnowledgements and - receipts are considered expired if a channel has been upgraded.`, - Example: fmt.Sprintf("%s tx %s %s prune-acknowledgements transfer channel-0 1000", version.AppName, ibcexported.ModuleName, types.SubModuleName), - Args: cobra.ExactArgs(3), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - portID, channelID := args[0], args[1] - limit, err := strconv.ParseUint(args[2], 10, 64) - if err != nil { - return err - } - - signer := clientCtx.GetFromAddress().String() - msg := types.NewMsgPruneAcknowledgements(portID, channelID, limit, signer) - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - return cmd -} - -func newUpgradeChannelsTxCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "upgrade-channels [version]", - Short: "Upgrade IBC channels", - Long: `Submit a governance proposal to upgrade all open channels whose port matches a specified pattern -(the default is transfer), optionally, an exact list of comma separated channel IDs may be specified.`, - Args: cobra.ExactArgs(1), - Example: fmt.Sprintf(`%s tx %s %s upgrade-channels "{\"fee_version\":\"ics29-1\",\"app_version\":\"ics20-1\"}" --deposit 10stake`, version.AppName, ibcexported.ModuleName, types.SubModuleName), - RunE: func(cmd *cobra.Command, args []string) error { - versionStr := args[0] - - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - portPattern, err := cmd.Flags().GetString(flagPortPattern) - if err != nil { - return err - } - - commaSeparatedChannelIDs, err := cmd.Flags().GetString(flagChannelIDs) - if err != nil { - return err - } - - displayJSON, err := cmd.Flags().GetBool(flagJSON) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - resp, err := queryClient.Channels(cmd.Context(), &types.QueryChannelsRequest{}) - if err != nil { - return err - } - - channelIDs := getChannelIDs(commaSeparatedChannelIDs) - - var msgs []sdk.Msg - pattern := regexp.MustCompile(portPattern) - - for _, ch := range resp.Channels { - - if !channelShouldBeUpgraded(*ch, pattern, channelIDs) { - continue - } - - // construct a MsgChannelUpgradeInit which will upgrade the specified channel to a specific version. - msgUpgradeInit := types.NewMsgChannelUpgradeInit(ch.PortId, ch.ChannelId, types.NewUpgradeFields(ch.Ordering, ch.ConnectionHops, versionStr), clientCtx.GetFromAddress().String()) - msgs = append(msgs, msgUpgradeInit) - } - - if len(msgs) == 0 { - return fmt.Errorf("no channels would be upgraded with pattern %s", portPattern) - } - - msgSubmitProposal, err := govcli.ReadGovPropFlags(clientCtx, cmd.Flags()) - if err != nil { - return err - } - - if err := msgSubmitProposal.SetMsgs(msgs); err != nil { - return err - } - - dryRun, _ := cmd.Flags().GetBool(flags.FlagDryRun) - if displayJSON || dryRun { - out, err := clientCtx.Codec.MarshalJSON(msgSubmitProposal) - if err != nil { - return err - } - return clientCtx.PrintBytes(out) - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgSubmitProposal) - }, - } - - flags.AddTxFlagsToCmd(cmd) - govcli.AddGovPropFlagsToCmd(cmd) - cmd.Flags().Bool(flagJSON, false, "specify true to output valid proposal.json contents, instead of submitting a governance proposal.") - cmd.Flags().String(flagPortPattern, "transfer", "The pattern to use to match port ids.") - cmd.Flags().String(flagChannelIDs, "", "a comma separated list of channel IDs to upgrade.") - cmd.Flags().Bool(flagExpedited, false, "set the expedited value for the governance proposal.") - - return cmd -} - -// getChannelIDs returns a slice of channel IDs based on a comma separated string of channel IDs. -func getChannelIDs(commaSeparatedList string) []string { - if strings.TrimSpace(commaSeparatedList) == "" { - return nil - } - return strings.Split(commaSeparatedList, ",") -} - -// channelShouldBeUpgraded returns a boolean indicating whether or not the given channel should be upgraded based -// on either the provided regex pattern or list of desired channel IDs. -func channelShouldBeUpgraded(channel types.IdentifiedChannel, pattern *regexp.Regexp, channelIDs []string) bool { - // skip any channel that is not open - if channel.State != types.OPEN { - return false - } - - // if specified, the channel ID must exactly match. - if len(channelIDs) > 0 { - return pattern.MatchString(channel.PortId) && slices.Contains(channelIDs, channel.ChannelId) - } - - // otherwise we only need the port pattern to match. - return pattern.MatchString(channel.PortId) -} diff --git a/modules/core/04-channel/client/utils/utils.go b/modules/core/04-channel/client/utils/utils.go index 7123948e187..12403d92e7d 100644 --- a/modules/core/04-channel/client/utils/utils.go +++ b/modules/core/04-channel/client/utils/utils.go @@ -196,92 +196,6 @@ func queryNextSequenceSendABCI(clientCtx client.Context, portID, channelID strin return types.NewQueryNextSequenceSendResponse(sequence, proofBz, proofHeight), nil } -// QueryUpgradeError returns the upgrade error. -// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise, -// it uses the gRPC query client. -func QueryUpgradeError( - clientCtx client.Context, portID, channelID string, prove bool, -) (*types.QueryUpgradeErrorResponse, error) { - if prove { - return queryUpgradeErrorABCI(clientCtx, portID, channelID) - } - - queryClient := types.NewQueryClient(clientCtx) - req := &types.QueryUpgradeErrorRequest{ - PortId: portID, - ChannelId: channelID, - } - - return queryClient.UpgradeError(context.Background(), req) -} - -// QueryUpgrade returns the upgrade. -// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise, -// it uses the gRPC query client. -func QueryUpgrade( - clientCtx client.Context, portID, channelID string, prove bool, -) (*types.QueryUpgradeResponse, error) { - if prove { - return queryUpgradeABCI(clientCtx, portID, channelID) - } - - queryClient := types.NewQueryClient(clientCtx) - req := &types.QueryUpgradeRequest{ - PortId: portID, - ChannelId: channelID, - } - - return queryClient.Upgrade(context.Background(), req) -} - -// queryUpgradeErrorABCI queries the upgrade error from the store. -func queryUpgradeErrorABCI(clientCtx client.Context, portID, channelID string) (*types.QueryUpgradeErrorResponse, error) { - key := host.ChannelUpgradeErrorKey(portID, channelID) - - value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) - if err != nil { - return nil, err - } - - // check if upgrade error exists - if len(value) == 0 { - return nil, errorsmod.Wrapf(types.ErrUpgradeErrorNotFound, "portID (%s), channelID (%s)", portID, channelID) - } - - cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) - - var receipt types.ErrorReceipt - if err := cdc.Unmarshal(value, &receipt); err != nil { - return nil, err - } - - return types.NewQueryUpgradeErrorResponse(receipt, proofBz, proofHeight), nil -} - -// queryUpgradeABCI queries the upgrade from the store. -func queryUpgradeABCI(clientCtx client.Context, portID, channelID string) (*types.QueryUpgradeResponse, error) { - key := host.ChannelUpgradeKey(portID, channelID) - - value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) - if err != nil { - return nil, err - } - - // check if upgrade exists - if len(value) == 0 { - return nil, errorsmod.Wrapf(types.ErrUpgradeErrorNotFound, "portID (%s), channelID (%s)", portID, channelID) - } - - cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) - - var upgrade types.Upgrade - if err := cdc.Unmarshal(value, &upgrade); err != nil { - return nil, err - } - - return types.NewQueryUpgradeResponse(upgrade, proofBz, proofHeight), nil -} - // QueryPacketCommitment returns a packet commitment. // If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise, // it uses the gRPC query client. diff --git a/modules/core/04-channel/genesis.go b/modules/core/04-channel/genesis.go index 08b3a522514..4d4c2778edf 100644 --- a/modules/core/04-channel/genesis.go +++ b/modules/core/04-channel/genesis.go @@ -1,8 +1,6 @@ package channel import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/v10/modules/core/04-channel/keeper" @@ -12,10 +10,6 @@ import ( // InitGenesis initializes the ibc channel submodule's state from a provided genesis // state. func InitGenesis(ctx sdk.Context, k *keeper.Keeper, gs types.GenesisState) { - if err := gs.Params.Validate(); err != nil { - panic(fmt.Sprintf("invalid ibc channel genesis state parameters: %v", err)) - } - k.SetParams(ctx, gs.Params) for _, channel := range gs.Channels { ch := types.NewChannel(channel.State, channel.Ordering, channel.Counterparty, channel.ConnectionHops, channel.Version) k.SetChannel(ctx, channel.PortId, channel.ChannelId, ch) @@ -52,6 +46,5 @@ func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) types.GenesisState { RecvSequences: k.GetAllPacketRecvSeqs(ctx), AckSequences: k.GetAllPacketAckSeqs(ctx), NextChannelSequence: k.GetNextChannelSequence(ctx), - Params: k.GetParams(ctx), } } diff --git a/modules/core/04-channel/keeper/events.go b/modules/core/04-channel/keeper/events.go index 8a8d88ff564..bb1f1551d5a 100644 --- a/modules/core/04-channel/keeper/events.go +++ b/modules/core/04-channel/keeper/events.go @@ -267,170 +267,3 @@ func emitChannelClosedEvent(ctx sdk.Context, packet types.Packet, channel types. ), }) } - -// EmitChannelUpgradeInitEvent emits a channel upgrade init event -func EmitChannelUpgradeInitEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeInit, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} - -// EmitChannelUpgradeTryEvent emits a channel upgrade try event -func EmitChannelUpgradeTryEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeTry, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} - -// EmitChannelUpgradeAckEvent emits a channel upgrade ack event -func EmitChannelUpgradeAckEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeAck, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} - -// EmitChannelUpgradeConfirmEvent emits a channel upgrade confirm event -func EmitChannelUpgradeConfirmEvent(ctx sdk.Context, portID, channelID string, channel types.Channel) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeConfirm, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeKeyChannelState, channel.State.String()), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} - -// EmitChannelUpgradeOpenEvent emits a channel upgrade open event -func EmitChannelUpgradeOpenEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeOpen, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeKeyChannelState, channel.State.String()), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} - -// EmitChannelUpgradeTimeoutEvent emits an upgrade timeout event. -func EmitChannelUpgradeTimeoutEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeTimeout, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeTimeoutHeight, upgrade.Timeout.Height.String()), - sdk.NewAttribute(types.AttributeKeyUpgradeTimeoutTimestamp, fmt.Sprintf("%d", upgrade.Timeout.Timestamp)), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} - -// EmitErrorReceiptEvent emits an error receipt event -func EmitErrorReceiptEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel, err error) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeError, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - sdk.NewAttribute(types.AttributeKeyErrorReceipt, err.Error()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} - -// EmitChannelUpgradeCancelEvent emits an upgraded cancelled event. -func EmitChannelUpgradeCancelEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeCancel, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} - -// emitChannelFlushCompleteEvent emits an flushing event. -func emitChannelFlushCompleteEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelFlushComplete, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyChannelState, channel.State.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} diff --git a/modules/core/04-channel/keeper/export_test.go b/modules/core/04-channel/keeper/export_test.go index b0e2964c5cb..1b1a48ab18a 100644 --- a/modules/core/04-channel/keeper/export_test.go +++ b/modules/core/04-channel/keeper/export_test.go @@ -10,26 +10,6 @@ import ( "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" ) -// StartFlushing is a wrapper around startFlushing to allow the function to be directly called in tests. -func (k *Keeper) StartFlushing(ctx sdk.Context, portID, channelID string, upgrade *types.Upgrade) error { - return k.startFlushing(ctx, portID, channelID, upgrade) -} - -// ValidateSelfUpgradeFields is a wrapper around validateSelfUpgradeFields to allow the function to be directly called in tests. -func (k *Keeper) ValidateSelfUpgradeFields(ctx sdk.Context, proposedUpgrade types.UpgradeFields, channel types.Channel) error { - return k.validateSelfUpgradeFields(ctx, proposedUpgrade, channel) -} - -// CheckForUpgradeCompatibility is a wrapper around checkForUpgradeCompatibility to allow the function to be directly called in tests. -func (k *Keeper) CheckForUpgradeCompatibility(ctx sdk.Context, upgradeFields, counterpartyUpgradeFields types.UpgradeFields) error { - return k.checkForUpgradeCompatibility(ctx, upgradeFields, counterpartyUpgradeFields) -} - -// SetUpgradeErrorReceipt is a wrapper around setUpgradeErrorReceipt to allow the function to be directly called in tests. -func (k *Keeper) SetUpgradeErrorReceipt(ctx sdk.Context, portID, channelID string, errorReceipt types.ErrorReceipt) { - k.setUpgradeErrorReceipt(ctx, portID, channelID, errorReceipt) -} - // SetRecvStartSequence is a wrapper around setRecvStartSequence to allow the function to be directly called in tests. func (k *Keeper) SetRecvStartSequence(ctx sdk.Context, portID, channelID string, sequence uint64) { k.setRecvStartSequence(ctx, portID, channelID, sequence) diff --git a/modules/core/04-channel/keeper/grpc_query.go b/modules/core/04-channel/keeper/grpc_query.go index b242cb5dedb..7be35383b5a 100644 --- a/modules/core/04-channel/keeper/grpc_query.go +++ b/modules/core/04-channel/keeper/grpc_query.go @@ -620,77 +620,3 @@ func (q *queryServer) NextSequenceSend(goCtx context.Context, req *types.QueryNe selfHeight := clienttypes.GetSelfHeight(ctx) return types.NewQueryNextSequenceSendResponse(sequence, nil, selfHeight), nil } - -// UpgradeErrorReceipt implements the Query/UpgradeErrorReceipt gRPC method -func (q *queryServer) UpgradeError(goCtx context.Context, req *types.QueryUpgradeErrorRequest) (*types.QueryUpgradeErrorResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - if err := validate.GRPCRequest(req.PortId, req.ChannelId); err != nil { - return nil, err - } - - found := q.HasChannel(ctx, req.PortId, req.ChannelId) - if !found { - return nil, status.Error( - codes.NotFound, - errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: %s, channel-id %s", req.PortId, req.ChannelId).Error(), - ) - } - - receipt, found := q.GetUpgradeErrorReceipt(ctx, req.PortId, req.ChannelId) - if !found { - return nil, status.Error( - codes.NotFound, - errorsmod.Wrapf(types.ErrUpgradeErrorNotFound, "port-id %s, channel-id %s", req.PortId, req.ChannelId).Error(), - ) - } - - selfHeight := clienttypes.GetSelfHeight(ctx) - return types.NewQueryUpgradeErrorResponse(receipt, nil, selfHeight), nil -} - -// Upgrade implements the Query/UpgradeSequence gRPC method -func (q *queryServer) Upgrade(goCtx context.Context, req *types.QueryUpgradeRequest) (*types.QueryUpgradeResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - if err := validate.GRPCRequest(req.PortId, req.ChannelId); err != nil { - return nil, err - } - - found := q.HasChannel(ctx, req.PortId, req.ChannelId) - if !found { - return nil, status.Error( - codes.NotFound, - errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: %s, channel-id %s", req.PortId, req.ChannelId).Error(), - ) - } - - upgrade, found := q.GetUpgrade(ctx, req.PortId, req.ChannelId) - if !found { - return nil, status.Error( - codes.NotFound, - errorsmod.Wrapf(types.ErrUpgradeNotFound, "port-id: %s, channel-id %s", req.PortId, req.ChannelId).Error(), - ) - } - - selfHeight := clienttypes.GetSelfHeight(ctx) - return types.NewQueryUpgradeResponse(upgrade, nil, selfHeight), nil -} - -// ChannelParams implements the Query/ChannelParams gRPC method. -func (q *queryServer) ChannelParams(goCtx context.Context, req *types.QueryChannelParamsRequest) (*types.QueryChannelParamsResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - params := q.GetParams(ctx) - - return &types.QueryChannelParamsResponse{ - Params: ¶ms, - }, nil -} diff --git a/modules/core/04-channel/keeper/grpc_query_test.go b/modules/core/04-channel/keeper/grpc_query_test.go index 794b6c926d5..e14c5892732 100644 --- a/modules/core/04-channel/keeper/grpc_query_test.go +++ b/modules/core/04-channel/keeper/grpc_query_test.go @@ -17,7 +17,6 @@ import ( host "github.com/cosmos/ibc-go/v10/modules/core/24-host" "github.com/cosmos/ibc-go/v10/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v10/testing" - "github.com/cosmos/ibc-go/v10/testing/mock" ) const doesnotexist = "doesnotexist" @@ -216,8 +215,8 @@ func (suite *KeeperTestSuite) TestQueryChannels() { if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(expChannels, res.Channels) suite.Require().Equal(len(expChannels), int(res.Pagination.Total)) + suite.Require().ElementsMatch(expChannels, res.Channels) // order of channels is not guaranteed, due to lexicographical ordering } else { suite.Require().Error(err) suite.Require().ErrorIs(err, tc.expErr) @@ -1929,223 +1928,3 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { }) } } - -func (suite *KeeperTestSuite) TestQueryUpgradeError() { - var ( - req *types.QueryUpgradeErrorRequest - upgradeErr *types.UpgradeError - ) - - testCases := []struct { - msg string - malleate func() - expErr error - }{ - { - "empty request", - func() { - req = nil - }, - status.Error(codes.InvalidArgument, "empty request"), - }, - { - "invalid port ID", - func() { - req = &types.QueryUpgradeErrorRequest{ - PortId: "", - ChannelId: "test-channel-id", - } - }, - status.Error( - codes.InvalidArgument, - errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), - ), - }, - { - "invalid channel ID", - func() { - req = &types.QueryUpgradeErrorRequest{ - PortId: "test-port-id", - ChannelId: "", - } - }, - status.Error( - codes.InvalidArgument, - errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), - ), - }, - { - "channel not found", - func() { - req = &types.QueryUpgradeErrorRequest{ - PortId: "test-port-id", - ChannelId: "test-channel-id", - } - }, - status.Error( - codes.NotFound, - errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: test-port-id, channel-id test-channel-id").Error(), - ), - }, - { - "success", - func() { - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - upgradeErr = types.NewUpgradeError(uint64(1), fmt.Errorf("test error")) - suite.chainA.App.GetIBCKeeper().ChannelKeeper.WriteErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgradeErr) - - req = &types.QueryUpgradeErrorRequest{ - PortId: path.EndpointA.ChannelConfig.PortID, - ChannelId: path.EndpointA.ChannelID, - } - }, - nil, - }, - } - - for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - - tc.malleate() - - ctx := suite.chainA.GetContext() - queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) - res, err := queryServer.UpgradeError(ctx, req) - - if tc.expErr == nil { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(upgradeErr.GetErrorReceipt(), res.ErrorReceipt) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expErr) - } - }) - } -} - -func (suite *KeeperTestSuite) TestQueryUpgrade() { - var ( - req *types.QueryUpgradeRequest - expectedUpgrade types.Upgrade - ) - - testCases := []struct { - msg string - malleate func() - expErr error - }{ - { - "empty request", - func() { - req = nil - }, - status.Error(codes.InvalidArgument, "empty request"), - }, - { - "invalid port ID", - func() { - req = &types.QueryUpgradeRequest{ - PortId: "", - ChannelId: "test-channel-id", - } - }, - status.Error( - codes.InvalidArgument, - errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), - ), - }, - { - "invalid channel ID", - func() { - req = &types.QueryUpgradeRequest{ - PortId: "test-port-id", - ChannelId: "", - } - }, - status.Error( - codes.InvalidArgument, - errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), - ), - }, - { - "channel not found", - func() { - req = &types.QueryUpgradeRequest{ - PortId: "test-port-id", - ChannelId: "test-channel-id", - } - }, - status.Error( - codes.NotFound, - errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: test-port-id, channel-id test-channel-id").Error(), - ), - }, - { - "upgrade not found", - func() { - storeKey := suite.chainA.GetSimApp().GetKey(exported.StoreKey) - kvStore := suite.chainA.GetContext().KVStore(storeKey) - kvStore.Delete(host.ChannelUpgradeKey(req.PortId, req.ChannelId)) - }, - status.Error( - codes.NotFound, - errorsmod.Wrapf(types.ErrUpgradeNotFound, "port-id: mock, channel-id channel-420").Error(), - ), - }, - { - "success", - func() { - }, - nil, - }, - } - - for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - expectedUpgrade = types.NewUpgrade( - types.NewUpgradeFields(types.UNORDERED, []string{ibctesting.FirstConnectionID}, mock.Version), - types.NewTimeout(clienttypes.ZeroHeight(), 1000000), - 0, - ) - - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.SetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, expectedUpgrade) - - req = &types.QueryUpgradeRequest{ - PortId: path.EndpointA.ChannelConfig.PortID, - ChannelId: path.EndpointA.ChannelID, - } - - tc.malleate() - - ctx := suite.chainA.GetContext() - - queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) - res, err := queryServer.Upgrade(ctx, req) - - if tc.expErr == nil { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(expectedUpgrade, res.Upgrade) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expErr) - } - }) - } -} - -func (suite *KeeperTestSuite) TestQueryChannelParams() { - ctx := suite.chainA.GetContext() - expParams := types.DefaultParams() - - queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) - res, _ := queryServer.ChannelParams(ctx, &types.QueryChannelParamsRequest{}) - suite.Require().Equal(&expParams, res.Params) -} diff --git a/modules/core/04-channel/keeper/handshake.go b/modules/core/04-channel/keeper/handshake.go index 011809da7f8..22de3c5748c 100644 --- a/modules/core/04-channel/keeper/handshake.go +++ b/modules/core/04-channel/keeper/handshake.go @@ -367,7 +367,6 @@ func (k *Keeper) ChanCloseConfirm( channelID string, initProof []byte, proofHeight exported.Height, - counterpartyUpgradeSequence uint64, ) error { channel, found := k.GetChannel(ctx, portID, channelID) if !found { @@ -391,12 +390,11 @@ func (k *Keeper) ChanCloseConfirm( counterparty := types.NewCounterparty(portID, channelID) expectedChannel := types.Channel{ - State: types.CLOSED, - Ordering: channel.Ordering, - Counterparty: counterparty, - ConnectionHops: counterpartyHops, - Version: channel.Version, - UpgradeSequence: counterpartyUpgradeSequence, + State: types.CLOSED, + Ordering: channel.Ordering, + Counterparty: counterparty, + ConnectionHops: counterpartyHops, + Version: channel.Version, } if err := k.connectionKeeper.VerifyChannelState( @@ -407,17 +405,6 @@ func (k *Keeper) ChanCloseConfirm( return err } - // If the channel is closing during an upgrade, then we can delete all upgrade information. - if k.hasUpgrade(ctx, portID, channelID) { - k.deleteUpgradeInfo(ctx, portID, channelID) - k.Logger(ctx).Info( - "upgrade info deleted", - "port_id", portID, - "channel_id", channelID, - "upgrade_sequence", channel.UpgradeSequence, - ) - } - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", channel.State, "new-state", types.CLOSED) defer telemetry.IncrCounter(1, "ibc", "channel", "close-confirm") diff --git a/modules/core/04-channel/keeper/handshake_test.go b/modules/core/04-channel/keeper/handshake_test.go index dd9f13217fd..d980326f57e 100644 --- a/modules/core/04-channel/keeper/handshake_test.go +++ b/modules/core/04-channel/keeper/handshake_test.go @@ -13,7 +13,6 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v10/modules/core/errors" "github.com/cosmos/ibc-go/v10/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v10/testing" - "github.com/cosmos/ibc-go/v10/testing/mock" ) type testCase = struct { @@ -567,9 +566,8 @@ func (suite *KeeperTestSuite) TestChanCloseInit() { // bypassed on chainA by setting the channel state in the ChannelKeeper. func (suite *KeeperTestSuite) TestChanCloseConfirm() { var ( - path *ibctesting.Path - heightDiff uint64 - counterpartyUpgradeSequence uint64 + path *ibctesting.Path + heightDiff uint64 ) testCases := []testCase{ @@ -577,26 +575,6 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { path.Setup() path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) }, nil}, - {"success with upgrade info", func() { - path.Setup() - - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) - - // add mock upgrade info to simulate that the channel is closing during - // an upgrade and verify that the upgrade information is deleted - upgrade := types.Upgrade{ - Fields: types.NewUpgradeFields(types.UNORDERED, []string{ibctesting.FirstConnectionID}, mock.UpgradeVersion), - Timeout: types.NewTimeout(clienttypes.ZeroHeight(), 1), - } - - counterpartyUpgrade := types.Upgrade{ - Fields: types.NewUpgradeFields(types.UNORDERED, []string{ibctesting.FirstConnectionID}, mock.UpgradeVersion), - Timeout: types.NewTimeout(clienttypes.ZeroHeight(), 1), - } - - path.EndpointB.SetChannelUpgrade(upgrade) - path.EndpointB.SetChannelCounterpartyUpgrade(counterpartyUpgrade) - }, nil}, {"channel doesn't exist", func() { // any non-nil values work for connections path.EndpointA.ChannelID = ibctesting.FirstChannelID @@ -637,28 +615,13 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { // channel not closed path.Setup() }, ibcerrors.ErrInvalidHeight}, - { - "failure: invalid counterparty upgrade sequence", - func() { - path.Setup() - - // trigger upgradeInit on A which will bump the counterparty upgrade sequence. - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) - }, - commitmenttypes.ErrInvalidProof, - }, } for _, tc := range testCases { tc := tc suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - heightDiff = 0 // must explicitly be changed - counterpartyUpgradeSequence = 0 // must explicitly be changed + suite.SetupTest() // reset + heightDiff = 0 // must explicitly be changed path = ibctesting.NewPath(suite.chainA, suite.chainB) tc.malleate() @@ -669,17 +632,11 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { ctx := suite.chainB.GetContext() err := suite.chainB.App.GetIBCKeeper().ChannelKeeper.ChanCloseConfirm( ctx, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, - proof, malleateHeight(proofHeight, heightDiff), counterpartyUpgradeSequence, + proof, malleateHeight(proofHeight, heightDiff), ) if tc.expErr == nil { suite.Require().NoError(err) - - // if the channel closed during an upgrade, there should not be any upgrade information - _, found := suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(ctx, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().False(found) - _, found = suite.chainB.App.GetIBCKeeper().ChannelKeeper.GetCounterpartyUpgrade(ctx, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().False(found) } else { suite.Require().Error(err) suite.Require().ErrorIs(err, tc.expErr) diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 06e05e5b1e7..b565f8151a6 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -228,14 +228,6 @@ func (k *Keeper) SetPacketReceipt(ctx sdk.Context, portID, channelID string, seq } } -// deletePacketReceipt deletes a packet receipt from the store -func (k *Keeper) deletePacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) - if err := store.Delete(host.PacketReceiptKey(portID, channelID, sequence)); err != nil { - panic(err) - } -} - // GetPacketCommitment gets the packet commitment hash from the store func (k *Keeper) GetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) []byte { store := k.storeService.OpenKVStore(ctx) @@ -305,14 +297,6 @@ func (k *Keeper) HasPacketAcknowledgement(ctx sdk.Context, portID, channelID str return has } -// deletePacketAcknowledgement deletes the packet ack hash from the store -func (k *Keeper) deletePacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) - if err := store.Delete(host.PacketAcknowledgementKey(portID, channelID, sequence)); err != nil { - panic(err) - } -} - // IteratePacketSequence provides an iterator over all send, receive or ack sequences. // For each sequence, cb will be called. If the cb returns true, the iterator // will close and stop. @@ -544,155 +528,6 @@ func (k *Keeper) GetChannelConnection(ctx sdk.Context, portID, channelID string) return connectionID, connection, nil } -// GetUpgradeErrorReceipt returns the upgrade error receipt for the provided port and channel identifiers. -func (k *Keeper) GetUpgradeErrorReceipt(ctx sdk.Context, portID, channelID string) (types.ErrorReceipt, bool) { - store := k.storeService.OpenKVStore(ctx) - bz, err := store.Get(host.ChannelUpgradeErrorKey(portID, channelID)) - if err != nil { - panic(err) - } - - if len(bz) == 0 { - return types.ErrorReceipt{}, false - } - - var errorReceipt types.ErrorReceipt - k.cdc.MustUnmarshal(bz, &errorReceipt) - - return errorReceipt, true -} - -// setUpgradeErrorReceipt sets the provided error receipt in store using the port and channel identifiers. -func (k *Keeper) setUpgradeErrorReceipt(ctx sdk.Context, portID, channelID string, errorReceipt types.ErrorReceipt) { - store := k.storeService.OpenKVStore(ctx) - bz := k.cdc.MustMarshal(&errorReceipt) - if err := store.Set(host.ChannelUpgradeErrorKey(portID, channelID), bz); err != nil { - panic(err) - } -} - -// hasUpgrade returns true if a proposed upgrade exists in store -func (k *Keeper) hasUpgrade(ctx sdk.Context, portID, channelID string) bool { - store := k.storeService.OpenKVStore(ctx) - has, err := store.Has(host.ChannelUpgradeKey(portID, channelID)) - if err != nil { - panic(err) - } - return has -} - -// GetUpgrade returns the proposed upgrade for the provided port and channel identifiers. -func (k *Keeper) GetUpgrade(ctx sdk.Context, portID, channelID string) (types.Upgrade, bool) { - store := k.storeService.OpenKVStore(ctx) - bz, err := store.Get(host.ChannelUpgradeKey(portID, channelID)) - if err != nil { - panic(err) - } - - if len(bz) == 0 { - return types.Upgrade{}, false - } - - var upgrade types.Upgrade - k.cdc.MustUnmarshal(bz, &upgrade) - - return upgrade, true -} - -// SetUpgrade sets the proposed upgrade using the provided port and channel identifiers. -func (k *Keeper) SetUpgrade(ctx sdk.Context, portID, channelID string, upgrade types.Upgrade) { - store := k.storeService.OpenKVStore(ctx) - bz := k.cdc.MustMarshal(&upgrade) - if err := store.Set(host.ChannelUpgradeKey(portID, channelID), bz); err != nil { - panic(err) - } -} - -// deleteUpgrade deletes the upgrade for the provided port and channel identifiers. -func (k *Keeper) deleteUpgrade(ctx sdk.Context, portID, channelID string) { - store := k.storeService.OpenKVStore(ctx) - if err := store.Delete(host.ChannelUpgradeKey(portID, channelID)); err != nil { - panic(err) - } -} - -// hasCounterpartyUpgrade returns true if a counterparty upgrade exists in store -func (k *Keeper) hasCounterpartyUpgrade(ctx sdk.Context, portID, channelID string) bool { - store := k.storeService.OpenKVStore(ctx) - has, err := store.Has(host.ChannelCounterpartyUpgradeKey(portID, channelID)) - if err != nil { - panic(err) - } - return has -} - -// GetCounterpartyUpgrade gets the counterparty upgrade from the store. -func (k *Keeper) GetCounterpartyUpgrade(ctx sdk.Context, portID, channelID string) (types.Upgrade, bool) { - store := k.storeService.OpenKVStore(ctx) - bz, err := store.Get(host.ChannelCounterpartyUpgradeKey(portID, channelID)) - if err != nil { - panic(err) - } - - if len(bz) == 0 { - return types.Upgrade{}, false - } - - var upgrade types.Upgrade - k.cdc.MustUnmarshal(bz, &upgrade) - - return upgrade, true -} - -// SetCounterpartyUpgrade sets the counterparty upgrade in the store. -func (k *Keeper) SetCounterpartyUpgrade(ctx sdk.Context, portID, channelID string, upgrade types.Upgrade) { - store := k.storeService.OpenKVStore(ctx) - bz := k.cdc.MustMarshal(&upgrade) - if err := store.Set(host.ChannelCounterpartyUpgradeKey(portID, channelID), bz); err != nil { - panic(err) - } -} - -// deleteCounterpartyUpgrade deletes the counterparty upgrade in the store. -func (k *Keeper) deleteCounterpartyUpgrade(ctx sdk.Context, portID, channelID string) { - store := k.storeService.OpenKVStore(ctx) - if err := store.Delete(host.ChannelCounterpartyUpgradeKey(portID, channelID)); err != nil { - panic(err) - } -} - -// deleteUpgradeInfo deletes all auxiliary upgrade information. -func (k *Keeper) deleteUpgradeInfo(ctx sdk.Context, portID, channelID string) { - k.deleteUpgrade(ctx, portID, channelID) - k.deleteCounterpartyUpgrade(ctx, portID, channelID) -} - -// SetParams sets the channel parameters. -func (k *Keeper) SetParams(ctx sdk.Context, params types.Params) { - store := k.storeService.OpenKVStore(ctx) - bz := k.cdc.MustMarshal(¶ms) - if err := store.Set([]byte(types.ParamsKey), bz); err != nil { - panic(err) - } -} - -// GetParams returns the total set of the channel parameters. -func (k *Keeper) GetParams(ctx sdk.Context) types.Params { - store := k.storeService.OpenKVStore(ctx) - bz, err := store.Get([]byte(types.ParamsKey)) - if err != nil { - panic(err) - } - - if bz == nil { // only panic on unset params and not on empty params - panic(errors.New("channel params are not set in store")) - } - - var params types.Params - k.cdc.MustUnmarshal(bz, ¶ms) - return params -} - // common functionality for IteratePacketCommitment and IteratePacketAcknowledgement func (k *Keeper) iterateHashes(ctx sdk.Context, iterator db.Iterator, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { defer sdk.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() }) @@ -749,76 +584,3 @@ func (k *Keeper) GetRecvStartSequence(ctx sdk.Context, portID, channelID string) return sdk.BigEndianToUint64(bz), true } - -// SetPruningSequenceStart sets a channel's pruning sequence start to the store. -func (k *Keeper) SetPruningSequenceStart(ctx sdk.Context, portID, channelID string, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) - bz := sdk.Uint64ToBigEndian(sequence) - if err := store.Set(host.PruningSequenceStartKey(portID, channelID), bz); err != nil { - panic(err) - } -} - -// GetPruningSequenceStart gets a channel's pruning sequence start from the store. -func (k *Keeper) GetPruningSequenceStart(ctx sdk.Context, portID, channelID string) (uint64, bool) { - store := k.storeService.OpenKVStore(ctx) - bz, err := store.Get(host.PruningSequenceStartKey(portID, channelID)) - if err != nil { - panic(err) - } - - if len(bz) == 0 { - return 0, false - } - - return sdk.BigEndianToUint64(bz), true -} - -// HasPruningSequenceStart returns true if the pruning sequence start is set for the specified channel. -func (k *Keeper) HasPruningSequenceStart(ctx sdk.Context, portID, channelID string) bool { - store := k.storeService.OpenKVStore(ctx) - has, err := store.Has(host.PruningSequenceStartKey(portID, channelID)) - if err != nil { - panic(err) - } - return has -} - -// PruneAcknowledgements prunes packet acknowledgements and receipts that have a sequence number less than pruning sequence end. -// The number of packet acks/receipts pruned is bounded by the limit. Pruning can only occur after a channel has been upgraded. -// -// Pruning sequence start keeps track of the packet ack/receipt that can be pruned next. When it reaches pruningSequenceEnd, -// pruning is complete. -func (k *Keeper) PruneAcknowledgements(ctx sdk.Context, portID, channelID string, limit uint64) (uint64, uint64, error) { - pruningSequenceStart, found := k.GetPruningSequenceStart(ctx, portID, channelID) - if !found { - return 0, 0, errorsmod.Wrapf(types.ErrPruningSequenceStartNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - pruningSequenceEnd, found := k.GetRecvStartSequence(ctx, portID, channelID) - if !found { - return 0, 0, errorsmod.Wrapf(types.ErrRecvStartSequenceNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - - start := pruningSequenceStart - end := pruningSequenceStart + limit // note: checked against limit overflowing. - for ; start < end; start++ { - // stop pruning if pruningSequenceStart has reached pruningSequenceEnd, pruningSequenceEnd is - // set to be equal to the _next_ sequence to be sent by the counterparty. - if start >= pruningSequenceEnd { - break - } - - k.deletePacketAcknowledgement(ctx, portID, channelID, start) - - // NOTE: packet receipts are only relevant for unordered channels. - k.deletePacketReceipt(ctx, portID, channelID, start) - } - - // set pruning sequence start to the updated value - k.SetPruningSequenceStart(ctx, portID, channelID, start) - - totalPruned := start - pruningSequenceStart - totalRemaining := pruningSequenceEnd - start - - return totalPruned, totalRemaining, nil -} diff --git a/modules/core/04-channel/keeper/keeper_test.go b/modules/core/04-channel/keeper/keeper_test.go index c4e38d8ad50..dc7f2100da6 100644 --- a/modules/core/04-channel/keeper/keeper_test.go +++ b/modules/core/04-channel/keeper/keeper_test.go @@ -1,20 +1,13 @@ package keeper_test import ( - "fmt" - "math" "reflect" "testing" testifysuite "github.com/stretchr/testify/suite" - errorsmod "cosmossdk.io/errors" - transfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/v10/modules/core/24-host" - "github.com/cosmos/ibc-go/v10/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v10/testing" ibcmock "github.com/cosmos/ibc-go/v10/testing/mock" ) @@ -475,478 +468,3 @@ func (suite *KeeperTestSuite) TestSetPacketAcknowledgement() { suite.Require().Equal(ackHash, storedAckHash) suite.Require().True(suite.chainA.App.GetIBCKeeper().ChannelKeeper.HasPacketAcknowledgement(ctxA, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, seq)) } - -func (suite *KeeperTestSuite) TestSetUpgradeErrorReceipt() { - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupConnections() - path.CreateChannels() - - errorReceipt, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().False(found) - suite.Require().Empty(errorReceipt) - - expError := types.NewUpgradeError(1, fmt.Errorf("testing")) - suite.chainA.App.GetIBCKeeper().ChannelKeeper.WriteErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, expError) - - errorReceipt, found = suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(expError.GetErrorReceipt(), errorReceipt) -} - -// TestDefaultSetParams tests the default params set are what is expected -func (suite *KeeperTestSuite) TestDefaultSetParams() { - expParams := types.DefaultParams() - - channelKeeper := suite.chainA.App.GetIBCKeeper().ChannelKeeper - params := channelKeeper.GetParams(suite.chainA.GetContext()) - - suite.Require().Equal(expParams, params) - suite.Require().Equal(expParams.UpgradeTimeout, channelKeeper.GetParams(suite.chainA.GetContext()).UpgradeTimeout) -} - -// TestParams tests that Param setting and retrieval works properly -func (suite *KeeperTestSuite) TestParams() { - testCases := []struct { - name string - input types.Params - expErr error - }{ - {"success: set default params", types.DefaultParams(), nil}, - {"success: zero timeout height", types.NewParams(types.NewTimeout(clienttypes.ZeroHeight(), 10000)), nil}, - {"fail: zero timeout timestamp", types.NewParams(types.NewTimeout(clienttypes.NewHeight(1, 1000), 0)), errorsmod.Wrapf(types.ErrInvalidUpgradeTimeout, "upgrade timeout height must be zero. ")}, - {"fail: zero timeout", types.NewParams(types.NewTimeout(clienttypes.ZeroHeight(), 0)), errorsmod.Wrapf(types.ErrInvalidUpgradeTimeout, "upgrade timeout height must be zero.")}, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - ctx := suite.chainA.GetContext() - err := tc.input.Validate() - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.SetParams(ctx, tc.input) - if tc.expErr == nil { - suite.Require().NoError(err) - expected := tc.input - p := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetParams(ctx) - suite.Require().Equal(expected, p) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expErr) - } - }) - } -} - -// TestUnsetParams tests that trying to get params that are not set panics. -func (suite *KeeperTestSuite) TestUnsetParams() { - suite.SetupTest() - ctx := suite.chainA.GetContext() - store := ctx.KVStore(suite.chainA.GetSimApp().GetKey(exported.StoreKey)) - store.Delete([]byte(types.ParamsKey)) - - suite.Require().Panics(func() { - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetParams(ctx) - }) -} - -func (suite *KeeperTestSuite) TestPruneAcknowledgements() { - var ( - path *ibctesting.Path - limit uint64 - upgradeFields types.UpgradeFields - - // postPruneExpState is a helper function to verify the expected state after pruning. Argument expLeft - // denotes the expected amount of packet acks and receipts left after pruning. Argument expSequenceStart - // denotes the expected value of PruneSequenceStart. - postPruneExpState = func(expAcksLen, expReceiptsLen, expPruningSequenceStart uint64) { - acks := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetAllPacketAcks(suite.chainA.GetContext()) - suite.Require().Len(acks, int(expAcksLen)) - - receipts := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetAllPacketReceipts(suite.chainA.GetContext()) - suite.Require().Len(receipts, int(expReceiptsLen)) - - start, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPruningSequenceStart(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(start, expPruningSequenceStart) - } - ) - - testCases := []struct { - name string - pre func() - malleate func() - post func(pruned, left uint64) - expError error - }{ - { - "success: no packets sent, no stale packet state pruned", - func() {}, - func() {}, - func(pruned, left uint64) { - // Assert that PruneSequenceStart and PruneSequenceEnd are both set to 1. - start, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetPruningSequenceStart(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - end, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetRecvStartSequence(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - - suite.Require().Equal(uint64(1), start) - suite.Require().Equal(uint64(1), end) - - // We expect 0 to be pruned and 0 left. - suite.Require().Equal(uint64(0), pruned) - suite.Require().Equal(uint64(0), left) - }, - nil, - }, - { - "success: stale packet state pruned up to limit", - func() { - // Send 10 packets from B -> A, creating 10 packet receipts and 10 packet acks on A. - suite.sendMockPackets(path, 10, true) - }, - func() {}, - func(pruned, left uint64) { - sequenceEnd, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetRecvStartSequence(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - - // We expect nothing to be left and sequenceStart == sequenceEnd. - postPruneExpState(0, 0, sequenceEnd) - - // We expect 10 to be pruned and 0 left. - suite.Require().Equal(uint64(10), pruned) - suite.Require().Equal(uint64(0), left) - }, - nil, - }, - { - "success: stale packet state partially pruned", - func() { - // Send 10 packets from B -> A, creating 10 packet receipts and 10 packet acks on A. - suite.sendMockPackets(path, 10, true) - }, - func() { - // Prune only 6 packet acks. - limit = 6 - }, - func(pruned, left uint64) { - // We expect 4 to be left and sequenceStart == 7. - postPruneExpState(4, 4, 7) - - // We expect 6 to be pruned and 4 left. - suite.Require().Equal(uint64(6), pruned) - suite.Require().Equal(uint64(4), left) - }, - nil, - }, - { - "success: stale packet state with a higher limit", - func() { - // Send 10 packets from B -> A, creating 10 packet receipts and 10 packet acks on A. - suite.sendMockPackets(path, 10, true) - }, - func() { - // Prune 13 packets acks > 10 packets sent. - limit = 13 - }, - func(pruned, left uint64) { - // We expect 0 to be left and sequenceStart == 11. - postPruneExpState(0, 0, 11) - - // We expect 10 to be pruned and 0 left. - suite.Require().Equal(uint64(10), pruned) - suite.Require().Equal(uint64(0), left) - }, - nil, - }, - { - "success: stale packet state pruned, two upgrades", - func() { - // Send 10 packets from B -> A, creating 10 packet receipts and 10 packet acks on A. - // This is _before_ the first upgrade. - suite.sendMockPackets(path, 10, true) - }, - func() { - // Previous upgrade is complete, send additional packets and do yet another upgrade. - // This is _after_ the first upgrade. - suite.sendMockPackets(path, 5, true) - - // Do another upgrade. - upgradeFields = types.UpgradeFields{Version: fmt.Sprintf("%s-v3", ibcmock.Version)} - suite.UpgradeChannel(path, upgradeFields) - - // set limit to 15, get them all in one go. - limit = 15 - }, - func(pruned, left uint64) { - sequenceEnd, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetRecvStartSequence(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - - // We expect nothing to be left and sequenceStart == sequenceEnd. - postPruneExpState(0, 0, sequenceEnd) - - // We expect 15 to be pruned and 0 left. - suite.Require().Equal(uint64(15), pruned) - suite.Require().Equal(uint64(0), left) - }, - nil, - }, - { - "success: stale packet state partially pruned, upgrade, prune again", - func() { - // Send 10 packets from B -> A, creating 10 packet receipts and 10 packet acks on A. - // This is _before_ the first upgrade. - suite.sendMockPackets(path, 10, true) - }, - func() { - // Prune 5 on A. - pruned, left, err := suite.chainA.App.GetIBCKeeper().ChannelKeeper.PruneAcknowledgements( - suite.chainA.GetContext(), - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - 4, // limit == 4 - ) - suite.Require().NoError(err) - - // We expect 4 to be pruned and 6 left. - suite.Require().Equal(uint64(4), pruned) - suite.Require().Equal(uint64(6), left) - - // Check state post-prune - postPruneExpState(6, 6, 5) - - // Previous upgrade is complete, send additional packets and do yet another upgrade. - // This is _after_ the first upgrade. - suite.sendMockPackets(path, 10, true) - - // Do another upgrade. - upgradeFields = types.UpgradeFields{Version: fmt.Sprintf("%s-v3", ibcmock.Version)} - suite.UpgradeChannel(path, upgradeFields) - - // A total of 16 stale acks/receipts exist on A. Prune 10 of them (default in test). - }, - func(pruned, left uint64) { - // Expected state should be 6 acks/receipts left, sequenceStart == 15. - postPruneExpState(6, 6, 15) - - // We expect 10 to be pruned and 6 left. - suite.Require().Equal(uint64(10), pruned) - suite.Require().Equal(uint64(6), left) - }, - nil, - }, - { - "success: unordered -> ordered -> unordered, acksLen != receiptsLen after packet sends", - func() { - // Send 5 packets from B -> A, creating 5 packet receipts and 5 packet acks on A. - // This is _before_ the first upgrade. - suite.sendMockPackets(path, 5, true) - - // Set Order for upgrade to Ordered. - upgradeFields = types.UpgradeFields{Version: fmt.Sprintf("%s-v2", ibcmock.Version), Ordering: types.ORDERED} - }, - func() { - // Previous upgrade is complete, send additional packets now on ordered channel (only acks!) - suite.sendMockPackets(path, 10, true) - - // Do another upgrade (go back to Unordered) - upgradeFields = types.UpgradeFields{Version: fmt.Sprintf("%s-v3", ibcmock.Version), Ordering: types.UNORDERED} - suite.UpgradeChannel(path, upgradeFields) - }, - func(pruned, left uint64) { - // After pruning 10 sequences we should be left with 5 acks and zero receipts. - postPruneExpState(5, 0, 11) - - // We expect 10 to be pruned and 5 left. - suite.Require().Equal(uint64(10), pruned) - suite.Require().Equal(uint64(5), left) - }, - nil, - }, - { - "success: packets sent before upgrade are pruned, after upgrade are not", - func() { - // Send 5 packets from B -> A, creating 5 packet receipts and 5 packet acks on A. - suite.sendMockPackets(path, 5, true) - }, - func() {}, - func(pruned, left uint64) { - // We expect 5 to be pruned and 0 left. - suite.Require().Equal(uint64(5), pruned) - suite.Require().Equal(uint64(0), left) - - // channel upgraded, send additional packets and try and prune. - suite.sendMockPackets(path, 12, true) - - // attempt to prune 5. - pruned, left, err := suite.chainA.App.GetIBCKeeper().ChannelKeeper.PruneAcknowledgements( - suite.chainA.GetContext(), - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - 5, - ) - suite.Require().NoError(err) - // We expect 0 to be pruned and 0 left. - suite.Require().Equal(uint64(0), pruned) - suite.Require().Equal(uint64(0), left) - - // we _do not_ expect error, simply a fast return - postPruneExpState(12, 12, 6) - }, - nil, - }, - { - "success: packets sent with 2 middle sequences that don't have an ack stored", - func() { - // Send 12 packets from B -> A with 2 packets that timeout - suite.sendMockPackets(path, 5, true) - suite.sendMockPackets(path, 2, false) - suite.sendMockPackets(path, 5, true) - }, - func() { - limit = 7 - }, - func(pruned, left uint64) { - // After pruning 7 sequences we should be left with 5 acks and 5 receipts, - // because the 2 packets that timeout are still counted as pruned, even though - // there was nothing to prune since both packets timed out - postPruneExpState(5, 5, 8) - - // We expect 7 to be pruned and 5 left. - suite.Require().Equal(uint64(7), pruned) - suite.Require().Equal(uint64(5), left) - }, - nil, - }, - { - "success: limit wraps around due to uint64 overflow", - func() { - // Send 10 packets from B -> A, creating 10 packet receipts and 10 packet acks on A. - suite.sendMockPackets(path, 10, true) - }, - func() { - limit = math.MaxUint64 - }, - func(pruned, left uint64) { - // Nothing should be pruned, by passing in a limit of math.MaxUint64, overflow occurs - // when initializing end to pruningSequenceStart + limit. This results in end always being - // equal to start - 1 and thereby not entering the for loop. - // We expect 10 acks, 10 receipts and pruningSequenceStart == 1 (loop not entered). - postPruneExpState(10, 10, 1) - - // We expect 0 to be pruned and 10 left. - suite.Require().Equal(uint64(0), pruned) - suite.Require().Equal(uint64(10), left) - }, - nil, - }, - { - "failure: packet sequence start not set", - func() {}, - func() { - path.EndpointA.ChannelConfig.PortID = "portidone" - }, - func(_, _ uint64) {}, - types.ErrPruningSequenceStartNotFound, - }, - { - "failure: packet sequence end not set", - func() {}, - func() { - store := suite.chainA.GetContext().KVStore(suite.chainA.GetSimApp().GetKey(exported.StoreKey)) - store.Delete(host.RecvStartSequenceKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - }, - func(_, _ uint64) {}, - types.ErrRecvStartSequenceNotFound, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - // Defaults will be filled in for rest. - upgradeFields = types.UpgradeFields{Version: ibcmock.UpgradeVersion} - limit = 10 - - // perform pre upgrade ops. - tc.pre() - - suite.UpgradeChannel(path, upgradeFields) - - tc.malleate() - - pruned, left, err := suite.chainA.App.GetIBCKeeper().ChannelKeeper.PruneAcknowledgements( - suite.chainA.GetContext(), - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - limit, - ) - - suite.Require().ErrorIs(err, tc.expError) - - // check on post state. - tc.post(pruned, left) - }) - } -} - -// UpgradeChannel performs a channel upgrade given a specific set of upgrade fields. -// Question(jim): setup.coordinator.UpgradeChannel() wen? -func (suite *KeeperTestSuite) UpgradeChannel(path *ibctesting.Path, upgradeFields types.UpgradeFields) { - // configure the channel upgrade version on testing endpoints - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields = upgradeFields - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields = upgradeFields - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeAck() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeConfirm() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeOpen() - suite.Require().NoError(err) - - err = path.EndpointA.UpdateClient() - suite.Require().NoError(err) -} - -// sendMockPackets sends a packet from source to dest and acknowledges it on the source (completing the packet lifecycle) -// if acknowledge is true. If acknowledge is false, then the packet will be sent, but timed out. -// Question(jim): find a nicer home for this? -func (suite *KeeperTestSuite) sendMockPackets(path *ibctesting.Path, numPackets int, acknowledge bool) { - for i := 0; i < numPackets; i++ { - - timeoutHeight := clienttypes.NewHeight(1, 1000) - timeoutTimestamp := disabledTimeoutTimestamp - if !acknowledge { - timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().UnixNano()) - } - - sequence, err := path.EndpointB.SendPacket(timeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - - packet := types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, timeoutHeight, timeoutTimestamp) - - if acknowledge { - err = path.RelayPacket(packet) - suite.Require().NoError(err) - } else { - err = path.EndpointB.UpdateClient() - suite.Require().NoError(err) - - err = path.EndpointB.TimeoutPacket(packet) - suite.Require().NoError(err) - } - } -} diff --git a/modules/core/04-channel/keeper/migrations.go b/modules/core/04-channel/keeper/migrations.go index 046eeddd28e..09b7a9ec2f4 100644 --- a/modules/core/04-channel/keeper/migrations.go +++ b/modules/core/04-channel/keeper/migrations.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" + v10 "github.com/cosmos/ibc-go/v10/modules/core/04-channel/migrations/v10" ) // Migrator is a struct for handling in-place store migrations. @@ -16,10 +16,12 @@ func NewMigrator(keeper *Keeper) Migrator { return Migrator{keeper: keeper} } -// MigrateParams migrates params to the default channel params. -func (m Migrator) MigrateParams(ctx sdk.Context) error { - params := channeltypes.DefaultParams() - m.keeper.SetParams(ctx, params) - m.keeper.Logger(ctx).Info("successfully migrated ibc channel params") - return nil +// Migrate7To8 migrates the channel store from module version 7 to 8 by: +// - Removing channel upgrade sequences +// - Removing any channel upgrade info (i.e. upgrades, counterparty upgrades, upgrade errors) +// - Removing channel params +// - Removing pruning sequences +// NOTE: This migration will fail if any channels are in the FLUSHING or FLUSHCOMPLETE state. +func (m *Migrator) Migrate7To8(ctx sdk.Context) error { + return v10.MigrateStore(ctx, m.keeper.storeService, m.keeper.cdc, m.keeper) } diff --git a/modules/core/04-channel/keeper/migrations_test.go b/modules/core/04-channel/keeper/migrations_test.go deleted file mode 100644 index 0786341643a..00000000000 --- a/modules/core/04-channel/keeper/migrations_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package keeper_test - -import ( - "github.com/cosmos/ibc-go/v10/modules/core/04-channel/keeper" - channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" -) - -// TestMigrateDefaultParams tests the migration for the channel params -func (suite *KeeperTestSuite) TestMigrateDefaultParams() { - testCases := []struct { - name string - expectedParams channeltypes.Params - }{ - { - "success: default params", - channeltypes.DefaultParams(), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - ctx := suite.chainA.GetContext() - migrator := keeper.NewMigrator(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper) - err := migrator.MigrateParams(ctx) - suite.Require().NoError(err) - - params := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetParams(ctx) - suite.Require().Equal(tc.expectedParams, params) - }) - } -} diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index 0db49b8dc6d..29a15261b23 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -2,7 +2,6 @@ package keeper import ( "bytes" - "slices" "strconv" errorsmod "cosmossdk.io/errors" @@ -109,21 +108,8 @@ func (k *Keeper) RecvPacket( return "", errorsmod.Wrap(types.ErrChannelNotFound, packet.GetDestChannel()) } - if !slices.Contains([]types.State{types.OPEN, types.FLUSHING, types.FLUSHCOMPLETE}, channel.State) { - return "", errorsmod.Wrapf(types.ErrInvalidChannelState, "expected channel state to be one of [%s, %s, %s], but got %s", types.OPEN, types.FLUSHING, types.FLUSHCOMPLETE, channel.State) - } - - // If counterpartyUpgrade is stored we need to ensure that the - // packet sequence is counterparty next sequence send. If the - // counterparty is implemented correctly, this may only occur - // when we are in FLUSHCOMPLETE and the counterparty has already - // completed the channel upgrade. - counterpartyUpgrade, found := k.GetCounterpartyUpgrade(ctx, packet.GetDestPort(), packet.GetDestChannel()) - if found { - counterpartyNextSequenceSend := counterpartyUpgrade.NextSequenceSend - if packet.GetSequence() >= counterpartyNextSequenceSend { - return "", errorsmod.Wrapf(types.ErrInvalidPacket, "cannot flush packet at sequence greater than or equal to counterparty next sequence send (%d) ≥ (%d).", packet.GetSequence(), counterpartyNextSequenceSend) - } + if channel.State != types.OPEN { + return "", errorsmod.Wrapf(types.ErrInvalidChannelState, "channel is not OPEN (got %s)", channel.State) } // packet must come from the channel's counterparty @@ -283,8 +269,8 @@ func (k *Keeper) WriteAcknowledgement( return errorsmod.Wrap(types.ErrChannelNotFound, packet.GetDestChannel()) } - if !slices.Contains([]types.State{types.OPEN, types.FLUSHING, types.FLUSHCOMPLETE}, channel.State) { - return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected one of [%s, %s, %s], got %s", types.OPEN, types.FLUSHING, types.FLUSHCOMPLETE, channel.State) + if channel.State != types.OPEN { + return errorsmod.Wrapf(types.ErrInvalidChannelState, "channel is not OPEN (got %s)", channel.State) } // REPLAY PROTECTION: The recvStartSequence will prevent historical proofs from allowing replay @@ -355,8 +341,8 @@ func (k *Keeper) AcknowledgePacket( ) } - if !slices.Contains([]types.State{types.OPEN, types.FLUSHING}, channel.State) { - return "", errorsmod.Wrapf(types.ErrInvalidChannelState, "packets cannot be acknowledged on channel with state (%s)", channel.State) + if channel.State != types.OPEN { + return "", errorsmod.Wrapf(types.ErrInvalidChannelState, "channel is not OPEN (got %s)", channel.State) } // packet must have been sent to the channel's counterparty @@ -450,33 +436,5 @@ func (k *Keeper) AcknowledgePacket( // emit an event marking that we have processed the acknowledgement emitAcknowledgePacketEvent(ctx, packet, channel) - // if an upgrade is in progress, handling packet flushing and update channel state appropriately - if channel.State == types.FLUSHING { - k.handleFlushState(ctx, packet, channel) - } - return channel.Version, nil } - -// handleFlushState is called when a packet is acknowledged or timed out and the channel is in -// FLUSHING state. It checks if the upgrade has timed out and if so, aborts the upgrade. If all -// packets have completed their lifecycle, it sets the channel state to FLUSHCOMPLETE and -// emits a channel_flush_complete event. Returns true if the upgrade was aborted, false otherwise. -func (k *Keeper) handleFlushState(ctx sdk.Context, packet types.Packet, channel types.Channel) { - if counterpartyUpgrade, found := k.GetCounterpartyUpgrade(ctx, packet.GetSourcePort(), packet.GetSourceChannel()); found { - timeout := counterpartyUpgrade.Timeout - selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(ctx.BlockTime().UnixNano()) - - if timeout.Elapsed(selfHeight, selfTimestamp) { - // packet flushing timeout has expired, abort the upgrade - // committing an error receipt to state, deleting upgrade information and restoring the channel. - k.Logger(ctx).Info("upgrade aborted", "port_id", packet.GetSourcePort(), "channel_id", packet.GetSourceChannel(), "upgrade_sequence", channel.UpgradeSequence) - k.MustAbortUpgrade(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp)) - } else if !k.HasInflightPackets(ctx, packet.GetSourcePort(), packet.GetSourceChannel()) { - // set the channel state to flush complete if all packets have been acknowledged/flushed. - channel.State = types.FLUSHCOMPLETE - k.SetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), channel) - emitChannelFlushCompleteEvent(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), channel) - } - } -} diff --git a/modules/core/04-channel/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index 75f44b2e5bc..1f3d4ed8edc 100644 --- a/modules/core/04-channel/keeper/packet_test.go +++ b/modules/core/04-channel/keeper/packet_test.go @@ -5,8 +5,6 @@ import ( errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - abci "github.com/cometbft/cometbft/abci/types" clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" @@ -193,32 +191,6 @@ func (suite *KeeperTestSuite) TestSendPacket() { types.NewChannel(types.OPEN, types.ORDERED, types.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID), []string{path.EndpointA.ConnectionID}, path.EndpointA.ChannelConfig.Version), ) }, errorsmod.Wrap(types.ErrSequenceSendNotFound, "")}, - { - "channel is in FLUSH_COMPLETE state", - func() { - path.Setup() - sourceChannel = path.EndpointA.ChannelID - - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHCOMPLETE }) - }, - types.ErrInvalidChannelState, - }, - { - "channel is in FLUSHING state", - func() { - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - - err := path.EndpointB.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeTry() - suite.Require().NoError(err) - }, - types.ErrChannelNotFound, - }, } for i, tc := range testCases { @@ -293,32 +265,6 @@ func (suite *KeeperTestSuite) TestRecvPacket() { }, nil, }, - { - "success UNORDERED channel in FLUSHING", - func() { - // setup uses an UNORDERED channel - path.Setup() - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - - sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - }, - nil, - }, - { - "success UNORDERED channel in FLUSHCOMPLETE", - func() { - // setup uses an UNORDERED channel - path.Setup() - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHCOMPLETE }) - - sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - }, - nil, - }, { "success with out of order packet: UNORDERED channel", func() { @@ -334,53 +280,6 @@ func (suite *KeeperTestSuite) TestRecvPacket() { }, nil, }, - { - "success with counterpartyNextSequenceSend higher than packet sequence", - func() { - path.Setup() - sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - - // set upgrade next sequence send to sequence + 1 - counterpartyUpgrade := types.Upgrade{NextSequenceSend: sequence + 1} - path.EndpointB.SetChannelCounterpartyUpgrade(counterpartyUpgrade) - }, - nil, - }, - { - "success with counterparty upgrade not found", - func() { - path.Setup() - sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - }, - nil, - }, - { - "failure while upgrading channel, packet sequence ≥ counterparty next send sequence", - func() { - path.Setup() - // send 2 packets so that when NextSequenceSend is set to sequence - 1, it is not 0. - _, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - - // set upgrade next sequence send to sequence - 1 - counterpartyUpgrade := types.Upgrade{NextSequenceSend: sequence - 1} - path.EndpointB.SetChannelCounterpartyUpgrade(counterpartyUpgrade) - }, - types.ErrInvalidPacket, - }, { "packet already relayed ORDERED channel (no-op)", func() { @@ -639,28 +538,6 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { }, nil, }, - { - "success: channel flushing", - func() { - path.Setup() - packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - ack = ibcmock.MockAcknowledgement - - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - }, - nil, - }, - { - "success: channel flush complete", - func() { - path.Setup() - packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - ack = ibcmock.MockAcknowledgement - - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHCOMPLETE }) - }, - nil, - }, {"channel not found", func() { // use wrong channel naming path.Setup() @@ -815,135 +692,6 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { }, expResult: assertSuccess(func() uint64 { return uint64(1) }, "sequence incremented for UNORDERED channel"), }, - { - name: "success on channel in flushing state", - malleate: func() { - // setup uses an UNORDERED channel - path.Setup() - - // create packet commitment - sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - - // create packet receipt and acknowledgement - packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - err = path.EndpointB.RecvPacket(packet) - suite.Require().NoError(err) - - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - }, - expResult: func(commitment []byte, channelVersion string, err error) { - suite.Require().NoError(err) - suite.Require().Nil(commitment) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(types.FLUSHING, channel.State) - suite.Require().Equal(channel.Version, channelVersion) - - nextSequenceAck, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceAck(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel()) - suite.Require().True(found) - suite.Require().Equal(uint64(1), nextSequenceAck, "sequence incremented for UNORDERED channel") - }, - }, - { - name: "success on channel in flushing state with valid timeout", - malleate: func() { - // setup uses an UNORDERED channel - path.Setup() - - // create packet commitment - sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - - // create packet receipt and acknowledgement - packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - err = path.EndpointB.RecvPacket(packet) - suite.Require().NoError(err) - - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - - counterpartyUpgrade := types.Upgrade{ - Timeout: types.NewTimeout(suite.chainB.GetTimeoutHeight(), 0), - } - - path.EndpointA.SetChannelCounterpartyUpgrade(counterpartyUpgrade) - }, - expResult: func(commitment []byte, channelVersion string, err error) { - suite.Require().NoError(err) - suite.Require().Nil(commitment) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(types.FLUSHCOMPLETE, channel.State) - suite.Require().Equal(channel.Version, channelVersion) - - nextSequenceAck, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceAck(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel()) - suite.Require().True(found) - suite.Require().Equal(uint64(1), nextSequenceAck, "sequence incremented for UNORDERED channel") - }, - expEvents: func(path *ibctesting.Path) []abci.Event { - return sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelFlushComplete, - sdk.NewAttribute(types.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(types.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(types.AttributeKeyChannelState, path.EndpointA.GetChannel().State.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }.ToABCIEvents() - }, - }, - { - name: "success on channel in flushing state with timeout passed", - malleate: func() { - // setup uses an UNORDERED channel - path.Setup() - - // create packet commitment - sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - - // create packet receipt and acknowledgement - packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - err = path.EndpointB.RecvPacket(packet) - suite.Require().NoError(err) - - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - - upgrade := types.Upgrade{ - Fields: types.NewUpgradeFields(types.UNORDERED, []string{ibctesting.FirstConnectionID}, ibcmock.UpgradeVersion), - Timeout: types.NewTimeout(clienttypes.ZeroHeight(), 1), - } - - counterpartyUpgrade := types.Upgrade{ - Fields: types.NewUpgradeFields(types.UNORDERED, []string{ibctesting.FirstConnectionID}, ibcmock.UpgradeVersion), - Timeout: types.NewTimeout(clienttypes.ZeroHeight(), 1), - } - - path.EndpointA.SetChannelUpgrade(upgrade) - path.EndpointA.SetChannelCounterpartyUpgrade(counterpartyUpgrade) - }, - expResult: func(commitment []byte, channelVersion string, err error) { - suite.Require().NoError(err) - suite.Require().Nil(commitment) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(types.OPEN, channel.State) - suite.Require().Equal(channel.Version, channelVersion) - - nextSequenceAck, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceAck(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel()) - suite.Require().True(found) - suite.Require().Equal(uint64(1), nextSequenceAck, "sequence incremented for UNORDERED channel") - - errorReceipt, found := path.EndpointA.Chain.App.GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().NotEmpty(errorReceipt) - }, - }, { name: "packet already acknowledged ordered channel (no-op)", malleate: func() { @@ -1013,21 +761,6 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { }, expResult: assertErr(types.ErrInvalidChannelState), }, - { - name: "channel in flush complete state", - malleate: func() { - path.Setup() - packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHCOMPLETE }) - }, - expResult: func(commitment []byte, channelVersion string, err error) { - suite.Require().Error(err) - suite.Require().ErrorIs(err, types.ErrInvalidChannelState) - suite.Require().Nil(commitment) - suite.Require().Equal("", channelVersion) - }, - }, { name: "packet destination port ≠ channel counterparty port", malleate: func() { diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index 0fa996f7658..37eb052eacd 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -123,9 +123,6 @@ func (k *Keeper) TimeoutPacket( // timeoutExecuted deletes the commitment send from this chain after it verifies timeout. // If the timed-out packet came from an ORDERED channel then this channel will be closed. -// If the channel is in the FLUSHING state and there is a counterparty upgrade, then the -// upgrade will be aborted if the upgrade has timed out. Otherwise, if there are no more inflight packets, -// then the channel will be set to the FLUSHCOMPLETE state. // // CONTRACT: this function must be called in the IBC handler func (k *Keeper) timeoutExecuted( @@ -135,24 +132,8 @@ func (k *Keeper) timeoutExecuted( ) error { k.deletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - // if an upgrade is in progress, handling packet flushing and update channel state appropriately - if channel.State == types.FLUSHING && channel.Ordering == types.UNORDERED { - k.handleFlushState(ctx, packet, channel) - } - if channel.Ordering == types.ORDERED { - // NOTE: if the channel is ORDERED and a packet is timed out in FLUSHING state then - // all upgrade information is deleted and the channel is set to CLOSED. - if channel.State == types.FLUSHING { - k.deleteUpgradeInfo(ctx, packet.GetSourcePort(), packet.GetSourceChannel()) - k.Logger(ctx).Info( - "upgrade info deleted", - "port_id", packet.GetSourcePort(), - "channel_id", packet.GetSourceChannel(), - "upgrade_sequence", channel.UpgradeSequence, - ) - } - + // Close the channel since the packet timed-out and the channel is ORDERED channel.State = types.CLOSED k.SetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), channel) emitChannelClosedEvent(ctx, packet, channel) @@ -183,7 +164,6 @@ func (k *Keeper) TimeoutOnClose( closedProof []byte, proofHeight exported.Height, nextSequenceRecv uint64, - counterpartyUpgradeSequence uint64, ) (string, error) { channel, found := k.GetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel()) if !found { @@ -231,12 +211,11 @@ func (k *Keeper) TimeoutOnClose( counterparty := types.NewCounterparty(packet.GetSourcePort(), packet.GetSourceChannel()) expectedChannel := types.Channel{ - State: types.CLOSED, - Ordering: channel.Ordering, - Counterparty: counterparty, - ConnectionHops: counterpartyHops, - Version: channel.Version, - UpgradeSequence: counterpartyUpgradeSequence, + State: types.CLOSED, + Ordering: channel.Ordering, + Counterparty: counterparty, + ConnectionHops: counterpartyHops, + Version: channel.Version, } // check that the opposing channel end has closed diff --git a/modules/core/04-channel/keeper/timeout_test.go b/modules/core/04-channel/keeper/timeout_test.go index b264b94fcdc..3de41970409 100644 --- a/modules/core/04-channel/keeper/timeout_test.go +++ b/modules/core/04-channel/keeper/timeout_test.go @@ -6,8 +6,6 @@ import ( errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - abci "github.com/cometbft/cometbft/abci/types" clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" @@ -18,7 +16,6 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v10/modules/core/errors" "github.com/cosmos/ibc-go/v10/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v10/testing" - "github.com/cosmos/ibc-go/v10/testing/mock" ) // TestTimeoutPacket test the TimeoutPacket call on chainA by ensuring the timeout has passed @@ -279,194 +276,6 @@ func (suite *KeeperTestSuite) TestTimeoutExecuted() { }, nil, }, - { - "set to flush complete with no inflight packets", - func() { - path.Setup() - timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) - timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().UnixNano()) - packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) - - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - - path.EndpointA.SetChannelCounterpartyUpgrade(types.Upgrade{ - Timeout: types.NewTimeout(clienttypes.ZeroHeight(), uint64(suite.chainA.GetContext().BlockTime().UnixNano())+types.DefaultTimeout.Timestamp), - }) - }, - func(packetCommitment []byte, err error) { - suite.Require().NoError(err) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(types.FLUSHCOMPLETE, channel.State, "channel state should still be set to FLUSHCOMPLETE") - }, - func(path *ibctesting.Path) []abci.Event { - return sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelFlushComplete, - sdk.NewAttribute(types.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(types.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(types.AttributeKeyChannelState, path.EndpointA.GetChannel().State.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }.ToABCIEvents() - }, - }, - { - "conterparty upgrade timeout is invalid", - func() { - path.Setup() - - timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) - timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().UnixNano()) - - sequence, err := path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - - packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) - - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - }, - func(packetCommitment []byte, err error) { - suite.Require().NoError(err) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(types.FLUSHING, channel.State, "channel state should still be FLUSHING") - }, - nil, - }, - { - "conterparty upgrade timed out (abort)", - func() { - path.Setup() - - timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) - timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().UnixNano()) - - sequence, err := path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - - packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) - - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - - path.EndpointA.SetChannelUpgrade(types.Upgrade{ - Fields: path.EndpointA.GetProposedUpgrade().Fields, - Timeout: types.NewTimeout(clienttypes.ZeroHeight(), 1), - }) - path.EndpointA.SetChannelCounterpartyUpgrade(types.Upgrade{ - Timeout: types.NewTimeout(clienttypes.ZeroHeight(), 1), - }) - }, - func(packetCommitment []byte, err error) { - suite.Require().NoError(err) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(types.OPEN, channel.State, "channel state should still be OPEN") - - upgrade, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().False(found, "upgrade should not be present") - suite.Require().Equal(types.Upgrade{}, upgrade, "upgrade should be zero value") - - upgrade, found = suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetCounterpartyUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().False(found, "counterparty upgrade should not be present") - suite.Require().Equal(types.Upgrade{}, upgrade, "counterparty upgrade should be zero value") - - errorReceipt, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found, "error receipt should be present") - suite.Require().Equal(channel.UpgradeSequence, errorReceipt.Sequence, "error receipt sequence should be equal to channel upgrade sequence") - }, - nil, - }, - { - "conterparty upgrade has not timed out with in-flight packets", - func() { - path.Setup() - - timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) - timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().UnixNano()) - - // we are sending two packets here as one will be removed in TimeoutExecuted. This is to ensure that - // there is still an in-flight packet so that the channel remains in the flushing state. - _, err := path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - - sequence, err := path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - - packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) - - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - - path.EndpointA.SetChannelUpgrade(types.Upgrade{ - Fields: path.EndpointA.GetProposedUpgrade().Fields, - Timeout: types.NewTimeout(clienttypes.ZeroHeight(), uint64(suite.chainA.GetContext().BlockTime().UnixNano())+types.DefaultTimeout.Timestamp), - }) - path.EndpointA.SetChannelCounterpartyUpgrade(types.Upgrade{ - Timeout: types.NewTimeout(clienttypes.ZeroHeight(), uint64(suite.chainB.GetContext().BlockTime().UnixNano())+types.DefaultTimeout.Timestamp), - }) - }, - func(packetCommitment []byte, err error) { - suite.Require().NoError(err) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(types.FLUSHING, channel.State, "channel state should still be FLUSHING") - - _, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found, "upgrade should not be deleted") - - _, found = suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetCounterpartyUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found, "counterparty upgrade should not be deleted") - - _, found = suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().False(found, "error receipt should not be written") - }, - nil, - }, - { - "ordered channel is closed and upgrade is aborted when timeout is executed", - func() { - path.SetChannelOrdered() - path.Setup() - - timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) - timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().UnixNano()) - - sequence, err := path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - - packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) - - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - - path.EndpointA.SetChannelUpgrade(types.Upgrade{ - Fields: path.EndpointA.GetProposedUpgrade().Fields, - Timeout: types.NewTimeout(clienttypes.ZeroHeight(), 1), - }) - path.EndpointA.SetChannelCounterpartyUpgrade(types.Upgrade{ - Timeout: types.NewTimeout(clienttypes.ZeroHeight(), 1), - }) - }, - func(packetCommitment []byte, err error) { - suite.Require().NoError(err) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(types.CLOSED, channel.State, "channel state should be CLOSED") - - upgrade, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().False(found, "upgrade should not be present") - suite.Require().Equal(types.Upgrade{}, upgrade, "upgrade should be zero value") - - upgrade, found = suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetCounterpartyUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().False(found, "counterparty upgrade should not be present") - suite.Require().Equal(types.Upgrade{}, upgrade, "counterparty upgrade should be zero value") - }, - nil, - }, } for i, tc := range testCases { @@ -497,11 +306,10 @@ func (suite *KeeperTestSuite) TestTimeoutExecuted() { // channel on chainB after the packet commitment has been created. func (suite *KeeperTestSuite) TestTimeoutOnClose() { var ( - path *ibctesting.Path - packet types.Packet - nextSeqRecv uint64 - counterpartyUpgradeSequence uint64 - ordered bool + path *ibctesting.Path + packet types.Packet + nextSeqRecv uint64 + ordered bool ) testCases := []testCase{ @@ -629,32 +437,6 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) }, errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "")}, - { - "failure: invalid counterparty upgrade sequence", - func() { - ordered = false - path.Setup() - - timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) - - sequence, err := path.EndpointA.SendPacket(timeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - - // trigger upgradeInit on B which will bump the counterparty upgrade sequence. - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - err = path.EndpointB.ChanUpgradeInit() - suite.Require().NoError(err) - - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) - - // need to update chainA's client representing chainB to prove missing ack - err = path.EndpointA.UpdateClient() - suite.Require().NoError(err) - - packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) - }, - errorsmod.Wrap(commitmenttypes.ErrInvalidProof, ""), - }, } for i, tc := range testCases { @@ -662,9 +444,8 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.msg, i, len(testCases)), func() { var proof []byte - suite.SetupTest() // reset - nextSeqRecv = 1 // must be explicitly changed - counterpartyUpgradeSequence = 0 // must be explicitly changed + suite.SetupTest() // reset + nextSeqRecv = 1 // must be explicitly changed path = ibctesting.NewPath(suite.chainA, suite.chainB) tc.malleate() @@ -688,7 +469,6 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { closedProof, proofHeight, nextSeqRecv, - counterpartyUpgradeSequence, ) if tc.expErr == nil { diff --git a/modules/core/04-channel/keeper/upgrade.go b/modules/core/04-channel/keeper/upgrade.go deleted file mode 100644 index 1afad987f8b..00000000000 --- a/modules/core/04-channel/keeper/upgrade.go +++ /dev/null @@ -1,1053 +0,0 @@ -package keeper - -import ( - "fmt" - "reflect" - "slices" - - errorsmod "cosmossdk.io/errors" - - "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" - - clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" - connectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types" - "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" - commitmenttypes "github.com/cosmos/ibc-go/v10/modules/core/23-commitment/types" - "github.com/cosmos/ibc-go/v10/modules/core/exported" -) - -// ChanUpgradeInit is called by a module to initiate a channel upgrade handshake with -// a module on another chain. -func (k *Keeper) ChanUpgradeInit( - ctx sdk.Context, - portID string, - channelID string, - upgradeFields types.UpgradeFields, -) (types.Upgrade, error) { - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - return types.Upgrade{}, errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - - if channel.State != types.OPEN { - return types.Upgrade{}, errorsmod.Wrapf(types.ErrInvalidChannelState, "expected %s, got %s", types.OPEN, channel.State) - } - - if err := k.validateSelfUpgradeFields(ctx, upgradeFields, channel); err != nil { - return types.Upgrade{}, err - } - - // NOTE: the Upgrade returned here is intentionally not fully populated. The Timeout remains unset - // until the counterparty calls ChanUpgradeTry. - return types.Upgrade{Fields: upgradeFields}, nil -} - -// WriteUpgradeInitChannel writes a channel which has successfully passed the UpgradeInit handshake step. -// An event is emitted for the handshake step. -func (k *Keeper) WriteUpgradeInitChannel(ctx sdk.Context, portID, channelID string, upgrade types.Upgrade, upgradeVersion string) (types.Channel, types.Upgrade) { - defer telemetry.IncrCounter(1, "ibc", "channel", "upgrade-init") - - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - panic(fmt.Errorf("could not find existing channel when updating channel state in successful ChanUpgradeInit step, channelID: %s, portID: %s", channelID, portID)) - } - - if k.hasUpgrade(ctx, portID, channelID) { - // invalidating previous upgrade - k.deleteUpgradeInfo(ctx, portID, channelID) - k.WriteErrorReceipt(ctx, portID, channelID, types.NewUpgradeError(channel.UpgradeSequence, types.ErrInvalidUpgrade)) - } - - channel.UpgradeSequence++ - - upgrade.Fields.Version = upgradeVersion - - k.SetChannel(ctx, portID, channelID, channel) - k.SetUpgrade(ctx, portID, channelID, upgrade) - - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "state", channel.State, "upgrade-sequence", fmt.Sprintf("%d", channel.UpgradeSequence)) - - return channel, upgrade -} - -// ChanUpgradeTry is called by a module to accept the first step of a channel upgrade handshake initiated by -// a module on another chain. If this function is successful, the proposed upgrade will be returned. If the upgrade fails, the upgrade sequence will still be incremented but an error will be returned. -func (k *Keeper) ChanUpgradeTry( - ctx sdk.Context, - portID, - channelID string, - proposedConnectionHops []string, - counterpartyUpgradeFields types.UpgradeFields, - counterpartyUpgradeSequence uint64, - channelProof, - upgradeProof []byte, - proofHeight clienttypes.Height, -) (types.Channel, types.Upgrade, error) { - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - return types.Channel{}, types.Upgrade{}, errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - - if channel.State != types.OPEN { - return types.Channel{}, types.Upgrade{}, errorsmod.Wrapf(types.ErrInvalidChannelState, "expected %s, got %s", types.OPEN, channel.State) - } - - connection, found := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) - if !found { - return types.Channel{}, types.Upgrade{}, errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, channel.ConnectionHops[0]) - } - - if connection.State != connectiontypes.OPEN { - return types.Channel{}, types.Upgrade{}, errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connection.State) - } - - // construct expected counterparty channel from information in state - // only the counterpartyUpgradeSequence is provided by the relayer - counterpartyConnectionHops := []string{connection.Counterparty.ConnectionId} - counterpartyChannel := types.Channel{ - State: types.OPEN, - Ordering: channel.Ordering, - Counterparty: types.NewCounterparty(portID, channelID), - ConnectionHops: counterpartyConnectionHops, - Version: channel.Version, - UpgradeSequence: counterpartyUpgradeSequence, // provided by the relayer - } - - // verify the counterparty channel state containing the upgrade sequence - if err := k.connectionKeeper.VerifyChannelState( - ctx, - connection, - proofHeight, channelProof, - channel.Counterparty.PortId, - channel.Counterparty.ChannelId, - counterpartyChannel, - ); err != nil { - return types.Channel{}, types.Upgrade{}, errorsmod.Wrap(err, "failed to verify counterparty channel state") - } - - var ( - err error - upgrade types.Upgrade - isCrossingHello bool - expectedUpgradeSequence uint64 - ) - - upgrade, isCrossingHello = k.GetUpgrade(ctx, portID, channelID) - if isCrossingHello { - expectedUpgradeSequence = channel.UpgradeSequence - } else { - // at the end of the TRY step, the current upgrade sequence will be incremented in the non-crossing - // hello case due to calling chanUpgradeInit, we should use this expected upgrade sequence for - // sequence mismatch comparison - expectedUpgradeSequence = channel.UpgradeSequence + 1 - } - if counterpartyUpgradeSequence < expectedUpgradeSequence { - // In this case, the counterparty upgrade is outdated. We want to force the counterparty - // to abort their upgrade and come back to sync with our own upgrade sequence. - - // In the crossing hello case, we already have an upgrade but it is at a higher sequence than the counterparty. - // Thus, our upgrade should take priority. We force the counterparty to abort their upgrade by invalidating all counterparty - // upgrade attempts below our own sequence by setting errorReceipt to upgradeSequence - 1. - // Since our channel upgrade sequence was incremented in the previous step, the counterparty will be forced to abort their upgrade - // and we will be able to proceed with our own upgrade. - // The upgrade handshake may then proceed on the counterparty with our sequence - // In the non-crossing hello (i.e. upgrade does not exist on our side), - // the sequence on both sides should move to a fresh sequence on the next upgrade attempt. - // Thus, we write an error receipt with our own upgrade sequence which will cause the counterparty - // to cancel their upgrade and move to the same sequence. When a new upgrade attempt is started from either - // side, it will be a fresh sequence for both sides (i.e. channel.upgradeSequence + 1). - // Note that expectedUpgradeSequence - 1 == channel.UpgradeSequence in the non-crossing hello case. - - // NOTE: Two possible outcomes may occur in this scenario. - // The ChanUpgradeCancel datagram may reach the counterparty first, which will cause the counterparty to cancel. The counterparty - // may then receive a TRY with our channel upgrade sequence and correctly increment their sequence to become synced with our upgrade attempt. - // The ChanUpgradeTry message may arrive first, in this case, **IF** the upgrade fields are mutually compatible; the counterparty will simply - // fast forward their sequence to our own and continue the upgrade. The following ChanUpgradeCancel message will be rejected as it is below the current sequence. - - return channel, upgrade, types.NewUpgradeError(expectedUpgradeSequence-1, errorsmod.Wrapf( - types.ErrInvalidUpgradeSequence, "counterparty upgrade sequence < current upgrade sequence (%d < %d)", counterpartyUpgradeSequence, channel.UpgradeSequence, - )) - } - - // verifies the proof that a particular proposed upgrade has been stored in the upgrade path of the counterparty - if err := k.connectionKeeper.VerifyChannelUpgrade( - ctx, - connection, - proofHeight, upgradeProof, - channel.Counterparty.PortId, - channel.Counterparty.ChannelId, - types.NewUpgrade(counterpartyUpgradeFields, types.Timeout{}, 0), - ); err != nil { - return types.Channel{}, types.Upgrade{}, errorsmod.Wrap(err, "failed to verify counterparty upgrade") - } - - // construct counterpartyChannel from existing information and provided counterpartyUpgradeSequence - // create upgrade fields from counterparty proposed upgrade and own verified connection hops - proposedUpgradeFields := types.UpgradeFields{ - Ordering: counterpartyUpgradeFields.Ordering, - ConnectionHops: proposedConnectionHops, - Version: counterpartyUpgradeFields.Version, - } - - // NOTE: if an upgrade exists (crossing hellos) then use existing upgrade fields - // otherwise, run the upgrade init sub-protocol - if isCrossingHello { - proposedUpgradeFields = upgrade.Fields - } else { - // NOTE: OnChanUpgradeInit will not be executed by the application - upgrade, err = k.ChanUpgradeInit(ctx, portID, channelID, proposedUpgradeFields) - if err != nil { - return types.Channel{}, types.Upgrade{}, errorsmod.Wrap(err, "failed to initialize upgrade") - } - - channel, upgrade = k.WriteUpgradeInitChannel(ctx, portID, channelID, upgrade, upgrade.Fields.Version) - } - - if err := k.checkForUpgradeCompatibility(ctx, proposedUpgradeFields, counterpartyUpgradeFields); err != nil { - return types.Channel{}, types.Upgrade{}, errorsmod.Wrap(err, "failed upgrade compatibility check") - } - - // if the counterparty sequence is greater than the current sequence, we fast-forward to the counterparty sequence. - if counterpartyUpgradeSequence > channel.UpgradeSequence { - channel.UpgradeSequence = counterpartyUpgradeSequence - k.SetChannel(ctx, portID, channelID, channel) - } - - if err := k.startFlushing(ctx, portID, channelID, &upgrade); err != nil { - return types.Channel{}, types.Upgrade{}, err - } - - return channel, upgrade, nil -} - -// WriteUpgradeTryChannel writes the channel end and upgrade to state after successfully passing the UpgradeTry handshake step. -// An event is emitted for the handshake step. -func (k *Keeper) WriteUpgradeTryChannel(ctx sdk.Context, portID, channelID string, upgrade types.Upgrade, upgradeVersion string) (types.Channel, types.Upgrade) { - defer telemetry.IncrCounter(1, "ibc", "channel", "upgrade-try") - - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - panic(fmt.Errorf("could not find existing channel when updating channel state in successful ChanUpgradeTry step, channelID: %s, portID: %s", channelID, portID)) - } - - upgrade.Fields.Version = upgradeVersion - k.SetUpgrade(ctx, portID, channelID, upgrade) - - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", types.OPEN, "new-state", channel.State) - - return channel, upgrade -} - -// ChanUpgradeAck is called by a module to accept the ACKUPGRADE handshake step of the channel upgrade protocol. -// This method should only be called by the IBC core msg server. -// This method will verify that the counterparty has called the ChanUpgradeTry handler. -// and that its own upgrade is compatible with the selected counterparty version. -// NOTE: the channel may be in either the OPEN or FLUSHING state. -// The channel may be in OPEN if we are in the happy path. -// -// A -> Init (OPEN), B -> Try (FLUSHING), A -> Ack (begins in OPEN) -// -// The channel may be in FLUSHING if we are in a crossing hellos situation. -// -// A -> Init (OPEN), B -> Init (OPEN) -> A -> Try (FLUSHING), B -> Try (FLUSHING), A -> Ack (begins in FLUSHING) -func (k *Keeper) ChanUpgradeAck( - ctx sdk.Context, - portID, - channelID string, - counterpartyUpgrade types.Upgrade, - channelProof, - upgradeProof []byte, - proofHeight clienttypes.Height, -) error { - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - - if !slices.Contains([]types.State{types.OPEN, types.FLUSHING}, channel.State) { - return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected one of [%s, %s], got %s", types.OPEN, types.FLUSHING, channel.State) - } - - connection, found := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) - if !found { - return errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, channel.ConnectionHops[0]) - } - - if connection.State != connectiontypes.OPEN { - return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connection.State) - } - - counterpartyHops := []string{connection.Counterparty.ConnectionId} - counterpartyChannel := types.Channel{ - State: types.FLUSHING, - Ordering: channel.Ordering, - ConnectionHops: counterpartyHops, - Counterparty: types.NewCounterparty(portID, channelID), - Version: channel.Version, - UpgradeSequence: channel.UpgradeSequence, - } - - // verify the counterparty channel state containing the upgrade sequence - if err := k.connectionKeeper.VerifyChannelState( - ctx, - connection, - proofHeight, channelProof, - channel.Counterparty.PortId, - channel.Counterparty.ChannelId, - counterpartyChannel, - ); err != nil { - return errorsmod.Wrap(err, "failed to verify counterparty channel state") - } - - // verifies the proof that a particular proposed upgrade has been stored in the upgrade path of the counterparty - if err := k.connectionKeeper.VerifyChannelUpgrade( - ctx, - connection, - proofHeight, upgradeProof, - channel.Counterparty.PortId, - channel.Counterparty.ChannelId, - counterpartyUpgrade, - ); err != nil { - return errorsmod.Wrap(err, "failed to verify counterparty upgrade") - } - - // if we have cancelled our upgrade after performing UpgradeInit - // or UpgradeTry, the lack of a stored upgrade will prevent us from - // continuing the upgrade handshake - upgrade, found := k.GetUpgrade(ctx, portID, channelID) - if !found { - return errorsmod.Wrapf(types.ErrUpgradeNotFound, "failed to retrieve channel upgrade: port ID (%s) channel ID (%s)", portID, channelID) - } - - // optimistically accept version that TRY chain proposes and pass this to callback for confirmation - // in the crossing hello case, we do not modify version that our TRY call returned and instead enforce - // that both TRY calls returned the same version. It is possible that this will fail in the OnChanUpgradeAck - // callback if the version is invalid. - if channel.State == types.OPEN { - upgrade.Fields.Version = counterpartyUpgrade.Fields.Version - } - - // if upgrades are not compatible by ACK step, then we restore the channel - if err := k.checkForUpgradeCompatibility(ctx, upgrade.Fields, counterpartyUpgrade.Fields); err != nil { - return types.NewUpgradeError(channel.UpgradeSequence, err) - } - - if channel.State == types.OPEN { - if err := k.startFlushing(ctx, portID, channelID, &upgrade); err != nil { - return err - } - } - - timeout := counterpartyUpgrade.Timeout - selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(ctx.BlockTime().UnixNano()) - - if timeout.Elapsed(selfHeight, selfTimestamp) { - return types.NewUpgradeError(channel.UpgradeSequence, errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "counterparty upgrade timeout elapsed")) - } - - return nil -} - -// WriteUpgradeAckChannel writes a channel which has successfully passed the UpgradeAck handshake step as well as -// setting the upgrade for that channel. -// An event is emitted for the handshake step. -func (k *Keeper) WriteUpgradeAckChannel(ctx sdk.Context, portID, channelID string, counterpartyUpgrade types.Upgrade) (types.Channel, types.Upgrade) { - defer telemetry.IncrCounter(1, "ibc", "channel", "upgrade-ack") - - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - panic(fmt.Errorf("could not find existing channel when updating channel state in successful ChanUpgradeAck step, channelID: %s, portID: %s", channelID, portID)) - } - - if !k.HasInflightPackets(ctx, portID, channelID) { - previousState := channel.State - channel.State = types.FLUSHCOMPLETE - k.SetChannel(ctx, portID, channelID, channel) - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", previousState, "new-state", channel.State) - } - - upgrade, found := k.GetUpgrade(ctx, portID, channelID) - if !found { - panic(fmt.Errorf("could not find existing upgrade when updating channel state in successful ChanUpgradeAck step, channelID: %s, portID: %s", channelID, portID)) - } - - upgrade.Fields.Version = counterpartyUpgrade.Fields.Version - - k.SetUpgrade(ctx, portID, channelID, upgrade) - k.SetCounterpartyUpgrade(ctx, portID, channelID, counterpartyUpgrade) - - return channel, upgrade -} - -// ChanUpgradeConfirm is called on the chain which is on FLUSHING after chanUpgradeAck is called on the counterparty. -// This will inform the TRY chain of the timeout set on ACK by the counterparty. If the timeout has already exceeded, we will write an error receipt and restore. -func (k *Keeper) ChanUpgradeConfirm( - ctx sdk.Context, - portID, - channelID string, - counterpartyChannelState types.State, - counterpartyUpgrade types.Upgrade, - channelProof, - upgradeProof []byte, - proofHeight clienttypes.Height, -) error { - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - - if channel.State != types.FLUSHING { - return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected %s, got %s", types.FLUSHING, channel.State) - } - - if !slices.Contains([]types.State{types.FLUSHING, types.FLUSHCOMPLETE}, counterpartyChannelState) { - return errorsmod.Wrapf(types.ErrInvalidCounterparty, "expected one of [%s, %s], got %s", types.FLUSHING, types.FLUSHCOMPLETE, counterpartyChannelState) - } - - connection, found := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) - if !found { - return errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, channel.ConnectionHops[0]) - } - - if connection.State != connectiontypes.OPEN { - return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connection.State) - } - - counterpartyHops := []string{connection.Counterparty.ConnectionId} - counterpartyChannel := types.Channel{ - State: counterpartyChannelState, - Ordering: channel.Ordering, - ConnectionHops: counterpartyHops, - Counterparty: types.NewCounterparty(portID, channelID), - Version: channel.Version, - UpgradeSequence: channel.UpgradeSequence, - } - - if err := k.connectionKeeper.VerifyChannelState( - ctx, - connection, - proofHeight, channelProof, - channel.Counterparty.PortId, - channel.Counterparty.ChannelId, - counterpartyChannel, - ); err != nil { - return errorsmod.Wrap(err, "failed to verify counterparty channel state") - } - - if err := k.connectionKeeper.VerifyChannelUpgrade( - ctx, - connection, - proofHeight, upgradeProof, - channel.Counterparty.PortId, - channel.Counterparty.ChannelId, - counterpartyUpgrade, - ); err != nil { - return errorsmod.Wrap(err, "failed to verify counterparty upgrade") - } - - // if we have cancelled our upgrade after performing UpgradeInit, - // UpgradeTry or UpgradeAck, the lack of a stored upgrade will prevent - // us from continuing the upgrade handshake - upgrade, found := k.GetUpgrade(ctx, portID, channelID) - if !found { - return errorsmod.Wrapf(types.ErrUpgradeNotFound, "failed to retrieve channel upgrade: port ID (%s) channel ID (%s)", portID, channelID) - } - - // in the crossing-hello case it is possible that both chains execute the - // INIT, TRY and CONFIRM steps without any of them executing ACK, therefore - // we also need to check that the upgrades are compatible on this step - if err := k.checkForUpgradeCompatibility(ctx, upgrade.Fields, counterpartyUpgrade.Fields); err != nil { - return types.NewUpgradeError(channel.UpgradeSequence, err) - } - - timeout := counterpartyUpgrade.Timeout - selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(ctx.BlockTime().UnixNano()) - - if timeout.Elapsed(selfHeight, selfTimestamp) { - return types.NewUpgradeError(channel.UpgradeSequence, errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "counterparty upgrade timeout elapsed")) - } - - return nil -} - -// WriteUpgradeConfirmChannel writes a channel which has successfully passed the ChanUpgradeConfirm handshake step. -// If the channel has no in-flight packets, its state is updated to indicate that flushing has completed. Otherwise, the counterparty upgrade is set -// and the channel state is left unchanged. -// An event is emitted for the handshake step. -func (k *Keeper) WriteUpgradeConfirmChannel(ctx sdk.Context, portID, channelID string, counterpartyUpgrade types.Upgrade) types.Channel { - defer telemetry.IncrCounter(1, "ibc", "channel", "upgrade-confirm") - - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - panic(fmt.Errorf("could not find existing channel when updating channel state in successful ChanUpgradeConfirm step, channelID: %s, portID: %s", channelID, portID)) - } - - if !k.HasInflightPackets(ctx, portID, channelID) { - previousState := channel.State - channel.State = types.FLUSHCOMPLETE - k.SetChannel(ctx, portID, channelID, channel) - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", previousState, "new-state", channel.State) - } - - k.SetCounterpartyUpgrade(ctx, portID, channelID, counterpartyUpgrade) - return channel -} - -// ChanUpgradeOpen is called by a module to complete the channel upgrade handshake and move the channel back to an OPEN state. -// This method should only be called after both channels have flushed any in-flight packets. -// This method should only be called directly by the core IBC message server. -func (k *Keeper) ChanUpgradeOpen( - ctx sdk.Context, - portID, - channelID string, - counterpartyChannelState types.State, - counterpartyUpgradeSequence uint64, - channelProof []byte, - proofHeight clienttypes.Height, -) error { - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - - if channel.State != types.FLUSHCOMPLETE { - return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected %s, got %s", types.FLUSHCOMPLETE, channel.State) - } - - connection, found := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) - if !found { - return errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, channel.ConnectionHops[0]) - } - - if connection.State != connectiontypes.OPEN { - return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connection.State) - } - - var counterpartyChannel types.Channel - switch counterpartyChannelState { - case types.OPEN: - upgrade, found := k.GetUpgrade(ctx, portID, channelID) - if !found { - return errorsmod.Wrapf(types.ErrUpgradeNotFound, "failed to retrieve channel upgrade: port ID (%s) channel ID (%s)", portID, channelID) - } - // If counterparty has reached OPEN, we must use the upgraded connection to verify the counterparty channel - upgradeConnection, found := k.connectionKeeper.GetConnection(ctx, upgrade.Fields.ConnectionHops[0]) - if !found { - return errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, upgrade.Fields.ConnectionHops[0]) - } - - if upgradeConnection.State != connectiontypes.OPEN { - return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", upgradeConnection.State) - } - - // The counterparty upgrade sequence must be greater than or equal to - // the channel upgrade sequence. It should normally be equivalent, but - // in the unlikely case a new upgrade is initiated after it reopens, - // then the upgrade sequence will be greater than our upgrade sequence. - if counterpartyUpgradeSequence < channel.UpgradeSequence { - return errorsmod.Wrapf(types.ErrInvalidUpgradeSequence, "counterparty channel upgrade sequence (%d) must be greater than or equal to current upgrade sequence (%d)", counterpartyUpgradeSequence, channel.UpgradeSequence) - } - - counterpartyChannel = types.Channel{ - State: types.OPEN, - Ordering: upgrade.Fields.Ordering, - ConnectionHops: []string{upgradeConnection.Counterparty.ConnectionId}, - Counterparty: types.NewCounterparty(portID, channelID), - Version: upgrade.Fields.Version, - UpgradeSequence: counterpartyUpgradeSequence, - } - - case types.FLUSHCOMPLETE: - counterpartyChannel = types.Channel{ - State: types.FLUSHCOMPLETE, - Ordering: channel.Ordering, - ConnectionHops: []string{connection.Counterparty.ConnectionId}, - Counterparty: types.NewCounterparty(portID, channelID), - Version: channel.Version, - UpgradeSequence: channel.UpgradeSequence, - } - - default: - return errorsmod.Wrapf(types.ErrInvalidCounterparty, "counterparty channel state must be one of [%s, %s], got %s", types.OPEN, types.FLUSHCOMPLETE, counterpartyChannelState) - } - - if err := k.connectionKeeper.VerifyChannelState( - ctx, - connection, - proofHeight, channelProof, - channel.Counterparty.PortId, - channel.Counterparty.ChannelId, - counterpartyChannel, - ); err != nil { - return errorsmod.Wrap(err, "failed to verify counterparty channel") - } - - return nil -} - -// WriteUpgradeOpenChannel writes the agreed upon upgrade fields to the channel, and sets the channel state back to OPEN. This can be called in one of two cases: -// - In the UpgradeConfirm step of the handshake if both sides have already flushed all in-flight packets. -// - In the UpgradeOpen step of the handshake. -func (k *Keeper) WriteUpgradeOpenChannel(ctx sdk.Context, portID, channelID string) types.Channel { - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - panic(fmt.Errorf("could not find existing channel when updating channel state, channelID: %s, portID: %s", channelID, portID)) - } - - upgrade, found := k.GetUpgrade(ctx, portID, channelID) - if !found { - panic(fmt.Errorf("could not find upgrade when updating channel state, channelID: %s, portID: %s", channelID, portID)) - } - - counterpartyUpgrade, found := k.GetCounterpartyUpgrade(ctx, portID, channelID) - if !found { - panic(fmt.Errorf("could not find counterparty upgrade when updating channel state, channelID: %s, portID: %s", channelID, portID)) - } - - // next seq recv and ack is used for ordered channels to verify the packet has been received/acked in the correct order - // this is no longer necessary if the channel is UNORDERED and should be reset to 1 - if channel.Ordering == types.ORDERED && upgrade.Fields.Ordering == types.UNORDERED { - k.SetNextSequenceRecv(ctx, portID, channelID, 1) - k.SetNextSequenceAck(ctx, portID, channelID, 1) - } - - // next seq recv and ack should updated when moving from UNORDERED to ORDERED using the counterparty NextSequenceSend as set just after blocking new packet sends. - // we can be sure that the next packet we are set to receive will be the first packet the counterparty sends after reopening. - // we can be sure that our next acknowledgement will be our first packet sent after upgrade, as the counterparty processed all sent packets after flushing completes. - if channel.Ordering == types.UNORDERED && upgrade.Fields.Ordering == types.ORDERED { - k.SetNextSequenceRecv(ctx, portID, channelID, counterpartyUpgrade.NextSequenceSend) - k.SetNextSequenceAck(ctx, portID, channelID, upgrade.NextSequenceSend) - } - - // Set the counterparty next sequence send as the recv start sequence. - // This will be the upper bound for pruning and it will allow for replay - // protection of historical packets. - k.setRecvStartSequence(ctx, portID, channelID, counterpartyUpgrade.NextSequenceSend) - - // First upgrade for this channel will set the pruning sequence to 1, the starting sequence for pruning. - // Subsequent upgrades will not modify the pruning sequence thereby allowing pruning to continue from the last - // pruned sequence. - if !k.HasPruningSequenceStart(ctx, portID, channelID) { - k.SetPruningSequenceStart(ctx, portID, channelID, 1) - } - - // Switch channel fields to upgrade fields and set channel state to OPEN - previousState := channel.State - channel.Ordering = upgrade.Fields.Ordering - channel.Version = upgrade.Fields.Version - channel.ConnectionHops = upgrade.Fields.ConnectionHops - channel.State = types.OPEN - - k.SetChannel(ctx, portID, channelID, channel) - - // delete state associated with upgrade which is no longer required. - k.deleteUpgradeInfo(ctx, portID, channelID) - - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", previousState, "new-state", types.OPEN) - return channel -} - -// ChanUpgradeCancel is called by the msg server to prove that an error receipt was written on the counterparty -// which constitutes a valid situation where the upgrade should be cancelled. An error is returned if sufficient evidence -// for cancelling the upgrade has not been provided. -func (k *Keeper) ChanUpgradeCancel(ctx sdk.Context, portID, channelID string, errorReceipt types.ErrorReceipt, errorReceiptProof []byte, proofHeight clienttypes.Height) error { - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - - _, found = k.GetUpgrade(ctx, portID, channelID) - if !found { - return errorsmod.Wrapf(types.ErrUpgradeNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - - // an error receipt proof must be provided. - if len(errorReceiptProof) == 0 { - return errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty error receipt proof unless the sender is authorized to cancel upgrades AND channel is not in FLUSHCOMPLETE") - } - - // REPLAY PROTECTION: The error receipt MUST have a sequence greater than or equal to the current upgrade sequence, - // except when the channel state is FLUSHCOMPLETE, in which case the sequences MUST match. This is required - // to guarantee that when a counterparty successfully completes an upgrade and moves to OPEN, this channel - // cannot cancel its upgrade. Without this strict sequence check, it would be possible for the counterparty - // to complete its upgrade, move to OPEN, initiate a new upgrade (and thus increment the upgrade sequence) and - // then cancel the new upgrade, all in the same block. This results in a valid error receipt being written at channel.UpgradeSequence + 1. - // The desired behaviour in this circumstance is for this channel to complete its current upgrade despite proof - // of an error receipt at a greater upgrade sequence - if channel.State == types.FLUSHCOMPLETE && errorReceipt.Sequence != channel.UpgradeSequence { - return errorsmod.Wrapf(types.ErrInvalidUpgradeSequence, "error receipt sequence (%d) must be equal to current upgrade sequence (%d) when the channel is in FLUSHCOMPLETE", errorReceipt.Sequence, channel.UpgradeSequence) - } - if errorReceipt.Sequence < channel.UpgradeSequence { - return errorsmod.Wrapf(types.ErrInvalidUpgradeSequence, "error receipt sequence (%d) must be greater than or equal to current upgrade sequence (%d)", errorReceipt.Sequence, channel.UpgradeSequence) - } - - // get underlying connection for proof verification - connection, found := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) - if !found { - return errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, channel.ConnectionHops[0]) - } - - if connection.State != connectiontypes.OPEN { - return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connection.State) - } - - if err := k.connectionKeeper.VerifyChannelUpgradeError( - ctx, - connection, - proofHeight, - errorReceiptProof, - channel.Counterparty.PortId, - channel.Counterparty.ChannelId, - errorReceipt, - ); err != nil { - return errorsmod.Wrap(err, "failed to verify counterparty error receipt") - } - - return nil -} - -// WriteUpgradeCancelChannel writes a channel which has canceled the upgrade process.Auxiliary upgrade state is -// also deleted. -func (k *Keeper) WriteUpgradeCancelChannel(ctx sdk.Context, portID, channelID string, sequence uint64) { - defer telemetry.IncrCounter(1, "ibc", "channel", "upgrade-cancel") - - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - panic(fmt.Errorf("could not find existing channel when updating channel state, channelID: %s, portID: %s", channelID, portID)) - } - - previousState := channel.State - - channel = k.restoreChannel(ctx, portID, channelID, sequence, channel) - k.WriteErrorReceipt(ctx, portID, channelID, types.NewUpgradeError(sequence, types.ErrInvalidUpgrade)) - - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", previousState, "new-state", types.OPEN) -} - -// ChanUpgradeTimeout times out an outstanding upgrade. -// This should be used by the initialising chain when the counterparty chain has not responded to an upgrade proposal within the specified timeout period. -func (k *Keeper) ChanUpgradeTimeout( - ctx sdk.Context, - portID, channelID string, - counterpartyChannel types.Channel, - counterpartyChannelProof []byte, - proofHeight exported.Height, -) error { - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - - if !slices.Contains([]types.State{types.FLUSHING, types.FLUSHCOMPLETE}, channel.State) { - return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected one of [%s, %s], got %s", types.FLUSHING, types.FLUSHCOMPLETE, channel.State) - } - - upgrade, found := k.GetUpgrade(ctx, portID, channelID) - if !found { - return errorsmod.Wrapf(types.ErrUpgradeNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - - connection, found := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) - if !found { - return errorsmod.Wrap( - connectiontypes.ErrConnectionNotFound, - channel.ConnectionHops[0], - ) - } - - if connection.State != connectiontypes.OPEN { - return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connection.State) - } - - proofTimestamp, err := k.clientKeeper.GetClientTimestampAtHeight(ctx, connection.ClientId, proofHeight) - if err != nil { - return err - } - - // proof must be from a height after timeout has elapsed. Either timeoutHeight or timeoutTimestamp must be defined. - // if timeoutHeight is defined and proof is from before timeout height, abort transaction - if !upgrade.Timeout.Elapsed(proofHeight.(clienttypes.Height), proofTimestamp) { - return errorsmod.Wrap(upgrade.Timeout.ErrTimeoutNotReached(proofHeight.(clienttypes.Height), proofTimestamp), "upgrade timeout not reached") - } - - // counterparty channel must be proved to still be in OPEN state or FLUSHING state. - if !slices.Contains([]types.State{types.OPEN, types.FLUSHING}, counterpartyChannel.State) { - return errorsmod.Wrapf(types.ErrInvalidCounterparty, "expected one of [%s, %s], got %s", types.OPEN, types.FLUSHING, counterpartyChannel.State) - } - - if counterpartyChannel.State == types.OPEN { - upgradeConnection, found := k.connectionKeeper.GetConnection(ctx, upgrade.Fields.ConnectionHops[0]) - if !found { - return errorsmod.Wrap( - connectiontypes.ErrConnectionNotFound, - upgrade.Fields.ConnectionHops[0], - ) - } - counterpartyHops := []string{upgradeConnection.Counterparty.ConnectionId} - - upgradeAlreadyComplete := upgrade.Fields.Version == counterpartyChannel.Version && upgrade.Fields.Ordering == counterpartyChannel.Ordering && upgrade.Fields.ConnectionHops[0] == counterpartyHops[0] - if upgradeAlreadyComplete { - // counterparty has already successfully upgraded so we cannot timeout - return errorsmod.Wrap(types.ErrUpgradeTimeoutFailed, "counterparty channel is already upgraded") - } - } - - if counterpartyChannel.UpgradeSequence < channel.UpgradeSequence { - return errorsmod.Wrapf(types.ErrInvalidUpgradeSequence, "counterparty channel upgrade sequence (%d) must be greater than or equal to current upgrade sequence (%d)", counterpartyChannel.UpgradeSequence, channel.UpgradeSequence) - } - - // NOTE: The counterpartyChannel upgrade fields are not checked in the case - // the counterpartyChannel is in FLUSHING. This is not required because - // we prove that the upgrade timeout has elapsed on the counterparty, - // thus no historical proofs can be submitted. It is not possible for the - // counterparty to have upgraded if they were in FLUSHING and the upgrade - // timeout elapsed. Do not make use of the relayer provided fields without - // verifying them. - - // verify the counterparty channel state - if err := k.connectionKeeper.VerifyChannelState( - ctx, - connection, - proofHeight, counterpartyChannelProof, - channel.Counterparty.PortId, - channel.Counterparty.ChannelId, - counterpartyChannel, - ); err != nil { - return errorsmod.Wrap(err, "failed to verify counterparty channel state") - } - - return nil -} - -// WriteUpgradeTimeoutChannel restores the channel state of an initialising chain in the event that the counterparty chain has passed the timeout set in ChanUpgradeInit to the state before the upgrade was proposed. -// Auxiliary upgrade state is also deleted. -// An event is emitted for the handshake step. -func (k *Keeper) WriteUpgradeTimeoutChannel( - ctx sdk.Context, - portID, channelID string, -) (types.Channel, types.Upgrade) { - defer telemetry.IncrCounter(1, "ibc", "channel", "upgrade-timeout") - - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - panic(fmt.Errorf("could not find existing channel when updating channel state in successful ChanUpgradeTimeout step, channelID: %s, portID: %s", channelID, portID)) - } - - upgrade, found := k.GetUpgrade(ctx, portID, channelID) - if !found { - panic(fmt.Errorf("could not find existing upgrade when cancelling channel upgrade, channelID: %s, portID: %s", channelID, portID)) - } - - channel = k.restoreChannel(ctx, portID, channelID, channel.UpgradeSequence, channel) - k.WriteErrorReceipt(ctx, portID, channelID, types.NewUpgradeError(channel.UpgradeSequence, types.ErrUpgradeTimeout)) - - k.Logger(ctx).Info("channel state restored", "port-id", portID, "channel-id", channelID) - - return channel, upgrade -} - -// startFlushing will set the upgrade last packet send and continue blocking the upgrade from continuing until all -// in-flight packets have been flushed. -func (k *Keeper) startFlushing(ctx sdk.Context, portID, channelID string, upgrade *types.Upgrade) error { - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - - connection, found := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) - if !found { - return errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, channel.ConnectionHops[0]) - } - - if connection.State != connectiontypes.OPEN { - return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connection.State) - } - - channel.State = types.FLUSHING - k.SetChannel(ctx, portID, channelID, channel) - - nextSequenceSend, found := k.GetNextSequenceSend(ctx, portID, channelID) - if !found { - return errorsmod.Wrapf(types.ErrSequenceSendNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - - upgrade.NextSequenceSend = nextSequenceSend - upgrade.Timeout = k.getAbsoluteUpgradeTimeout(ctx) - k.SetUpgrade(ctx, portID, channelID, *upgrade) - - return nil -} - -// getAbsoluteUpgradeTimeout returns the absolute timeout for the given upgrade. -func (k *Keeper) getAbsoluteUpgradeTimeout(ctx sdk.Context) types.Timeout { - upgradeTimeout := k.GetParams(ctx).UpgradeTimeout - return types.NewTimeout(clienttypes.ZeroHeight(), uint64(ctx.BlockTime().UnixNano())+upgradeTimeout.Timestamp) -} - -// checkForUpgradeCompatibility checks performs stateful validation of self upgrade fields relative to counterparty upgrade. -func (k *Keeper) checkForUpgradeCompatibility(ctx sdk.Context, upgradeFields, counterpartyUpgradeFields types.UpgradeFields) error { - // assert that both sides propose the same channel ordering - if upgradeFields.Ordering != counterpartyUpgradeFields.Ordering { - return errorsmod.Wrapf(types.ErrIncompatibleCounterpartyUpgrade, "expected upgrade ordering (%s) to match counterparty upgrade ordering (%s)", upgradeFields.Ordering, counterpartyUpgradeFields.Ordering) - } - - if upgradeFields.Version != counterpartyUpgradeFields.Version { - return errorsmod.Wrapf(types.ErrIncompatibleCounterpartyUpgrade, "expected upgrade version (%s) to match counterparty upgrade version (%s)", upgradeFields.Version, counterpartyUpgradeFields.Version) - } - - connection, found := k.connectionKeeper.GetConnection(ctx, upgradeFields.ConnectionHops[0]) - if !found { - // NOTE: this error is expected to be unreachable as the proposed upgrade connectionID should have been - // validated in the upgrade INIT and TRY handlers - return errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, upgradeFields.ConnectionHops[0]) - } - - if connection.State != connectiontypes.OPEN { - // NOTE: this error is expected to be unreachable as the proposed upgrade connectionID should have been - // validated in the upgrade INIT and TRY handlers - return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "expected proposed connection to be OPEN (got %s)", connection.State) - } - - // connectionHops can change in a channelUpgrade, however both sides must still be each other's counterparty. - if counterpartyUpgradeFields.ConnectionHops[0] != connection.Counterparty.ConnectionId { - return errorsmod.Wrapf( - types.ErrIncompatibleCounterpartyUpgrade, "counterparty upgrade connection end is not a counterparty of self proposed connection end (%s != %s)", counterpartyUpgradeFields.ConnectionHops[0], connection.Counterparty.ConnectionId) - } - - return nil -} - -// validateSelfUpgradeFields validates the proposed upgrade fields against the existing channel. -// It returns an error if the following constraints are not met: -// - there exists at least one valid proposed change to the existing channel fields -// - the proposed connection hops do not exist -// - the proposed version is non-empty (checked in UpgradeFields.ValidateBasic()) -// - the proposed connection hops are not open -func (k *Keeper) validateSelfUpgradeFields(ctx sdk.Context, proposedUpgrade types.UpgradeFields, channel types.Channel) error { - currentFields := extractUpgradeFields(channel) - - if reflect.DeepEqual(proposedUpgrade, currentFields) { - return errorsmod.Wrapf(types.ErrInvalidUpgrade, "existing channel end is identical to proposed upgrade channel end: got %s", proposedUpgrade) - } - - connectionID := proposedUpgrade.ConnectionHops[0] - connection, found := k.connectionKeeper.GetConnection(ctx, connectionID) - if !found { - return errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "failed to retrieve connection: %s", connectionID) - } - - if connection.State != connectiontypes.OPEN { - return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connection.State) - } - - getVersions := connection.Versions - if len(getVersions) != 1 { - return errorsmod.Wrapf( - connectiontypes.ErrInvalidVersion, - "single version must be negotiated on connection before opening channel, got: %v", - getVersions, - ) - } - - if !connectiontypes.VerifySupportedFeature(getVersions[0], proposedUpgrade.Ordering.String()) { - return errorsmod.Wrapf( - connectiontypes.ErrInvalidVersion, - "connection version %s does not support channel ordering: %s", - getVersions[0], proposedUpgrade.Ordering.String(), - ) - } - - return nil -} - -// extractUpgradeFields returns the upgrade fields from the provided channel. -func extractUpgradeFields(channel types.Channel) types.UpgradeFields { - return types.UpgradeFields{ - Ordering: channel.Ordering, - ConnectionHops: channel.ConnectionHops, - Version: channel.Version, - } -} - -// MustAbortUpgrade will restore the channel state to its pre-upgrade state so that upgrade is aborted. -// Any unnecessary state is deleted and an error receipt is written. -// This function is expected to always succeed, a panic will occur if an error occurs. -func (k *Keeper) MustAbortUpgrade(ctx sdk.Context, portID, channelID string, err error) { - if err := k.abortUpgrade(ctx, portID, channelID, err); err != nil { - panic(err) - } -} - -// abortUpgrade will restore the channel state to its pre-upgrade state so that upgrade is aborted. -// All upgrade information associated with the upgrade attempt is deleted and an upgrade error -// receipt is written for that upgrade attempt. This prevents the upgrade handshake from continuing -// on our side and provides proof for the counterparty to safely abort the upgrade. -func (k *Keeper) abortUpgrade(ctx sdk.Context, portID, channelID string, err error) error { - if err == nil { - return errorsmod.Wrap(types.ErrInvalidUpgradeError, "cannot abort upgrade handshake with nil error") - } - - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) - } - - // in the case of application callbacks, the error may not be an upgrade error. - // in this case we need to construct one in order to write the error receipt. - upgradeError, ok := err.(*types.UpgradeError) - if !ok { - upgradeError = types.NewUpgradeError(channel.UpgradeSequence, err) - } - - // the channel upgrade sequence has already been updated in ChannelUpgradeTry, so we can pass - // its updated value. - k.restoreChannel(ctx, portID, channelID, channel.UpgradeSequence, channel) - k.WriteErrorReceipt(ctx, portID, channelID, upgradeError) - - return nil -} - -// restoreChannel will restore the channel state to its pre-upgrade state so that upgrade is aborted. -// When an upgrade attempt is aborted, the upgrade information must be deleted. This prevents us -// from continuing an upgrade handshake after we cancel an upgrade attempt. -func (k *Keeper) restoreChannel(ctx sdk.Context, portID, channelID string, upgradeSequence uint64, channel types.Channel) types.Channel { - channel.State = types.OPEN - channel.UpgradeSequence = upgradeSequence - - k.SetChannel(ctx, portID, channelID, channel) - - // delete state associated with upgrade which is no longer required. - k.deleteUpgradeInfo(ctx, portID, channelID) - - return channel -} - -// WriteErrorReceipt will write an error receipt from the provided UpgradeError. -func (k *Keeper) WriteErrorReceipt(ctx sdk.Context, portID, channelID string, upgradeError *types.UpgradeError) { - channel, found := k.GetChannel(ctx, portID, channelID) - if !found { - panic(errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID)) - } - - errorReceiptToWrite := upgradeError.GetErrorReceipt() - - existingErrorReceipt, found := k.GetUpgradeErrorReceipt(ctx, portID, channelID) - if found && existingErrorReceipt.Sequence >= errorReceiptToWrite.Sequence { - panic(errorsmod.Wrapf(types.ErrInvalidUpgradeSequence, "error receipt sequence (%d) must be greater than existing error receipt sequence (%d)", errorReceiptToWrite.Sequence, existingErrorReceipt.Sequence)) - } - - // Ensure that no upgrade attempt exists for the same sequence we are - // writing an error receipt for. This could lead to divergent behaviour - // on the counterparty. - if channel.UpgradeSequence <= errorReceiptToWrite.Sequence { - upgradeFound := k.hasUpgrade(ctx, portID, channelID) - counterpartyUpgradeFound := k.hasCounterpartyUpgrade(ctx, portID, channelID) - if upgradeFound || counterpartyUpgradeFound { - panic(errorsmod.Wrapf(types.ErrInvalidUpgradeSequence, "attempting to write error receipt at sequence (%d) while upgrade information exists at the same sequence", errorReceiptToWrite.Sequence)) - } - } - - k.setUpgradeErrorReceipt(ctx, portID, channelID, errorReceiptToWrite) - EmitErrorReceiptEvent(ctx, portID, channelID, channel, upgradeError) -} diff --git a/modules/core/04-channel/keeper/upgrade_test.go b/modules/core/04-channel/keeper/upgrade_test.go deleted file mode 100644 index dec4471d105..00000000000 --- a/modules/core/04-channel/keeper/upgrade_test.go +++ /dev/null @@ -1,2779 +0,0 @@ -package keeper_test - -import ( - "fmt" - "math" - "testing" - - errorsmod "cosmossdk.io/errors" - - clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" - connectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types" - channelkeeper "github.com/cosmos/ibc-go/v10/modules/core/04-channel/keeper" - "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" - commitmenttypes "github.com/cosmos/ibc-go/v10/modules/core/23-commitment/types" - host "github.com/cosmos/ibc-go/v10/modules/core/24-host" - "github.com/cosmos/ibc-go/v10/modules/core/exported" - ibctesting "github.com/cosmos/ibc-go/v10/testing" - "github.com/cosmos/ibc-go/v10/testing/mock" -) - -func (suite *KeeperTestSuite) TestChanUpgradeInit() { - var ( - path *ibctesting.Path - expSequence uint64 - upgradeFields types.UpgradeFields - ) - - testCases := []struct { - name string - malleate func() - expErr error - }{ - { - "success", - func() {}, - nil, - }, - { - "success with later upgrade sequence", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 4 }) - expSequence = 5 - }, - nil, - }, - { - "upgrade fields are identical to channel end", - func() { - channel := path.EndpointA.GetChannel() - upgradeFields = types.NewUpgradeFields(channel.Ordering, channel.ConnectionHops, channel.Version) - }, - errorsmod.Wrapf(types.ErrInvalidUpgrade, "existing channel end is identical to proposed upgrade channel end: got {ORDER_UNORDERED [connection-0] mock-version}"), - }, - { - "channel not found", - func() { - path.EndpointA.ChannelID = "invalid-channel" - path.EndpointA.ChannelConfig.PortID = "invalid-port" - }, - errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (invalid-port) channel ID (invalid-channel)"), - }, - { - "channel state is not in OPEN state", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) - }, - errorsmod.Wrapf(types.ErrInvalidChannelState, "expected STATE_OPEN, got STATE_CLOSED"), - }, - { - "proposed channel connection not found", - func() { - upgradeFields.ConnectionHops = []string{"connection-100"} - }, - errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "failed to retrieve connection: connection-100"), - }, - { - "invalid proposed channel connection state", - func() { - path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.State = connectiontypes.UNINITIALIZED }) - upgradeFields.ConnectionHops = []string{"connection-100"} - }, - errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "failed to retrieve connection: connection-100"), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - expSequence = 1 - - upgradeFields = types.NewUpgradeFields(types.UNORDERED, []string{path.EndpointA.ConnectionID}, mock.UpgradeVersion) - - tc.malleate() - - upgrade, err := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeInit( - suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgradeFields, - ) - - if tc.expErr == nil { - ctx := suite.chainA.GetContext() - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteUpgradeInitChannel(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgrade, upgrade.Fields.Version) - channel := path.EndpointA.GetChannel() - - suite.Require().NoError(err) - suite.Require().Equal(expSequence, channel.UpgradeSequence) - suite.Require().Equal(mock.Version, channel.Version) - suite.Require().Equal(types.OPEN, channel.State) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expErr) - } - }) - } -} - -func (suite *KeeperTestSuite) TestChanUpgradeTry() { - var ( - path *ibctesting.Path - proposedUpgrade types.Upgrade - counterpartyUpgrade types.Upgrade - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "success: crossing hellos", - func() { - err := path.EndpointB.ChanUpgradeInit() - suite.Require().NoError(err) - }, - nil, - }, - { - "success: upgrade sequence is fast forwarded to counterparty upgrade sequence", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 5 }) - }, - nil, - }, - { - "channel not found", - func() { - path.EndpointB.ChannelID = ibctesting.InvalidID - }, - types.ErrChannelNotFound, - }, - { - "channel state is not in OPEN state", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) - }, - types.ErrInvalidChannelState, - }, - { - "connection not found", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.ConnectionHops = []string{"connection-100"} }) - }, - connectiontypes.ErrConnectionNotFound, - }, - { - "invalid connection state", - func() { - path.EndpointB.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.State = connectiontypes.UNINITIALIZED }) - }, - connectiontypes.ErrInvalidConnectionState, - }, - { - "initializing handshake fails, proposed connection hops do not exist", - func() { - proposedUpgrade.Fields.ConnectionHops = []string{ibctesting.InvalidID} - }, - connectiontypes.ErrConnectionNotFound, - }, - { - "fails due to proof verification failure, counterparty channel ordering does not match expected ordering", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.Ordering = types.ORDERED }) - }, - commitmenttypes.ErrInvalidProof, - }, - { - "fails due to proof verification failure, counterparty upgrade connection hops are tampered with", - func() { - counterpartyUpgrade.Fields.ConnectionHops = []string{ibctesting.InvalidID} - }, - commitmenttypes.ErrInvalidProof, - }, - { - "fails due to incompatible upgrades, chainB proposes a new connection hop that does not match counterparty", - func() { - // reuse existing connection to create a new connection in a non OPEN state - connection := path.EndpointB.GetConnection() - // ensure counterparty connectionID does not match connectionID set in counterparty proposed upgrade - connection.Counterparty.ConnectionId = "connection-50" - - // set proposed connection in state - proposedConnectionID := "connection-100" //nolint:goconst - suite.chainB.GetSimApp().GetIBCKeeper().ConnectionKeeper.SetConnection(suite.chainB.GetContext(), proposedConnectionID, connection) - proposedUpgrade.Fields.ConnectionHops[0] = proposedConnectionID - }, - types.ErrIncompatibleCounterpartyUpgrade, - }, - { - "fails due to mismatch in upgrade sequences", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 5 }) - }, - // channel sequence will be returned so that counterparty inits on completely fresh sequence for both sides - types.NewUpgradeError(5, types.ErrInvalidUpgradeSequence), - }, - { - "fails due to mismatch in upgrade sequences: chainB is on incremented sequence without an upgrade indicating it has already processed upgrade at this sequence.", - func() { - errorReceipt := types.NewUpgradeError(1, types.ErrInvalidUpgrade) - suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.WriteErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, errorReceipt) - - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 1 }) - }, - types.NewUpgradeError(1, types.ErrInvalidUpgradeSequence), - }, - { - "fails due to mismatch in upgrade sequences, crossing hello with the TRY chain having a higher sequence", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 4 }) - - // upgrade sequence is 5 after this call - err := path.EndpointB.ChanUpgradeInit() - suite.Require().NoError(err) - }, - types.NewUpgradeError(4, types.ErrInvalidUpgradeSequence), - }, - { - // ChainA(Sequence: 0, mock-version-v2), ChainB(Sequence: 0, mock-version-v3) - // ChainA.INIT(Sequence: 1) - // ChainB.INIT(Sequence: 1) - // ChainA.TRY => error (incompatible versions) - // ChainB.TRY => error (incompatible versions) - "crossing hellos: fails due to incompatible version", - func() { - // use incompatible version - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = fmt.Sprintf("%s-v3", mock.Version) - proposedUpgrade = path.EndpointB.GetProposedUpgrade() - - err := path.EndpointB.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeTry() - suite.Require().Error(err) - suite.Require().ErrorContains(err, "incompatible counterparty upgrade") - suite.Require().Equal(uint64(1), path.EndpointA.GetChannel().UpgradeSequence) - }, - types.ErrIncompatibleCounterpartyUpgrade, - }, - { - // ChainA(Sequence: 0, mock-version-v2), ChainB(Sequence: 4, mock-version-v3) - // ChainA.INIT(Sequence: 1) - // ChainB.INIT(Sequence: 5) - // ChainA.TRY => error (incompatible versions) - // ChainB.TRY(ErrorReceipt: 4) - "crossing hellos: upgrade starts with mismatching upgrade sequences and try fails on counterparty due to incompatible version", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 4 }) - - // use incompatible version - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = fmt.Sprintf("%s-v3", mock.Version) - proposedUpgrade = path.EndpointB.GetProposedUpgrade() - - err := path.EndpointB.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeTry() - suite.Require().Error(err) - suite.Require().ErrorContains(err, "incompatible counterparty upgrade") - suite.Require().Equal(uint64(1), path.EndpointA.GetChannel().UpgradeSequence) - }, - types.NewUpgradeError(4, types.ErrInvalidUpgradeSequence), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - proposedUpgrade = path.EndpointB.GetProposedUpgrade() - - var found bool - counterpartyUpgrade, found = path.EndpointA.Chain.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgrade(path.EndpointA.Chain.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - - tc.malleate() - - // ensure clients are up to date to receive valid proofs - suite.Require().NoError(path.EndpointB.UpdateClient()) - - channelProof, upgradeProof, proofHeight := path.EndpointA.QueryChannelUpgradeProof() - - _, upgrade, err := suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeTry( - suite.chainB.GetContext(), - path.EndpointB.ChannelConfig.PortID, - path.EndpointB.ChannelID, - proposedUpgrade.Fields.ConnectionHops, - counterpartyUpgrade.Fields, - path.EndpointA.GetChannel().UpgradeSequence, - channelProof, - upgradeProof, - proofHeight, - ) - - if tc.expError == nil { - suite.Require().NoError(err) - suite.Require().NotEmpty(upgrade) - suite.Require().Equal(proposedUpgrade.Fields, upgrade.Fields) - - channel := path.EndpointB.GetChannel() - suite.Require().Equal(types.FLUSHING, channel.State) - - nextSequenceSend, found := path.EndpointB.Chain.GetSimApp().IBCKeeper.ChannelKeeper.GetNextSequenceSend(path.EndpointB.Chain.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(found) - suite.Require().Equal(nextSequenceSend, upgrade.NextSequenceSend) - } else { - suite.assertUpgradeError(err, tc.expError) - } - }) - } -} - -// TestChanUpgrade_CrossingHellos_UpgradeSucceeds_AfterCancel verifies that under crossing hellos if upgrade -// sequences become out of sync, the upgrade can still be performed successfully after the upgrade is cancelled. -// ChainA(Sequence: 0), ChainB(Sequence 4) -// ChainA.INIT(Sequence: 1) -// ChainB.INIT(Sequence: 5) -// ChainB.TRY(ErrorReceipt: 4) -// ChainA.Cancel(Sequence: 4) -// ChainA.TRY(Sequence: 5) // fastforward -// ChainB.ACK => Success -// ChainA.Confirm => Success -// ChainB.Open => Success -func (suite *KeeperTestSuite) TestChanUpgrade_CrossingHellos_UpgradeSucceeds_AfterCancel() { - var path *ibctesting.Path - - suite.Run("setup path", func() { - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - }) - - suite.Run("chainA upgrade init", func() { - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - }) - - suite.Run("set chainB upgrade sequence ahead of counterparty", func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 4 }) - }) - - suite.Run("chainB upgrade init (crossing hello)", func() { - err := path.EndpointB.ChanUpgradeInit() - suite.Require().NoError(err) - }) - - suite.Run("chainB upgrade try fails with invalid sequence", func() { - err := path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - errorReceipt, found := path.EndpointB.Chain.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(4), errorReceipt.Sequence) - }) - - suite.Run("cancel upgrade on chainA and fast forward upgrade sequence", func() { - err := path.EndpointA.ChanUpgradeCancel() - suite.Require().NoError(err) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(types.OPEN, channel.State) - suite.Require().Equal(uint64(4), channel.UpgradeSequence) - }) - - suite.Run("try chainA upgrade now succeeds with synchronized upgrade sequences", func() { - err := path.EndpointA.ChanUpgradeTry() - suite.Require().NoError(err) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(types.FLUSHING, channel.State) - suite.Require().Equal(uint64(5), channel.UpgradeSequence) - }) - - suite.Run("upgrade handshake completes successfully", func() { - err := path.EndpointB.ChanUpgradeAck() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeConfirm() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeOpen() - suite.Require().NoError(err) - }) - - suite.Run("assert successful upgrade expected channel state", func() { - channelA := path.EndpointA.GetChannel() - suite.Require().Equal(types.OPEN, channelA.State, "channel should be in OPEN state") - suite.Require().Equal(mock.UpgradeVersion, channelA.Version, "version should be correctly upgraded") - suite.Require().Equal(mock.UpgradeVersion, path.EndpointB.GetChannel().Version, "version should be correctly upgraded") - suite.Require().Equal(uint64(5), channelA.UpgradeSequence, "upgrade sequence should be incremented") - - channelB := path.EndpointB.GetChannel() - suite.Require().Equal(types.OPEN, channelB.State, "channel should be in OPEN state") - suite.Require().Equal(mock.UpgradeVersion, channelB.Version, "version should be correctly upgraded") - suite.Require().Equal(mock.UpgradeVersion, channelB.Version, "version should be correctly upgraded") - suite.Require().Equal(uint64(5), channelB.UpgradeSequence, "upgrade sequence should be incremented") - }) -} - -// TestChanUpgrade_CrossingHellos_UpgradeSucceeds_AfterCancelErrors verifies that under crossing hellos if upgrade -// sequences become out of sync, the upgrade can still be performed successfully after the cancel fails. -// ChainA(Sequence: 0), ChainB(Sequence 4) -// ChainA.INIT(Sequence: 1) -// ChainB.INIT(Sequence: 5) -// ChainA.TRY(Sequence: 5) // fastforward -// ChainB.TRY(ErrorReceipt: 4) -// ChainA.Cancel => Error (errorReceipt.Sequence < channel.UpgradeSequence) -// ChainB.ACK => Success -// ChainA.Confirm => Success -// ChainB.Open => Success -func (suite *KeeperTestSuite) TestChanUpgrade_CrossingHellos_UpgradeSucceeds_AfterCancelErrors() { - var ( - historicalChannelProof []byte - historicalUpgradeProof []byte - proofHeight clienttypes.Height - path *ibctesting.Path - ) - - suite.Run("setup path", func() { - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - }) - - suite.Run("chainA upgrade init", func() { - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(uint64(1), channel.UpgradeSequence) - }) - - suite.Run("set chainB upgrade sequence ahead of counterparty", func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 4 }) - }) - - suite.Run("chainB upgrade init (crossing hello)", func() { - err := path.EndpointB.ChanUpgradeInit() - suite.Require().NoError(err) - - channel := path.EndpointB.GetChannel() - suite.Require().Equal(uint64(5), channel.UpgradeSequence) - }) - - suite.Run("query proofs at chainA upgrade sequence 1", func() { - // commit block and update client on chainB - suite.coordinator.CommitBlock(suite.chainA, suite.chainB) - suite.Require().NoError(path.EndpointB.UpdateClient()) - // use proofs when chain A has not executed TRY yet and use them when executing TRY on chain B - historicalChannelProof, historicalUpgradeProof, proofHeight = path.EndpointA.QueryChannelUpgradeProof() - }) - - suite.Run("chainA upgrade try (fast-forwards sequence)", func() { - err := path.EndpointA.ChanUpgradeTry() - suite.Require().NoError(err) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(uint64(5), channel.UpgradeSequence) - }) - - suite.Run("chainB upgrade try fails with written error receipt (4)", func() { - // NOTE: ante handlers are bypassed here and the handler is invoked directly. - // Thus, we set the upgrade error receipt explicitly below - _, _, err := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.ChanUpgradeTry( - suite.chainB.GetContext(), - path.EndpointB.ChannelConfig.PortID, - path.EndpointB.ChannelID, - path.EndpointB.GetChannelUpgrade().Fields.ConnectionHops, - path.EndpointA.GetChannelUpgrade().Fields, - 1, // proofs queried at chainA upgrade sequence 1 - historicalChannelProof, - historicalUpgradeProof, - proofHeight, - ) - suite.Require().Error(err) - suite.assertUpgradeError(err, types.NewUpgradeError(4, types.ErrInvalidUpgradeSequence)) - - suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.WriteErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, err.(*types.UpgradeError)) - suite.coordinator.CommitBlock(suite.chainB) - }) - - suite.Run("chainA upgrade cancellation fails for invalid sequence", func() { - err := path.EndpointA.ChanUpgradeCancel() - suite.Require().Error(err) - suite.Require().ErrorContains(err, "invalid upgrade sequence") - - // assert channel remains in flushing state at upgrade sequence 5 - channel := path.EndpointA.GetChannel() - suite.Require().Equal(types.FLUSHING, channel.State) - suite.Require().Equal(uint64(5), channel.UpgradeSequence) - }) - - suite.Run("upgrade handshake completes successfully", func() { - err := path.EndpointB.ChanUpgradeAck() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeConfirm() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeOpen() - suite.Require().NoError(err) - }) - - suite.Run("assert successful upgrade expected channel state", func() { - channelA := path.EndpointA.GetChannel() - suite.Require().Equal(types.OPEN, channelA.State, "channel should be in OPEN state") - suite.Require().Equal(mock.UpgradeVersion, channelA.Version, "version should be correctly upgraded") - suite.Require().Equal(mock.UpgradeVersion, path.EndpointB.GetChannel().Version, "version should be correctly upgraded") - suite.Require().Equal(uint64(5), channelA.UpgradeSequence, "upgrade sequence should be incremented") - - channelB := path.EndpointB.GetChannel() - suite.Require().Equal(types.OPEN, channelB.State, "channel should be in OPEN state") - suite.Require().Equal(mock.UpgradeVersion, channelB.Version, "version should be correctly upgraded") - suite.Require().Equal(mock.UpgradeVersion, channelB.Version, "version should be correctly upgraded") - suite.Require().Equal(uint64(5), channelB.UpgradeSequence, "upgrade sequence should be incremented") - }) -} - -func (suite *KeeperTestSuite) TestWriteUpgradeTry() { - var ( - path *ibctesting.Path - proposedUpgrade types.Upgrade - ) - - testCases := []struct { - name string - malleate func() - }{ - { - "success with no packet commitments", - func() {}, - }, - { - "success with packet commitments", - func() { - // manually set packet commitment - sequence, err := path.EndpointB.SendPacket(suite.chainB.GetTimeoutHeight(), 0, ibctesting.MockPacketData) - suite.Require().NoError(err) - suite.Require().Equal(uint64(1), sequence) - }, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - proposedUpgrade = path.EndpointB.GetProposedUpgrade() - - tc.malleate() - - ctx := suite.chainB.GetContext() - upgradedChannelEnd, upgradeWithAppCallbackVersion := suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.WriteUpgradeTryChannel( - ctx, - path.EndpointB.ChannelConfig.PortID, - path.EndpointB.ChannelID, - proposedUpgrade, - proposedUpgrade.Fields.Version, - ) - - channel := path.EndpointB.GetChannel() - suite.Require().Equal(upgradedChannelEnd, channel) - - upgrade, found := suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgrade(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(found) - suite.Require().Equal(upgradeWithAppCallbackVersion, upgrade) - }) - } -} - -func (suite *KeeperTestSuite) TestChanUpgradeAck() { - var ( - path *ibctesting.Path - counterpartyUpgrade types.Upgrade - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "success with later upgrade sequence", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 10 }) - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 10 }) - - err := path.EndpointA.UpdateClient() - suite.Require().NoError(err) - }, - nil, - }, - { - "failure if initializing chain reinitializes before ACK", - func() { - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - }, - commitmenttypes.ErrInvalidProof, // sequences are out of sync - }, - { - "channel not found", - func() { - path.EndpointA.ChannelID = ibctesting.InvalidID - path.EndpointA.ChannelConfig.PortID = ibctesting.InvalidID - }, - types.ErrChannelNotFound, - }, - { - "channel state is not in FLUSHING state", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) - }, - types.ErrInvalidChannelState, - }, - { - "connection not found", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.ConnectionHops = []string{"connection-100"} }) - }, - connectiontypes.ErrConnectionNotFound, - }, - { - "invalid connection state", - func() { - path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.State = connectiontypes.UNINITIALIZED }) - }, - connectiontypes.ErrInvalidConnectionState, - }, - { - "upgrade not found", - func() { - store := suite.chainA.GetContext().KVStore(suite.chainA.GetSimApp().GetKey(exported.ModuleName)) - store.Delete(host.ChannelUpgradeKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - }, - types.ErrUpgradeNotFound, - }, - { - "fails due to upgrade incompatibility", - func() { - // Need to set counterparty upgrade in state and update clients to ensure - // proofs submitted reflect the altered upgrade. - counterpartyUpgrade.Fields.ConnectionHops = []string{ibctesting.InvalidID} - path.EndpointB.SetChannelUpgrade(counterpartyUpgrade) - - suite.coordinator.CommitBlock(suite.chainB) - - err := path.EndpointA.UpdateClient() - suite.Require().NoError(err) - }, - types.NewUpgradeError(1, types.ErrIncompatibleCounterpartyUpgrade), - }, - { - "fails due to proof verification failure, counterparty channel ordering does not match expected ordering", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.Ordering = types.ORDERED }) - }, - commitmenttypes.ErrInvalidProof, - }, - { - "fails due to proof verification failure, counterparty update has unexpected sequence", - func() { - // Decrementing NextSequenceSend is sufficient to cause the proof to fail. - counterpartyUpgrade.NextSequenceSend-- - }, - commitmenttypes.ErrInvalidProof, - }, - { - "fails due to mismatch in upgrade ordering", - func() { - upgrade := path.EndpointA.GetChannelUpgrade() - upgrade.Fields.Ordering = types.NONE - - path.EndpointA.SetChannelUpgrade(upgrade) - }, - types.NewUpgradeError(1, types.ErrIncompatibleCounterpartyUpgrade), - }, - { - "counterparty timeout has elapsed", - func() { - // Need to set counterparty upgrade in state and update clients to ensure - // proofs submitted reflect the altered upgrade. - counterpartyUpgrade.Timeout = types.NewTimeout(clienttypes.NewHeight(0, 1), 0) - path.EndpointB.SetChannelUpgrade(counterpartyUpgrade) - - err := path.EndpointB.UpdateClient() - suite.Require().NoError(err) - err = path.EndpointA.UpdateClient() - suite.Require().NoError(err) - }, - types.NewUpgradeError(1, types.ErrTimeoutElapsed), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - // manually set packet commitment so that the chainB channel state is FLUSHING - sequence, err := path.EndpointB.SendPacket(suite.chainB.GetTimeoutHeight(), 0, ibctesting.MockPacketData) - suite.Require().NoError(err) - suite.Require().Equal(uint64(1), sequence) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - // ensure client is up to date to receive valid proofs - err = path.EndpointA.UpdateClient() - suite.Require().NoError(err) - - counterpartyUpgrade = path.EndpointB.GetChannelUpgrade() - - tc.malleate() - - channelProof, upgradeProof, proofHeight := path.EndpointB.QueryChannelUpgradeProof() - - err = suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeAck( - suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, counterpartyUpgrade, - channelProof, upgradeProof, proofHeight, - ) - - if tc.expError == nil { - suite.Require().NoError(err) - - channel := path.EndpointA.GetChannel() - // ChanUpgradeAck will set the channel state to FLUSHING - // It will be set to FLUSHING_COMPLETE in the write function. - suite.Require().Equal(types.FLUSHING, channel.State) - } else { - suite.assertUpgradeError(err, tc.expError) - } - }) - } -} - -func (suite *KeeperTestSuite) TestWriteChannelUpgradeAck() { - var ( - path *ibctesting.Path - proposedUpgrade types.Upgrade - ) - - testCases := []struct { - name string - malleate func() - hasPacketCommitments bool - }{ - { - "success with no packet commitments", - func() {}, - false, - }, - { - "success with packet commitments", - func() { - // manually set packet commitment - sequence, err := path.EndpointA.SendPacket(suite.chainB.GetTimeoutHeight(), 0, ibctesting.MockPacketData) - suite.Require().NoError(err) - suite.Require().Equal(uint64(1), sequence) - }, - true, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - tc.malleate() - - // perform the upgrade handshake. - suite.Require().NoError(path.EndpointA.ChanUpgradeInit()) - - suite.Require().NoError(path.EndpointB.ChanUpgradeTry()) - - ctx := suite.chainA.GetContext() - proposedUpgrade = path.EndpointB.GetChannelUpgrade() - - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteUpgradeAckChannel(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, proposedUpgrade) - - channel := path.EndpointA.GetChannel() - upgrade := path.EndpointA.GetChannelUpgrade() - suite.Require().Equal(mock.UpgradeVersion, upgrade.Fields.Version) - - if !tc.hasPacketCommitments { - suite.Require().Equal(types.FLUSHCOMPLETE, channel.State) - } - counterpartyUpgrade, ok := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetCounterpartyUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(ok) - suite.Require().Equal(proposedUpgrade, counterpartyUpgrade) - }) - } -} - -func (suite *KeeperTestSuite) TestChanUpgrade_ReinitializedBeforeAck() { - var path *ibctesting.Path - suite.Run("setup path", func() { - path = ibctesting.NewPath(suite.chainA, suite.chainB) - suite.coordinator.Setup(path) - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - }) - - suite.Run("chainA upgrade init", func() { - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(uint64(1), channel.UpgradeSequence) - }) - - suite.Run("chainB upgrade try", func() { - err := path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - }) - - suite.Run("chainA upgrade init reinitialized after ack", func() { - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(uint64(2), channel.UpgradeSequence) - }) - - suite.Run("chan upgrade ack fails", func() { - err := path.EndpointA.ChanUpgradeAck() - suite.Require().Error(err) - }) - - suite.Run("chainB upgrade cancel", func() { - err := path.EndpointB.ChanUpgradeCancel() - suite.Require().NoError(err) - }) - - suite.Run("upgrade handshake succeeds on new upgrade attempt", func() { - err := path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeAck() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeConfirm() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeOpen() - suite.Require().NoError(err) - }) - - suite.Run("assert successful upgrade expected channel state", func() { - channelA := path.EndpointA.GetChannel() - suite.Require().Equal(types.OPEN, channelA.State, "channel should be in OPEN state") - suite.Require().Equal(mock.UpgradeVersion, channelA.Version, "version should be correctly upgraded") - suite.Require().Equal(mock.UpgradeVersion, path.EndpointB.GetChannel().Version, "version should be correctly upgraded") - suite.Require().Equal(uint64(2), channelA.UpgradeSequence, "upgrade sequence should be incremented") - - channelB := path.EndpointB.GetChannel() - suite.Require().Equal(types.OPEN, channelB.State, "channel should be in OPEN state") - suite.Require().Equal(mock.UpgradeVersion, channelB.Version, "version should be correctly upgraded") - suite.Require().Equal(mock.UpgradeVersion, channelB.Version, "version should be correctly upgraded") - suite.Require().Equal(uint64(2), channelB.UpgradeSequence, "upgrade sequence should be incremented") - }) -} - -func (suite *KeeperTestSuite) TestChanUpgradeConfirm() { - var ( - path *ibctesting.Path - counterpartyChannelState types.State - counterpartyUpgrade types.Upgrade - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "success with later upgrade sequence", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 10 }) - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 10 }) - - err := path.EndpointB.UpdateClient() - suite.Require().NoError(err) - }, - nil, - }, - { - "success with in-flight packets on init chain", - func() { - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - seq, err := path.EndpointA.SendPacket(defaultTimeoutHeight, 0, ibctesting.MockPacketData) - suite.Require().Equal(uint64(1), seq) - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeAck() - suite.Require().NoError(err) - - err = path.EndpointB.UpdateClient() - suite.Require().NoError(err) - - counterpartyChannelState = path.EndpointA.GetChannel().State - counterpartyUpgrade = path.EndpointA.GetChannelUpgrade() - }, - nil, - }, - { - "success with in-flight packets on try chain", - func() { - portID, channelID := path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID - suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), portID, channelID, 1, []byte("hash")) - }, - nil, - }, - { - "channel not found", - func() { - path.EndpointB.ChannelID = ibctesting.InvalidID - path.EndpointB.ChannelConfig.PortID = ibctesting.InvalidID - }, - types.ErrChannelNotFound, - }, - { - "channel is not in FLUSHING state", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) - }, - types.ErrInvalidChannelState, - }, - { - "invalid counterparty channel state", - func() { - counterpartyChannelState = types.CLOSED - }, - types.ErrInvalidCounterparty, - }, - { - "connection not found", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.ConnectionHops = []string{"connection-100"} }) - }, - connectiontypes.ErrConnectionNotFound, - }, - { - "invalid connection state", - func() { - path.EndpointB.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.State = connectiontypes.UNINITIALIZED }) - }, - connectiontypes.ErrInvalidConnectionState, - }, - { - "fails due to proof verification failure, counterparty channel ordering does not match expected ordering", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.Ordering = types.ORDERED }) - - err := path.EndpointB.UpdateClient() - suite.Require().NoError(err) - }, - commitmenttypes.ErrInvalidProof, - }, - { - "fails due to mismatch in upgrade ordering", - func() { - upgrade := path.EndpointA.GetChannelUpgrade() - upgrade.Fields.Ordering = types.NONE - - path.EndpointA.SetChannelUpgrade(upgrade) - - suite.coordinator.CommitBlock(suite.chainA) - - err := path.EndpointB.UpdateClient() - suite.Require().NoError(err) - }, - commitmenttypes.ErrInvalidProof, - }, - { - "counterparty timeout has elapsed", - func() { - // Need to set counterparty upgrade in state and update clients to ensure - // proofs submitted reflect the altered upgrade. - counterpartyUpgrade.Timeout = types.NewTimeout(clienttypes.NewHeight(0, 1), 0) - path.EndpointA.SetChannelUpgrade(counterpartyUpgrade) - - suite.coordinator.CommitBlock(suite.chainA) - - err := path.EndpointB.UpdateClient() - suite.Require().NoError(err) - }, - types.NewUpgradeError(1, types.ErrTimeoutElapsed), - }, - { - "upgrade not found", - func() { - path.EndpointB.Chain.DeleteKey(host.ChannelUpgradeKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID)) - }, - types.ErrUpgradeNotFound, - }, - { - "upgrades are not compatible", - func() { - // the expected upgrade version is mock-version-v2 - counterpartyUpgrade.Fields.Version = fmt.Sprintf("%s-v3", mock.Version) - path.EndpointA.SetChannelUpgrade(counterpartyUpgrade) - - suite.coordinator.CommitBlock(suite.chainA) - - err := path.EndpointB.UpdateClient() - suite.Require().NoError(err) - }, - types.NewUpgradeError(1, types.ErrIncompatibleCounterpartyUpgrade), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeAck() - suite.Require().NoError(err) - - err = path.EndpointB.UpdateClient() - suite.Require().NoError(err) - - counterpartyChannelState = path.EndpointA.GetChannel().State - counterpartyUpgrade = path.EndpointA.GetChannelUpgrade() - - tc.malleate() - - channelProof, upgradeProof, proofHeight := path.EndpointA.QueryChannelUpgradeProof() - - err = suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeConfirm( - suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, counterpartyChannelState, counterpartyUpgrade, - channelProof, upgradeProof, proofHeight, - ) - - if tc.expError == nil { - suite.Require().NoError(err) - } else { - suite.assertUpgradeError(err, tc.expError) - } - }) - } -} - -func (suite *KeeperTestSuite) TestWriteUpgradeConfirm() { - var ( - path *ibctesting.Path - proposedUpgrade types.Upgrade - ) - - testCases := []struct { - name string - malleate func() - hasPacketCommitments bool - }{ - { - "success with no packet commitments", - func() {}, - false, - }, - { - "success with packet commitments", - func() { - // manually set packet commitment - sequence, err := path.EndpointA.SendPacket(suite.chainB.GetTimeoutHeight(), 0, ibctesting.MockPacketData) - suite.Require().NoError(err) - suite.Require().Equal(uint64(1), sequence) - }, - true, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - tc.malleate() - - // perform the upgrade handshake. - suite.Require().NoError(path.EndpointB.ChanUpgradeInit()) - - suite.Require().NoError(path.EndpointA.ChanUpgradeTry()) - - suite.Require().NoError(path.EndpointB.ChanUpgradeAck()) - - ctx := suite.chainA.GetContext() - proposedUpgrade = path.EndpointB.GetChannelUpgrade() - - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteUpgradeConfirmChannel(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, proposedUpgrade) - - channel := path.EndpointA.GetChannel() - upgrade := path.EndpointA.GetChannelUpgrade() - suite.Require().Equal(mock.UpgradeVersion, upgrade.Fields.Version) - - if !tc.hasPacketCommitments { - suite.Require().Equal(types.FLUSHCOMPLETE, channel.State) - } else { - suite.Require().Equal(types.FLUSHING, channel.State) - } - counterpartyUpgrade, ok := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetCounterpartyUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(ok, "counterparty upgrade should be present") - suite.Require().Equal(proposedUpgrade, counterpartyUpgrade) - }) - } -} - -func (suite *KeeperTestSuite) TestChanUpgradeOpen() { - var path *ibctesting.Path - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "success: counterparty in flushcomplete", - func() { - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - // Need to create a packet commitment on A so as to keep it from going to FLUSHCOMPLETE if no inflight packets exist. - sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - packet := types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - err = path.EndpointB.RecvPacket(packet) - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeAck() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeConfirm() - suite.Require().NoError(err) - - err = path.EndpointA.AcknowledgePacket(packet, ibctesting.MockAcknowledgement) - suite.Require().NoError(err) - - // cause the packet commitment on chain A to be deleted and the channel state to be updated to FLUSHCOMPLETE. - suite.coordinator.CommitBlock(suite.chainA, suite.chainB) - suite.Require().NoError(path.EndpointA.UpdateClient()) - }, - nil, - }, - { - "success: counterparty initiated new upgrade after opening", - func() { - // create reason to upgrade - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion + "additional upgrade" - - err := path.EndpointB.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointA.UpdateClient() - suite.Require().NoError(err) - }, - nil, - }, - { - "success: counterparty upgrade sequence is incorrect", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence-- }) - }, - types.ErrInvalidUpgradeSequence, - }, - { - "channel not found", - func() { - path.EndpointA.ChannelConfig.PortID = ibctesting.InvalidID - }, - types.ErrChannelNotFound, - }, - { - "channel state is not FLUSHCOMPLETE", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - }, - types.ErrInvalidChannelState, - }, - { - "connection not found", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.ConnectionHops = []string{"connection-100"} }) - }, - connectiontypes.ErrConnectionNotFound, - }, - { - "invalid connection state", - func() { - path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.State = connectiontypes.UNINITIALIZED }) - }, - connectiontypes.ErrInvalidConnectionState, - }, - { - "invalid counterparty channel state", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) - }, - types.ErrInvalidCounterparty, - }, - } - - // Create an initial path used only to invoke a ChanOpenInit handshake. - // This bumps the channel identifier generated for chain A on the - // next path used to run the upgrade handshake. - // See issue 4062. - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupConnections() - suite.Require().NoError(path.EndpointA.ChanOpenInit()) - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeAck() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeConfirm() - suite.Require().NoError(err) - - err = path.EndpointA.UpdateClient() - suite.Require().NoError(err) - - tc.malleate() - - channelKey := host.ChannelKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - channelProof, proofHeight := path.EndpointB.QueryProof(channelKey) - - err = suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeOpen( - suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, - path.EndpointB.GetChannel().State, path.EndpointB.GetChannel().UpgradeSequence, channelProof, proofHeight, - ) - - if tc.expError == nil { - suite.Require().NoError(err) - } else { - suite.Require().ErrorIs(err, tc.expError) - } - }) - } -} - -func (suite *KeeperTestSuite) TestWriteUpgradeOpenChannel() { - var path *ibctesting.Path - - testCases := []struct { - name string - malleate func() - expPanic bool - }{ - { - name: "success", - malleate: func() {}, - expPanic: false, - }, - { - name: "channel not found", - malleate: func() { - path.EndpointA.Chain.DeleteKey(host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - }, - expPanic: true, - }, - { - name: "upgrade not found", - malleate: func() { - path.EndpointA.Chain.DeleteKey(host.ChannelUpgradeKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - }, - expPanic: true, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - // Need to create a packet commitment on A so as to keep it from going to OPEN if no inflight packets exist. - sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - packet := types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - err = path.EndpointB.RecvPacket(packet) - suite.Require().NoError(err) - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - suite.Require().NoError(path.EndpointA.ChanUpgradeInit()) - suite.Require().NoError(path.EndpointB.ChanUpgradeTry()) - suite.Require().NoError(path.EndpointA.ChanUpgradeAck()) - suite.Require().NoError(path.EndpointB.ChanUpgradeConfirm()) - - // Ack packet to delete packet commitment before calling WriteUpgradeOpenChannel - err = path.EndpointA.AcknowledgePacket(packet, ibctesting.MockAcknowledgement) - suite.Require().NoError(err) - - ctx := suite.chainA.GetContext() - - tc.malleate() - - if tc.expPanic { - suite.Require().Panics(func() { - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteUpgradeOpenChannel(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - }) - } else { - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteUpgradeOpenChannel(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - channel := path.EndpointA.GetChannel() - - // Assert that channel state has been updated - suite.Require().Equal(types.OPEN, channel.State) - suite.Require().Equal(mock.UpgradeVersion, channel.Version) - - // Assert that state stored for upgrade has been deleted - upgrade, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().Equal(types.Upgrade{}, upgrade) - suite.Require().False(found) - - counterpartyUpgrade, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetCounterpartyUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().Equal(types.Upgrade{}, counterpartyUpgrade) - suite.Require().False(found) - } - }) - } -} - -func (suite *KeeperTestSuite) TestWriteUpgradeOpenChannel_Ordering() { - var path *ibctesting.Path - - testCases := []struct { - name string - malleate func() - preUpgrade func() - postUpgrade func() - }{ - { - name: "success: ORDERED -> UNORDERED", - malleate: func() { - path.EndpointA.ChannelConfig.Order = types.ORDERED - path.EndpointB.ChannelConfig.Order = types.ORDERED - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Ordering = types.UNORDERED - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Ordering = types.UNORDERED - }, - preUpgrade: func() { - ctx := suite.chainA.GetContext() - - // assert that NextSeqAck is incremented to 2 because channel is still ordered - seq, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetNextSequenceAck(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(2), seq) - - // assert that NextSeqRecv is incremented to 2 because channel is still ordered - seq, found = suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetNextSequenceRecv(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(2), seq) - - // Assert that pruning sequence start has not been initialized. - suite.Require().False(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.HasPruningSequenceStart(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - - // Assert that recv start sequence has not been set - counterpartyNextSequenceSend, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetRecvStartSequence(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().False(found) - suite.Require().Equal(uint64(0), counterpartyNextSequenceSend) - }, - postUpgrade: func() { - channel := path.EndpointA.GetChannel() - ctx := suite.chainA.GetContext() - - // Assert that channel state has been updated - suite.Require().Equal(types.OPEN, channel.State) - suite.Require().Equal(types.UNORDERED, channel.Ordering) - - // assert that NextSeqRecv is now 1, because channel is now UNORDERED - seq, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetNextSequenceRecv(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(1), seq) - - // assert that NextSeqAck is now 1, because channel is now UNORDERED - seq, found = suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetNextSequenceAck(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(1), seq) - - // Assert that pruning sequence start has been initialized (set to 1) - suite.Require().True(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.HasPruningSequenceStart(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - pruningSeq, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetPruningSequenceStart(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(1), pruningSeq) - - // Assert that the recv start sequence has been set correctly - counterpartySequenceSend, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetRecvStartSequence(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(2), counterpartySequenceSend) - }, - }, - { - name: "success: UNORDERED -> ORDERED", - malleate: func() { - path.EndpointA.ChannelConfig.Order = types.UNORDERED - path.EndpointB.ChannelConfig.Order = types.UNORDERED - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Ordering = types.ORDERED - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Ordering = types.ORDERED - }, - preUpgrade: func() { - ctx := suite.chainA.GetContext() - - // assert that NextSeqRecv is 1 because channel is UNORDERED - seq, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetNextSequenceRecv(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(1), seq) - - // assert that NextSeqAck is 1 because channel is UNORDERED - seq, found = suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetNextSequenceAck(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(1), seq) - - // Assert that pruning sequence start has not been initialized. - suite.Require().False(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.HasPruningSequenceStart(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - - // Assert that recv start sequence has not been set - counterpartyNextSequenceSend, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetRecvStartSequence(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().False(found) - suite.Require().Equal(uint64(0), counterpartyNextSequenceSend) - }, - postUpgrade: func() { - channel := path.EndpointA.GetChannel() - ctx := suite.chainA.GetContext() - - // Assert that channel state has been updated - suite.Require().Equal(types.OPEN, channel.State) - suite.Require().Equal(types.ORDERED, channel.Ordering) - - // assert that NextSeqRecv is incremented to 2, because channel is now ORDERED - // NextSeqRecv updated in WriteUpgradeOpenChannel to latest sequence (one packet sent) + 1 - seq, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetNextSequenceRecv(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(2), seq) - - // assert that NextSeqAck is incremented to 2 because channel is now ORDERED - seq, found = suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetNextSequenceAck(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(2), seq) - - // Assert that pruning sequence start has been initialized (set to 1) - suite.Require().True(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.HasPruningSequenceStart(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - pruningSeq, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetPruningSequenceStart(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(1), pruningSeq) - - // Assert that the recv start sequence has been set correctly - counterpartySequenceSend, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetRecvStartSequence(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(2), counterpartySequenceSend) - }, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - - tc.malleate() - - path.Setup() - - // Need to create a packet commitment on A so as to keep it from going to OPEN if no inflight packets exist. - sequenceA, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - packetA := types.NewPacket(ibctesting.MockPacketData, sequenceA, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - err = path.EndpointB.RecvPacket(packetA) - suite.Require().NoError(err) - - // send second packet from B to A - sequenceB, err := path.EndpointB.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - packetB := types.NewPacket(ibctesting.MockPacketData, sequenceB, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - err = path.EndpointA.RecvPacket(packetB) - suite.Require().NoError(err) - - suite.Require().NoError(path.EndpointA.ChanUpgradeInit()) - suite.Require().NoError(path.EndpointB.ChanUpgradeTry()) - suite.Require().NoError(path.EndpointA.ChanUpgradeAck()) - suite.Require().NoError(path.EndpointB.ChanUpgradeConfirm()) - - // Ack packets to delete packet commitments before calling WriteUpgradeOpenChannel - err = path.EndpointA.AcknowledgePacket(packetA, ibctesting.MockAcknowledgement) - suite.Require().NoError(err) - - err = path.EndpointB.AcknowledgePacket(packetB, ibctesting.MockAcknowledgement) - suite.Require().NoError(err) - - // pre upgrade assertions - tc.preUpgrade() - - tc.malleate() - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteUpgradeOpenChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - - // post upgrade assertions - tc.postUpgrade() - - // Assert that state stored for upgrade has been deleted - upgrade, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().Equal(types.Upgrade{}, upgrade) - suite.Require().False(found) - - counterpartyUpgrade, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetCounterpartyUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().Equal(types.Upgrade{}, counterpartyUpgrade) - suite.Require().False(found) - }) - } -} - -func (suite *KeeperTestSuite) TestChanUpgradeCancel() { - var ( - path *ibctesting.Path - errorReceipt types.ErrorReceipt - errorReceiptProof []byte - proofHeight clienttypes.Height - ) - - tests := []struct { - name string - malleate func() - expError error - }{ - { - name: "success with flushing state", - malleate: func() { - }, - expError: nil, - }, - { - name: "success with flush complete state", - malleate: func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHCOMPLETE }) - - var ok bool - errorReceipt, ok = suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(ok) - - // the error receipt upgrade sequence and the channel upgrade sequence must match - errorReceipt.Sequence = path.EndpointA.GetChannel().UpgradeSequence - - suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.SetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, errorReceipt) - - suite.coordinator.CommitBlock(suite.chainB) - - suite.Require().NoError(path.EndpointA.UpdateClient()) - - upgradeErrorReceiptKey := host.ChannelUpgradeErrorKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - errorReceiptProof, proofHeight = suite.chainB.QueryProof(upgradeErrorReceiptKey) - }, - expError: nil, - }, - { - name: "upgrade cannot be cancelled in FLUSHCOMPLETE with invalid error receipt", - malleate: func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHCOMPLETE }) - - errorReceiptProof = nil - }, - expError: commitmenttypes.ErrInvalidProof, - }, - { - name: "channel not found", - malleate: func() { - path.EndpointA.Chain.DeleteKey(host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - }, - expError: types.ErrChannelNotFound, - }, - { - name: "upgrade not found", - malleate: func() { - path.EndpointA.Chain.DeleteKey(host.ChannelUpgradeKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - }, - expError: types.ErrUpgradeNotFound, - }, - { - name: "error receipt sequence less than channel upgrade sequence", - malleate: func() { - var ok bool - errorReceipt, ok = suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(ok) - - errorReceipt.Sequence = path.EndpointA.GetChannel().UpgradeSequence - 1 - - suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.SetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, errorReceipt) - - suite.coordinator.CommitBlock(suite.chainB) - - suite.Require().NoError(path.EndpointA.UpdateClient()) - - upgradeErrorReceiptKey := host.ChannelUpgradeErrorKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - errorReceiptProof, proofHeight = suite.chainB.QueryProof(upgradeErrorReceiptKey) - }, - expError: types.ErrInvalidUpgradeSequence, - }, - { - name: "error receipt sequence greater than channel upgrade sequence when channel in FLUSHCOMPLETE", - malleate: func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHCOMPLETE }) - }, - expError: types.ErrInvalidUpgradeSequence, - }, - { - name: "error receipt sequence smaller than channel upgrade sequence when channel in FLUSHCOMPLETE", - malleate: func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHCOMPLETE }) - - var ok bool - errorReceipt, ok = suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(ok) - - errorReceipt.Sequence = path.EndpointA.GetChannel().UpgradeSequence - 1 - - suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.SetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, errorReceipt) - - suite.coordinator.CommitBlock(suite.chainB) - - suite.Require().NoError(path.EndpointA.UpdateClient()) - - upgradeErrorReceiptKey := host.ChannelUpgradeErrorKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - errorReceiptProof, proofHeight = suite.chainB.QueryProof(upgradeErrorReceiptKey) - }, - expError: types.ErrInvalidUpgradeSequence, - }, - { - name: "connection not found", - malleate: func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.ConnectionHops = []string{"connection-100"} }) - }, - expError: connectiontypes.ErrConnectionNotFound, - }, - { - name: "channel is in flush complete, error verification failed", - malleate: func() { - var ok bool - errorReceipt, ok = suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(ok) - - errorReceipt.Message = ibctesting.InvalidID - - suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.SetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, errorReceipt) - suite.coordinator.CommitBlock(suite.chainB) - }, - expError: commitmenttypes.ErrInvalidProof, - }, - { - name: "error verification failed", - malleate: func() { - var ok bool - errorReceipt, ok = suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(ok) - - errorReceipt.Message = ibctesting.InvalidID - suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.SetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, errorReceipt) - suite.coordinator.CommitBlock(suite.chainB) - }, - expError: commitmenttypes.ErrInvalidProof, - }, - { - name: "error verification failed with empty proof", - malleate: func() { - errorReceiptProof = nil - }, - expError: commitmenttypes.ErrInvalidProof, - }, - } - - for _, tc := range tests { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - suite.Require().NoError(path.EndpointA.ChanUpgradeInit()) - - // cause the upgrade to fail on chain b so an error receipt is written. - // if the counterparty (chain A) upgrade sequence is less than the current sequence, (chain B) - // an upgrade error will be returned by chain B during ChanUpgradeTry. - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 1 }) - - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 2 }) - - suite.Require().NoError(path.EndpointA.UpdateClient()) - suite.Require().NoError(path.EndpointB.UpdateClient()) - - // error receipt is written to chain B here. - suite.Require().NoError(path.EndpointB.ChanUpgradeTry()) - - suite.Require().NoError(path.EndpointA.UpdateClient()) - - upgradeErrorReceiptKey := host.ChannelUpgradeErrorKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - errorReceiptProof, proofHeight = suite.chainB.QueryProof(upgradeErrorReceiptKey) - - var ok bool - errorReceipt, ok = suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(ok) - - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - - tc.malleate() - - err := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeCancel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, errorReceipt, errorReceiptProof, proofHeight) - - if tc.expError == nil { - suite.Require().NoError(err) - } else { - suite.Require().ErrorIs(err, tc.expError) - } - }) - } -} - -// TestChanUpgrade_UpgradeSucceeds_AfterCancel verifies that if upgrade sequences -// become out of sync, the upgrade can still be performed successfully after the upgrade is cancelled. -func (suite *KeeperTestSuite) TestChanUpgrade_UpgradeSucceeds_AfterCancel() { - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - suite.Require().NoError(path.EndpointA.ChanUpgradeInit()) - - // cause the upgrade to fail on chain b so an error receipt is written. - // if the counterparty (chain A) upgrade sequence is less than the current sequence, (chain B) - // an upgrade error will be returned by chain B during ChanUpgradeTry. - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 1 }) - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 5 }) - - suite.Require().NoError(path.EndpointA.UpdateClient()) - suite.Require().NoError(path.EndpointB.UpdateClient()) - - // error receipt is written to chain B here. - suite.Require().NoError(path.EndpointB.ChanUpgradeTry()) - - suite.Require().NoError(path.EndpointA.UpdateClient()) - - var errorReceipt types.ErrorReceipt - suite.T().Run("error receipt written", func(t *testing.T) { - var ok bool - errorReceipt, ok = suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(ok) - }) - - suite.T().Run("upgrade cancelled successfully", func(t *testing.T) { - upgradeErrorReceiptKey := host.ChannelUpgradeErrorKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - errorReceiptProof, proofHeight := suite.chainB.QueryProof(upgradeErrorReceiptKey) - - err := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeCancel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, errorReceipt, errorReceiptProof, proofHeight) - suite.Require().NoError(err) - - // need to explicitly call WriteUpgradeOpenChannel as this usually would happen in the msg server layer. - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteUpgradeCancelChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, errorReceipt.Sequence) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(types.OPEN, channel.State) - - suite.T().Run("verify upgrade sequence fastforwards to channelB sequence", func(t *testing.T) { - suite.Require().Equal(uint64(5), channel.UpgradeSequence) - }) - }) - - suite.T().Run("successfully completes upgrade", func(t *testing.T) { - suite.Require().NoError(path.EndpointA.ChanUpgradeInit()) - suite.Require().NoError(path.EndpointB.ChanUpgradeTry()) - suite.Require().NoError(path.EndpointA.ChanUpgradeAck()) - suite.Require().NoError(path.EndpointB.ChanUpgradeConfirm()) - suite.Require().NoError(path.EndpointA.ChanUpgradeOpen()) - }) - - suite.T().Run("channel in expected state", func(t *testing.T) { - channel := path.EndpointA.GetChannel() - suite.Require().Equal(types.OPEN, channel.State, "channel should be in OPEN state") - suite.Require().Equal(mock.UpgradeVersion, channel.Version, "version should be correctly upgraded") - suite.Require().Equal(mock.UpgradeVersion, path.EndpointB.GetChannel().Version, "version should be correctly upgraded") - suite.Require().Equal(uint64(6), channel.UpgradeSequence, "upgrade sequence should be incremented") - suite.Require().Equal(uint64(6), path.EndpointB.GetChannel().UpgradeSequence, "upgrade sequence should be incremented on counterparty") - }) -} - -func (suite *KeeperTestSuite) TestWriteUpgradeCancelChannel() { - var path *ibctesting.Path - - testCases := []struct { - name string - malleate func() - expPanic bool - }{ - { - name: "success", - malleate: func() {}, - expPanic: false, - }, - { - name: "channel not found", - malleate: func() { - path.EndpointA.Chain.DeleteKey(host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - }, - expPanic: true, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - suite.Require().NoError(path.EndpointA.ChanUpgradeInit()) - - // cause the upgrade to fail on chain b so an error receipt is written. - // if the counterparty (chain A) upgrade sequence is less than the current sequence, (chain B) - // an upgrade error will be returned by chain B during ChanUpgradeTry. - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 1 }) - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 2 }) - - err := path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - err = path.EndpointA.UpdateClient() - suite.Require().NoError(err) - - errorReceipt, ok := suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(ok) - - ctx := suite.chainA.GetContext() - tc.malleate() - - if tc.expPanic { - suite.Require().Panics(func() { - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteUpgradeCancelChannel(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, errorReceipt.Sequence) - }) - } else { - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteUpgradeCancelChannel(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, errorReceipt.Sequence) - - channel := path.EndpointA.GetChannel() - - // Verify that channel has been restored to previous state - suite.Require().Equal(types.OPEN, channel.State) - suite.Require().Equal(mock.Version, channel.Version) - suite.Require().Equal(errorReceipt.Sequence, channel.UpgradeSequence) - - // Assert that state stored for upgrade has been deleted - upgrade, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().Equal(types.Upgrade{}, upgrade) - suite.Require().False(found) - - counterpartyUpgrade, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetCounterpartyUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().Equal(types.Upgrade{}, counterpartyUpgrade) - suite.Require().False(found) - } - }) - } -} - -func (suite *KeeperTestSuite) TestChanUpgradeTimeout() { - var ( - path *ibctesting.Path - channelProof []byte - proofHeight exported.Height - ) - - timeoutUpgrade := func() { - upgrade := path.EndpointA.GetProposedUpgrade() - upgrade.Timeout = types.NewTimeout(clienttypes.ZeroHeight(), 1) - path.EndpointA.SetChannelUpgrade(upgrade) - suite.Require().NoError(path.EndpointB.UpdateClient()) - } - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success: proof timestamp has passed", - func() { - timeoutUpgrade() - - channelKey := host.ChannelKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - channelProof, proofHeight = path.EndpointB.QueryProof(channelKey) - }, - nil, - }, - { - "channel not found", - func() { - path.EndpointA.ChannelID = ibctesting.InvalidID - }, - types.ErrChannelNotFound, - }, - { - "channel state is not in FLUSHING or FLUSHINGCOMPLETE state", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.OPEN }) - }, - types.ErrInvalidChannelState, - }, - { - "current upgrade not found", - func() { - suite.chainA.DeleteKey(host.ChannelUpgradeKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - }, - types.ErrUpgradeNotFound, - }, - { - "connection not found", - func() { - path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.ConnectionHops[0] = ibctesting.InvalidID }) - }, - connectiontypes.ErrConnectionNotFound, - }, - { - "connection not open", - func() { - path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.State = connectiontypes.UNINITIALIZED }) - }, - connectiontypes.ErrInvalidConnectionState, - }, - { - "unable to retrieve timestamp at proof height", - func() { - // TODO: revert this when the upgrade timeout is not hard coded to 1000 - proofHeight = clienttypes.NewHeight(clienttypes.ParseChainID(suite.chainA.ChainID), uint64(suite.chainA.GetContext().BlockHeight())+1000) - }, - clienttypes.ErrConsensusStateNotFound, - }, - { - "invalid channel state proof", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.OPEN }) - - timeoutUpgrade() - - suite.Require().NoError(path.EndpointA.UpdateClient()) - - channelKey := host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - channelProof, proofHeight = path.EndpointB.QueryProof(channelKey) - - // modify state so the proof becomes invalid. - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) - }, - commitmenttypes.ErrInvalidProof, - }, - { - "invalid counterparty upgrade sequence", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { - channel.UpgradeSequence = path.EndpointA.GetChannel().UpgradeSequence - 1 - }) - - timeoutUpgrade() - - suite.Require().NoError(path.EndpointA.UpdateClient()) - - channelKey := host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - channelProof, proofHeight = path.EndpointB.QueryProof(channelKey) - }, - types.ErrInvalidUpgradeSequence, - }, - { - "timeout timestamp has not passed", - func() { - upgrade := path.EndpointA.GetProposedUpgrade() - upgrade.Timeout.Timestamp = math.MaxUint64 - path.EndpointA.SetChannelUpgrade(upgrade) - - suite.Require().NoError(path.EndpointB.UpdateClient()) - - channelKey := host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - channelProof, proofHeight = path.EndpointB.QueryProof(channelKey) - }, - types.ErrTimeoutNotReached, - }, - { - "counterparty channel state is not OPEN or FLUSHING (crossing hellos)", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHCOMPLETE }) - - timeoutUpgrade() - - suite.Require().NoError(path.EndpointA.UpdateClient()) - - channelKey := host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - channelProof, proofHeight = path.EndpointB.QueryProof(channelKey) - }, - types.ErrInvalidCounterparty, - }, - { - "counterparty proposed connection invalid", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.OPEN }) - - timeoutUpgrade() - - upgrade := path.EndpointA.GetChannelUpgrade() - upgrade.Fields.ConnectionHops = []string{"connection-100"} - path.EndpointA.SetChannelUpgrade(upgrade) - - suite.Require().NoError(path.EndpointA.UpdateClient()) - suite.Require().NoError(path.EndpointB.UpdateClient()) - - channelKey := host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - channelProof, proofHeight = path.EndpointB.QueryProof(channelKey) - }, - connectiontypes.ErrConnectionNotFound, - }, - { - "counterparty channel already upgraded", - func() { - // put chainA channel into OPEN state since both sides are in FLUSHCOMPLETE - suite.Require().NoError(path.EndpointB.ChanUpgradeConfirm()) - - timeoutUpgrade() - - suite.Require().NoError(path.EndpointA.UpdateClient()) - - channelKey := host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - channelProof, proofHeight = path.EndpointB.QueryProof(channelKey) - }, - types.ErrUpgradeTimeoutFailed, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - suite.Require().NoError(path.EndpointA.ChanUpgradeInit()) - suite.Require().NoError(path.EndpointB.ChanUpgradeTry()) - suite.Require().NoError(path.EndpointA.ChanUpgradeAck()) - - channelKey := host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - channelProof, proofHeight = path.EndpointB.QueryProof(channelKey) - - tc.malleate() - - err := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeTimeout( - suite.chainA.GetContext(), - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - path.EndpointB.GetChannel(), - channelProof, - proofHeight, - ) - - if tc.expError == nil { - suite.Require().NoError(err) - } else { - suite.assertUpgradeError(err, tc.expError) - } - }) - } -} - -func (suite *KeeperTestSuite) TestStartFlush() { - var path *ibctesting.Path - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "channel not found", - func() { - path.EndpointB.ChannelID = "invalid-channel" - path.EndpointB.ChannelConfig.PortID = "invalid-port" - }, - types.ErrChannelNotFound, - }, - { - "connection not found", - func() { - path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.ConnectionHops[0] = ibctesting.InvalidID }) - }, - connectiontypes.ErrConnectionNotFound, - }, - { - "connection state is not in OPEN state", - func() { - path.EndpointB.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.State = connectiontypes.INIT }) - }, - connectiontypes.ErrInvalidConnectionState, - }, - { - "next sequence send not found", - func() { - // Delete next sequence send key from store - store := suite.chainB.GetContext().KVStore(suite.chainB.GetSimApp().GetKey(exported.StoreKey)) - store.Delete(host.NextSequenceSendKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID)) - }, - types.ErrSequenceSendNotFound, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - // crossing hellos so that the upgrade is created on chain B. - // the ChanUpgradeInit sub protocol is also called when it is not a crossing hello situation. - err = path.EndpointB.ChanUpgradeInit() - suite.Require().NoError(err) - - upgrade := path.EndpointB.GetChannelUpgrade() - - tc.malleate() - - err = suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.StartFlushing( - suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, &upgrade, - ) - - if tc.expError != nil { - suite.assertUpgradeError(err, tc.expError) - } else { - channel := path.EndpointB.GetChannel() - - nextSequenceSend, ok := suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.GetNextSequenceSend(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(ok) - - suite.Require().Equal(types.FLUSHING, channel.State) - suite.Require().Equal(nextSequenceSend, upgrade.NextSequenceSend) - - expectedTimeoutTimestamp := types.DefaultTimeout.Timestamp + uint64(suite.chainB.GetContext().BlockTime().UnixNano()) - suite.Require().Equal(expectedTimeoutTimestamp, upgrade.Timeout.Timestamp) - suite.Require().Equal(clienttypes.ZeroHeight(), upgrade.Timeout.Height, "only timestamp should be set") - suite.Require().NoError(err) - } - }) - } -} - -func (suite *KeeperTestSuite) TestValidateUpgradeFields() { - var ( - proposedUpgrade *types.UpgradeFields - path *ibctesting.Path - ) - tests := []struct { - name string - malleate func() - expErr error - }{ - { - name: "change channel version", - malleate: func() { - proposedUpgrade.Version = mock.UpgradeVersion - }, - expErr: nil, - }, - { - name: "change connection hops", - malleate: func() { - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - proposedUpgrade.ConnectionHops = []string{path.EndpointA.ConnectionID} - }, - expErr: nil, - }, - { - name: "fails with unmodified fields", - malleate: func() {}, - expErr: errorsmod.Wrapf(types.ErrInvalidUpgrade, "existing channel end is identical to proposed upgrade channel end: got {ORDER_UNORDERED [connection-0] mock-version}"), - }, - { - name: "fails when connection is not set", - malleate: func() { - storeKey := suite.chainA.GetSimApp().GetKey(exported.StoreKey) - kvStore := suite.chainA.GetContext().KVStore(storeKey) - kvStore.Delete(host.ConnectionKey(ibctesting.FirstConnectionID)) - }, - expErr: errorsmod.Wrapf(types.ErrInvalidUpgrade, "existing channel end is identical to proposed upgrade channel end: got {ORDER_UNORDERED [connection-0] mock-version}"), - }, - { - name: "fails when connection is not open", - malleate: func() { - path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.State = connectiontypes.UNINITIALIZED }) - }, - expErr: errorsmod.Wrapf(types.ErrInvalidUpgrade, "existing channel end is identical to proposed upgrade channel end: got {ORDER_UNORDERED [connection-0] mock-version}"), - }, - { - name: "fails when connection versions do not exist", - malleate: func() { - // update channel version first so that existing channel end is not identical to proposed upgrade - proposedUpgrade.Version = mock.UpgradeVersion - - path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { - c.Versions = []*connectiontypes.Version{} - }) - }, - expErr: errorsmod.Wrapf(connectiontypes.ErrInvalidVersion, "single version must be negotiated on connection before opening channel, got: []"), - }, - { - name: "fails when connection version does not support the new ordering", - malleate: func() { - // update channel version first so that existing channel end is not identical to proposed upgrade - proposedUpgrade.Version = mock.UpgradeVersion - - path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { - c.Versions = []*connectiontypes.Version{connectiontypes.NewVersion("1", []string{"ORDER_ORDERED"})} - }) - }, - expErr: errorsmod.Wrapf(connectiontypes.ErrInvalidVersion, "connection version identifier:\"1\" features:\"ORDER_ORDERED\" does not support channel ordering: ORDER_UNORDERED"), - }, - } - - for _, tc := range tests { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - existingChannel := path.EndpointA.GetChannel() - proposedUpgrade = &types.UpgradeFields{ - Ordering: existingChannel.Ordering, - ConnectionHops: existingChannel.ConnectionHops, - Version: existingChannel.Version, - } - - tc.malleate() - - err := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ValidateSelfUpgradeFields(suite.chainA.GetContext(), *proposedUpgrade, existingChannel) - if tc.expErr == nil { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expErr) - } - }) - } -} - -func (suite *KeeperTestSuite) assertUpgradeError(actualError, expError error) { - suite.Require().Error(actualError) - - if expUpgradeError, ok := expError.(*types.UpgradeError); ok { - upgradeError, ok := actualError.(*types.UpgradeError) - suite.Require().True(ok) - suite.Require().Equal(expUpgradeError.GetErrorReceipt(), upgradeError.GetErrorReceipt()) - } - - suite.Require().True(errorsmod.IsOf(actualError, expError), fmt.Sprintf("expected error: %s, actual error: %s", expError, actualError)) -} - -// TestAbortUpgrade tests that when the channel handshake is aborted, the channel state -// is restored the previous state and that an error receipt is written, and upgrade state which -// is no longer required is deleted. -func (suite *KeeperTestSuite) TestAbortUpgrade() { - var ( - path *ibctesting.Path - upgradeError error - ) - - tests := []struct { - name string - malleate func() - expErr error - }{ - { - name: "success", - malleate: func() {}, - expErr: nil, - }, - { - name: "regular error", - malleate: func() { - // in app callbacks error receipts should still be written if a regular error is returned. - // i.e. not an instance of `types.UpgradeError` - upgradeError = types.ErrInvalidUpgrade - }, - expErr: nil, - }, - { - name: "channel does not exist", - malleate: func() { - suite.chainA.DeleteKey(host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - }, - expErr: types.ErrChannelNotFound, - }, - { - name: "fails with nil upgrade error", - malleate: func() { - upgradeError = nil - }, - expErr: types.ErrInvalidUpgradeError, - }, - } - - for _, tc := range tests { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - channelKeeper := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper - - path.EndpointA.ChannelConfig.Version = mock.UpgradeVersion - suite.Require().NoError(path.EndpointA.ChanUpgradeInit()) - - // fetch the upgrade before abort for assertions later on. - actualUpgrade, ok := channelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(ok, "upgrade should be found") - - upgradeError = types.NewUpgradeError(1, types.ErrInvalidChannel) - - tc.malleate() - - if tc.expErr == nil { - - ctx := suite.chainA.GetContext() - - suite.Require().NotPanics(func() { - channelKeeper.MustAbortUpgrade(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgradeError) - }) - - channel, found := channelKeeper.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found, "channel should be found") - - suite.Require().Equal(types.OPEN, channel.State, "channel state should be %s", types.OPEN.String()) - - _, found = channelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().False(found, "upgrade info should be deleted") - - errorReceipt, found := channelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found, "error receipt should be found") - - if upgradeError, ok := upgradeError.(*types.UpgradeError); ok { - suite.Require().Equal(upgradeError.GetErrorReceipt(), errorReceipt, "error receipt does not match expected error receipt") - } - } else { - - suite.Require().Panics(func() { - channelKeeper.MustAbortUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgradeError) - }) - - channel, found := channelKeeper.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - if found { // test cases uses a channel that exists - suite.Require().Equal(types.OPEN, channel.State, "channel state should not be restored to %s", types.OPEN.String()) - } - - _, found = channelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().False(found, "error receipt should not be found") - - upgrade, found := channelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - if found { // this should be all test cases except for when the upgrade is explicitly deleted. - suite.Require().Equal(actualUpgrade, upgrade, "upgrade info should not be deleted") - } - } - }) - } -} - -func (suite *KeeperTestSuite) TestCheckForUpgradeCompatibility() { - var ( - path *ibctesting.Path - upgradeFields types.UpgradeFields - counterpartyUpgradeFields types.UpgradeFields - ) - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "upgrade ordering is not the same on both sides", - func() { - upgradeFields.Ordering = types.ORDERED - }, - types.ErrIncompatibleCounterpartyUpgrade, - }, - { - "proposed connection is not found", - func() { - upgradeFields.ConnectionHops[0] = ibctesting.InvalidID - }, - connectiontypes.ErrConnectionNotFound, - }, - { - "proposed connection is not in OPEN state", - func() { - // reuse existing connection to create a new connection in a non OPEN state - connectionEnd := path.EndpointB.GetConnection() - connectionEnd.State = connectiontypes.UNINITIALIZED - connectionEnd.Counterparty.ConnectionId = counterpartyUpgradeFields.ConnectionHops[0] // both sides must be each other's counterparty - - // set proposed connection in state - proposedConnectionID := "connection-100" - suite.chainB.GetSimApp().GetIBCKeeper().ConnectionKeeper.SetConnection(suite.chainB.GetContext(), proposedConnectionID, connectionEnd) - upgradeFields.ConnectionHops[0] = proposedConnectionID - }, - connectiontypes.ErrInvalidConnectionState, - }, - { - "proposed connection ends are not each other's counterparty", - func() { - // reuse existing connection to create a new connection in a non OPEN state - connectionEnd := path.EndpointB.GetConnection() - // ensure counterparty connectionID does not match connectionID set in counterparty proposed upgrade - connectionEnd.Counterparty.ConnectionId = "connection-50" - - // set proposed connection in state - proposedConnectionID := "connection-100" - suite.chainB.GetSimApp().GetIBCKeeper().ConnectionKeeper.SetConnection(suite.chainB.GetContext(), proposedConnectionID, connectionEnd) - upgradeFields.ConnectionHops[0] = proposedConnectionID - }, - types.ErrIncompatibleCounterpartyUpgrade, - }, - { - "proposed upgrade version is not the same on both sides", - func() { - upgradeFields.Version = mock.Version - }, - types.ErrIncompatibleCounterpartyUpgrade, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - upgradeFields = path.EndpointA.GetProposedUpgrade().Fields - counterpartyUpgradeFields = path.EndpointB.GetProposedUpgrade().Fields - - tc.malleate() - - err = suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.CheckForUpgradeCompatibility(suite.chainB.GetContext(), upgradeFields, counterpartyUpgradeFields) - if tc.expError != nil { - suite.Require().ErrorIs(err, tc.expError) - } else { - suite.Require().NoError(err) - } - }) - } -} - -func (suite *KeeperTestSuite) TestChanUpgradeCrossingHelloWithHistoricalProofs() { - var path *ibctesting.Path - - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success", - func() {}, - nil, - }, - { - "counterparty (chain B) has already progressed to ACK step", - func() { - err := path.EndpointB.ChanUpgradeAck() - suite.Require().NoError(err) - }, - types.ErrInvalidChannelState, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeInit() - suite.Require().NoError(err) - - suite.coordinator.CommitBlock(suite.chainA, suite.chainB) - - err = path.EndpointB.UpdateClient() - suite.Require().NoError(err) - - historicalChannelProof, historicalUpgradeProof, proofHeight := path.EndpointA.QueryChannelUpgradeProof() - - err = path.EndpointA.ChanUpgradeTry() - suite.Require().NoError(err) - - tc.malleate() - - _, upgrade, err := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.ChanUpgradeTry( - suite.chainB.GetContext(), - path.EndpointB.ChannelConfig.PortID, - path.EndpointB.ChannelID, - path.EndpointB.GetChannelUpgrade().Fields.ConnectionHops, - path.EndpointA.GetChannelUpgrade().Fields, - 1, - historicalChannelProof, - historicalUpgradeProof, - proofHeight, - ) - - if tc.expError == nil { - suite.Require().NoError(err) - suite.Require().NotEmpty(upgrade) - } else { - suite.Require().ErrorIs(err, tc.expError) - } - }) - } -} - -func (suite *KeeperTestSuite) TestWriteErrorReceipt() { - var ( - path *ibctesting.Path - upgradeError *types.UpgradeError - channelKeeper *channelkeeper.Keeper - writeErrorReceiptFunc = func() { - channelKeeper.WriteErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgradeError) - } - ) - - testCases := []struct { - name string - malleate func() - expResult func() - }{ - { - "success", - func() {}, - func() { - suite.NotPanics(func() { writeErrorReceiptFunc() }) - }, - }, - { - "success: existing error receipt found at a lower sequence", - func() { - // write an error sequence with a lower sequence number - previousUpgradeError := types.NewUpgradeError(upgradeError.GetErrorReceipt().Sequence-1, types.ErrInvalidUpgrade) - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, previousUpgradeError) - }, - func() { - suite.NotPanics(func() { writeErrorReceiptFunc() }) - }, - }, - { - "failure: existing error receipt found at a higher sequence", - func() { - // write an error sequence with a higher sequence number - previousUpgradeError := types.NewUpgradeError(upgradeError.GetErrorReceipt().Sequence+1, types.ErrInvalidUpgrade) - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, previousUpgradeError) - }, - func() { - suite.PanicsWithError(errorsmod.Wrap(types.ErrInvalidUpgradeSequence, "error receipt sequence (10) must be greater than existing error receipt sequence (11)").Error(), writeErrorReceiptFunc) - }, - }, - { - "failure: upgrade exists for error receipt being written", - func() { - // attempt to write error receipt for existing upgrade without deleting upgrade info - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - ch := path.EndpointA.GetChannel() - upgradeError = types.NewUpgradeError(ch.UpgradeSequence, types.ErrInvalidUpgrade) - }, - func() { - suite.PanicsWithError(errorsmod.Wrap(types.ErrInvalidUpgradeSequence, "attempting to write error receipt at sequence (1) while upgrade information exists at the same sequence").Error(), writeErrorReceiptFunc) - }, - }, - { - "failure: channel not found", - func() { - suite.chainA.DeleteKey(host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) - }, - func() { - suite.PanicsWithError(errorsmod.Wrap(types.ErrChannelNotFound, fmt.Sprintf("port ID (mock) channel ID (%s)", path.EndpointA.ChannelID)).Error(), writeErrorReceiptFunc) - }, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - channelKeeper = suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper - - upgradeError = types.NewUpgradeError(10, types.ErrInvalidUpgrade) - - tc.malleate() - - tc.expResult() - }) - } -} diff --git a/modules/core/04-channel/migrations/v10/channel.pb.go b/modules/core/04-channel/migrations/v10/channel.pb.go new file mode 100644 index 00000000000..06fc23c08b7 --- /dev/null +++ b/modules/core/04-channel/migrations/v10/channel.pb.go @@ -0,0 +1,2964 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc.core.channel.v0/channel.proto + +package v10 + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + types "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// State defines if a channel is in one of the following states: +// CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or UNINITIALIZED. +type State int32 + +const ( + // Default State + UNINITIALIZED State = 0 + // A channel has just started the opening handshake. + INIT State = 1 + // A channel has acknowledged the handshake step on the counterparty chain. + TRYOPEN State = 2 + // A channel has completed the handshake. Open channels are + // ready to send and receive packets. + OPEN State = 3 + // A channel has been closed and can no longer be used to send or receive + // packets. + CLOSED State = 4 + // A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. + FLUSHING State = 5 + // A channel has just completed flushing any in-flight packets. + FLUSHCOMPLETE State = 6 +) + +var State_name = map[int32]string{ + 0: "STATE_UNINITIALIZED_UNSPECIFIED", + 1: "STATE_INIT", + 2: "STATE_TRYOPEN", + 3: "STATE_OPEN", + 4: "STATE_CLOSED", + 5: "STATE_FLUSHING", + 6: "STATE_FLUSHCOMPLETE", +} + +var State_value = map[string]int32{ + "STATE_UNINITIALIZED_UNSPECIFIED": 0, + "STATE_INIT": 1, + "STATE_TRYOPEN": 2, + "STATE_OPEN": 3, + "STATE_CLOSED": 4, + "STATE_FLUSHING": 5, + "STATE_FLUSHCOMPLETE": 6, +} + +func (x State) String() string { + return proto.EnumName(State_name, int32(x)) +} + +func (State) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{0} +} + +// Order defines if a channel is ORDERED or UNORDERED +type Order int32 + +const ( + // zero-value for channel ordering + NONE Order = 0 + // packets can be delivered in any order, which may differ from the order in + // which they were sent. + UNORDERED Order = 1 + // packets are delivered exactly in the order which they were sent + ORDERED Order = 2 +) + +var Order_name = map[int32]string{ + 0: "ORDER_NONE_UNSPECIFIED", + 1: "ORDER_UNORDERED", + 2: "ORDER_ORDERED", +} + +var Order_value = map[string]int32{ + "ORDER_NONE_UNSPECIFIED": 0, + "ORDER_UNORDERED": 1, + "ORDER_ORDERED": 2, +} + +func (x Order) String() string { + return proto.EnumName(Order_name, int32(x)) +} + +func (Order) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{1} +} + +// Channel defines pipeline for exactly-once packet delivery between specific +// modules on separate blockchains, which has at least one end capable of +// sending packets and one end capable of receiving packets. +type Channel struct { + // current state of the channel end + State State `protobuf:"varint,1,opt,name=state,proto3,enum=ibc.core.channel.v0.State" json:"state,omitempty"` + // whether the channel is ordered or unordered + Ordering Order `protobuf:"varint,2,opt,name=ordering,proto3,enum=ibc.core.channel.v0.Order" json:"ordering,omitempty"` + // counterparty channel end + Counterparty Counterparty `protobuf:"bytes,3,opt,name=counterparty,proto3" json:"counterparty"` + // list of connection identifiers, in order, along which packets sent on + // this channel will travel + ConnectionHops []string `protobuf:"bytes,4,rep,name=connection_hops,json=connectionHops,proto3" json:"connection_hops,omitempty"` + // opaque channel version, which is agreed upon during the handshake + Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"` + // upgrade sequence indicates the latest upgrade attempt performed by this channel + // the value of 0 indicates the channel has never been upgraded + UpgradeSequence uint64 `protobuf:"varint,6,opt,name=upgrade_sequence,json=upgradeSequence,proto3" json:"upgrade_sequence,omitempty"` +} + +func (m *Channel) Reset() { *m = Channel{} } +func (m *Channel) String() string { return proto.CompactTextString(m) } +func (*Channel) ProtoMessage() {} +func (*Channel) Descriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{0} +} +func (m *Channel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Channel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Channel.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Channel) XXX_Merge(src proto.Message) { + xxx_messageInfo_Channel.Merge(m, src) +} +func (m *Channel) XXX_Size() int { + return m.Size() +} +func (m *Channel) XXX_DiscardUnknown() { + xxx_messageInfo_Channel.DiscardUnknown(m) +} + +var xxx_messageInfo_Channel proto.InternalMessageInfo + +// IdentifiedChannel defines a channel with additional port and channel +// identifier fields. +type IdentifiedChannel struct { + // current state of the channel end + State State `protobuf:"varint,1,opt,name=state,proto3,enum=ibc.core.channel.v0.State" json:"state,omitempty"` + // whether the channel is ordered or unordered + Ordering Order `protobuf:"varint,2,opt,name=ordering,proto3,enum=ibc.core.channel.v0.Order" json:"ordering,omitempty"` + // counterparty channel end + Counterparty Counterparty `protobuf:"bytes,3,opt,name=counterparty,proto3" json:"counterparty"` + // list of connection identifiers, in order, along which packets sent on + // this channel will travel + ConnectionHops []string `protobuf:"bytes,4,rep,name=connection_hops,json=connectionHops,proto3" json:"connection_hops,omitempty"` + // opaque channel version, which is agreed upon during the handshake + Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"` + // port identifier + PortId string `protobuf:"bytes,6,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // channel identifier + ChannelId string `protobuf:"bytes,7,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // upgrade sequence indicates the latest upgrade attempt performed by this channel + // the value of 0 indicates the channel has never been upgraded + UpgradeSequence uint64 `protobuf:"varint,8,opt,name=upgrade_sequence,json=upgradeSequence,proto3" json:"upgrade_sequence,omitempty"` +} + +func (m *IdentifiedChannel) Reset() { *m = IdentifiedChannel{} } +func (m *IdentifiedChannel) String() string { return proto.CompactTextString(m) } +func (*IdentifiedChannel) ProtoMessage() {} +func (*IdentifiedChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{1} +} +func (m *IdentifiedChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IdentifiedChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IdentifiedChannel.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *IdentifiedChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_IdentifiedChannel.Merge(m, src) +} +func (m *IdentifiedChannel) XXX_Size() int { + return m.Size() +} +func (m *IdentifiedChannel) XXX_DiscardUnknown() { + xxx_messageInfo_IdentifiedChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_IdentifiedChannel proto.InternalMessageInfo + +// Counterparty defines a channel end counterparty +type Counterparty struct { + // port on the counterparty chain which owns the other end of the channel. + PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // channel end on the counterparty chain + ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *Counterparty) Reset() { *m = Counterparty{} } +func (m *Counterparty) String() string { return proto.CompactTextString(m) } +func (*Counterparty) ProtoMessage() {} +func (*Counterparty) Descriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{2} +} +func (m *Counterparty) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Counterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Counterparty.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Counterparty) XXX_Merge(src proto.Message) { + xxx_messageInfo_Counterparty.Merge(m, src) +} +func (m *Counterparty) XXX_Size() int { + return m.Size() +} +func (m *Counterparty) XXX_DiscardUnknown() { + xxx_messageInfo_Counterparty.DiscardUnknown(m) +} + +var xxx_messageInfo_Counterparty proto.InternalMessageInfo + +// Packet defines a type that carries data across different chains through IBC +type Packet struct { + // number corresponds to the order of sends and receives, where a Packet + // with an earlier sequence number must be sent and received before a Packet + // with a later sequence number. + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` + // identifies the port on the sending chain. + SourcePort string `protobuf:"bytes,2,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty"` + // identifies the channel end on the sending chain. + SourceChannel string `protobuf:"bytes,3,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty"` + // identifies the port on the receiving chain. + DestinationPort string `protobuf:"bytes,4,opt,name=destination_port,json=destinationPort,proto3" json:"destination_port,omitempty"` + // identifies the channel end on the receiving chain. + DestinationChannel string `protobuf:"bytes,5,opt,name=destination_channel,json=destinationChannel,proto3" json:"destination_channel,omitempty"` + // actual opaque bytes transferred directly to the application module + Data []byte `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"` + // block height after which the packet times out + TimeoutHeight types.Height `protobuf:"bytes,7,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height"` + // block timestamp (in nanoseconds) after which the packet times out + TimeoutTimestamp uint64 `protobuf:"varint,8,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` +} + +func (m *Packet) Reset() { *m = Packet{} } +func (m *Packet) String() string { return proto.CompactTextString(m) } +func (*Packet) ProtoMessage() {} +func (*Packet) Descriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{3} +} +func (m *Packet) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Packet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Packet.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Packet) XXX_Merge(src proto.Message) { + xxx_messageInfo_Packet.Merge(m, src) +} +func (m *Packet) XXX_Size() int { + return m.Size() +} +func (m *Packet) XXX_DiscardUnknown() { + xxx_messageInfo_Packet.DiscardUnknown(m) +} + +var xxx_messageInfo_Packet proto.InternalMessageInfo + +// PacketState defines the generic type necessary to retrieve and store +// packet commitments, acknowledgements, and receipts. +// Caller is responsible for knowing the context necessary to interpret this +// state as a commitment, acknowledgement, or a receipt. +type PacketState struct { + // channel port identifier. + PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // channel unique identifier. + ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // packet sequence. + Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"` + // embedded data that represents packet state. + Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *PacketState) Reset() { *m = PacketState{} } +func (m *PacketState) String() string { return proto.CompactTextString(m) } +func (*PacketState) ProtoMessage() {} +func (*PacketState) Descriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{4} +} +func (m *PacketState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PacketState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PacketState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PacketState) XXX_Merge(src proto.Message) { + xxx_messageInfo_PacketState.Merge(m, src) +} +func (m *PacketState) XXX_Size() int { + return m.Size() +} +func (m *PacketState) XXX_DiscardUnknown() { + xxx_messageInfo_PacketState.DiscardUnknown(m) +} + +var xxx_messageInfo_PacketState proto.InternalMessageInfo + +// PacketId is an identifier for a unique Packet +// Source chains refer to packets by source port/channel +// Destination chains refer to packets by destination port/channel +type PacketId struct { + // channel port identifier + PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + // channel unique identifier + ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // packet sequence + Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *PacketId) Reset() { *m = PacketId{} } +func (m *PacketId) String() string { return proto.CompactTextString(m) } +func (*PacketId) ProtoMessage() {} +func (*PacketId) Descriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{5} +} +func (m *PacketId) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PacketId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PacketId.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PacketId) XXX_Merge(src proto.Message) { + xxx_messageInfo_PacketId.Merge(m, src) +} +func (m *PacketId) XXX_Size() int { + return m.Size() +} +func (m *PacketId) XXX_DiscardUnknown() { + xxx_messageInfo_PacketId.DiscardUnknown(m) +} + +var xxx_messageInfo_PacketId proto.InternalMessageInfo + +// Acknowledgement is the recommended acknowledgement format to be used by +// app-specific protocols. +// NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental +// conflicts with other protobuf message formats used for acknowledgements. +// The first byte of any message with this format will be the non-ASCII values +// `0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: +// https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#acknowledgement-envelope +type Acknowledgement struct { + // response contains either a result or an error and must be non-empty + // + // Types that are valid to be assigned to Response: + // *Acknowledgement_Result + // *Acknowledgement_Error + Response isAcknowledgement_Response `protobuf_oneof:"response"` +} + +func (m *Acknowledgement) Reset() { *m = Acknowledgement{} } +func (m *Acknowledgement) String() string { return proto.CompactTextString(m) } +func (*Acknowledgement) ProtoMessage() {} +func (*Acknowledgement) Descriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{6} +} +func (m *Acknowledgement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Acknowledgement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Acknowledgement.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Acknowledgement) XXX_Merge(src proto.Message) { + xxx_messageInfo_Acknowledgement.Merge(m, src) +} +func (m *Acknowledgement) XXX_Size() int { + return m.Size() +} +func (m *Acknowledgement) XXX_DiscardUnknown() { + xxx_messageInfo_Acknowledgement.DiscardUnknown(m) +} + +var xxx_messageInfo_Acknowledgement proto.InternalMessageInfo + +type isAcknowledgement_Response interface { + isAcknowledgement_Response() + MarshalTo([]byte) (int, error) + Size() int +} + +type Acknowledgement_Result struct { + Result []byte `protobuf:"bytes,21,opt,name=result,proto3,oneof" json:"result,omitempty"` +} +type Acknowledgement_Error struct { + Error string `protobuf:"bytes,22,opt,name=error,proto3,oneof" json:"error,omitempty"` +} + +func (*Acknowledgement_Result) isAcknowledgement_Response() {} +func (*Acknowledgement_Error) isAcknowledgement_Response() {} + +func (m *Acknowledgement) GetResponse() isAcknowledgement_Response { + if m != nil { + return m.Response + } + return nil +} + +func (m *Acknowledgement) GetResult() []byte { + if x, ok := m.GetResponse().(*Acknowledgement_Result); ok { + return x.Result + } + return nil +} + +func (m *Acknowledgement) GetError() string { + if x, ok := m.GetResponse().(*Acknowledgement_Error); ok { + return x.Error + } + return "" +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Acknowledgement) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Acknowledgement_Result)(nil), + (*Acknowledgement_Error)(nil), + } +} + +// Timeout defines an execution deadline structure for 04-channel handlers. +// This includes packet lifecycle handlers as well as the upgrade handshake handlers. +// A valid Timeout contains either one or both of a timestamp and block height (sequence). +type Timeout struct { + // block height after which the packet or upgrade times out + Height types.Height `protobuf:"bytes,1,opt,name=height,proto3" json:"height"` + // block timestamp (in nanoseconds) after which the packet or upgrade times out + Timestamp uint64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (m *Timeout) Reset() { *m = Timeout{} } +func (m *Timeout) String() string { return proto.CompactTextString(m) } +func (*Timeout) ProtoMessage() {} +func (*Timeout) Descriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{7} +} +func (m *Timeout) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Timeout) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Timeout.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Timeout) XXX_Merge(src proto.Message) { + xxx_messageInfo_Timeout.Merge(m, src) +} +func (m *Timeout) XXX_Size() int { + return m.Size() +} +func (m *Timeout) XXX_DiscardUnknown() { + xxx_messageInfo_Timeout.DiscardUnknown(m) +} + +var xxx_messageInfo_Timeout proto.InternalMessageInfo + +func (m *Timeout) GetHeight() types.Height { + if m != nil { + return m.Height + } + return types.Height{} +} + +func (m *Timeout) GetTimestamp() uint64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +// Params defines the set of IBC channel parameters. +type Params struct { + // the relative timeout after which channel upgrades will time out. + UpgradeTimeout Timeout `protobuf:"bytes,1,opt,name=upgrade_timeout,json=upgradeTimeout,proto3" json:"upgrade_timeout"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{8} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetUpgradeTimeout() Timeout { + if m != nil { + return m.UpgradeTimeout + } + return Timeout{} +} + +func init() { + proto.RegisterEnum("ibc.core.channel.v0.State", State_name, State_value) + proto.RegisterEnum("ibc.core.channel.v0.Order", Order_name, Order_value) + proto.RegisterType((*Channel)(nil), "ibc.core.channel.v0.Channel") + proto.RegisterType((*IdentifiedChannel)(nil), "ibc.core.channel.v0.IdentifiedChannel") + proto.RegisterType((*Counterparty)(nil), "ibc.core.channel.v0.Counterparty") + proto.RegisterType((*Packet)(nil), "ibc.core.channel.v0.Packet") + proto.RegisterType((*PacketState)(nil), "ibc.core.channel.v0.PacketState") + proto.RegisterType((*PacketId)(nil), "ibc.core.channel.v0.PacketId") + proto.RegisterType((*Acknowledgement)(nil), "ibc.core.channel.v0.Acknowledgement") + proto.RegisterType((*Timeout)(nil), "ibc.core.channel.v0.Timeout") + proto.RegisterType((*Params)(nil), "ibc.core.channel.v0.Params") +} + +func init() { proto.RegisterFile("ibc.core.channel.v0/channel.proto", fileDescriptor_c3a07336710636a0) } + +var fileDescriptor_c3a07336710636a0 = []byte{ + // 936 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x4f, 0x6f, 0xe2, 0x46, + 0x14, 0xc7, 0xc4, 0xfc, 0x7b, 0x49, 0xc0, 0x3b, 0x69, 0x53, 0xcb, 0x4a, 0xc1, 0x8b, 0x5a, 0x95, + 0x4d, 0xb5, 0x90, 0x6c, 0xab, 0xaa, 0xda, 0x5b, 0x02, 0xde, 0xc5, 0x5a, 0x0a, 0xc8, 0xc0, 0xa1, + 0x7b, 0x41, 0xc6, 0x9e, 0x82, 0xb5, 0xe0, 0xa1, 0xf6, 0xc0, 0x6a, 0xd5, 0x73, 0xa5, 0x15, 0xa7, + 0x7e, 0x01, 0xa4, 0x4a, 0xfd, 0x0a, 0xfd, 0x10, 0x7b, 0xdc, 0xe3, 0x9e, 0xaa, 0x2a, 0xf9, 0x0e, + 0x3d, 0x57, 0x9e, 0x19, 0x07, 0x88, 0xa2, 0xa8, 0xaa, 0xd4, 0x5b, 0x4f, 0xcc, 0xfb, 0xbd, 0xdf, + 0x7b, 0xbf, 0xf7, 0x67, 0x18, 0x19, 0x1e, 0x7a, 0x23, 0xa7, 0xe6, 0x90, 0x00, 0xd7, 0x9c, 0x89, + 0xed, 0xfb, 0x78, 0x5a, 0x5b, 0x9e, 0xc7, 0xc7, 0xea, 0x3c, 0x20, 0x94, 0xa0, 0x23, 0x6f, 0xe4, + 0x54, 0x23, 0x4a, 0x35, 0xc6, 0x97, 0xe7, 0xda, 0x47, 0x63, 0x32, 0x26, 0xcc, 0x5f, 0x8b, 0x4e, + 0x9c, 0xaa, 0x95, 0x36, 0xd9, 0xa6, 0x1e, 0xf6, 0x29, 0x4b, 0xc6, 0x4e, 0x9c, 0x50, 0xfe, 0x3d, + 0x09, 0x99, 0x3a, 0xcf, 0x82, 0xce, 0x20, 0x15, 0x52, 0x9b, 0x62, 0x55, 0xd2, 0xa5, 0x4a, 0xfe, + 0x89, 0x56, 0xbd, 0x43, 0xa7, 0xda, 0x8b, 0x18, 0x16, 0x27, 0xa2, 0x6f, 0x20, 0x4b, 0x02, 0x17, + 0x07, 0x9e, 0x3f, 0x56, 0x93, 0xf7, 0x04, 0x75, 0x22, 0x92, 0x75, 0xc3, 0x45, 0x2f, 0xe0, 0xc0, + 0x21, 0x0b, 0x9f, 0xe2, 0x60, 0x6e, 0x07, 0xf4, 0x8d, 0xba, 0xa7, 0x4b, 0x95, 0xfd, 0x27, 0x0f, + 0xef, 0x8c, 0xad, 0x6f, 0x11, 0x2f, 0xe5, 0x77, 0x7f, 0x94, 0x12, 0xd6, 0x4e, 0x30, 0xfa, 0x02, + 0x0a, 0x0e, 0xf1, 0x7d, 0xec, 0x50, 0x8f, 0xf8, 0xc3, 0x09, 0x99, 0x87, 0xaa, 0xac, 0xef, 0x55, + 0x72, 0x56, 0x7e, 0x03, 0x37, 0xc9, 0x3c, 0x44, 0x2a, 0x64, 0x96, 0x38, 0x08, 0x3d, 0xe2, 0xab, + 0x29, 0x5d, 0xaa, 0xe4, 0xac, 0xd8, 0x44, 0x8f, 0x40, 0x59, 0xcc, 0xc7, 0x81, 0xed, 0xe2, 0x61, + 0x88, 0x7f, 0x5c, 0x60, 0xdf, 0xc1, 0x6a, 0x5a, 0x97, 0x2a, 0xb2, 0x55, 0x10, 0x78, 0x4f, 0xc0, + 0x4f, 0xe5, 0xb7, 0xbf, 0x96, 0x12, 0xe5, 0xbf, 0x92, 0xf0, 0xc0, 0x74, 0xb1, 0x4f, 0xbd, 0x1f, + 0x3c, 0xec, 0xfe, 0x3f, 0xc0, 0x4f, 0x20, 0x33, 0x27, 0x01, 0x1d, 0x7a, 0x2e, 0x9b, 0x5b, 0xce, + 0x4a, 0x47, 0xa6, 0xe9, 0xa2, 0x4f, 0x01, 0x44, 0x29, 0x91, 0x2f, 0xc3, 0x7c, 0x39, 0x81, 0x98, + 0xee, 0x9d, 0x83, 0xcf, 0xde, 0x37, 0xf8, 0x16, 0x1c, 0x6c, 0xf7, 0xb3, 0x2d, 0x2c, 0xdd, 0x23, + 0x9c, 0xbc, 0x25, 0x2c, 0xb2, 0x7d, 0x48, 0x42, 0xba, 0x6b, 0x3b, 0xaf, 0x30, 0x45, 0x1a, 0x64, + 0x6f, 0x2a, 0x90, 0x58, 0x05, 0x37, 0x36, 0x2a, 0xc1, 0x7e, 0x48, 0x16, 0x81, 0x83, 0x87, 0x51, + 0x72, 0x91, 0x0c, 0x38, 0xd4, 0x25, 0x01, 0x45, 0x9f, 0x43, 0x5e, 0x10, 0x84, 0x02, 0x5b, 0x48, + 0xce, 0x3a, 0xe4, 0x68, 0x7c, 0x3f, 0x1e, 0x81, 0xe2, 0xe2, 0x90, 0x7a, 0xbe, 0xcd, 0x26, 0xcd, + 0x92, 0xc9, 0x8c, 0x58, 0xd8, 0xc2, 0x59, 0xc6, 0x1a, 0x1c, 0x6d, 0x53, 0xe3, 0xb4, 0x7c, 0xec, + 0x68, 0xcb, 0x15, 0xe7, 0x46, 0x20, 0xbb, 0x36, 0xb5, 0xd9, 0xf8, 0x0f, 0x2c, 0x76, 0x46, 0xcf, + 0x21, 0x4f, 0xbd, 0x19, 0x26, 0x0b, 0x3a, 0x9c, 0x60, 0x6f, 0x3c, 0xa1, 0x6c, 0x01, 0xfb, 0x3b, + 0x77, 0x8c, 0x3f, 0x06, 0xcb, 0xf3, 0x6a, 0x93, 0x31, 0xc4, 0x05, 0x39, 0x14, 0x71, 0x1c, 0x44, + 0x5f, 0xc2, 0x83, 0x38, 0x51, 0xf4, 0x1b, 0x52, 0x7b, 0x36, 0x17, 0x7b, 0x52, 0x84, 0xa3, 0x1f, + 0xe3, 0x62, 0xb4, 0x3f, 0xc1, 0x3e, 0x9f, 0x2c, 0xbb, 0xef, 0xff, 0x76, 0x4f, 0x3b, 0x6b, 0xd9, + 0xbb, 0xb5, 0x96, 0xb8, 0x65, 0x79, 0xd3, 0xb2, 0x10, 0x77, 0x21, 0xcb, 0xc5, 0x4d, 0xf7, 0xbf, + 0x50, 0x16, 0x2a, 0x1d, 0x28, 0x5c, 0x38, 0xaf, 0x7c, 0xf2, 0x7a, 0x8a, 0xdd, 0x31, 0x9e, 0x61, + 0x9f, 0x22, 0x15, 0xd2, 0x01, 0x0e, 0x17, 0x53, 0xaa, 0x7e, 0x1c, 0x15, 0xd5, 0x4c, 0x58, 0xc2, + 0x46, 0xc7, 0x90, 0xc2, 0x41, 0x40, 0x02, 0xf5, 0x38, 0x12, 0x6a, 0x26, 0x2c, 0x6e, 0x5e, 0x02, + 0x64, 0x03, 0x1c, 0xce, 0x89, 0x1f, 0xe2, 0xb2, 0x0d, 0x99, 0x3e, 0x9f, 0x26, 0xfa, 0x16, 0xd2, + 0x62, 0x65, 0xd2, 0x3f, 0x5c, 0x99, 0xe0, 0xa3, 0x13, 0xc8, 0x6d, 0x76, 0x94, 0x64, 0x85, 0x6f, + 0x80, 0xf2, 0x20, 0xba, 0xf0, 0x81, 0x3d, 0x0b, 0xd1, 0x0b, 0x88, 0xff, 0x62, 0x43, 0xb1, 0x42, + 0x21, 0x75, 0x72, 0xe7, 0x2b, 0x22, 0x0a, 0x13, 0x62, 0x79, 0x11, 0x2a, 0xd0, 0xd3, 0x9f, 0x93, + 0x90, 0xea, 0x89, 0x17, 0xad, 0xd4, 0xeb, 0x5f, 0xf4, 0x8d, 0xe1, 0xa0, 0x6d, 0xb6, 0xcd, 0xbe, + 0x79, 0xd1, 0x32, 0x5f, 0x1a, 0x8d, 0xe1, 0xa0, 0xdd, 0xeb, 0x1a, 0x75, 0xf3, 0x99, 0x69, 0x34, + 0x94, 0x84, 0xf6, 0x60, 0xb5, 0xd6, 0x0f, 0x77, 0x08, 0x48, 0x05, 0xe0, 0x71, 0x11, 0xa8, 0x48, + 0x5a, 0x76, 0xb5, 0xd6, 0xe5, 0xe8, 0x8c, 0x8a, 0x70, 0xc8, 0x3d, 0x7d, 0xeb, 0xfb, 0x4e, 0xd7, + 0x68, 0x2b, 0x49, 0x6d, 0x7f, 0xb5, 0xd6, 0x33, 0xc2, 0xdc, 0x44, 0x32, 0xe7, 0x1e, 0x8f, 0x64, + 0x9e, 0x13, 0x38, 0xe0, 0x9e, 0x7a, 0xab, 0xd3, 0x33, 0x1a, 0x8a, 0xac, 0xc1, 0x6a, 0xad, 0xa7, + 0xb9, 0x85, 0x74, 0xc8, 0x73, 0xef, 0xb3, 0xd6, 0xa0, 0xd7, 0x34, 0xdb, 0xcf, 0x95, 0x94, 0x76, + 0xb0, 0x5a, 0xeb, 0xd9, 0xd8, 0x46, 0xa7, 0x70, 0xb4, 0xc5, 0xa8, 0x77, 0xbe, 0xeb, 0xb6, 0x8c, + 0xbe, 0xa1, 0xa4, 0x79, 0xfd, 0x3b, 0xa0, 0x26, 0xbf, 0xfd, 0xad, 0x98, 0x38, 0x7d, 0x0d, 0x29, + 0xf6, 0x54, 0xa3, 0xcf, 0xe0, 0xb8, 0x63, 0x35, 0x0c, 0x6b, 0xd8, 0xee, 0xb4, 0x8d, 0x5b, 0xdd, + 0xb3, 0x02, 0x23, 0x1c, 0x95, 0xa1, 0xc0, 0x59, 0x83, 0x36, 0xfb, 0x35, 0x1a, 0x8a, 0xa4, 0x1d, + 0xae, 0xd6, 0x7a, 0xee, 0x06, 0x88, 0xda, 0xe7, 0x9c, 0x98, 0x21, 0xda, 0x17, 0x26, 0x17, 0xbe, + 0xec, 0xbf, 0xbb, 0x2a, 0x4a, 0xef, 0xaf, 0x8a, 0xd2, 0x9f, 0x57, 0x45, 0xe9, 0x97, 0xeb, 0x62, + 0xe2, 0xfd, 0x75, 0x31, 0xf1, 0xe1, 0xba, 0x98, 0x78, 0xf9, 0x74, 0xec, 0xd1, 0xc9, 0x62, 0x54, + 0x75, 0xc8, 0xac, 0xe6, 0x90, 0x70, 0x46, 0xc2, 0x9a, 0x37, 0x72, 0x1e, 0x8f, 0x49, 0x6d, 0x79, + 0x7e, 0x56, 0x9b, 0x11, 0x77, 0x31, 0xc5, 0x21, 0xff, 0x46, 0x38, 0xfb, 0xfa, 0x71, 0xfc, 0xd1, + 0x41, 0xdf, 0xcc, 0x71, 0x38, 0x4a, 0xb3, 0x8f, 0x84, 0xaf, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, + 0xaf, 0x78, 0x54, 0x46, 0x95, 0x08, 0x00, 0x00, +} + +func (m *Channel) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Channel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Channel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.UpgradeSequence != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.UpgradeSequence)) + i-- + dAtA[i] = 0x30 + } + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0x2a + } + if len(m.ConnectionHops) > 0 { + for iNdEx := len(m.ConnectionHops) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ConnectionHops[iNdEx]) + copy(dAtA[i:], m.ConnectionHops[iNdEx]) + i = encodeVarintChannel(dAtA, i, uint64(len(m.ConnectionHops[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + { + size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Ordering != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.Ordering)) + i-- + dAtA[i] = 0x10 + } + if m.State != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.State)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *IdentifiedChannel) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IdentifiedChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IdentifiedChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.UpgradeSequence != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.UpgradeSequence)) + i-- + dAtA[i] = 0x40 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x3a + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0x32 + } + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0x2a + } + if len(m.ConnectionHops) > 0 { + for iNdEx := len(m.ConnectionHops) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ConnectionHops[iNdEx]) + copy(dAtA[i:], m.ConnectionHops[iNdEx]) + i = encodeVarintChannel(dAtA, i, uint64(len(m.ConnectionHops[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + { + size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Ordering != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.Ordering)) + i-- + dAtA[i] = 0x10 + } + if m.State != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.State)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Counterparty) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Counterparty) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Counterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Packet) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Packet) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TimeoutTimestamp != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.TimeoutTimestamp)) + i-- + dAtA[i] = 0x40 + } + { + size, err := m.TimeoutHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x32 + } + if len(m.DestinationChannel) > 0 { + i -= len(m.DestinationChannel) + copy(dAtA[i:], m.DestinationChannel) + i = encodeVarintChannel(dAtA, i, uint64(len(m.DestinationChannel))) + i-- + dAtA[i] = 0x2a + } + if len(m.DestinationPort) > 0 { + i -= len(m.DestinationPort) + copy(dAtA[i:], m.DestinationPort) + i = encodeVarintChannel(dAtA, i, uint64(len(m.DestinationPort))) + i-- + dAtA[i] = 0x22 + } + if len(m.SourceChannel) > 0 { + i -= len(m.SourceChannel) + copy(dAtA[i:], m.SourceChannel) + i = encodeVarintChannel(dAtA, i, uint64(len(m.SourceChannel))) + i-- + dAtA[i] = 0x1a + } + if len(m.SourcePort) > 0 { + i -= len(m.SourcePort) + copy(dAtA[i:], m.SourcePort) + i = encodeVarintChannel(dAtA, i, uint64(len(m.SourcePort))) + i-- + dAtA[i] = 0x12 + } + if m.Sequence != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PacketState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PacketState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PacketState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x22 + } + if m.Sequence != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x18 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PacketId) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PacketId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PacketId) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sequence != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x18 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Acknowledgement) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Acknowledgement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Acknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Response != nil { + { + size := m.Response.Size() + i -= size + if _, err := m.Response.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *Acknowledgement_Result) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Acknowledgement_Result) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Result != nil { + i -= len(m.Result) + copy(dAtA[i:], m.Result) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Result))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xaa + } + return len(dAtA) - i, nil +} +func (m *Acknowledgement_Error) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Acknowledgement_Error) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i -= len(m.Error) + copy(dAtA[i:], m.Error) + i = encodeVarintChannel(dAtA, i, uint64(len(m.Error))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xb2 + return len(dAtA) - i, nil +} +func (m *Timeout) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Timeout) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Timeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Timestamp != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x10 + } + { + size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.UpgradeTimeout.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChannel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintChannel(dAtA []byte, offset int, v uint64) int { + offset -= sovChannel(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Channel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.State != 0 { + n += 1 + sovChannel(uint64(m.State)) + } + if m.Ordering != 0 { + n += 1 + sovChannel(uint64(m.Ordering)) + } + l = m.Counterparty.Size() + n += 1 + l + sovChannel(uint64(l)) + if len(m.ConnectionHops) > 0 { + for _, s := range m.ConnectionHops { + l = len(s) + n += 1 + l + sovChannel(uint64(l)) + } + } + l = len(m.Version) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + if m.UpgradeSequence != 0 { + n += 1 + sovChannel(uint64(m.UpgradeSequence)) + } + return n +} + +func (m *IdentifiedChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.State != 0 { + n += 1 + sovChannel(uint64(m.State)) + } + if m.Ordering != 0 { + n += 1 + sovChannel(uint64(m.Ordering)) + } + l = m.Counterparty.Size() + n += 1 + l + sovChannel(uint64(l)) + if len(m.ConnectionHops) > 0 { + for _, s := range m.ConnectionHops { + l = len(s) + n += 1 + l + sovChannel(uint64(l)) + } + } + l = len(m.Version) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + if m.UpgradeSequence != 0 { + n += 1 + sovChannel(uint64(m.UpgradeSequence)) + } + return n +} + +func (m *Counterparty) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + return n +} + +func (m *Packet) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sequence != 0 { + n += 1 + sovChannel(uint64(m.Sequence)) + } + l = len(m.SourcePort) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.SourceChannel) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.DestinationPort) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.DestinationChannel) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = m.TimeoutHeight.Size() + n += 1 + l + sovChannel(uint64(l)) + if m.TimeoutTimestamp != 0 { + n += 1 + sovChannel(uint64(m.TimeoutTimestamp)) + } + return n +} + +func (m *PacketState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovChannel(uint64(m.Sequence)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + return n +} + +func (m *PacketId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovChannel(uint64(m.Sequence)) + } + return n +} + +func (m *Acknowledgement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Response != nil { + n += m.Response.Size() + } + return n +} + +func (m *Acknowledgement_Result) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Result != nil { + l = len(m.Result) + n += 2 + l + sovChannel(uint64(l)) + } + return n +} +func (m *Acknowledgement_Error) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Error) + n += 2 + l + sovChannel(uint64(l)) + return n +} +func (m *Timeout) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Height.Size() + n += 1 + l + sovChannel(uint64(l)) + if m.Timestamp != 0 { + n += 1 + sovChannel(uint64(m.Timestamp)) + } + return n +} + +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.UpgradeTimeout.Size() + n += 1 + l + sovChannel(uint64(l)) + return n +} + +func sovChannel(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozChannel(x uint64) (n int) { + return sovChannel(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Channel) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Channel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Channel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) + } + m.State = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.State |= State(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Ordering", wireType) + } + m.Ordering = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Ordering |= Order(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionHops", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnectionHops = append(m.ConnectionHops, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UpgradeSequence", wireType) + } + m.UpgradeSequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UpgradeSequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *IdentifiedChannel) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IdentifiedChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IdentifiedChannel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) + } + m.State = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.State |= State(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Ordering", wireType) + } + m.Ordering = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Ordering |= Order(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionHops", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnectionHops = append(m.ConnectionHops, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UpgradeSequence", wireType) + } + m.UpgradeSequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UpgradeSequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Counterparty) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Counterparty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Counterparty: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Packet) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Packet: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Packet: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePort", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourcePort = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceChannel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DestinationPort", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DestinationPort = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DestinationChannel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DestinationChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TimeoutHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutTimestamp", wireType) + } + m.TimeoutTimestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeoutTimestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PacketState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PacketState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PacketState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PacketId) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PacketId: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PacketId: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Acknowledgement) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Acknowledgement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Acknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 21: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := make([]byte, postIndex-iNdEx) + copy(v, dAtA[iNdEx:postIndex]) + m.Response = &Acknowledgement_Result{v} + iNdEx = postIndex + case 22: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Response = &Acknowledgement_Error{string(dAtA[iNdEx:postIndex])} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Timeout) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Timeout: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Timeout: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Height.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpgradeTimeout", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.UpgradeTimeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipChannel(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowChannel + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowChannel + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowChannel + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthChannel + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupChannel + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthChannel + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthChannel = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowChannel = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupChannel = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/04-channel/migrations/v10/expected_keepers.go b/modules/core/04-channel/migrations/v10/expected_keepers.go new file mode 100644 index 00000000000..480a945908c --- /dev/null +++ b/modules/core/04-channel/migrations/v10/expected_keepers.go @@ -0,0 +1,14 @@ +package v10 + +import ( + "cosmossdk.io/log" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" +) + +type ChannelKeeper interface { + Logger(ctx sdk.Context) log.Logger + SetChannel(ctx sdk.Context, portID, channelID string, channel types.Channel) +} diff --git a/modules/core/04-channel/migrations/v10/store.go b/modules/core/04-channel/migrations/v10/store.go new file mode 100644 index 00000000000..29f6f5cadf1 --- /dev/null +++ b/modules/core/04-channel/migrations/v10/store.go @@ -0,0 +1,123 @@ +package v10 + +import ( + fmt "fmt" + + corestore "cosmossdk.io/core/store" + storetypes "cosmossdk.io/store/types" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/runtime" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v10/modules/core/24-host" +) + +const ( + // ParamsKey defines the key to store the params in the keeper. + ParamsKey = "channelParams" + KeyPruningSequenceStart = "pruningSequenceStart" + + KeyChannelUpgradePrefix = "channelUpgrades" + KeyUpgradePrefix = "upgrades" + KeyUpgradeErrorPrefix = "upgradeError" + KeyCounterpartyUpgrade = "counterpartyUpgrade" +) + +// PruningSequenceStartKey returns the store key for the pruning sequence start of a particular channel +func PruningSequenceStartKey(portID, channelID string) []byte { + return []byte(fmt.Sprintf("%s/%s", KeyPruningSequenceStart, channelPath(portID, channelID))) +} + +func ChannelUpgradeKey(portID, channelID string) []byte { + return []byte(fmt.Sprintf("%s/%s/%s", KeyChannelUpgradePrefix, KeyUpgradePrefix, channelPath(portID, channelID))) +} + +func ChannelUpgradeErrorKey(portID, channelID string) []byte { + return []byte(fmt.Sprintf("%s/%s/%s", KeyChannelUpgradePrefix, KeyUpgradeErrorPrefix, channelPath(portID, channelID))) +} + +func ChannelCounterpartyUpgradeKey(portID, channelID string) []byte { + return []byte(fmt.Sprintf("%s/%s/%s", KeyChannelUpgradePrefix, KeyCounterpartyUpgrade, channelPath(portID, channelID))) +} + +func channelPath(portID, channelID string) string { + return fmt.Sprintf("%s/%s/%s/%s", host.KeyPortPrefix, portID, host.KeyChannelPrefix, channelID) +} + +// MigrateStore migrates the channel store to the ibc-go v10 store by: +// - Removing channel upgrade sequences +// - Removing any channel upgrade info (i.e. upgrades, counterparty upgrades, upgrade errors) +// - Removing channel params +// - Removing pruning sequences +// NOTE: This migration will fail if any channels are in the FLUSHING or FLUSHCOMPLETE state. +func MigrateStore(ctx sdk.Context, storeService corestore.KVStoreService, cdc codec.BinaryCodec, channelKeeper ChannelKeeper) error { + store := storeService.OpenKVStore(ctx) + + if err := handleChannelMigration(ctx, store, cdc, channelKeeper); err != nil { + return err + } + if err := deleteChannelUpgrades(store); err != nil { + return err + } + if err := deleteParams(store); err != nil { + return err + } + if err := deletePruneSequences(store); err != nil { + return err + } + + // TODO: See if there is more to migrate/delete from store + + return nil +} + +func handleChannelMigration(ctx sdk.Context, store corestore.KVStore, cdc codec.BinaryCodec, channelKeeper ChannelKeeper) error { + // Remove channel upgrade sequences and set in-upgrade channels back to open + iterator := storetypes.KVStorePrefixIterator(runtime.KVStoreAdapter(store), []byte(host.KeyChannelEndPrefix)) + + defer sdk.LogDeferred(channelKeeper.Logger(ctx), func() error { return iterator.Close() }) + for ; iterator.Valid(); iterator.Next() { + var channel Channel + cdc.MustUnmarshal(iterator.Value(), &channel) + + if channel.State == FLUSHING || channel.State == FLUSHCOMPLETE { + return fmt.Errorf("channel in state FLUSHING or FLUSHCOMPLETE found, to proceed with migration, please ensure no channels are currently upgrading") + } + + newChannel := types.Channel{ + State: types.State(channel.State), + Ordering: types.Order(channel.Ordering), + Counterparty: types.Counterparty{ + PortId: channel.Counterparty.PortId, + ChannelId: channel.Counterparty.ChannelId, + }, + ConnectionHops: channel.ConnectionHops, + Version: channel.Version, + } + // Any pitfalls of doing this? + if err := newChannel.ValidateBasic(); err != nil { + return err + } + portID, channelID := host.MustParseChannelPath(string(iterator.Key())) + channelKeeper.SetChannel(ctx, portID, channelID, newChannel) + } + + return nil +} + +func deleteChannelUpgrades(store corestore.KVStore) error { + // Delete channel upgrades (i.e. upgrades, counterparty upgrades, upgrade errors, which are stored in the channelUpgrades prefix) + return store.Delete([]byte(KeyChannelUpgradePrefix)) +} + +func deleteParams(store corestore.KVStore) error { + // Delete channel params + return store.Delete([]byte(ParamsKey)) +} + +func deletePruneSequences(store corestore.KVStore) error { + // Delete all pruning sequences + return store.Delete([]byte(KeyPruningSequenceStart)) +} diff --git a/modules/core/04-channel/migrations/v10/store_test.go b/modules/core/04-channel/migrations/v10/store_test.go new file mode 100644 index 00000000000..f9e0cd54f5b --- /dev/null +++ b/modules/core/04-channel/migrations/v10/store_test.go @@ -0,0 +1,232 @@ +package v10_test + +import ( + "testing" + + testifysuite "github.com/stretchr/testify/suite" + + corestore "cosmossdk.io/core/store" + storetypes "cosmossdk.io/store/types" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/runtime" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/v10/modules/core/04-channel/keeper" + v10 "github.com/cosmos/ibc-go/v10/modules/core/04-channel/migrations/v10" + host "github.com/cosmos/ibc-go/v10/modules/core/24-host" + ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported" + ibctesting "github.com/cosmos/ibc-go/v10/testing" +) + +type MigrationsV10TestSuite struct { + testifysuite.Suite + + coordinator *ibctesting.Coordinator + + chainA *ibctesting.TestChain + chainB *ibctesting.TestChain +} + +func (suite *MigrationsV10TestSuite) SetupTest() { + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) + + suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) + suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) +} + +func TestMigrationsV10TestSuite(t *testing.T) { + testifysuite.Run(t, new(MigrationsV10TestSuite)) +} + +// set up channels that are still in upgrade state, and assert that the upgrade fails. +// migrate the store, and assert that the channels have been upgraded and state removed as expected +func (suite *MigrationsV10TestSuite) TestMigrateStoreWithUpgradingChannels() { + ctx := suite.chainA.GetContext() + cdc := suite.chainA.App.AppCodec() + channelKeeper := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper + storeService := runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey)) + + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.Setup() + path = ibctesting.NewPath(suite.chainA, suite.chainB) + path.Setup() + + preMigrationChannels := suite.getPreMigrationTypeChannels(ctx, cdc, storeService) + suite.Require().Len(preMigrationChannels, 2) + + // Set up some channels with old state + flushingChannel := preMigrationChannels[0] + flushingChannel.State = v10.FLUSHING + suite.setPreMigrationChannel(ctx, cdc, storeService, flushingChannel) + + flushCompleteChannel := preMigrationChannels[1] + flushCompleteChannel.State = v10.FLUSHCOMPLETE + suite.setPreMigrationChannel(ctx, cdc, storeService, flushCompleteChannel) + + err := v10.MigrateStore(ctx, storeService, cdc, channelKeeper) + suite.Require().Errorf(err, "channel in state FLUSHING or FLUSHCOMPLETE found, to proceed with migration, please ensure no channels are currently upgrading") +} + +// set up channels, upgrades, params, and prune sequences in the store, +// migrate the store, and assert that the channels have been upgraded and state removed as expected +func (suite *MigrationsV10TestSuite) TestMigrateStore() { + ctx := suite.chainA.GetContext() + cdc := suite.chainA.App.AppCodec() + channelKeeper := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper + storeService := runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey)) + store := storeService.OpenKVStore(ctx) + numberOfChannels := 100 + + for i := 0; i < numberOfChannels; i++ { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.Setup() + } + + preMigrationChannels := suite.getPreMigrationTypeChannels(ctx, cdc, storeService) + suite.Require().Len(preMigrationChannels, numberOfChannels) + + // Set up some channels with old state + testChannel1 := preMigrationChannels[0] + testChannel2 := preMigrationChannels[1] + + // Set some upgrades + upgrade := v10.Upgrade{ + Fields: v10.UpgradeFields{ + Ordering: v10.ORDERED, + ConnectionHops: []string{"connection-0"}, + Version: testChannel1.Version, + }, + Timeout: v10.Timeout{}, + NextSequenceSend: 2, + } + err := store.Set(v10.ChannelUpgradeKey(testChannel1.PortId, testChannel1.ChannelId), cdc.MustMarshal(&upgrade)) + suite.Require().NoError(err) + upgrade = v10.Upgrade{ + Fields: v10.UpgradeFields{ + Ordering: v10.ORDERED, + ConnectionHops: []string{"connection-0"}, + Version: testChannel2.Version, + }, + Timeout: v10.Timeout{}, + NextSequenceSend: 20, + } + err = store.Set(v10.ChannelUpgradeKey(testChannel2.PortId, testChannel2.ChannelId), cdc.MustMarshal(&upgrade)) + suite.Require().NoError(err) + + counterpartyUpgrade := v10.Upgrade{ + Fields: v10.UpgradeFields{ + Ordering: v10.ORDERED, + ConnectionHops: []string{"connection-0"}, + Version: testChannel2.Version, + }, + Timeout: v10.Timeout{}, + NextSequenceSend: 20, + } + err = store.Set(v10.ChannelCounterpartyUpgradeKey(testChannel2.PortId, testChannel2.ChannelId), cdc.MustMarshal(&counterpartyUpgrade)) + suite.Require().NoError(err) + + errorReceipt := v10.ErrorReceipt{ + Sequence: 3, + Message: "🤷", + } + err = store.Set(v10.ChannelUpgradeErrorKey(testChannel1.PortId, testChannel1.ChannelId), cdc.MustMarshal(&errorReceipt)) + suite.Require().NoError(err) + + // Set some params + err = store.Set([]byte(v10.ParamsKey), cdc.MustMarshal(&v10.Params{UpgradeTimeout: v10.Timeout{ + Timestamp: 1000, + }})) + suite.Require().NoError(err) + + // Set some prune sequences + err = store.Set(v10.PruningSequenceStartKey(testChannel1.PortId, testChannel1.ChannelId), sdk.Uint64ToBigEndian(0)) + suite.Require().NoError(err) + err = store.Set(v10.PruningSequenceStartKey(testChannel2.PortId, testChannel2.ChannelId), sdk.Uint64ToBigEndian(42)) + suite.Require().NoError(err) + + err = v10.MigrateStore(ctx, storeService, cdc, channelKeeper) + suite.Require().NoError(err) + + suite.assertChannelsUpgraded(ctx, suite.chainA.App.AppCodec(), storeService, channelKeeper, preMigrationChannels) + suite.assertNoUpgrades(ctx, storeService) + suite.assertNoParms(ctx, storeService) + suite.assertNoPruneSequences(ctx, storeService) +} + +func (suite *MigrationsV10TestSuite) setPreMigrationChannel(ctx sdk.Context, cdc codec.Codec, storeService corestore.KVStoreService, channel v10.IdentifiedChannel) { + store := storeService.OpenKVStore(ctx) + channelKey := host.ChannelKey(channel.PortId, channel.ChannelId) + err := store.Set(channelKey, cdc.MustMarshal(&v10.Channel{ + State: channel.State, + Ordering: channel.Ordering, + Counterparty: channel.Counterparty, + ConnectionHops: channel.ConnectionHops, + Version: channel.Version, + UpgradeSequence: channel.UpgradeSequence, + })) + suite.Require().NoError(err) +} + +func (suite *MigrationsV10TestSuite) getPreMigrationTypeChannels(ctx sdk.Context, cdc codec.Codec, storeService corestore.KVStoreService) []v10.IdentifiedChannel { + var channels []v10.IdentifiedChannel + + iterator := storetypes.KVStorePrefixIterator(runtime.KVStoreAdapter(storeService.OpenKVStore(ctx)), []byte(host.KeyChannelEndPrefix)) + for ; iterator.Valid(); iterator.Next() { + var channel v10.Channel + err := cdc.Unmarshal(iterator.Value(), &channel) + suite.Require().NoError(err) + + portID, channelID, err := host.ParseChannelPath(string(iterator.Key())) + identifiedChannel := v10.IdentifiedChannel{ + State: channel.State, + Ordering: channel.Ordering, + Counterparty: channel.Counterparty, + ConnectionHops: channel.ConnectionHops, + Version: channel.Version, + PortId: portID, + ChannelId: channelID, + UpgradeSequence: channel.UpgradeSequence, + } + suite.Require().NoError(err) + channels = append(channels, identifiedChannel) + + } + iterator.Close() + + return channels +} + +func (suite *MigrationsV10TestSuite) assertChannelsUpgraded(ctx sdk.Context, cdc codec.Codec, storeService corestore.KVStoreService, channelKeeper *keeper.Keeper, preMigrationChannels []v10.IdentifiedChannel) { + // First check that all channels have gotten the old state pruned + newChannelsWithPreMigrationType := suite.getPreMigrationTypeChannels(ctx, cdc, storeService) + for _, channel := range newChannelsWithPreMigrationType { + suite.Require().NotEqual(v10.FLUSHING, channel.State) + suite.Require().NotEqual(v10.FLUSHCOMPLETE, channel.State) + suite.Require().Equal(uint64(0), channel.UpgradeSequence) + } + + // Then check that we can still receive all the channels + newChannelsWithPostMigrationType := channelKeeper.GetAllChannels(ctx) + for _, channel := range newChannelsWithPostMigrationType { + suite.Require().NoError(channel.ValidateBasic()) + } + + suite.Require().Equal(len(newChannelsWithPreMigrationType), len(newChannelsWithPostMigrationType)) + suite.Require().Equal(len(newChannelsWithPostMigrationType), len(preMigrationChannels)) +} + +func (suite *MigrationsV10TestSuite) assertNoUpgrades(ctx sdk.Context, storeService corestore.KVStoreService) { + store := storeService.OpenKVStore(ctx) + suite.Require().False(store.Has([]byte(v10.KeyChannelUpgradePrefix))) +} + +func (suite *MigrationsV10TestSuite) assertNoParms(ctx sdk.Context, storeService corestore.KVStoreService) { + store := storeService.OpenKVStore(ctx) + suite.Require().False(store.Has([]byte(v10.ParamsKey))) +} + +func (suite *MigrationsV10TestSuite) assertNoPruneSequences(ctx sdk.Context, storeService corestore.KVStoreService) { + store := storeService.OpenKVStore(ctx) + suite.Require().False(store.Has([]byte(v10.KeyPruningSequenceStart))) +} diff --git a/modules/core/04-channel/types/upgrade.pb.go b/modules/core/04-channel/migrations/v10/upgrade.pb.go similarity index 99% rename from modules/core/04-channel/types/upgrade.pb.go rename to modules/core/04-channel/migrations/v10/upgrade.pb.go index df9efba8634..f902a86f907 100644 --- a/modules/core/04-channel/types/upgrade.pb.go +++ b/modules/core/04-channel/migrations/v10/upgrade.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: ibc/core/channel/v1/upgrade.proto -package types +package v10 import ( fmt "fmt" diff --git a/modules/core/04-channel/module.go b/modules/core/04-channel/module.go index 4bb9300c2d1..81b1dbe8625 100644 --- a/modules/core/04-channel/module.go +++ b/modules/core/04-channel/module.go @@ -12,11 +12,6 @@ func Name() string { return types.SubModuleName } -// GetTxCmd returns the root tx command for IBC channels. -func GetTxCmd() *cobra.Command { - return cli.NewTxCmd() -} - // GetQueryCmd returns the root query command for IBC channels. func GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() diff --git a/modules/core/04-channel/types/channel.go b/modules/core/04-channel/types/channel.go index 1ffd62bd2d1..1e33aedc231 100644 --- a/modules/core/04-channel/types/channel.go +++ b/modules/core/04-channel/types/channel.go @@ -19,8 +19,6 @@ func NewChannel( Counterparty: counterparty, ConnectionHops: hops, Version: version, - // UpgradeSequence is intentionally left empty as a new channel has not performed an upgrade. - UpgradeSequence: 0, } } @@ -68,14 +66,13 @@ func (c Counterparty) ValidateBasic() error { // NewIdentifiedChannel creates a new IdentifiedChannel instance func NewIdentifiedChannel(portID, channelID string, ch Channel) IdentifiedChannel { return IdentifiedChannel{ - State: ch.State, - Ordering: ch.Ordering, - Counterparty: ch.Counterparty, - ConnectionHops: ch.ConnectionHops, - Version: ch.Version, - UpgradeSequence: ch.UpgradeSequence, - PortId: portID, - ChannelId: channelID, + State: ch.State, + Ordering: ch.Ordering, + Counterparty: ch.Counterparty, + ConnectionHops: ch.ConnectionHops, + Version: ch.Version, + PortId: portID, + ChannelId: channelID, } } diff --git a/modules/core/04-channel/types/channel.pb.go b/modules/core/04-channel/types/channel.pb.go index bd46f4b69fd..9f0d745d27f 100644 --- a/modules/core/04-channel/types/channel.pb.go +++ b/modules/core/04-channel/types/channel.pb.go @@ -25,7 +25,7 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // State defines if a channel is in one of the following states: -// CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or UNINITIALIZED. +// CLOSED, INIT, TRYOPEN, OPEN, or UNINITIALIZED. type State int32 const ( @@ -41,10 +41,6 @@ const ( // A channel has been closed and can no longer be used to send or receive // packets. CLOSED State = 4 - // A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - FLUSHING State = 5 - // A channel has just completed flushing any in-flight packets. - FLUSHCOMPLETE State = 6 ) var State_name = map[int32]string{ @@ -53,8 +49,6 @@ var State_name = map[int32]string{ 2: "STATE_TRYOPEN", 3: "STATE_OPEN", 4: "STATE_CLOSED", - 5: "STATE_FLUSHING", - 6: "STATE_FLUSHCOMPLETE", } var State_value = map[string]int32{ @@ -63,8 +57,6 @@ var State_value = map[string]int32{ "STATE_TRYOPEN": 2, "STATE_OPEN": 3, "STATE_CLOSED": 4, - "STATE_FLUSHING": 5, - "STATE_FLUSHCOMPLETE": 6, } func (x State) String() string { @@ -123,9 +115,6 @@ type Channel struct { ConnectionHops []string `protobuf:"bytes,4,rep,name=connection_hops,json=connectionHops,proto3" json:"connection_hops,omitempty"` // opaque channel version, which is agreed upon during the handshake Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"` - // upgrade sequence indicates the latest upgrade attempt performed by this channel - // the value of 0 indicates the channel has never been upgraded - UpgradeSequence uint64 `protobuf:"varint,6,opt,name=upgrade_sequence,json=upgradeSequence,proto3" json:"upgrade_sequence,omitempty"` } func (m *Channel) Reset() { *m = Channel{} } @@ -179,9 +168,6 @@ type IdentifiedChannel struct { PortId string `protobuf:"bytes,6,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` // channel identifier ChannelId string `protobuf:"bytes,7,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - // upgrade sequence indicates the latest upgrade attempt performed by this channel - // the value of 0 indicates the channel has never been upgraded - UpgradeSequence uint64 `protobuf:"varint,8,opt,name=upgrade_sequence,json=upgradeSequence,proto3" json:"upgrade_sequence,omitempty"` } func (m *IdentifiedChannel) Reset() { *m = IdentifiedChannel{} } @@ -501,12 +487,12 @@ func (*Acknowledgement) XXX_OneofWrappers() []interface{} { } // Timeout defines an execution deadline structure for 04-channel handlers. -// This includes packet lifecycle handlers as well as the upgrade handshake handlers. +// This includes packet lifecycle handlers. // A valid Timeout contains either one or both of a timestamp and block height (sequence). type Timeout struct { - // block height after which the packet or upgrade times out + // block height after which the packet times out Height types.Height `protobuf:"bytes,1,opt,name=height,proto3" json:"height"` - // block timestamp (in nanoseconds) after which the packet or upgrade times out + // block timestamp (in nanoseconds) after which the packet times out Timestamp uint64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } @@ -557,52 +543,6 @@ func (m *Timeout) GetTimestamp() uint64 { return 0 } -// Params defines the set of IBC channel parameters. -type Params struct { - // the relative timeout after which channel upgrades will time out. - UpgradeTimeout Timeout `protobuf:"bytes,1,opt,name=upgrade_timeout,json=upgradeTimeout,proto3" json:"upgrade_timeout"` -} - -func (m *Params) Reset() { *m = Params{} } -func (m *Params) String() string { return proto.CompactTextString(m) } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_c3a07336710636a0, []int{8} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func (m *Params) GetUpgradeTimeout() Timeout { - if m != nil { - return m.UpgradeTimeout - } - return Timeout{} -} - func init() { proto.RegisterEnum("ibc.core.channel.v1.State", State_name, State_value) proto.RegisterEnum("ibc.core.channel.v1.Order", Order_name, Order_value) @@ -614,72 +554,65 @@ func init() { proto.RegisterType((*PacketId)(nil), "ibc.core.channel.v1.PacketId") proto.RegisterType((*Acknowledgement)(nil), "ibc.core.channel.v1.Acknowledgement") proto.RegisterType((*Timeout)(nil), "ibc.core.channel.v1.Timeout") - proto.RegisterType((*Params)(nil), "ibc.core.channel.v1.Params") } func init() { proto.RegisterFile("ibc/core/channel/v1/channel.proto", fileDescriptor_c3a07336710636a0) } var fileDescriptor_c3a07336710636a0 = []byte{ - // 936 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x4f, 0x6f, 0xe2, 0x46, - 0x14, 0xc7, 0xc4, 0xfc, 0x7b, 0x49, 0xc0, 0x3b, 0x69, 0x53, 0xcb, 0x4a, 0xc1, 0x8b, 0x5a, 0x95, - 0x4d, 0xb5, 0x90, 0x6c, 0xab, 0xaa, 0xda, 0x5b, 0x02, 0xde, 0xc5, 0x5a, 0x0a, 0xc8, 0xc0, 0xa1, - 0x7b, 0x41, 0xc6, 0x9e, 0x82, 0xb5, 0xe0, 0xa1, 0xf6, 0xc0, 0x6a, 0xd5, 0x73, 0xa5, 0x15, 0xa7, - 0x7e, 0x01, 0xa4, 0x4a, 0xfd, 0x0a, 0xfd, 0x10, 0x7b, 0xdc, 0xe3, 0x9e, 0xaa, 0x2a, 0xf9, 0x0e, - 0x3d, 0x57, 0x9e, 0x19, 0x07, 0x88, 0xa2, 0xa8, 0xaa, 0xd4, 0x5b, 0x4f, 0xcc, 0xfb, 0xbd, 0xdf, - 0x7b, 0xbf, 0xf7, 0x67, 0x18, 0x19, 0x1e, 0x7a, 0x23, 0xa7, 0xe6, 0x90, 0x00, 0xd7, 0x9c, 0x89, - 0xed, 0xfb, 0x78, 0x5a, 0x5b, 0x9e, 0xc7, 0xc7, 0xea, 0x3c, 0x20, 0x94, 0xa0, 0x23, 0x6f, 0xe4, - 0x54, 0x23, 0x4a, 0x35, 0xc6, 0x97, 0xe7, 0xda, 0x47, 0x63, 0x32, 0x26, 0xcc, 0x5f, 0x8b, 0x4e, - 0x9c, 0xaa, 0x95, 0x36, 0xd9, 0xa6, 0x1e, 0xf6, 0x29, 0x4b, 0xc6, 0x4e, 0x9c, 0x50, 0xfe, 0x3d, - 0x09, 0x99, 0x3a, 0xcf, 0x82, 0xce, 0x20, 0x15, 0x52, 0x9b, 0x62, 0x55, 0xd2, 0xa5, 0x4a, 0xfe, - 0x89, 0x56, 0xbd, 0x43, 0xa7, 0xda, 0x8b, 0x18, 0x16, 0x27, 0xa2, 0x6f, 0x20, 0x4b, 0x02, 0x17, - 0x07, 0x9e, 0x3f, 0x56, 0x93, 0xf7, 0x04, 0x75, 0x22, 0x92, 0x75, 0xc3, 0x45, 0x2f, 0xe0, 0xc0, - 0x21, 0x0b, 0x9f, 0xe2, 0x60, 0x6e, 0x07, 0xf4, 0x8d, 0xba, 0xa7, 0x4b, 0x95, 0xfd, 0x27, 0x0f, - 0xef, 0x8c, 0xad, 0x6f, 0x11, 0x2f, 0xe5, 0x77, 0x7f, 0x94, 0x12, 0xd6, 0x4e, 0x30, 0xfa, 0x02, - 0x0a, 0x0e, 0xf1, 0x7d, 0xec, 0x50, 0x8f, 0xf8, 0xc3, 0x09, 0x99, 0x87, 0xaa, 0xac, 0xef, 0x55, - 0x72, 0x56, 0x7e, 0x03, 0x37, 0xc9, 0x3c, 0x44, 0x2a, 0x64, 0x96, 0x38, 0x08, 0x3d, 0xe2, 0xab, - 0x29, 0x5d, 0xaa, 0xe4, 0xac, 0xd8, 0x44, 0x8f, 0x40, 0x59, 0xcc, 0xc7, 0x81, 0xed, 0xe2, 0x61, - 0x88, 0x7f, 0x5c, 0x60, 0xdf, 0xc1, 0x6a, 0x5a, 0x97, 0x2a, 0xb2, 0x55, 0x10, 0x78, 0x4f, 0xc0, - 0x4f, 0xe5, 0xb7, 0xbf, 0x96, 0x12, 0xe5, 0xbf, 0x92, 0xf0, 0xc0, 0x74, 0xb1, 0x4f, 0xbd, 0x1f, - 0x3c, 0xec, 0xfe, 0x3f, 0xc0, 0x4f, 0x20, 0x33, 0x27, 0x01, 0x1d, 0x7a, 0x2e, 0x9b, 0x5b, 0xce, - 0x4a, 0x47, 0xa6, 0xe9, 0xa2, 0x4f, 0x01, 0x44, 0x29, 0x91, 0x2f, 0xc3, 0x7c, 0x39, 0x81, 0x98, - 0xee, 0x9d, 0x83, 0xcf, 0xde, 0x37, 0xf8, 0x16, 0x1c, 0x6c, 0xf7, 0xb3, 0x2d, 0x2c, 0xdd, 0x23, - 0x9c, 0xbc, 0x25, 0x2c, 0xb2, 0x7d, 0x48, 0x42, 0xba, 0x6b, 0x3b, 0xaf, 0x30, 0x45, 0x1a, 0x64, - 0x6f, 0x2a, 0x90, 0x58, 0x05, 0x37, 0x36, 0x2a, 0xc1, 0x7e, 0x48, 0x16, 0x81, 0x83, 0x87, 0x51, - 0x72, 0x91, 0x0c, 0x38, 0xd4, 0x25, 0x01, 0x45, 0x9f, 0x43, 0x5e, 0x10, 0x84, 0x02, 0x5b, 0x48, - 0xce, 0x3a, 0xe4, 0x68, 0x7c, 0x3f, 0x1e, 0x81, 0xe2, 0xe2, 0x90, 0x7a, 0xbe, 0xcd, 0x26, 0xcd, - 0x92, 0xc9, 0x8c, 0x58, 0xd8, 0xc2, 0x59, 0xc6, 0x1a, 0x1c, 0x6d, 0x53, 0xe3, 0xb4, 0x7c, 0xec, - 0x68, 0xcb, 0x15, 0xe7, 0x46, 0x20, 0xbb, 0x36, 0xb5, 0xd9, 0xf8, 0x0f, 0x2c, 0x76, 0x46, 0xcf, - 0x21, 0x4f, 0xbd, 0x19, 0x26, 0x0b, 0x3a, 0x9c, 0x60, 0x6f, 0x3c, 0xa1, 0x6c, 0x01, 0xfb, 0x3b, - 0x77, 0x8c, 0x3f, 0x06, 0xcb, 0xf3, 0x6a, 0x93, 0x31, 0xc4, 0x05, 0x39, 0x14, 0x71, 0x1c, 0x44, - 0x5f, 0xc2, 0x83, 0x38, 0x51, 0xf4, 0x1b, 0x52, 0x7b, 0x36, 0x17, 0x7b, 0x52, 0x84, 0xa3, 0x1f, - 0xe3, 0x62, 0xb4, 0x3f, 0xc1, 0x3e, 0x9f, 0x2c, 0xbb, 0xef, 0xff, 0x76, 0x4f, 0x3b, 0x6b, 0xd9, - 0xbb, 0xb5, 0x96, 0xb8, 0x65, 0x79, 0xd3, 0xb2, 0x10, 0x77, 0x21, 0xcb, 0xc5, 0x4d, 0xf7, 0xbf, - 0x50, 0x16, 0x2a, 0x1d, 0x28, 0x5c, 0x38, 0xaf, 0x7c, 0xf2, 0x7a, 0x8a, 0xdd, 0x31, 0x9e, 0x61, - 0x9f, 0x22, 0x15, 0xd2, 0x01, 0x0e, 0x17, 0x53, 0xaa, 0x7e, 0x1c, 0x15, 0xd5, 0x4c, 0x58, 0xc2, - 0x46, 0xc7, 0x90, 0xc2, 0x41, 0x40, 0x02, 0xf5, 0x38, 0x12, 0x6a, 0x26, 0x2c, 0x6e, 0x5e, 0x02, - 0x64, 0x03, 0x1c, 0xce, 0x89, 0x1f, 0xe2, 0xb2, 0x0d, 0x99, 0x3e, 0x9f, 0x26, 0xfa, 0x16, 0xd2, - 0x62, 0x65, 0xd2, 0x3f, 0x5c, 0x99, 0xe0, 0xa3, 0x13, 0xc8, 0x6d, 0x76, 0x94, 0x64, 0x85, 0x6f, - 0x80, 0xf2, 0x20, 0xba, 0xf0, 0x81, 0x3d, 0x0b, 0xd1, 0x0b, 0x88, 0xff, 0x62, 0x43, 0xb1, 0x42, - 0x21, 0x75, 0x72, 0xe7, 0x2b, 0x22, 0x0a, 0x13, 0x62, 0x79, 0x11, 0x2a, 0xd0, 0xd3, 0x9f, 0x93, - 0x90, 0xea, 0x89, 0x17, 0xad, 0xd4, 0xeb, 0x5f, 0xf4, 0x8d, 0xe1, 0xa0, 0x6d, 0xb6, 0xcd, 0xbe, - 0x79, 0xd1, 0x32, 0x5f, 0x1a, 0x8d, 0xe1, 0xa0, 0xdd, 0xeb, 0x1a, 0x75, 0xf3, 0x99, 0x69, 0x34, - 0x94, 0x84, 0xf6, 0x60, 0xb5, 0xd6, 0x0f, 0x77, 0x08, 0x48, 0x05, 0xe0, 0x71, 0x11, 0xa8, 0x48, - 0x5a, 0x76, 0xb5, 0xd6, 0xe5, 0xe8, 0x8c, 0x8a, 0x70, 0xc8, 0x3d, 0x7d, 0xeb, 0xfb, 0x4e, 0xd7, - 0x68, 0x2b, 0x49, 0x6d, 0x7f, 0xb5, 0xd6, 0x33, 0xc2, 0xdc, 0x44, 0x32, 0xe7, 0x1e, 0x8f, 0x64, - 0x9e, 0x13, 0x38, 0xe0, 0x9e, 0x7a, 0xab, 0xd3, 0x33, 0x1a, 0x8a, 0xac, 0xc1, 0x6a, 0xad, 0xa7, - 0xb9, 0x85, 0x74, 0xc8, 0x73, 0xef, 0xb3, 0xd6, 0xa0, 0xd7, 0x34, 0xdb, 0xcf, 0x95, 0x94, 0x76, - 0xb0, 0x5a, 0xeb, 0xd9, 0xd8, 0x46, 0xa7, 0x70, 0xb4, 0xc5, 0xa8, 0x77, 0xbe, 0xeb, 0xb6, 0x8c, - 0xbe, 0xa1, 0xa4, 0x79, 0xfd, 0x3b, 0xa0, 0x26, 0xbf, 0xfd, 0xad, 0x98, 0x38, 0x7d, 0x0d, 0x29, - 0xf6, 0x54, 0xa3, 0xcf, 0xe0, 0xb8, 0x63, 0x35, 0x0c, 0x6b, 0xd8, 0xee, 0xb4, 0x8d, 0x5b, 0xdd, - 0xb3, 0x02, 0x23, 0x1c, 0x95, 0xa1, 0xc0, 0x59, 0x83, 0x36, 0xfb, 0x35, 0x1a, 0x8a, 0xa4, 0x1d, - 0xae, 0xd6, 0x7a, 0xee, 0x06, 0x88, 0xda, 0xe7, 0x9c, 0x98, 0x21, 0xda, 0x17, 0x26, 0x17, 0xbe, - 0xec, 0xbf, 0xbb, 0x2a, 0x4a, 0xef, 0xaf, 0x8a, 0xd2, 0x9f, 0x57, 0x45, 0xe9, 0x97, 0xeb, 0x62, - 0xe2, 0xfd, 0x75, 0x31, 0xf1, 0xe1, 0xba, 0x98, 0x78, 0xf9, 0x74, 0xec, 0xd1, 0xc9, 0x62, 0x54, - 0x75, 0xc8, 0xac, 0xe6, 0x90, 0x70, 0x46, 0xc2, 0x9a, 0x37, 0x72, 0x1e, 0x8f, 0x49, 0x6d, 0x79, - 0x7e, 0x56, 0x9b, 0x11, 0x77, 0x31, 0xc5, 0x21, 0xff, 0x46, 0x38, 0xfb, 0xfa, 0x71, 0xfc, 0xd1, - 0x41, 0xdf, 0xcc, 0x71, 0x38, 0x4a, 0xb3, 0x8f, 0x84, 0xaf, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, - 0xaf, 0x78, 0x54, 0x46, 0x95, 0x08, 0x00, 0x00, + // 843 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x55, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x26, 0x65, 0xea, 0x6f, 0x64, 0xd9, 0xf2, 0xa6, 0x75, 0x09, 0x22, 0xa5, 0x18, 0xa3, 0x45, + 0xdd, 0x14, 0x11, 0xad, 0xb4, 0x28, 0x8a, 0xdc, 0x6c, 0x89, 0xad, 0x88, 0x1a, 0x92, 0x40, 0xc9, + 0x87, 0xe6, 0x22, 0x50, 0xe4, 0x56, 0x22, 0x22, 0x71, 0x59, 0x72, 0xa5, 0x20, 0xe8, 0x0b, 0xa4, + 0x3a, 0xf5, 0x05, 0x04, 0x14, 0xe8, 0x43, 0xf4, 0x15, 0x02, 0xf4, 0x92, 0x63, 0x4e, 0x45, 0x61, + 0xbf, 0x48, 0xc1, 0xdd, 0xa5, 0x25, 0x05, 0x46, 0x50, 0x14, 0xe8, 0x29, 0x27, 0xed, 0x7c, 0xf3, + 0xcd, 0x37, 0xc3, 0x6f, 0x28, 0x2e, 0x3c, 0x08, 0xc6, 0x9e, 0xe9, 0x91, 0x18, 0x9b, 0xde, 0xd4, + 0x0d, 0x43, 0x3c, 0x33, 0x97, 0xcd, 0xec, 0xd8, 0x88, 0x62, 0x42, 0x09, 0xba, 0x17, 0x8c, 0xbd, + 0x46, 0x4a, 0x69, 0x64, 0xf8, 0xb2, 0xa9, 0x7d, 0x30, 0x21, 0x13, 0xc2, 0xf2, 0x66, 0x7a, 0xe2, + 0x54, 0xad, 0xbe, 0x51, 0x9b, 0x05, 0x38, 0xa4, 0x4c, 0x8c, 0x9d, 0x38, 0xe1, 0xe4, 0x97, 0x1c, + 0x14, 0x5b, 0x5c, 0x05, 0x9d, 0x41, 0x3e, 0xa1, 0x2e, 0xc5, 0xaa, 0x6c, 0xc8, 0xa7, 0x07, 0x8f, + 0xb5, 0xc6, 0x1d, 0x7d, 0x1a, 0x83, 0x94, 0xe1, 0x70, 0x22, 0xfa, 0x1a, 0x4a, 0x24, 0xf6, 0x71, + 0x1c, 0x84, 0x13, 0x35, 0xf7, 0x8e, 0xa2, 0x5e, 0x4a, 0x72, 0x6e, 0xb9, 0xe8, 0x7b, 0xd8, 0xf7, + 0xc8, 0x22, 0xa4, 0x38, 0x8e, 0xdc, 0x98, 0xbe, 0x50, 0xf7, 0x0c, 0xf9, 0xb4, 0xf2, 0xf8, 0xc1, + 0x9d, 0xb5, 0xad, 0x2d, 0xe2, 0x85, 0xf2, 0xea, 0xaf, 0xba, 0xe4, 0xec, 0x14, 0xa3, 0xcf, 0xe0, + 0xd0, 0x23, 0x61, 0x88, 0x3d, 0x1a, 0x90, 0x70, 0x34, 0x25, 0x51, 0xa2, 0x2a, 0xc6, 0xde, 0x69, + 0xd9, 0x39, 0xd8, 0xc0, 0x1d, 0x12, 0x25, 0x48, 0x85, 0xe2, 0x12, 0xc7, 0x49, 0x40, 0x42, 0x35, + 0x6f, 0xc8, 0xa7, 0x65, 0x27, 0x0b, 0x9f, 0x28, 0x2f, 0x7f, 0xab, 0x4b, 0x27, 0x7f, 0xe6, 0xe0, + 0xc8, 0xf6, 0x71, 0x48, 0x83, 0x1f, 0x03, 0xec, 0xbf, 0xf7, 0xae, 0xa0, 0x8f, 0xa0, 0x18, 0x91, + 0x98, 0x8e, 0x02, 0x5f, 0x2d, 0xb0, 0x4c, 0x21, 0x0d, 0x6d, 0x1f, 0x7d, 0x0c, 0x20, 0x46, 0x49, + 0x73, 0x45, 0x96, 0x2b, 0x0b, 0xc4, 0xf6, 0x85, 0x9b, 0x97, 0xb0, 0xbf, 0x3d, 0xe4, 0xb6, 0x9a, + 0xfc, 0x0e, 0xb5, 0xdc, 0xdd, 0x6a, 0x6f, 0x72, 0x50, 0xe8, 0xbb, 0xde, 0x33, 0x4c, 0x91, 0x06, + 0xa5, 0x04, 0xff, 0xb4, 0xc0, 0xa1, 0xc7, 0x77, 0xa2, 0x38, 0xb7, 0x31, 0xaa, 0x43, 0x25, 0x21, + 0x8b, 0xd8, 0xc3, 0xa3, 0x54, 0x5c, 0x88, 0x01, 0x87, 0xfa, 0x24, 0xa6, 0xe8, 0x53, 0x38, 0x10, + 0x04, 0xd1, 0x81, 0xb9, 0x5c, 0x76, 0xaa, 0x1c, 0xcd, 0x96, 0xfe, 0x39, 0xd4, 0x7c, 0x9c, 0xd0, + 0x20, 0x74, 0x99, 0x7d, 0x4c, 0x4c, 0x61, 0xc4, 0xc3, 0x2d, 0x9c, 0x29, 0x9a, 0x70, 0x6f, 0x9b, + 0x9a, 0xc9, 0x72, 0x2f, 0xd1, 0x56, 0x2a, 0xd3, 0x46, 0xa0, 0xf8, 0x2e, 0x75, 0x99, 0xa7, 0xfb, + 0x0e, 0x3b, 0xa3, 0xef, 0xe0, 0x80, 0x06, 0x73, 0x4c, 0x16, 0x74, 0x34, 0xc5, 0xc1, 0x64, 0x4a, + 0x99, 0xab, 0x95, 0x9d, 0x17, 0x87, 0xff, 0x6d, 0x97, 0xcd, 0x46, 0x87, 0x31, 0xc4, 0xd6, 0xab, + 0xa2, 0x8e, 0x83, 0xe8, 0x0b, 0x38, 0xca, 0x84, 0xd2, 0xdf, 0x84, 0xba, 0xf3, 0x48, 0x2d, 0x31, + 0x97, 0x6a, 0x22, 0x31, 0xcc, 0x70, 0x61, 0xed, 0xcf, 0x50, 0xe1, 0xce, 0xb2, 0x97, 0xf8, 0xbf, + 0xee, 0x69, 0x67, 0x2d, 0x7b, 0x6f, 0xad, 0x25, 0x7b, 0x64, 0x65, 0xf3, 0xc8, 0xa2, 0xb9, 0x0f, + 0x25, 0xde, 0xdc, 0xf6, 0xff, 0x8f, 0xce, 0xa2, 0x4b, 0x0f, 0x0e, 0xcf, 0xbd, 0x67, 0x21, 0x79, + 0x3e, 0xc3, 0xfe, 0x04, 0xcf, 0x71, 0x48, 0x91, 0x0a, 0x85, 0x18, 0x27, 0x8b, 0x19, 0x55, 0x3f, + 0x4c, 0x87, 0xea, 0x48, 0x8e, 0x88, 0xd1, 0x31, 0xe4, 0x71, 0x1c, 0x93, 0x58, 0x3d, 0x4e, 0x1b, + 0x75, 0x24, 0x87, 0x87, 0x17, 0x00, 0xa5, 0x18, 0x27, 0x11, 0x09, 0x13, 0x7c, 0xe2, 0x42, 0x71, + 0xc8, 0xdd, 0x44, 0xdf, 0x40, 0x41, 0xac, 0x4c, 0xfe, 0x97, 0x2b, 0x13, 0x7c, 0x74, 0x1f, 0xca, + 0x9b, 0x1d, 0xe5, 0xd8, 0xe0, 0x1b, 0xe0, 0xe1, 0x1f, 0x32, 0xe4, 0x07, 0xe2, 0x7b, 0x52, 0x1f, + 0x0c, 0xcf, 0x87, 0xd6, 0xe8, 0xaa, 0x6b, 0x77, 0xed, 0xa1, 0x7d, 0x7e, 0x69, 0x3f, 0xb5, 0xda, + 0xa3, 0xab, 0xee, 0xa0, 0x6f, 0xb5, 0xec, 0x6f, 0x6d, 0xab, 0x5d, 0x93, 0xb4, 0xa3, 0xd5, 0xda, + 0xa8, 0xee, 0x10, 0x90, 0x0a, 0xc0, 0xeb, 0x52, 0xb0, 0x26, 0x6b, 0xa5, 0xd5, 0xda, 0x50, 0xd2, + 0x33, 0xd2, 0xa1, 0xca, 0x33, 0x43, 0xe7, 0x87, 0x5e, 0xdf, 0xea, 0xd6, 0x72, 0x5a, 0x65, 0xb5, + 0x36, 0x8a, 0x22, 0xdc, 0x54, 0xb2, 0xe4, 0x1e, 0xaf, 0x64, 0x99, 0xfb, 0xb0, 0xcf, 0x33, 0xad, + 0xcb, 0xde, 0xc0, 0x6a, 0xd7, 0x14, 0x0d, 0x56, 0x6b, 0xa3, 0xc0, 0x23, 0x4d, 0x79, 0xf9, 0xbb, + 0x2e, 0x3d, 0x7c, 0x0e, 0x79, 0xf6, 0x69, 0x43, 0x9f, 0xc0, 0x71, 0xcf, 0x69, 0x5b, 0xce, 0xa8, + 0xdb, 0xeb, 0x5a, 0x6f, 0xcd, 0xcb, 0x24, 0x53, 0x1c, 0x9d, 0xc0, 0x21, 0x67, 0x5d, 0x75, 0xd9, + 0xaf, 0xd5, 0xae, 0xc9, 0x5a, 0x75, 0xb5, 0x36, 0xca, 0xb7, 0x40, 0x3a, 0x30, 0xe7, 0x64, 0x0c, + 0x31, 0xb0, 0x08, 0x79, 0xe3, 0x8b, 0xe1, 0xab, 0x6b, 0x5d, 0x7e, 0x7d, 0xad, 0xcb, 0x7f, 0x5f, + 0xeb, 0xf2, 0xaf, 0x37, 0xba, 0xf4, 0xfa, 0x46, 0x97, 0xde, 0xdc, 0xe8, 0xd2, 0xd3, 0x27, 0x93, + 0x80, 0x4e, 0x17, 0xe3, 0x86, 0x47, 0xe6, 0xa6, 0x47, 0x92, 0x39, 0x49, 0xcc, 0x60, 0xec, 0x3d, + 0x9a, 0x10, 0x73, 0xd9, 0x3c, 0x33, 0xe7, 0xc4, 0x5f, 0xcc, 0x70, 0xc2, 0x2f, 0xca, 0xb3, 0xaf, + 0x1e, 0x65, 0x37, 0x2f, 0x7d, 0x11, 0xe1, 0x64, 0x5c, 0x60, 0x37, 0xe5, 0x97, 0xff, 0x04, 0x00, + 0x00, 0xff, 0xff, 0xf1, 0xb2, 0x33, 0xdb, 0x9a, 0x07, 0x00, 0x00, } func (m *Channel) Marshal() (dAtA []byte, err error) { @@ -702,11 +635,6 @@ func (m *Channel) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.UpgradeSequence != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.UpgradeSequence)) - i-- - dAtA[i] = 0x30 - } if len(m.Version) > 0 { i -= len(m.Version) copy(dAtA[i:], m.Version) @@ -766,11 +694,6 @@ func (m *IdentifiedChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.UpgradeSequence != 0 { - i = encodeVarintChannel(dAtA, i, uint64(m.UpgradeSequence)) - i-- - dAtA[i] = 0x40 - } if len(m.ChannelId) > 0 { i -= len(m.ChannelId) copy(dAtA[i:], m.ChannelId) @@ -1134,39 +1057,6 @@ func (m *Timeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Params) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.UpgradeTimeout.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintChannel(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - func encodeVarintChannel(dAtA []byte, offset int, v uint64) int { offset -= sovChannel(v) base := offset @@ -1202,9 +1092,6 @@ func (m *Channel) Size() (n int) { if l > 0 { n += 1 + l + sovChannel(uint64(l)) } - if m.UpgradeSequence != 0 { - n += 1 + sovChannel(uint64(m.UpgradeSequence)) - } return n } @@ -1240,9 +1127,6 @@ func (m *IdentifiedChannel) Size() (n int) { if l > 0 { n += 1 + l + sovChannel(uint64(l)) } - if m.UpgradeSequence != 0 { - n += 1 + sovChannel(uint64(m.UpgradeSequence)) - } return n } @@ -1392,17 +1276,6 @@ func (m *Timeout) Size() (n int) { return n } -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.UpgradeTimeout.Size() - n += 1 + l + sovChannel(uint64(l)) - return n -} - func sovChannel(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1573,25 +1446,6 @@ func (m *Channel) Unmarshal(dAtA []byte) error { } m.Version = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UpgradeSequence", wireType) - } - m.UpgradeSequence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UpgradeSequence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipChannel(dAtA[iNdEx:]) @@ -1841,25 +1695,6 @@ func (m *IdentifiedChannel) Unmarshal(dAtA []byte) error { } m.ChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UpgradeSequence", wireType) - } - m.UpgradeSequence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UpgradeSequence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipChannel(dAtA[iNdEx:]) @@ -2795,89 +2630,6 @@ func (m *Timeout) Unmarshal(dAtA []byte) error { } return nil } -func (m *Params) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UpgradeTimeout", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChannel - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthChannel - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthChannel - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.UpgradeTimeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipChannel(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthChannel - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipChannel(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/types/codec.go b/modules/core/04-channel/types/codec.go index 4d28f2c90b2..b184cda9b7a 100644 --- a/modules/core/04-channel/types/codec.go +++ b/modules/core/04-channel/types/codec.go @@ -29,15 +29,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgAcknowledgement{}, &MsgTimeout{}, &MsgTimeoutOnClose{}, - &MsgChannelUpgradeInit{}, - &MsgChannelUpgradeTry{}, - &MsgChannelUpgradeAck{}, - &MsgChannelUpgradeConfirm{}, - &MsgChannelUpgradeOpen{}, - &MsgChannelUpgradeTimeout{}, - &MsgChannelUpgradeCancel{}, - &MsgPruneAcknowledgements{}, - &MsgUpdateParams{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/modules/core/04-channel/types/codec_test.go b/modules/core/04-channel/types/codec_test.go index 90b7123ec12..7b1f6e7fbd1 100644 --- a/modules/core/04-channel/types/codec_test.go +++ b/modules/core/04-channel/types/codec_test.go @@ -74,51 +74,6 @@ func TestCodecTypeRegistration(t *testing.T) { sdk.MsgTypeURL(&types.MsgTimeoutOnClose{}), nil, }, - { - "success: MsgChannelUpgradeInit", - sdk.MsgTypeURL(&types.MsgChannelUpgradeInit{}), - nil, - }, - { - "success: MsgChannelUpgradeTry", - sdk.MsgTypeURL(&types.MsgChannelUpgradeTry{}), - nil, - }, - { - "success: MsgChannelUpgradeAck", - sdk.MsgTypeURL(&types.MsgChannelUpgradeAck{}), - nil, - }, - { - "success: MsgChannelUpgradeConfirm", - sdk.MsgTypeURL(&types.MsgChannelUpgradeConfirm{}), - nil, - }, - { - "success: MsgChannelUpgradeOpen", - sdk.MsgTypeURL(&types.MsgChannelUpgradeOpen{}), - nil, - }, - { - "success: MsgChannelUpgradeTimeout", - sdk.MsgTypeURL(&types.MsgChannelUpgradeTimeout{}), - nil, - }, - { - "success: MsgChannelUpgradeCancel", - sdk.MsgTypeURL(&types.MsgChannelUpgradeCancel{}), - nil, - }, - { - "success: MsgPruneAcknowledgements", - sdk.MsgTypeURL(&types.MsgPruneAcknowledgements{}), - nil, - }, - { - "success: MsgUpdateParams", - sdk.MsgTypeURL(&types.MsgUpdateParams{}), - nil, - }, { "type not registered on codec", "ibc.invalid.MsgTypeURL", diff --git a/modules/core/04-channel/types/events.go b/modules/core/04-channel/types/events.go index 8f8fde0e3fd..996f4019211 100644 --- a/modules/core/04-channel/types/events.go +++ b/modules/core/04-channel/types/events.go @@ -16,12 +16,6 @@ const ( AttributeKeyConnectionHops = "connection_hops" AttributeKeyOrdering = "ordering" - // upgrade specific keys - AttributeKeyUpgradeTimeoutHeight = "timeout_height" - AttributeKeyUpgradeTimeoutTimestamp = "timeout_timestamp" - AttributeKeyUpgradeSequence = "upgrade_sequence" - AttributeKeyErrorReceipt = "error_receipt" - AttributeCounterpartyPortID = "counterparty_port_id" AttributeCounterpartyChannelID = "counterparty_channel_id" @@ -46,22 +40,13 @@ const ( // IBC channel events vars var ( - EventTypeChannelOpenInit = "channel_open_init" - EventTypeChannelOpenTry = "channel_open_try" - EventTypeChannelOpenAck = "channel_open_ack" - EventTypeChannelOpenConfirm = "channel_open_confirm" - EventTypeChannelCloseInit = "channel_close_init" - EventTypeChannelCloseConfirm = "channel_close_confirm" - EventTypeChannelClosed = "channel_close" - EventTypeChannelUpgradeInit = "channel_upgrade_init" - EventTypeChannelUpgradeTry = "channel_upgrade_try" - EventTypeChannelUpgradeAck = "channel_upgrade_ack" - EventTypeChannelUpgradeConfirm = "channel_upgrade_confirm" - EventTypeChannelUpgradeOpen = "channel_upgrade_open" - EventTypeChannelUpgradeTimeout = "channel_upgrade_timeout" - EventTypeChannelUpgradeCancel = "channel_upgrade_cancelled" - EventTypeChannelUpgradeError = "channel_upgrade_error" - EventTypeChannelFlushComplete = "channel_flush_complete" + EventTypeChannelOpenInit = "channel_open_init" + EventTypeChannelOpenTry = "channel_open_try" + EventTypeChannelOpenAck = "channel_open_ack" + EventTypeChannelOpenConfirm = "channel_open_confirm" + EventTypeChannelCloseInit = "channel_close_init" + EventTypeChannelCloseConfirm = "channel_close_confirm" + EventTypeChannelClosed = "channel_close" AttributeValueCategory = fmt.Sprintf("%s_%s", ibcexported.ModuleName, SubModuleName) ) diff --git a/modules/core/04-channel/types/expected_keepers.go b/modules/core/04-channel/types/expected_keepers.go index 2356d402efc..9b6f12d6e95 100644 --- a/modules/core/04-channel/types/expected_keepers.go +++ b/modules/core/04-channel/types/expected_keepers.go @@ -67,22 +67,4 @@ type ConnectionKeeper interface { channelID string, nextSequenceRecv uint64, ) error - VerifyChannelUpgrade( - ctx sdk.Context, - connection connectiontypes.ConnectionEnd, - height exported.Height, - proof []byte, - portID, - channelID string, - upgrade Upgrade, - ) error - VerifyChannelUpgradeError( - ctx sdk.Context, - connection connectiontypes.ConnectionEnd, - height exported.Height, - proof []byte, - portID, - channelID string, - errorReceipt ErrorReceipt, - ) error } diff --git a/modules/core/04-channel/types/genesis.go b/modules/core/04-channel/types/genesis.go index e54acfedeb5..69e423659a9 100644 --- a/modules/core/04-channel/types/genesis.go +++ b/modules/core/04-channel/types/genesis.go @@ -48,7 +48,6 @@ func (ps PacketSequence) Validate() error { func NewGenesisState( channels []IdentifiedChannel, acks, receipts, commitments []PacketState, sendSeqs, recvSeqs, ackSeqs []PacketSequence, nextChannelSequence uint64, - params Params, ) GenesisState { return GenesisState{ Channels: channels, @@ -59,7 +58,6 @@ func NewGenesisState( RecvSequences: recvSeqs, AckSequences: ackSeqs, NextChannelSequence: nextChannelSequence, - Params: params, } } @@ -74,7 +72,6 @@ func DefaultGenesisState() GenesisState { RecvSequences: []PacketSequence{}, AckSequences: []PacketSequence{}, NextChannelSequence: 0, - Params: DefaultParams(), } } diff --git a/modules/core/04-channel/types/genesis.pb.go b/modules/core/04-channel/types/genesis.pb.go index 5300af06d93..3a7af8f3d67 100644 --- a/modules/core/04-channel/types/genesis.pb.go +++ b/modules/core/04-channel/types/genesis.pb.go @@ -34,7 +34,6 @@ type GenesisState struct { AckSequences []PacketSequence `protobuf:"bytes,7,rep,name=ack_sequences,json=ackSequences,proto3" json:"ack_sequences"` // the sequence for the next generated channel identifier NextChannelSequence uint64 `protobuf:"varint,8,opt,name=next_channel_sequence,json=nextChannelSequence,proto3" json:"next_channel_sequence,omitempty"` - Params Params `protobuf:"bytes,9,opt,name=params,proto3" json:"params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -126,13 +125,6 @@ func (m *GenesisState) GetNextChannelSequence() uint64 { return 0 } -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - // PacketSequence defines the genesis type necessary to retrieve and store // next send and receive sequences. type PacketSequence struct { @@ -203,37 +195,35 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v1/genesis.proto", fileDescriptor_cb06ec201f452595) } var fileDescriptor_cb06ec201f452595 = []byte{ - // 472 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xc1, 0x6e, 0xd3, 0x40, - 0x14, 0x45, 0xe3, 0x26, 0x4d, 0x93, 0x49, 0x5b, 0xc1, 0x14, 0x84, 0x09, 0xc2, 0x35, 0x45, 0x42, - 0xd9, 0xd4, 0x6e, 0x02, 0x1b, 0x58, 0x86, 0x05, 0x64, 0x83, 0x2a, 0xc3, 0x0a, 0x09, 0x45, 0xf6, - 0xcc, 0xc3, 0x1d, 0x25, 0x9e, 0x31, 0x9e, 0x49, 0x80, 0xbf, 0xe0, 0x5b, 0xf8, 0x8a, 0x2e, 0xbb, - 0x64, 0x55, 0xa1, 0xe4, 0x2f, 0x58, 0x21, 0x8f, 0xc7, 0x6e, 0x50, 0x42, 0xa5, 0xec, 0x3c, 0xef, - 0xdd, 0x7b, 0xee, 0x5d, 0xf8, 0xa1, 0x27, 0x2c, 0x22, 0x3e, 0x11, 0x19, 0xf8, 0xe4, 0x22, 0xe4, - 0x1c, 0xa6, 0xfe, 0xbc, 0xef, 0xc7, 0xc0, 0x41, 0x32, 0xe9, 0xa5, 0x99, 0x50, 0x02, 0x1f, 0xb1, - 0x88, 0x78, 0xb9, 0xc4, 0x33, 0x12, 0x6f, 0xde, 0xef, 0xde, 0x8b, 0x45, 0x2c, 0xf4, 0xde, 0xcf, - 0xbf, 0x0a, 0x69, 0x77, 0x23, 0xad, 0x74, 0x69, 0xc9, 0xc9, 0xcf, 0x5d, 0xb4, 0xff, 0xa6, 0xe0, - 0xbf, 0x57, 0xa1, 0x02, 0xfc, 0x09, 0xb5, 0x8c, 0x42, 0xda, 0x96, 0x5b, 0xef, 0x75, 0x06, 0xcf, - 0xbc, 0x0d, 0x89, 0xde, 0x88, 0x02, 0x57, 0xec, 0x33, 0x03, 0xfa, 0xba, 0x18, 0x0e, 0x1f, 0x5e, - 0x5e, 0x1f, 0xd7, 0xfe, 0x5c, 0x1f, 0xdf, 0x5d, 0x5b, 0x05, 0x15, 0x12, 0x07, 0xe8, 0x4e, 0x48, - 0x26, 0x5c, 0x7c, 0x9d, 0x02, 0x8d, 0x21, 0x01, 0xae, 0xa4, 0xbd, 0xa3, 0x63, 0xdc, 0x8d, 0x31, - 0xe7, 0x21, 0x99, 0x80, 0xd2, 0xd5, 0x86, 0x8d, 0x3c, 0x20, 0x58, 0xf3, 0xe3, 0xb7, 0xa8, 0x43, - 0x44, 0x92, 0x30, 0x55, 0xe0, 0xea, 0x5b, 0xe1, 0x56, 0xad, 0x78, 0x88, 0x5a, 0x19, 0x10, 0x60, - 0xa9, 0x92, 0x76, 0x63, 0x2b, 0x4c, 0xe5, 0xc3, 0xe7, 0xe8, 0x50, 0x02, 0xa7, 0x63, 0x09, 0x5f, - 0x66, 0xc0, 0x09, 0x48, 0x7b, 0x57, 0x93, 0x9e, 0xde, 0x46, 0x32, 0x5a, 0x03, 0x3b, 0xc8, 0x01, - 0xe5, 0x4c, 0x13, 0x33, 0x20, 0xf3, 0x15, 0x62, 0x73, 0x6b, 0x62, 0x0e, 0xb8, 0x21, 0xbe, 0x43, - 0x07, 0x21, 0x99, 0xac, 0x00, 0xf7, 0xb6, 0x05, 0xee, 0x87, 0x64, 0x72, 0xc3, 0x1b, 0xa0, 0xfb, - 0x1c, 0xbe, 0xa9, 0xb1, 0x71, 0x55, 0x60, 0xbb, 0xe5, 0x5a, 0xbd, 0x46, 0x70, 0x94, 0x2f, 0xcd, - 0xbf, 0x50, 0x9a, 0xf0, 0x4b, 0xd4, 0x4c, 0xc3, 0x2c, 0x4c, 0xa4, 0xdd, 0x76, 0xad, 0x5e, 0x67, - 0xf0, 0xe8, 0x3f, 0xe1, 0xb9, 0xc4, 0x84, 0x1a, 0xc3, 0x09, 0x45, 0x87, 0xff, 0x96, 0xc2, 0x0f, - 0xd0, 0x5e, 0x2a, 0x32, 0x35, 0x66, 0xd4, 0xb6, 0x5c, 0xab, 0xd7, 0x0e, 0x9a, 0xf9, 0x73, 0x44, - 0xf1, 0x63, 0x84, 0xca, 0x52, 0x8c, 0xda, 0x3b, 0x7a, 0xd7, 0x36, 0x93, 0x11, 0xc5, 0x5d, 0xd4, - 0xaa, 0xba, 0xd6, 0x75, 0xd7, 0xea, 0x3d, 0xfc, 0x70, 0xb9, 0x70, 0xac, 0xab, 0x85, 0x63, 0xfd, - 0x5e, 0x38, 0xd6, 0x8f, 0xa5, 0x53, 0xbb, 0x5a, 0x3a, 0xb5, 0x5f, 0x4b, 0xa7, 0xf6, 0xf1, 0x55, - 0xcc, 0xd4, 0xc5, 0x2c, 0xf2, 0x88, 0x48, 0x7c, 0x22, 0x64, 0x22, 0xa4, 0xcf, 0x22, 0x72, 0x1a, - 0x0b, 0x7f, 0xde, 0x3f, 0xf3, 0x13, 0x41, 0x67, 0x53, 0x90, 0xc5, 0xe1, 0x9d, 0xbd, 0x38, 0x2d, - 0x6f, 0x4f, 0x7d, 0x4f, 0x41, 0x46, 0x4d, 0x7d, 0x77, 0xcf, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, - 0xea, 0x81, 0x10, 0xf0, 0xea, 0x03, 0x00, 0x00, + // 447 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd3, 0x4d, 0x6f, 0xd3, 0x30, + 0x18, 0x07, 0xf0, 0x66, 0x2d, 0x5d, 0xe7, 0xbd, 0x08, 0x3c, 0x10, 0xa1, 0x12, 0x59, 0x19, 0x12, + 0xea, 0x65, 0xf1, 0x3a, 0x38, 0x71, 0x0c, 0x07, 0xe8, 0x05, 0x4d, 0x81, 0x13, 0x12, 0xaa, 0x12, + 0xfb, 0x21, 0xb3, 0xd2, 0xd8, 0x21, 0x76, 0x03, 0x7c, 0x0b, 0x3e, 0xd6, 0x8e, 0x3b, 0x72, 0x9a, + 0x50, 0xfb, 0x21, 0x90, 0x38, 0xa1, 0x38, 0x2f, 0x2b, 0x5a, 0x35, 0x29, 0xb7, 0xda, 0xcf, 0xf3, + 0xff, 0xfd, 0x7b, 0x88, 0xd1, 0x33, 0x1e, 0x52, 0x42, 0x65, 0x06, 0x84, 0x5e, 0x04, 0x42, 0xc0, + 0x9c, 0xe4, 0x13, 0x12, 0x81, 0x00, 0xc5, 0x95, 0x9b, 0x66, 0x52, 0x4b, 0x7c, 0xc8, 0x43, 0xea, + 0x16, 0x2b, 0x6e, 0xb5, 0xe2, 0xe6, 0x93, 0xe1, 0xc3, 0x48, 0x46, 0xd2, 0xcc, 0x49, 0xf1, 0xab, + 0x5c, 0x1d, 0x6e, 0xd4, 0xea, 0x94, 0x59, 0x39, 0xfe, 0xd3, 0x43, 0x7b, 0x6f, 0x4b, 0xff, 0x83, + 0x0e, 0x34, 0xe0, 0xcf, 0x68, 0x50, 0x6d, 0x28, 0xdb, 0x1a, 0x75, 0xc7, 0xbb, 0x67, 0x2f, 0xdc, + 0x0d, 0x8d, 0xee, 0x94, 0x81, 0xd0, 0xfc, 0x0b, 0x07, 0xf6, 0xa6, 0xbc, 0xf4, 0x9e, 0x5c, 0x5e, + 0x1f, 0x75, 0xfe, 0x5e, 0x1f, 0x3d, 0xb8, 0x35, 0xf2, 0x1b, 0x12, 0xfb, 0xe8, 0x7e, 0x40, 0x63, + 0x21, 0xbf, 0xcd, 0x81, 0x45, 0x90, 0x80, 0xd0, 0xca, 0xde, 0x32, 0x35, 0xa3, 0x8d, 0x35, 0xe7, + 0x01, 0x8d, 0x41, 0x9b, 0xbf, 0xe6, 0xf5, 0x8a, 0x02, 0xff, 0x56, 0x1e, 0xbf, 0x43, 0xbb, 0x54, + 0x26, 0x09, 0xd7, 0x25, 0xd7, 0x6d, 0xc5, 0xad, 0x47, 0xb1, 0x87, 0x06, 0x19, 0x50, 0xe0, 0xa9, + 0x56, 0x76, 0xaf, 0x15, 0xd3, 0xe4, 0xf0, 0x39, 0x3a, 0x50, 0x20, 0xd8, 0x4c, 0xc1, 0xd7, 0x05, + 0x08, 0x0a, 0xca, 0xbe, 0x67, 0xa4, 0xe7, 0x77, 0x49, 0xd5, 0x6e, 0x85, 0xed, 0x17, 0x40, 0x7d, + 0x67, 0xc4, 0x0c, 0x68, 0xbe, 0x26, 0xf6, 0x5b, 0x8b, 0x05, 0x70, 0x23, 0xbe, 0x47, 0xfb, 0x01, + 0x8d, 0xd7, 0xc0, 0xed, 0xb6, 0xe0, 0x5e, 0x40, 0xe3, 0x1b, 0xef, 0x0c, 0x3d, 0x12, 0xf0, 0x5d, + 0xcf, 0xaa, 0x54, 0x03, 0xdb, 0x83, 0x91, 0x35, 0xee, 0xf9, 0x87, 0xc5, 0xb0, 0xfa, 0x16, 0xea, + 0xd0, 0x31, 0x43, 0x07, 0xff, 0xcb, 0xf8, 0x31, 0xda, 0x4e, 0x65, 0xa6, 0x67, 0x9c, 0xd9, 0xd6, + 0xc8, 0x1a, 0xef, 0xf8, 0xfd, 0xe2, 0x38, 0x65, 0xf8, 0x29, 0x42, 0xb5, 0xcc, 0x99, 0xbd, 0x65, + 0x66, 0x3b, 0xd5, 0xcd, 0x94, 0xe1, 0x21, 0x1a, 0x34, 0x85, 0x5d, 0x53, 0xd8, 0x9c, 0xbd, 0x8f, + 0x97, 0x4b, 0xc7, 0xba, 0x5a, 0x3a, 0xd6, 0xef, 0xa5, 0x63, 0xfd, 0x5c, 0x39, 0x9d, 0xab, 0x95, + 0xd3, 0xf9, 0xb5, 0x72, 0x3a, 0x9f, 0x5e, 0x47, 0x5c, 0x5f, 0x2c, 0x42, 0x97, 0xca, 0x84, 0x50, + 0xa9, 0x12, 0xa9, 0x08, 0x0f, 0xe9, 0x49, 0x24, 0x49, 0x3e, 0x39, 0x25, 0x89, 0x64, 0x8b, 0x39, + 0xa8, 0xf2, 0xf5, 0x9c, 0xbe, 0x3a, 0xa9, 0x1f, 0x90, 0xfe, 0x91, 0x82, 0x0a, 0xfb, 0xe6, 0xf1, + 0xbc, 0xfc, 0x17, 0x00, 0x00, 0xff, 0xff, 0xd5, 0x69, 0xaa, 0xca, 0xaf, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -256,16 +246,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a if m.NextChannelSequence != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.NextChannelSequence)) i-- @@ -476,8 +456,6 @@ func (m *GenesisState) Size() (n int) { if m.NextChannelSequence != 0 { n += 1 + sovGenesis(uint64(m.NextChannelSequence)) } - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) return n } @@ -793,39 +771,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { break } } - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/modules/core/04-channel/types/genesis_test.go b/modules/core/04-channel/types/genesis_test.go index 5fe3b747b84..c58217ae6c4 100644 --- a/modules/core/04-channel/types/genesis_test.go +++ b/modules/core/04-channel/types/genesis_test.go @@ -69,7 +69,6 @@ func TestValidateGenesis(t *testing.T) { types.NewPacketSequence(testPort2, testChannel2, 1), }, 2, - types.Params{UpgradeTimeout: types.DefaultTimeout}, ), expErr: nil, }, @@ -174,7 +173,6 @@ func TestValidateGenesis(t *testing.T) { types.NewPacketSequence(testPort2, testChannel2, 1), }, 0, - types.Params{UpgradeTimeout: types.DefaultTimeout}, ), expErr: host.ErrInvalidID, }, @@ -212,7 +210,6 @@ func TestValidateGenesis(t *testing.T) { types.NewPacketSequence(testPort2, testChannel2, 1), }, 0, - types.Params{UpgradeTimeout: types.DefaultTimeout}, ), expErr: ibcerrors.ErrInvalidSequence, }, diff --git a/modules/core/04-channel/types/keys.go b/modules/core/04-channel/types/keys.go index 8a6f4db8bf7..d4229e29564 100644 --- a/modules/core/04-channel/types/keys.go +++ b/modules/core/04-channel/types/keys.go @@ -28,9 +28,6 @@ const ( // ChannelPrefix is the prefix used when creating a channel identifier ChannelPrefix = "channel-" - - // ParamsKey defines the key to store the params in the keeper. - ParamsKey = "channelParams" ) // FormatChannelIdentifier returns the channel identifier with the sequence appended. diff --git a/modules/core/04-channel/types/msgs.go b/modules/core/04-channel/types/msgs.go index d8e3f30261b..b18f45d1ee2 100644 --- a/modules/core/04-channel/types/msgs.go +++ b/modules/core/04-channel/types/msgs.go @@ -2,7 +2,6 @@ package types import ( "encoding/base64" - "slices" errorsmod "cosmossdk.io/errors" @@ -25,13 +24,6 @@ var ( _ sdk.Msg = (*MsgAcknowledgement)(nil) _ sdk.Msg = (*MsgTimeout)(nil) _ sdk.Msg = (*MsgTimeoutOnClose)(nil) - _ sdk.Msg = (*MsgChannelUpgradeInit)(nil) - _ sdk.Msg = (*MsgChannelUpgradeTry)(nil) - _ sdk.Msg = (*MsgChannelUpgradeAck)(nil) - _ sdk.Msg = (*MsgChannelUpgradeConfirm)(nil) - _ sdk.Msg = (*MsgChannelUpgradeTimeout)(nil) - _ sdk.Msg = (*MsgChannelUpgradeCancel)(nil) - _ sdk.Msg = (*MsgPruneAcknowledgements)(nil) _ sdk.HasValidateBasic = (*MsgChannelOpenInit)(nil) _ sdk.HasValidateBasic = (*MsgChannelOpenTry)(nil) @@ -43,13 +35,6 @@ var ( _ sdk.HasValidateBasic = (*MsgAcknowledgement)(nil) _ sdk.HasValidateBasic = (*MsgTimeout)(nil) _ sdk.HasValidateBasic = (*MsgTimeoutOnClose)(nil) - _ sdk.HasValidateBasic = (*MsgChannelUpgradeInit)(nil) - _ sdk.HasValidateBasic = (*MsgChannelUpgradeTry)(nil) - _ sdk.HasValidateBasic = (*MsgChannelUpgradeAck)(nil) - _ sdk.HasValidateBasic = (*MsgChannelUpgradeConfirm)(nil) - _ sdk.HasValidateBasic = (*MsgChannelUpgradeTimeout)(nil) - _ sdk.HasValidateBasic = (*MsgChannelUpgradeCancel)(nil) - _ sdk.HasValidateBasic = (*MsgPruneAcknowledgements)(nil) ) // NewMsgChannelOpenInit creates a new MsgChannelOpenInit. It sets the counterparty channel @@ -235,15 +220,14 @@ func (msg MsgChannelCloseInit) ValidateBasic() error { // NewMsgChannelCloseConfirm creates a new MsgChannelCloseConfirm instance func NewMsgChannelCloseConfirm( portID, channelID string, initProof []byte, proofHeight clienttypes.Height, - signer string, counterpartyUpgradeSequence uint64, + signer string, ) *MsgChannelCloseConfirm { return &MsgChannelCloseConfirm{ - PortId: portID, - ChannelId: channelID, - ProofInit: initProof, - ProofHeight: proofHeight, - Signer: signer, - CounterpartyUpgradeSequence: counterpartyUpgradeSequence, + PortId: portID, + ChannelId: channelID, + ProofInit: initProof, + ProofHeight: proofHeight, + Signer: signer, } } @@ -331,16 +315,14 @@ func NewMsgTimeoutOnClose( packet Packet, nextSequenceRecv uint64, unreceivedProof, closeProof []byte, proofHeight clienttypes.Height, signer string, - counterpartyUpgradeSequence uint64, ) *MsgTimeoutOnClose { return &MsgTimeoutOnClose{ - Packet: packet, - NextSequenceRecv: nextSequenceRecv, - ProofUnreceived: unreceivedProof, - ProofClose: closeProof, - ProofHeight: proofHeight, - Signer: signer, - CounterpartyUpgradeSequence: counterpartyUpgradeSequence, + Packet: packet, + NextSequenceRecv: nextSequenceRecv, + ProofUnreceived: unreceivedProof, + ProofClose: closeProof, + ProofHeight: proofHeight, + Signer: signer, } } @@ -392,385 +374,3 @@ func (msg MsgAcknowledgement) ValidateBasic() error { } return msg.Packet.ValidateBasic() } - -var _ sdk.Msg = &MsgChannelUpgradeInit{} - -// NewMsgChannelUpgradeInit constructs a new MsgChannelUpgradeInit -// nolint:interfacer -func NewMsgChannelUpgradeInit( - portID, channelID string, - upgradeFields UpgradeFields, - signer string, -) *MsgChannelUpgradeInit { - return &MsgChannelUpgradeInit{ - PortId: portID, - ChannelId: channelID, - Fields: upgradeFields, - Signer: signer, - } -} - -// ValidateBasic implements sdk.Msg -func (msg MsgChannelUpgradeInit) ValidateBasic() error { - if err := host.PortIdentifierValidator(msg.PortId); err != nil { - return errorsmod.Wrap(err, "invalid port ID") - } - if !IsValidChannelID(msg.ChannelId) { - return ErrInvalidChannelIdentifier - } - - _, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - return msg.Fields.ValidateBasic() -} - -var _ sdk.Msg = &MsgChannelUpgradeTry{} - -// NewMsgChannelUpgradeTry constructs a new MsgChannelUpgradeTry -// nolint:interfacer -func NewMsgChannelUpgradeTry( - portID, - channelID string, - proposedConnectionHops []string, - counterpartyUpgradeFields UpgradeFields, - counterpartyUpgradeSequence uint64, - channelProof []byte, - upgradeProof []byte, - proofHeight clienttypes.Height, - signer string, -) *MsgChannelUpgradeTry { - return &MsgChannelUpgradeTry{ - PortId: portID, - ChannelId: channelID, - ProposedUpgradeConnectionHops: proposedConnectionHops, - CounterpartyUpgradeFields: counterpartyUpgradeFields, - CounterpartyUpgradeSequence: counterpartyUpgradeSequence, - ProofChannel: channelProof, - ProofUpgrade: upgradeProof, - ProofHeight: proofHeight, - Signer: signer, - } -} - -// ValidateBasic implements sdk.Msg -func (msg MsgChannelUpgradeTry) ValidateBasic() error { - if err := host.PortIdentifierValidator(msg.PortId); err != nil { - return errorsmod.Wrap(err, "invalid port ID") - } - - if !IsValidChannelID(msg.ChannelId) { - return ErrInvalidChannelIdentifier - } - - if len(msg.ProposedUpgradeConnectionHops) == 0 { - return errorsmod.Wrap(ErrInvalidUpgrade, "proposed connection hops cannot be empty") - } - - if err := msg.CounterpartyUpgradeFields.ValidateBasic(); err != nil { - return errorsmod.Wrap(err, "error validating counterparty upgrade fields") - } - - if msg.CounterpartyUpgradeSequence == 0 { - return errorsmod.Wrap(ErrInvalidUpgradeSequence, "counterparty sequence cannot be 0") - } - - if len(msg.ProofChannel) == 0 { - return errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty channel proof") - } - - if len(msg.ProofUpgrade) == 0 { - return errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty upgrade proof") - } - - _, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - return nil -} - -var _ sdk.Msg = &MsgChannelUpgradeAck{} - -// NewMsgChannelUpgradeAck constructs a new MsgChannelUpgradeAck -// nolint:interfacer -func NewMsgChannelUpgradeAck(portID, channelID string, counterpartyUpgrade Upgrade, channelProof, upgradeProof []byte, proofHeight clienttypes.Height, signer string) *MsgChannelUpgradeAck { - return &MsgChannelUpgradeAck{ - PortId: portID, - ChannelId: channelID, - CounterpartyUpgrade: counterpartyUpgrade, - ProofChannel: channelProof, - ProofUpgrade: upgradeProof, - ProofHeight: proofHeight, - Signer: signer, - } -} - -// ValidateBasic implements sdk.Msg -func (msg MsgChannelUpgradeAck) ValidateBasic() error { - if err := host.PortIdentifierValidator(msg.PortId); err != nil { - return errorsmod.Wrap(err, "invalid port ID") - } - if !IsValidChannelID(msg.ChannelId) { - return ErrInvalidChannelIdentifier - } - if len(msg.ProofChannel) == 0 { - return errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty channel proof") - } - if len(msg.ProofUpgrade) == 0 { - return errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty upgrade sequence proof") - } - if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - return msg.CounterpartyUpgrade.ValidateBasic() -} - -var _ sdk.Msg = &MsgChannelUpgradeConfirm{} - -// NewMsgChannelUpgradeConfirm constructs a new MsgChannelUpgradeConfirm -func NewMsgChannelUpgradeConfirm( - portID, - channelID string, - counterpartyChannelState State, - counterpartyUpgrade Upgrade, - channelProof, - upgradeProof []byte, - proofHeight clienttypes.Height, - signer string, -) *MsgChannelUpgradeConfirm { - return &MsgChannelUpgradeConfirm{ - PortId: portID, - ChannelId: channelID, - CounterpartyChannelState: counterpartyChannelState, - CounterpartyUpgrade: counterpartyUpgrade, - ProofChannel: channelProof, - ProofUpgrade: upgradeProof, - ProofHeight: proofHeight, - Signer: signer, - } -} - -// ValidateBasic implements sdk.Msg -func (msg MsgChannelUpgradeConfirm) ValidateBasic() error { - if err := host.PortIdentifierValidator(msg.PortId); err != nil { - return errorsmod.Wrap(err, "invalid port ID") - } - - if !IsValidChannelID(msg.ChannelId) { - return ErrInvalidChannelIdentifier - } - - if !slices.Contains([]State{FLUSHING, FLUSHCOMPLETE}, msg.CounterpartyChannelState) { - return errorsmod.Wrapf(ErrInvalidChannelState, "expected channel state to be one of: %s or %s, got: %s", FLUSHING, FLUSHCOMPLETE, msg.CounterpartyChannelState) - } - - if len(msg.ProofChannel) == 0 { - return errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty channel proof") - } - - if len(msg.ProofUpgrade) == 0 { - return errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty upgrade proof") - } - - _, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - return msg.CounterpartyUpgrade.ValidateBasic() -} - -var _ sdk.Msg = &MsgChannelUpgradeOpen{} - -// NewMsgChannelUpgradeOpen constructs a new MsgChannelUpgradeOpen -// nolint:interfacer -func NewMsgChannelUpgradeOpen( - portID, - channelID string, - counterpartyChannelState State, - counterpartyUpgradeSequence uint64, - channelProof []byte, - proofHeight clienttypes.Height, - signer string, -) *MsgChannelUpgradeOpen { - return &MsgChannelUpgradeOpen{ - PortId: portID, - ChannelId: channelID, - CounterpartyChannelState: counterpartyChannelState, - CounterpartyUpgradeSequence: counterpartyUpgradeSequence, - ProofChannel: channelProof, - ProofHeight: proofHeight, - Signer: signer, - } -} - -// ValidateBasic implements sdk.Msg -func (msg MsgChannelUpgradeOpen) ValidateBasic() error { - if err := host.PortIdentifierValidator(msg.PortId); err != nil { - return errorsmod.Wrap(err, "invalid port ID") - } - - if !IsValidChannelID(msg.ChannelId) { - return ErrInvalidChannelIdentifier - } - - if len(msg.ProofChannel) == 0 { - return errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty channel proof") - } - - if !slices.Contains([]State{FLUSHCOMPLETE, OPEN}, msg.CounterpartyChannelState) { - return errorsmod.Wrapf(ErrInvalidChannelState, "expected channel state to be one of: [%s, %s], got: %s", FLUSHCOMPLETE, OPEN, msg.CounterpartyChannelState) - } - - if msg.CounterpartyUpgradeSequence == 0 { - return errorsmod.Wrap(ErrInvalidUpgradeSequence, "counterparty upgrade sequence must be non-zero") - } - - _, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - return nil -} - -var _ sdk.Msg = &MsgChannelUpgradeTimeout{} - -// NewMsgChannelUpgradeTimeout constructs a new MsgChannelUpgradeTimeout -// nolint:interfacer -func NewMsgChannelUpgradeTimeout( - portID, channelID string, - counterpartyChannel Channel, - channelProof []byte, - proofHeight clienttypes.Height, - signer string, -) *MsgChannelUpgradeTimeout { - return &MsgChannelUpgradeTimeout{ - PortId: portID, - ChannelId: channelID, - CounterpartyChannel: counterpartyChannel, - ProofChannel: channelProof, - ProofHeight: proofHeight, - Signer: signer, - } -} - -// ValidateBasic implements sdk.Msg -func (msg MsgChannelUpgradeTimeout) ValidateBasic() error { - if err := host.PortIdentifierValidator(msg.PortId); err != nil { - return errorsmod.Wrap(err, "invalid port ID") - } - - if !IsValidChannelID(msg.ChannelId) { - return ErrInvalidChannelIdentifier - } - - if len(msg.ProofChannel) == 0 { - return errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") - } - - if !slices.Contains([]State{FLUSHING, OPEN}, msg.CounterpartyChannel.State) { - return errorsmod.Wrapf(ErrInvalidChannelState, "expected counterparty channel state to be one of: [%s, %s], got: %s", FLUSHING, OPEN, msg.CounterpartyChannel.State) - } - - _, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - return nil -} - -var _ sdk.Msg = &MsgChannelUpgradeCancel{} - -// NewMsgChannelUpgradeCancel constructs a new MsgChannelUpgradeCancel -// nolint:interfacer -func NewMsgChannelUpgradeCancel( - portID, channelID string, - errorReceipt ErrorReceipt, - errorReceiptProof []byte, - proofHeight clienttypes.Height, - signer string, -) *MsgChannelUpgradeCancel { - return &MsgChannelUpgradeCancel{ - PortId: portID, - ChannelId: channelID, - ErrorReceipt: errorReceipt, - ProofErrorReceipt: errorReceiptProof, - ProofHeight: proofHeight, - Signer: signer, - } -} - -// ValidateBasic implements sdk.Msg. No checks are done for ErrorReceipt and ProofErrorReceipt -// since they are not required if the current channel state is not in FLUSHCOMPLETE and the signer -// is the designated authority (e.g. the governance module). -func (msg MsgChannelUpgradeCancel) ValidateBasic() error { - if err := host.PortIdentifierValidator(msg.PortId); err != nil { - return errorsmod.Wrap(err, "invalid port ID") - } - - if !IsValidChannelID(msg.ChannelId) { - return ErrInvalidChannelIdentifier - } - - _, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - return nil -} - -// NewMsgUpdateChannelParams creates a new instance of MsgUpdateParams. -func NewMsgUpdateChannelParams(authority string, params Params) *MsgUpdateParams { - return &MsgUpdateParams{ - Authority: authority, - Params: params, - } -} - -// ValidateBasic performs basic checks on a MsgUpdateParams. -func (msg *MsgUpdateParams) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - return msg.Params.Validate() -} - -// NewMsgPruneAcknowledgements creates a new instance of MsgPruneAcknowledgements. -func NewMsgPruneAcknowledgements(portID, channelID string, limit uint64, signer string) *MsgPruneAcknowledgements { - return &MsgPruneAcknowledgements{ - PortId: portID, - ChannelId: channelID, - Limit: limit, - Signer: signer, - } -} - -// ValidateBasic performs basic checks on a MsgPruneAcknowledgements. -func (msg *MsgPruneAcknowledgements) ValidateBasic() error { - if err := host.PortIdentifierValidator(msg.PortId); err != nil { - return errorsmod.Wrap(err, "invalid port ID") - } - - if !IsValidChannelID(msg.ChannelId) { - return ErrInvalidChannelIdentifier - } - - _, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) - } - - if msg.Limit == 0 { - return errorsmod.Wrap(ErrInvalidPruningLimit, "number of acknowledgements to prune must be greater than 0") - } - - return nil -} diff --git a/modules/core/04-channel/types/msgs_test.go b/modules/core/04-channel/types/msgs_test.go index 0f3853a4f0f..7304351ab2a 100644 --- a/modules/core/04-channel/types/msgs_test.go +++ b/modules/core/04-channel/types/msgs_test.go @@ -17,8 +17,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ibc "github.com/cosmos/ibc-go/v10/modules/core" clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" @@ -26,18 +24,15 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v10/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v10/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v10/modules/core/errors" - ibctesting "github.com/cosmos/ibc-go/v10/testing" - "github.com/cosmos/ibc-go/v10/testing/mock" "github.com/cosmos/ibc-go/v10/testing/simapp" ) const ( // valid constants used for testing - portid = "testportid" - chanid = "channel-0" - cpportid = "testcpport" - cpchanid = "testcpchannel" - counterpartyUpgradeSequence = 0 + portid = "testportid" + chanid = "channel-0" + cpportid = "testcpport" + cpchanid = "testcpchannel" version = "1.0" @@ -742,17 +737,17 @@ func (suite *TypesTestSuite) TestMsgChannelCloseConfirmValidateBasic() { }{ { "success", - types.NewMsgChannelCloseConfirm(portid, chanid, suite.proof, height, addr, 0), + types.NewMsgChannelCloseConfirm(portid, chanid, suite.proof, height, addr), nil, }, { "success, positive counterparty upgrade sequence", - types.NewMsgChannelCloseConfirm(portid, chanid, suite.proof, height, addr, 1), + types.NewMsgChannelCloseConfirm(portid, chanid, suite.proof, height, addr), nil, }, { "too short port id", - types.NewMsgChannelCloseConfirm(invalidShortPort, chanid, suite.proof, height, addr, 0), + types.NewMsgChannelCloseConfirm(invalidShortPort, chanid, suite.proof, height, addr), errorsmod.Wrap( errorsmod.Wrapf( host.ErrInvalidID, @@ -763,7 +758,7 @@ func (suite *TypesTestSuite) TestMsgChannelCloseConfirmValidateBasic() { }, { "too long port id", - types.NewMsgChannelCloseConfirm(invalidLongPort, chanid, suite.proof, height, addr, 0), + types.NewMsgChannelCloseConfirm(invalidLongPort, chanid, suite.proof, height, addr), errorsmod.Wrap( errorsmod.Wrapf( host.ErrInvalidID, @@ -774,7 +769,7 @@ func (suite *TypesTestSuite) TestMsgChannelCloseConfirmValidateBasic() { }, { "port id contains non-alpha", - types.NewMsgChannelCloseConfirm(invalidPort, chanid, suite.proof, height, addr, 0), + types.NewMsgChannelCloseConfirm(invalidPort, chanid, suite.proof, height, addr), errorsmod.Wrap( errorsmod.Wrapf( host.ErrInvalidID, @@ -785,22 +780,22 @@ func (suite *TypesTestSuite) TestMsgChannelCloseConfirmValidateBasic() { }, { "too short channel id", - types.NewMsgChannelCloseConfirm(portid, invalidShortChannel, suite.proof, height, addr, 0), + types.NewMsgChannelCloseConfirm(portid, invalidShortChannel, suite.proof, height, addr), types.ErrInvalidChannelIdentifier, }, { "too long channel id", - types.NewMsgChannelCloseConfirm(portid, invalidLongChannel, suite.proof, height, addr, 0), + types.NewMsgChannelCloseConfirm(portid, invalidLongChannel, suite.proof, height, addr), types.ErrInvalidChannelIdentifier, }, { "channel id contains non-alpha", - types.NewMsgChannelCloseConfirm(portid, invalidChannel, suite.proof, height, addr, 0), + types.NewMsgChannelCloseConfirm(portid, invalidChannel, suite.proof, height, addr), types.ErrInvalidChannelIdentifier, }, { "empty proof", - types.NewMsgChannelCloseConfirm(portid, chanid, emptyProof, height, addr, 0), + types.NewMsgChannelCloseConfirm(portid, chanid, emptyProof, height, addr), errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty init proof"), }, } @@ -824,7 +819,7 @@ func (suite *TypesTestSuite) TestMsgChannelCloseConfirmValidateBasic() { func (suite *TypesTestSuite) TestMsgChannelCloseConfirmGetSigners() { expSigner, err := sdk.AccAddressFromBech32(addr) suite.Require().NoError(err) - msg := types.NewMsgChannelCloseConfirm(portid, chanid, suite.proof, height, addr, counterpartyUpgradeSequence) + msg := types.NewMsgChannelCloseConfirm(portid, chanid, suite.proof, height, addr) encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) @@ -958,37 +953,37 @@ func (suite *TypesTestSuite) TestMsgTimeoutOnCloseValidateBasic() { }{ { "success", - types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, height, addr, 0), + types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, height, addr), nil, }, { "success, positive counterparty upgrade sequence", - types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, height, addr, 1), + types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, height, addr), nil, }, { "seq 0", - types.NewMsgTimeoutOnClose(packet, 0, suite.proof, suite.proof, height, addr, 0), + types.NewMsgTimeoutOnClose(packet, 0, suite.proof, suite.proof, height, addr), errorsmod.Wrap(ibcerrors.ErrInvalidSequence, "next sequence receive cannot be 0"), }, { "signer address is empty", - types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, height, emptyAddr, 0), + types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, height, emptyAddr), errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", errors.New("empty address string is not allowed")), }, { "empty proof", - types.NewMsgTimeoutOnClose(packet, 1, emptyProof, suite.proof, height, addr, 0), + types.NewMsgTimeoutOnClose(packet, 1, emptyProof, suite.proof, height, addr), errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty unreceived proof"), }, { "empty proof close", - types.NewMsgTimeoutOnClose(packet, 1, suite.proof, emptyProof, height, addr, 0), + types.NewMsgTimeoutOnClose(packet, 1, suite.proof, emptyProof, height, addr), errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof of closed counterparty channel end"), }, { "invalid packet", - types.NewMsgTimeoutOnClose(invalidPacket, 1, suite.proof, suite.proof, height, addr, 0), + types.NewMsgTimeoutOnClose(invalidPacket, 1, suite.proof, suite.proof, height, addr), errorsmod.Wrap(types.ErrInvalidPacket, "packet sequence cannot be 0"), }, } @@ -1012,7 +1007,7 @@ func (suite *TypesTestSuite) TestMsgTimeoutOnCloseValidateBasic() { func (suite *TypesTestSuite) TestMsgTimeoutOnCloseGetSigners() { expSigner, err := sdk.AccAddressFromBech32(addr) suite.Require().NoError(err) - msg := types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, height, addr, counterpartyUpgradeSequence) + msg := types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, height, addr) encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) @@ -1081,830 +1076,3 @@ func (suite *TypesTestSuite) TestMsgAcknowledgementGetSigners() { suite.Require().NoError(err) suite.Require().Equal(expSigner.Bytes(), signers[0]) } - -func (suite *TypesTestSuite) TestMsgChannelUpgradeInitValidateBasic() { - var msg *types.MsgChannelUpgradeInit - - testCases := []struct { - name string - malleate func() - expErr error - }{ - { - "success", - func() {}, - nil, - }, - { - "invalid port identifier", - func() { - msg.PortId = invalidPort - }, - errorsmod.Wrap( - errorsmod.Wrapf( - host.ErrInvalidID, - "identifier %s must contain only alphanumeric or the following characters: '.', '_', '+', '-', '#', '[', ']', '<', '>'", - invalidPort, - ), "invalid port ID", - ), - }, - { - "invalid channel identifier", - func() { - msg.ChannelId = invalidChannel - }, - types.ErrInvalidChannelIdentifier, - }, - { - "empty proposed upgrade channel version", - func() { - msg.Fields.Version = " " - }, - errorsmod.Wrap(types.ErrInvalidChannelVersion, "version cannot be empty"), - }, - { - "missing signer address", - func() { - msg.Signer = emptyAddr - }, - errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", errors.New("empty address string is not allowed")), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - msg = types.NewMsgChannelUpgradeInit( - ibctesting.MockPort, ibctesting.FirstChannelID, - types.NewUpgradeFields(types.UNORDERED, []string{ibctesting.FirstConnectionID}, mock.Version), - addr, - ) - - tc.malleate() - err := msg.ValidateBasic() - - if tc.expErr == nil { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - suite.Require().Equal(err.Error(), tc.expErr.Error()) - } - }) - } -} - -func (suite *TypesTestSuite) TestMsgChannelUpgradeInitGetSigners() { - expSigner, err := sdk.AccAddressFromBech32(addr) - suite.Require().NoError(err) - msg := types.NewMsgChannelUpgradeInit( - ibctesting.MockPort, ibctesting.FirstChannelID, - types.NewUpgradeFields(types.UNORDERED, []string{ibctesting.FirstConnectionID}, mock.Version), - addr, - ) - - encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) - signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) - - suite.Require().NoError(err) - suite.Require().Equal(expSigner.Bytes(), signers[0]) -} - -func (suite *TypesTestSuite) TestMsgChannelUpgradeTryValidateBasic() { - var msg *types.MsgChannelUpgradeTry - - testCases := []struct { - name string - malleate func() - expErr error - }{ - { - "success", - func() {}, - nil, - }, - { - "invalid port identifier", - func() { - msg.PortId = invalidPort - }, - errorsmod.Wrap( - errorsmod.Wrapf( - host.ErrInvalidID, - "identifier %s must contain only alphanumeric or the following characters: '.', '_', '+', '-', '#', '[', ']', '<', '>'", - invalidPort, - ), "invalid port ID", - ), - }, - { - "invalid channel identifier", - func() { - msg.ChannelId = invalidChannel - }, - types.ErrInvalidChannelIdentifier, - }, - { - "counterparty sequence cannot be zero", - func() { - msg.CounterpartyUpgradeSequence = 0 - }, - errorsmod.Wrap(types.ErrInvalidUpgradeSequence, "counterparty sequence cannot be 0"), - }, - { - "invalid connection hops", - func() { - msg.ProposedUpgradeConnectionHops = []string{} - }, - errorsmod.Wrap(types.ErrInvalidUpgrade, "proposed connection hops cannot be empty"), - }, - { - "invalid counterparty upgrade fields ordering", - func() { - msg.CounterpartyUpgradeFields.Ordering = types.NONE - }, - errorsmod.Wrap( - errorsmod.Wrap(types.ErrInvalidChannelOrdering, types.NONE.String()), "error validating counterparty upgrade fields", - ), - }, - { - "cannot submit an empty channel proof", - func() { - msg.ProofChannel = emptyProof - }, - errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty channel proof"), - }, - { - "cannot submit an empty upgrade proof", - func() { - msg.ProofUpgrade = emptyProof - }, - errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty upgrade proof"), - }, - { - "missing signer address", - func() { - msg.Signer = emptyAddr - }, - errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", errors.New("empty address string is not allowed")), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - msg = types.NewMsgChannelUpgradeTry( - ibctesting.MockPort, - ibctesting.FirstChannelID, - []string{ibctesting.FirstConnectionID}, - types.NewUpgradeFields(types.UNORDERED, []string{ibctesting.FirstConnectionID}, mock.Version), - 1, - suite.proof, - suite.proof, - height, - addr, - ) - - tc.malleate() - err := msg.ValidateBasic() - - if tc.expErr == nil { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - suite.Require().Equal(err.Error(), tc.expErr.Error()) - } - }) - } -} - -func (suite *TypesTestSuite) TestMsgChannelUpgradeTryGetSigners() { - expSigner, err := sdk.AccAddressFromBech32(addr) - suite.Require().NoError(err) - msg := types.NewMsgChannelUpgradeTry( - ibctesting.MockPort, - ibctesting.FirstChannelID, - []string{ibctesting.FirstConnectionID}, - types.NewUpgradeFields(types.UNORDERED, []string{ibctesting.FirstConnectionID}, mock.Version), - 1, - suite.proof, - suite.proof, - height, - addr, - ) - - encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) - signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) - - suite.Require().NoError(err) - suite.Require().Equal(expSigner.Bytes(), signers[0]) -} - -func (suite *TypesTestSuite) TestMsgChannelUpgradeAckValidateBasic() { - var msg *types.MsgChannelUpgradeAck - - testCases := []struct { - name string - malleate func() - expErr error - }{ - { - "success", - func() {}, - nil, - }, - { - "invalid port identifier", - func() { - msg.PortId = invalidPort - }, - errorsmod.Wrap( - errorsmod.Wrapf( - host.ErrInvalidID, - "identifier %s must contain only alphanumeric or the following characters: '.', '_', '+', '-', '#', '[', ']', '<', '>'", - invalidPort, - ), "invalid port ID", - ), - }, - { - "invalid channel identifier", - func() { - msg.ChannelId = invalidChannel - }, - types.ErrInvalidChannelIdentifier, - }, - { - "cannot submit an empty channel proof", - func() { - msg.ProofChannel = emptyProof - }, - errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty channel proof"), - }, - { - "cannot submit an empty upgrade proof", - func() { - msg.ProofUpgrade = emptyProof - }, - errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty upgrade sequence proof"), - }, - { - "missing signer address", - func() { - msg.Signer = emptyAddr - }, - errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", errors.New("empty address string is not allowed")), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - upgrade := types.NewUpgrade( - types.NewUpgradeFields(types.ORDERED, []string{ibctesting.FirstConnectionID}, mock.Version), - types.NewTimeout(clienttypes.NewHeight(1, 100), 0), - 0, - ) - - msg = types.NewMsgChannelUpgradeAck( - ibctesting.MockPort, ibctesting.FirstChannelID, - upgrade, suite.proof, suite.proof, - height, addr, - ) - - tc.malleate() - err := msg.ValidateBasic() - - if tc.expErr == nil { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - suite.Require().Equal(err.Error(), tc.expErr.Error()) - } - }) - } -} - -func (suite *TypesTestSuite) TestMsgChannelUpgradeAckGetSigners() { - expSigner, err := sdk.AccAddressFromBech32(addr) - suite.Require().NoError(err) - upgrade := types.NewUpgrade( - types.NewUpgradeFields(types.ORDERED, []string{ibctesting.FirstConnectionID}, mock.Version), - types.NewTimeout(clienttypes.NewHeight(1, 100), 0), - 0, - ) - - msg := types.NewMsgChannelUpgradeAck( - ibctesting.MockPort, ibctesting.FirstChannelID, - upgrade, suite.proof, suite.proof, - height, addr, - ) - - encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) - signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) - - suite.Require().NoError(err) - suite.Require().Equal(expSigner.Bytes(), signers[0]) -} - -func (suite *TypesTestSuite) TestMsgChannelUpgradeConfirmValidateBasic() { - var msg *types.MsgChannelUpgradeConfirm - - testCases := []struct { - name string - malleate func() - expErr error - }{ - { - "success", - func() {}, - nil, - }, - { - "success: counterparty state set to FLUSHCOMPLETE", - func() { - msg.CounterpartyChannelState = types.FLUSHCOMPLETE - }, - nil, - }, - { - "invalid port identifier", - func() { - msg.PortId = invalidPort - }, - errorsmod.Wrap( - errorsmod.Wrapf( - host.ErrInvalidID, - "identifier %s must contain only alphanumeric or the following characters: '.', '_', '+', '-', '#', '[', ']', '<', '>'", - invalidPort, - ), "invalid port ID", - ), - }, - { - "invalid channel identifier", - func() { - msg.ChannelId = invalidChannel - }, - types.ErrInvalidChannelIdentifier, - }, - { - "invalid counterparty channel state", - func() { - msg.CounterpartyChannelState = types.CLOSED - }, - errorsmod.Wrapf(types.ErrInvalidChannelState, "expected channel state to be one of: %s or %s, got: %s", types.FLUSHING, types.FLUSHCOMPLETE, types.CLOSED), - }, - { - "cannot submit an empty channel proof", - func() { - msg.ProofChannel = emptyProof - }, - errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty channel proof"), - }, - { - "cannot submit an empty upgrade proof", - func() { - msg.ProofUpgrade = emptyProof - }, - errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty upgrade proof"), - }, - { - "missing signer address", - func() { - msg.Signer = emptyAddr - }, - errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", errors.New("empty address string is not allowed")), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - counterpartyUpgrade := types.NewUpgrade( - types.NewUpgradeFields(types.UNORDERED, []string{ibctesting.FirstConnectionID}, mock.Version), - types.NewTimeout(clienttypes.NewHeight(0, 10000), timeoutTimestamp), - 0, - ) - - msg = types.NewMsgChannelUpgradeConfirm( - ibctesting.MockPort, ibctesting.FirstChannelID, - types.FLUSHING, counterpartyUpgrade, suite.proof, suite.proof, - height, addr, - ) - - tc.malleate() - err := msg.ValidateBasic() - - if tc.expErr == nil { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - suite.Require().Equal(err.Error(), tc.expErr.Error()) - } - }) - } -} - -func (suite *TypesTestSuite) TestMsgChannelUpgradeConfirmGetSigners() { - expSigner, err := sdk.AccAddressFromBech32(addr) - suite.Require().NoError(err) - - msg := &types.MsgChannelUpgradeConfirm{Signer: addr} - - encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) - signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) - - suite.Require().NoError(err) - suite.Require().Equal(expSigner.Bytes(), signers[0]) -} - -func (suite *TypesTestSuite) TestMsgChannelUpgradeOpenValidateBasic() { - var msg *types.MsgChannelUpgradeOpen - - testCases := []struct { - name string - malleate func() - expErr error - }{ - { - "success: flushcomplete state", - func() {}, - nil, - }, - { - "success: open state", - func() { - msg.CounterpartyChannelState = types.OPEN - }, - nil, - }, - { - "invalid port identifier", - func() { - msg.PortId = invalidPort - }, - errorsmod.Wrap( - errorsmod.Wrapf( - host.ErrInvalidID, - "identifier %s must contain only alphanumeric or the following characters: '.', '_', '+', '-', '#', '[', ']', '<', '>'", - invalidPort, - ), "invalid port ID", - ), - }, - { - "invalid channel identifier", - func() { - msg.ChannelId = invalidChannel - }, - types.ErrInvalidChannelIdentifier, - }, - { - "invalid counterparty channel state", - func() { - msg.CounterpartyChannelState = types.CLOSED - }, - errorsmod.Wrapf(types.ErrInvalidChannelState, "expected channel state to be one of: [%s, %s], got: %s", types.FLUSHCOMPLETE, types.OPEN, types.CLOSED), - }, - { - "invalid counterparty upgrade sequence", - func() { - msg.CounterpartyUpgradeSequence = 0 - }, - errorsmod.Wrapf(types.ErrInvalidUpgradeSequence, "counterparty upgrade sequence must be non-zero"), - }, - - { - "cannot submit an empty channel proof", - func() { - msg.ProofChannel = emptyProof - }, - errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty channel proof"), - }, - { - "missing signer address", - func() { - msg.Signer = emptyAddr - }, - errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", errors.New("empty address string is not allowed")), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - msg = types.NewMsgChannelUpgradeOpen( - ibctesting.MockPort, ibctesting.FirstChannelID, - types.FLUSHCOMPLETE, 1, suite.proof, - height, addr, - ) - - tc.malleate() - err := msg.ValidateBasic() - - if tc.expErr == nil { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - suite.Require().Equal(err.Error(), tc.expErr.Error()) - } - }) - } -} - -func (suite *TypesTestSuite) TestMsgChannelUpgradeTimeoutValidateBasic() { - var msg *types.MsgChannelUpgradeTimeout - - testCases := []struct { - name string - malleate func() - expErr error - }{ - { - "success", - func() {}, - nil, - }, - { - "invalid port identifier", - func() { - msg.PortId = invalidPort - }, - errorsmod.Wrap( - errorsmod.Wrapf( - host.ErrInvalidID, - "identifier %s must contain only alphanumeric or the following characters: '.', '_', '+', '-', '#', '[', ']', '<', '>'", - invalidPort, - ), "invalid port ID", - ), - }, - { - "invalid channel identifier", - func() { - msg.ChannelId = invalidChannel - }, - types.ErrInvalidChannelIdentifier, - }, - { - "cannot submit an empty proof", - func() { - msg.ProofChannel = emptyProof - }, - errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof"), - }, - { - "invalid counterparty channel state", - func() { - msg.CounterpartyChannel.State = types.CLOSED - }, - errorsmod.Wrapf(types.ErrInvalidChannelState, "expected counterparty channel state to be one of: [%s, %s], got: %s", types.FLUSHING, types.OPEN, types.CLOSED), - }, - { - "missing signer address", - func() { - msg.Signer = emptyAddr - }, - errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", errors.New("empty address string is not allowed")), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - msg = types.NewMsgChannelUpgradeTimeout( - ibctesting.MockPort, ibctesting.FirstChannelID, - types.Channel{State: types.OPEN}, - suite.proof, - height, addr, - ) - - tc.malleate() - err := msg.ValidateBasic() - - if tc.expErr == nil { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - suite.Require().Equal(err.Error(), tc.expErr.Error()) - } - }) - } -} - -func (suite *TypesTestSuite) TestMsgChannelUpgradeTimeoutGetSigners() { - expSigner, err := sdk.AccAddressFromBech32(addr) - suite.Require().NoError(err) - - msg := types.NewMsgChannelUpgradeTimeout( - ibctesting.MockPort, ibctesting.FirstChannelID, - types.Channel{}, - suite.proof, - height, addr, - ) - encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) - signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) - - suite.Require().NoError(err) - suite.Require().Equal(expSigner.Bytes(), signers[0]) -} - -func (suite *TypesTestSuite) TestMsgChannelUpgradeCancelValidateBasic() { - var msg *types.MsgChannelUpgradeCancel - - testCases := []struct { - name string - malleate func() - expErr error - }{ - { - "success", - func() {}, - nil, - }, - { - "invalid port identifier", - func() { - msg.PortId = invalidPort - }, - errorsmod.Wrap( - errorsmod.Wrapf( - host.ErrInvalidID, - "identifier %s must contain only alphanumeric or the following characters: '.', '_', '+', '-', '#', '[', ']', '<', '>'", - invalidPort, - ), "invalid port ID", - ), - }, - { - "invalid channel identifier", - func() { - msg.ChannelId = invalidChannel - }, - types.ErrInvalidChannelIdentifier, - }, - { - "can submit an empty proof", - func() { - msg.ProofErrorReceipt = emptyProof - }, - nil, - }, - { - "missing signer address", - func() { - msg.Signer = emptyAddr - }, - errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", errors.New("empty address string is not allowed")), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - msg = types.NewMsgChannelUpgradeCancel(ibctesting.MockPort, ibctesting.FirstChannelID, types.ErrorReceipt{Sequence: 1}, suite.proof, height, addr) - - tc.malleate() - err := msg.ValidateBasic() - - if tc.expErr == nil { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - suite.Require().Equal(err.Error(), tc.expErr.Error()) - } - }) - } -} - -func (suite *TypesTestSuite) TestMsgChannelUpgradeCancelGetSigners() { - expSigner, err := sdk.AccAddressFromBech32(addr) - suite.Require().NoError(err) - - msg := types.NewMsgChannelUpgradeCancel(ibctesting.MockPort, ibctesting.FirstChannelID, types.ErrorReceipt{Sequence: 1}, suite.proof, height, addr) - encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) - signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) - - suite.Require().NoError(err) - suite.Require().Equal(expSigner.Bytes(), signers[0]) -} - -func (suite *TypesTestSuite) TestMsgPruneAcknowledgementsValidateBasic() { - var msg *types.MsgPruneAcknowledgements - - testCases := []struct { - name string - malleate func() - expErr error - }{ - { - "success", - func() {}, - nil, - }, - { - "failure: zero pruning limit", - func() { - msg.Limit = 0 - }, - types.ErrInvalidPruningLimit, - }, - { - "invalid port identifier", - func() { - msg.PortId = invalidPort - }, - host.ErrInvalidID, - }, - { - "invalid channel identifier", - func() { - msg.ChannelId = invalidChannel - }, - types.ErrInvalidChannelIdentifier, - }, - { - "empty signer address", - func() { - msg.Signer = emptyAddr - }, - ibcerrors.ErrInvalidAddress, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - msg = types.NewMsgPruneAcknowledgements(ibctesting.MockPort, ibctesting.FirstChannelID, 1, addr) - - tc.malleate() - err := msg.ValidateBasic() - - if tc.expErr == nil { - suite.Require().NoError(err) - } else { - suite.Require().ErrorIs(err, tc.expErr) - } - }) - } -} - -func (suite *TypesTestSuite) TestMsgUpdateParamsValidateBasic() { - var msg *types.MsgUpdateParams - - testCases := []struct { - name string - malleate func() - expErr error - }{ - { - "success", - func() {}, - nil, - }, - { - "invalid authority", - func() { - msg.Authority = "invalid-address" - }, - ibcerrors.ErrInvalidAddress, - }, - { - "invalid params: non zero height", - func() { - newHeight := clienttypes.NewHeight(1, 1000) - msg = types.NewMsgUpdateChannelParams(authtypes.NewModuleAddress(govtypes.ModuleName).String(), types.NewParams(types.NewTimeout(newHeight, uint64(100000)))) - }, - types.ErrInvalidUpgradeTimeout, - }, - { - "invalid params: zero timestamp", - func() { - msg = types.NewMsgUpdateChannelParams(authtypes.NewModuleAddress(govtypes.ModuleName).String(), types.NewParams(types.NewTimeout(clienttypes.ZeroHeight(), uint64(0)))) - }, - types.ErrInvalidUpgradeTimeout, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - msg = types.NewMsgUpdateChannelParams(authtypes.NewModuleAddress(govtypes.ModuleName).String(), types.NewParams(types.NewTimeout(clienttypes.ZeroHeight(), uint64(100000)))) - - tc.malleate() - err := msg.ValidateBasic() - - if tc.expErr == nil { - suite.Require().NoError(err) - } else { - suite.Require().ErrorIs(err, tc.expErr) - } - }) - } -} - -func (suite *TypesTestSuite) TestMsgPruneAcknowledgementsGetSigners() { - expSigner, err := sdk.AccAddressFromBech32(addr) - suite.Require().NoError(err) - - msg := types.NewMsgPruneAcknowledgements(ibctesting.MockPort, ibctesting.FirstChannelID, 0, addr) - encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) - signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg) - - suite.Require().NoError(err) - suite.Require().Equal(expSigner.Bytes(), signers[0]) -} diff --git a/modules/core/04-channel/types/params.go b/modules/core/04-channel/types/params.go deleted file mode 100644 index 65af645180c..00000000000 --- a/modules/core/04-channel/types/params.go +++ /dev/null @@ -1,37 +0,0 @@ -package types - -import ( - "time" - - errorsmod "cosmossdk.io/errors" - - clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" -) - -// DefaultTimeout defines a default parameter for the channel upgrade protocol. -// It allows relayers a window in which they can flush all in-flight packets on a channel before completing the upgrade handshake. -// This parameter can be overridden by a valid authority using the UpdateChannelParams rpc. -var DefaultTimeout = NewTimeout(clienttypes.ZeroHeight(), uint64(10*time.Minute.Nanoseconds())) - -// NewParams creates a new parameter configuration for the channel submodule -func NewParams(upgradeTimeout Timeout) Params { - return Params{ - UpgradeTimeout: upgradeTimeout, - } -} - -// DefaultParams is the default parameter configuration for the channel submodule -func DefaultParams() Params { - return NewParams(DefaultTimeout) -} - -// Validate the params. -func (p Params) Validate() error { - if !p.UpgradeTimeout.Height.IsZero() { - return errorsmod.Wrapf(ErrInvalidUpgradeTimeout, "upgrade timeout height must be zero. got : %v", p.UpgradeTimeout.Height) - } - if p.UpgradeTimeout.Timestamp == 0 { - return errorsmod.Wrapf(ErrInvalidUpgradeTimeout, "upgrade timeout timestamp invalid: %v", p.UpgradeTimeout.Timestamp) - } - return nil -} diff --git a/modules/core/04-channel/types/query.go b/modules/core/04-channel/types/query.go index 54a5b016b1f..b6c7d7c2f15 100644 --- a/modules/core/04-channel/types/query.go +++ b/modules/core/04-channel/types/query.go @@ -104,21 +104,3 @@ func NewQueryNextSequenceSendResponse( ProofHeight: height, } } - -// NewQueryUpgradeErrorResponse creates a new QueryUpgradeErrorResponse instance -func NewQueryUpgradeErrorResponse(errorReceipt ErrorReceipt, proof []byte, height clienttypes.Height) *QueryUpgradeErrorResponse { - return &QueryUpgradeErrorResponse{ - ErrorReceipt: errorReceipt, - Proof: proof, - ProofHeight: height, - } -} - -// NewQueryUpgradeResponse creates a new QueryUpgradeResponse instance -func NewQueryUpgradeResponse(upgrade Upgrade, proof []byte, height clienttypes.Height) *QueryUpgradeResponse { - return &QueryUpgradeResponse{ - Upgrade: upgrade, - Proof: proof, - ProofHeight: height, - } -} diff --git a/modules/core/04-channel/types/query.pb.go b/modules/core/04-channel/types/query.pb.go index 8427d5caba5..ea141f84ad9 100644 --- a/modules/core/04-channel/types/query.pb.go +++ b/modules/core/04-channel/types/query.pb.go @@ -1797,321 +1797,6 @@ func (m *QueryNextSequenceSendResponse) GetProofHeight() types.Height { return types.Height{} } -// QueryUpgradeErrorRequest is the request type for the Query/QueryUpgradeError RPC method -type QueryUpgradeErrorRequest struct { - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` -} - -func (m *QueryUpgradeErrorRequest) Reset() { *m = QueryUpgradeErrorRequest{} } -func (m *QueryUpgradeErrorRequest) String() string { return proto.CompactTextString(m) } -func (*QueryUpgradeErrorRequest) ProtoMessage() {} -func (*QueryUpgradeErrorRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_1034a1e9abc4cca1, []int{28} -} -func (m *QueryUpgradeErrorRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryUpgradeErrorRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryUpgradeErrorRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryUpgradeErrorRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryUpgradeErrorRequest.Merge(m, src) -} -func (m *QueryUpgradeErrorRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryUpgradeErrorRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryUpgradeErrorRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryUpgradeErrorRequest proto.InternalMessageInfo - -func (m *QueryUpgradeErrorRequest) GetPortId() string { - if m != nil { - return m.PortId - } - return "" -} - -func (m *QueryUpgradeErrorRequest) GetChannelId() string { - if m != nil { - return m.ChannelId - } - return "" -} - -// QueryUpgradeErrorResponse is the response type for the Query/QueryUpgradeError RPC method -type QueryUpgradeErrorResponse struct { - ErrorReceipt ErrorReceipt `protobuf:"bytes,1,opt,name=error_receipt,json=errorReceipt,proto3" json:"error_receipt"` - // merkle proof of existence - Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` - // height at which the proof was retrieved - ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` -} - -func (m *QueryUpgradeErrorResponse) Reset() { *m = QueryUpgradeErrorResponse{} } -func (m *QueryUpgradeErrorResponse) String() string { return proto.CompactTextString(m) } -func (*QueryUpgradeErrorResponse) ProtoMessage() {} -func (*QueryUpgradeErrorResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1034a1e9abc4cca1, []int{29} -} -func (m *QueryUpgradeErrorResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryUpgradeErrorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryUpgradeErrorResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryUpgradeErrorResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryUpgradeErrorResponse.Merge(m, src) -} -func (m *QueryUpgradeErrorResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryUpgradeErrorResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryUpgradeErrorResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryUpgradeErrorResponse proto.InternalMessageInfo - -func (m *QueryUpgradeErrorResponse) GetErrorReceipt() ErrorReceipt { - if m != nil { - return m.ErrorReceipt - } - return ErrorReceipt{} -} - -func (m *QueryUpgradeErrorResponse) GetProof() []byte { - if m != nil { - return m.Proof - } - return nil -} - -func (m *QueryUpgradeErrorResponse) GetProofHeight() types.Height { - if m != nil { - return m.ProofHeight - } - return types.Height{} -} - -// QueryUpgradeRequest is the request type for the QueryUpgradeRequest RPC method -type QueryUpgradeRequest struct { - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` -} - -func (m *QueryUpgradeRequest) Reset() { *m = QueryUpgradeRequest{} } -func (m *QueryUpgradeRequest) String() string { return proto.CompactTextString(m) } -func (*QueryUpgradeRequest) ProtoMessage() {} -func (*QueryUpgradeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_1034a1e9abc4cca1, []int{30} -} -func (m *QueryUpgradeRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryUpgradeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryUpgradeRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryUpgradeRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryUpgradeRequest.Merge(m, src) -} -func (m *QueryUpgradeRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryUpgradeRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryUpgradeRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryUpgradeRequest proto.InternalMessageInfo - -func (m *QueryUpgradeRequest) GetPortId() string { - if m != nil { - return m.PortId - } - return "" -} - -func (m *QueryUpgradeRequest) GetChannelId() string { - if m != nil { - return m.ChannelId - } - return "" -} - -// QueryUpgradeResponse is the response type for the QueryUpgradeResponse RPC method -type QueryUpgradeResponse struct { - Upgrade Upgrade `protobuf:"bytes,1,opt,name=upgrade,proto3" json:"upgrade"` - // merkle proof of existence - Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` - // height at which the proof was retrieved - ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` -} - -func (m *QueryUpgradeResponse) Reset() { *m = QueryUpgradeResponse{} } -func (m *QueryUpgradeResponse) String() string { return proto.CompactTextString(m) } -func (*QueryUpgradeResponse) ProtoMessage() {} -func (*QueryUpgradeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1034a1e9abc4cca1, []int{31} -} -func (m *QueryUpgradeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryUpgradeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryUpgradeResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryUpgradeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryUpgradeResponse.Merge(m, src) -} -func (m *QueryUpgradeResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryUpgradeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryUpgradeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryUpgradeResponse proto.InternalMessageInfo - -func (m *QueryUpgradeResponse) GetUpgrade() Upgrade { - if m != nil { - return m.Upgrade - } - return Upgrade{} -} - -func (m *QueryUpgradeResponse) GetProof() []byte { - if m != nil { - return m.Proof - } - return nil -} - -func (m *QueryUpgradeResponse) GetProofHeight() types.Height { - if m != nil { - return m.ProofHeight - } - return types.Height{} -} - -// QueryChannelParamsRequest is the request type for the Query/ChannelParams RPC method. -type QueryChannelParamsRequest struct { -} - -func (m *QueryChannelParamsRequest) Reset() { *m = QueryChannelParamsRequest{} } -func (m *QueryChannelParamsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryChannelParamsRequest) ProtoMessage() {} -func (*QueryChannelParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_1034a1e9abc4cca1, []int{32} -} -func (m *QueryChannelParamsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryChannelParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryChannelParamsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryChannelParamsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryChannelParamsRequest.Merge(m, src) -} -func (m *QueryChannelParamsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryChannelParamsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryChannelParamsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryChannelParamsRequest proto.InternalMessageInfo - -// QueryChannelParamsResponse is the response type for the Query/ChannelParams RPC method. -type QueryChannelParamsResponse struct { - // params defines the parameters of the module. - Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` -} - -func (m *QueryChannelParamsResponse) Reset() { *m = QueryChannelParamsResponse{} } -func (m *QueryChannelParamsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryChannelParamsResponse) ProtoMessage() {} -func (*QueryChannelParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1034a1e9abc4cca1, []int{33} -} -func (m *QueryChannelParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryChannelParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryChannelParamsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryChannelParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryChannelParamsResponse.Merge(m, src) -} -func (m *QueryChannelParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryChannelParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryChannelParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryChannelParamsResponse proto.InternalMessageInfo - -func (m *QueryChannelParamsResponse) GetParams() *Params { - if m != nil { - return m.Params - } - return nil -} - func init() { proto.RegisterType((*QueryChannelRequest)(nil), "ibc.core.channel.v1.QueryChannelRequest") proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.channel.v1.QueryChannelResponse") @@ -2141,128 +1826,109 @@ func init() { proto.RegisterType((*QueryNextSequenceReceiveResponse)(nil), "ibc.core.channel.v1.QueryNextSequenceReceiveResponse") proto.RegisterType((*QueryNextSequenceSendRequest)(nil), "ibc.core.channel.v1.QueryNextSequenceSendRequest") proto.RegisterType((*QueryNextSequenceSendResponse)(nil), "ibc.core.channel.v1.QueryNextSequenceSendResponse") - proto.RegisterType((*QueryUpgradeErrorRequest)(nil), "ibc.core.channel.v1.QueryUpgradeErrorRequest") - proto.RegisterType((*QueryUpgradeErrorResponse)(nil), "ibc.core.channel.v1.QueryUpgradeErrorResponse") - proto.RegisterType((*QueryUpgradeRequest)(nil), "ibc.core.channel.v1.QueryUpgradeRequest") - proto.RegisterType((*QueryUpgradeResponse)(nil), "ibc.core.channel.v1.QueryUpgradeResponse") - proto.RegisterType((*QueryChannelParamsRequest)(nil), "ibc.core.channel.v1.QueryChannelParamsRequest") - proto.RegisterType((*QueryChannelParamsResponse)(nil), "ibc.core.channel.v1.QueryChannelParamsResponse") } func init() { proto.RegisterFile("ibc/core/channel/v1/query.proto", fileDescriptor_1034a1e9abc4cca1) } var fileDescriptor_1034a1e9abc4cca1 = []byte{ - // 1753 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x5a, 0xcf, 0x6f, 0xd4, 0x46, - 0x14, 0xce, 0x24, 0x21, 0x3f, 0x86, 0x00, 0x61, 0x92, 0x94, 0xe0, 0x24, 0x9b, 0xb0, 0xa8, 0x25, - 0xa0, 0x62, 0xe7, 0x07, 0xa5, 0x08, 0x51, 0x24, 0x92, 0xb6, 0x10, 0x54, 0x20, 0x6c, 0xa0, 0x05, - 0xa4, 0x76, 0xeb, 0xf5, 0x0e, 0x1b, 0x2b, 0x59, 0xdb, 0xac, 0xbd, 0x0b, 0x28, 0x4d, 0x55, 0xf5, - 0x40, 0x39, 0x56, 0x45, 0x55, 0xa5, 0x5e, 0x2a, 0xf5, 0x54, 0x2a, 0x55, 0x55, 0xff, 0x82, 0x5e, - 0x7a, 0xe0, 0x56, 0x24, 0x7a, 0xa8, 0x84, 0x44, 0x2b, 0x42, 0x45, 0xaf, 0xbd, 0xf4, 0x5c, 0x79, - 0xe6, 0x8d, 0xd7, 0xde, 0xb5, 0x9d, 0x6c, 0x9c, 0x95, 0x50, 0x6f, 0xeb, 0xf1, 0xbc, 0x37, 0xdf, - 0xf7, 0xbd, 0x99, 0xe7, 0x79, 0x2f, 0xc1, 0xa3, 0x7a, 0x4e, 0x53, 0x34, 0xb3, 0x44, 0x15, 0x6d, - 0x51, 0x35, 0x0c, 0xba, 0xac, 0x54, 0x26, 0x95, 0x1b, 0x65, 0x5a, 0xba, 0x2d, 0x5b, 0x25, 0xd3, - 0x31, 0x49, 0x9f, 0x9e, 0xd3, 0x64, 0x77, 0x82, 0x0c, 0x13, 0xe4, 0xca, 0xa4, 0xe4, 0xb3, 0x5a, - 0xd6, 0xa9, 0xe1, 0xb8, 0x46, 0xfc, 0x17, 0xb7, 0x92, 0x0e, 0x69, 0xa6, 0x5d, 0x34, 0x6d, 0x25, - 0xa7, 0xda, 0x94, 0xbb, 0x53, 0x2a, 0x93, 0x39, 0xea, 0xa8, 0x93, 0x8a, 0xa5, 0x16, 0x74, 0x43, - 0x75, 0x74, 0xd3, 0x80, 0xb9, 0xfb, 0xc2, 0x20, 0x88, 0xc5, 0xf8, 0x94, 0xe1, 0x82, 0x69, 0x16, - 0x96, 0xa9, 0xa2, 0x5a, 0xba, 0xa2, 0x1a, 0x86, 0xe9, 0x30, 0x7b, 0x1b, 0xde, 0xee, 0x85, 0xb7, - 0xec, 0x29, 0x57, 0xbe, 0xae, 0xa8, 0x06, 0xa0, 0x97, 0xfa, 0x0b, 0x66, 0xc1, 0x64, 0x3f, 0x15, - 0xf7, 0x57, 0xdc, 0x8a, 0x65, 0xab, 0x50, 0x52, 0xf3, 0x94, 0x4f, 0x49, 0x9f, 0xc3, 0x7d, 0x17, - 0x5d, 0xd8, 0xb3, 0x7c, 0x42, 0x86, 0xde, 0x28, 0x53, 0xdb, 0x21, 0x7b, 0x70, 0xa7, 0x65, 0x96, - 0x9c, 0xac, 0x9e, 0x1f, 0x44, 0x63, 0x68, 0xbc, 0x3b, 0xd3, 0xe1, 0x3e, 0xce, 0xe5, 0xc9, 0x08, - 0xc6, 0xe0, 0xcb, 0x7d, 0xd7, 0xca, 0xde, 0x75, 0xc3, 0xc8, 0x5c, 0x3e, 0x7d, 0x1f, 0xe1, 0xfe, - 0xa0, 0x3f, 0xdb, 0x32, 0x0d, 0x9b, 0x92, 0xa3, 0xb8, 0x13, 0x66, 0x31, 0x87, 0xdb, 0xa7, 0x86, - 0xe5, 0x10, 0xc1, 0x65, 0x61, 0x26, 0x26, 0x93, 0x7e, 0xbc, 0xcd, 0x2a, 0x99, 0xe6, 0x75, 0xb6, - 0x54, 0x4f, 0x86, 0x3f, 0x90, 0x59, 0xdc, 0xc3, 0x7e, 0x64, 0x17, 0xa9, 0x5e, 0x58, 0x74, 0x06, - 0xdb, 0x98, 0x4b, 0xc9, 0xe7, 0x92, 0x07, 0xa9, 0x32, 0x29, 0x9f, 0x61, 0x33, 0x66, 0xda, 0x1f, - 0x3c, 0x19, 0x6d, 0xc9, 0x6c, 0x67, 0x56, 0x7c, 0x28, 0xfd, 0x41, 0x10, 0xaa, 0x2d, 0xb8, 0xbf, - 0x8d, 0x71, 0x35, 0x76, 0x80, 0xf6, 0x15, 0x99, 0x07, 0x5a, 0x76, 0x03, 0x2d, 0xf3, 0x7d, 0x03, - 0x81, 0x96, 0xe7, 0xd5, 0x02, 0x05, 0xdb, 0x8c, 0xcf, 0x32, 0xfd, 0x04, 0xe1, 0x81, 0x9a, 0x05, - 0x40, 0x8c, 0x19, 0xdc, 0x05, 0xfc, 0xec, 0x41, 0x34, 0xd6, 0xc6, 0xfc, 0x87, 0xa9, 0x31, 0x97, - 0xa7, 0x86, 0xa3, 0x5f, 0xd7, 0x69, 0x5e, 0xe8, 0xe2, 0xd9, 0x91, 0xd3, 0x01, 0x94, 0xad, 0x0c, - 0xe5, 0x81, 0x75, 0x51, 0x72, 0x00, 0x7e, 0x98, 0xe4, 0x18, 0xee, 0x68, 0x50, 0x45, 0x98, 0x9f, - 0xbe, 0x8b, 0x70, 0x8a, 0x13, 0x34, 0x0d, 0x83, 0x6a, 0xae, 0xb7, 0x5a, 0x2d, 0x53, 0x18, 0x6b, - 0xde, 0x4b, 0xd8, 0x4a, 0xbe, 0x91, 0x1a, 0xad, 0x5b, 0x37, 0xad, 0xf5, 0xdf, 0x08, 0x8f, 0x46, - 0x42, 0xf9, 0x7f, 0xa9, 0x7e, 0x45, 0x88, 0xce, 0x31, 0xcd, 0xb2, 0xd9, 0x0b, 0x8e, 0xea, 0xd0, - 0xa4, 0x87, 0xf7, 0x0f, 0x4f, 0xc4, 0x10, 0xd7, 0x20, 0xa2, 0x8a, 0xf7, 0xe8, 0x9e, 0x3e, 0x59, - 0x0e, 0x35, 0x6b, 0xbb, 0x53, 0xe0, 0xa4, 0x1c, 0x0c, 0x23, 0xe2, 0x93, 0xd4, 0xe7, 0x73, 0x40, - 0x0f, 0x1b, 0x6e, 0xe6, 0x91, 0xff, 0x01, 0xe1, 0x7d, 0x01, 0x86, 0x2e, 0x27, 0xc3, 0x2e, 0xdb, - 0x5b, 0xa1, 0x1f, 0x39, 0x80, 0x77, 0x95, 0x68, 0x45, 0xb7, 0x75, 0xd3, 0xc8, 0x1a, 0xe5, 0x62, - 0x8e, 0x96, 0x18, 0xca, 0xf6, 0xcc, 0x4e, 0x31, 0x7c, 0x9e, 0x8d, 0x06, 0x26, 0x02, 0x9d, 0xf6, - 0xe0, 0x44, 0xc0, 0xfb, 0x18, 0xe1, 0x74, 0x1c, 0x5e, 0x08, 0xca, 0x1b, 0x78, 0x97, 0x26, 0xde, - 0x04, 0x82, 0xd1, 0x2f, 0xf3, 0x4f, 0x86, 0x2c, 0x3e, 0x19, 0xf2, 0x29, 0xe3, 0x76, 0x66, 0xa7, - 0x16, 0x70, 0x43, 0x86, 0x70, 0x37, 0x04, 0xd2, 0x63, 0xd5, 0xc5, 0x07, 0xe6, 0xf2, 0xd5, 0x68, - 0xb4, 0xc5, 0x45, 0xa3, 0x7d, 0x33, 0xd1, 0x28, 0xe1, 0x61, 0x46, 0x6e, 0x5e, 0xd5, 0x96, 0xa8, - 0x33, 0x6b, 0x16, 0x8b, 0xba, 0x53, 0xa4, 0x86, 0x93, 0x34, 0x0e, 0x12, 0xee, 0xb2, 0x5d, 0x17, - 0x86, 0x46, 0x21, 0x00, 0xde, 0x73, 0xfa, 0x6b, 0x84, 0x47, 0x22, 0x16, 0x05, 0x31, 0x59, 0xca, - 0x12, 0xa3, 0x6c, 0xe1, 0x9e, 0x8c, 0x6f, 0xa4, 0x99, 0xdb, 0xf3, 0x9b, 0x28, 0x70, 0x76, 0x52, - 0x49, 0x82, 0x79, 0xb6, 0x6d, 0xd3, 0x79, 0xf6, 0xb9, 0x48, 0xf9, 0x21, 0x08, 0xbd, 0x34, 0xbb, - 0xbd, 0xaa, 0x96, 0xc8, 0xb4, 0x63, 0xa1, 0x99, 0x96, 0x3b, 0xe1, 0x7b, 0xd9, 0x6f, 0xf4, 0x22, - 0xa4, 0x59, 0x13, 0xef, 0xf5, 0x11, 0xcd, 0x50, 0x8d, 0xea, 0x56, 0x53, 0x77, 0xe6, 0x3d, 0x84, - 0xa5, 0xb0, 0x15, 0x41, 0x56, 0x09, 0x77, 0x95, 0xdc, 0xa1, 0x0a, 0xe5, 0x7e, 0xbb, 0x32, 0xde, - 0x73, 0x33, 0xcf, 0xe8, 0x4d, 0x48, 0x98, 0x1c, 0xd4, 0x29, 0x6d, 0xc9, 0x30, 0x6f, 0x2e, 0xd3, - 0x7c, 0x81, 0x36, 0xfb, 0xa0, 0xde, 0x17, 0xa9, 0x2f, 0x62, 0x65, 0x90, 0x65, 0x1c, 0xef, 0x52, - 0x83, 0xaf, 0xe0, 0xc8, 0xd6, 0x0e, 0x37, 0xf3, 0xdc, 0x3e, 0x8b, 0xc5, 0xfa, 0xa2, 0x1c, 0x5e, - 0x72, 0x12, 0x0f, 0x59, 0x0c, 0x60, 0xb6, 0x7a, 0xd6, 0xb2, 0x42, 0x70, 0x7b, 0xb0, 0x7d, 0xac, - 0x6d, 0xbc, 0x3d, 0xb3, 0xd7, 0xaa, 0x39, 0xd9, 0x0b, 0x62, 0x42, 0xfa, 0x5f, 0x84, 0xf7, 0xc7, - 0xd2, 0x84, 0x98, 0xbc, 0x83, 0x7b, 0x6b, 0xc4, 0xdf, 0x78, 0x1a, 0xa8, 0xb3, 0x7c, 0x11, 0x72, - 0xc1, 0x57, 0x22, 0x2f, 0x5f, 0x36, 0xc4, 0x99, 0xe3, 0x98, 0x13, 0x87, 0x76, 0x9d, 0x90, 0xb4, - 0xad, 0x17, 0x92, 0x5b, 0x90, 0x8e, 0x43, 0x80, 0x41, 0x30, 0x86, 0x71, 0x77, 0xd5, 0x1f, 0x62, - 0xfe, 0xaa, 0x03, 0x3e, 0x4d, 0x5a, 0x1b, 0xd4, 0xe4, 0x8e, 0x48, 0x57, 0xd5, 0xa5, 0x4f, 0x69, - 0x4b, 0x89, 0x05, 0x99, 0xc0, 0xfd, 0x20, 0x88, 0xaa, 0x2d, 0xd5, 0x29, 0x41, 0x2c, 0xb1, 0xf3, - 0xaa, 0x12, 0x94, 0xf1, 0x50, 0x28, 0x8e, 0x26, 0xf3, 0xbf, 0x0a, 0x77, 0xe5, 0xf3, 0xf4, 0x96, - 0x17, 0x8f, 0x0c, 0x07, 0x90, 0xf4, 0x1e, 0xfe, 0x13, 0xc2, 0x63, 0xd1, 0xbe, 0x81, 0xd7, 0x14, - 0x1e, 0x30, 0xe8, 0xad, 0xea, 0x66, 0xc9, 0x02, 0x7b, 0xb6, 0x54, 0x7b, 0xa6, 0xcf, 0xa8, 0xb7, - 0x6d, 0x66, 0x0a, 0x7c, 0x17, 0xee, 0x72, 0x7e, 0xc8, 0x0b, 0xd4, 0xc8, 0x27, 0xd5, 0xe2, 0x3b, - 0x71, 0xf4, 0xea, 0x1d, 0x83, 0x10, 0xaf, 0x62, 0x12, 0x14, 0xc2, 0xa6, 0x46, 0x1e, 0x54, 0xe8, - 0x35, 0x6a, 0xac, 0x9a, 0x29, 0x41, 0x06, 0x0f, 0xf2, 0x8d, 0xc8, 0x1b, 0x2c, 0x6f, 0x95, 0x4a, - 0x66, 0x29, 0x29, 0xfd, 0x5f, 0x10, 0x5c, 0x43, 0x82, 0x4e, 0xbd, 0x44, 0xbb, 0x83, 0xba, 0x03, - 0x3c, 0xf6, 0x96, 0x03, 0xb7, 0xfe, 0x7d, 0xa1, 0x59, 0x16, 0x4c, 0xd9, 0x44, 0x80, 0xdf, 0x43, - 0x7d, 0x63, 0xcd, 0x94, 0x46, 0x74, 0x99, 0x80, 0x45, 0x52, 0x55, 0x7e, 0x14, 0x5d, 0x26, 0xcf, - 0x1f, 0x08, 0x72, 0x02, 0x77, 0x42, 0x7b, 0x2b, 0xb6, 0xcb, 0x04, 0x66, 0x80, 0x54, 0x98, 0x34, - 0x53, 0x80, 0x21, 0x08, 0x23, 0xd4, 0x71, 0xf3, 0x6a, 0x49, 0x2d, 0x8a, 0x5c, 0x99, 0xbe, 0x08, - 0x99, 0xb4, 0xe6, 0x25, 0x70, 0x9a, 0xc6, 0x1d, 0x16, 0x1b, 0x01, 0x4a, 0x43, 0x11, 0xdf, 0x50, - 0x66, 0x04, 0x53, 0xa7, 0xfe, 0x1a, 0xc2, 0xdb, 0x98, 0x4f, 0xf2, 0x2d, 0xc2, 0x9d, 0xe0, 0x98, - 0x8c, 0x87, 0x9a, 0x86, 0xf4, 0xff, 0xa4, 0x83, 0x1b, 0x98, 0xc9, 0xf1, 0xa5, 0x67, 0x3e, 0x7d, - 0xf4, 0xec, 0x5e, 0xeb, 0x09, 0x72, 0x5c, 0x89, 0xe9, 0x6f, 0xda, 0xca, 0x4a, 0x35, 0xa0, 0xab, - 0x8a, 0x1b, 0x66, 0x5b, 0x59, 0x81, 0xe0, 0xaf, 0x92, 0xbb, 0x08, 0x77, 0x89, 0x7e, 0x0d, 0x59, - 0x7f, 0x6d, 0xa1, 0x9c, 0x74, 0x68, 0x23, 0x53, 0x01, 0xe7, 0xcb, 0x0c, 0xe7, 0x28, 0x19, 0x89, - 0xc5, 0x49, 0x7e, 0x46, 0x98, 0xd4, 0x37, 0x91, 0xc8, 0x74, 0xcc, 0x4a, 0x51, 0xdd, 0x2f, 0xe9, - 0x48, 0x63, 0x46, 0x00, 0xf4, 0x24, 0x03, 0x7a, 0x8c, 0x1c, 0x0d, 0x07, 0xea, 0x19, 0xba, 0x9a, - 0x7a, 0x0f, 0xab, 0x55, 0x06, 0x0f, 0x5d, 0x06, 0x75, 0x1d, 0x9c, 0x58, 0x06, 0x51, 0xad, 0xa4, - 0x58, 0x06, 0x91, 0x4d, 0xa2, 0xf4, 0x05, 0xc6, 0x60, 0x8e, 0x9c, 0xde, 0xfc, 0x96, 0x50, 0xfc, - 0xad, 0x25, 0xf2, 0x45, 0x2b, 0x1e, 0x08, 0x6d, 0x81, 0x90, 0xa3, 0xeb, 0x03, 0x0c, 0xeb, 0xf1, - 0x48, 0xaf, 0x37, 0x6c, 0x07, 0xdc, 0x3e, 0x43, 0x8c, 0xdc, 0x27, 0x88, 0x7c, 0x9c, 0x84, 0x5d, - 0xb0, 0x5d, 0xa3, 0x88, 0xbe, 0x8f, 0xb2, 0x52, 0xd3, 0x41, 0x5a, 0x55, 0x78, 0xda, 0xf1, 0xbd, - 0xe0, 0x03, 0xab, 0xe4, 0x31, 0xc2, 0xbd, 0xb5, 0x65, 0x38, 0x99, 0x8c, 0xe6, 0x15, 0xd1, 0x66, - 0x91, 0xa6, 0x1a, 0x31, 0x01, 0x15, 0x3e, 0x64, 0x22, 0x5c, 0x23, 0x57, 0x12, 0x68, 0x50, 0x77, - 0xf1, 0xb5, 0x95, 0x15, 0xf1, 0x11, 0x5f, 0x25, 0x8f, 0x10, 0xde, 0x5d, 0xd7, 0x64, 0x20, 0x0d, - 0x60, 0xf5, 0x4e, 0xe1, 0x74, 0x43, 0x36, 0x40, 0xf0, 0x32, 0x23, 0x78, 0x81, 0x9c, 0xdb, 0x52, - 0x82, 0xe4, 0x57, 0x84, 0x77, 0x04, 0xea, 0x7b, 0x22, 0xaf, 0x87, 0x2e, 0xd8, 0x7a, 0x90, 0x94, - 0x0d, 0xcf, 0x07, 0x26, 0xef, 0x33, 0x26, 0xef, 0x91, 0xcb, 0xc9, 0x99, 0xc0, 0x35, 0x23, 0x10, - 0xa7, 0x35, 0x84, 0x07, 0x42, 0xeb, 0xc1, 0xb8, 0xa3, 0x19, 0xd7, 0x4d, 0x88, 0x3b, 0x9a, 0xb1, - 0xbd, 0x80, 0xf4, 0x55, 0xc6, 0x74, 0x81, 0x5c, 0x4c, 0xce, 0x54, 0xd5, 0x96, 0x02, 0x2c, 0x9f, - 0x23, 0xfc, 0x52, 0x78, 0xd5, 0x4b, 0x1a, 0x85, 0xeb, 0xed, 0xcb, 0x63, 0x8d, 0x1b, 0x02, 0xd1, - 0x6b, 0x8c, 0xe8, 0x25, 0x92, 0xd9, 0x12, 0xa2, 0x41, 0x3a, 0x77, 0x5a, 0xf1, 0xee, 0xba, 0x6a, - 0x32, 0xee, 0xdc, 0x45, 0xd5, 0xc4, 0x71, 0xe7, 0x2e, 0xb2, 0x5c, 0xdd, 0xa2, 0xf4, 0x1a, 0x96, - 0x5a, 0x62, 0xea, 0xec, 0x55, 0xa5, 0xec, 0x01, 0xca, 0x5a, 0x40, 0xf9, 0x1f, 0x84, 0x77, 0x06, - 0x6b, 0x4a, 0xa2, 0x6c, 0x84, 0x91, 0xaf, 0x0a, 0x96, 0x26, 0x36, 0x6e, 0x00, 0xfc, 0x3f, 0x62, - 0xf4, 0x2b, 0xc4, 0x69, 0x0e, 0xfb, 0x40, 0x51, 0x1d, 0xa0, 0xed, 0xee, 0x78, 0xf2, 0x1b, 0xc2, - 0x7d, 0x21, 0x45, 0x27, 0x89, 0xb9, 0x06, 0x44, 0xd7, 0xbf, 0xd2, 0x6b, 0x0d, 0x5a, 0x81, 0x04, - 0xf3, 0x4c, 0x82, 0xb3, 0xe4, 0x4c, 0x02, 0x09, 0x02, 0x15, 0xa1, 0x7b, 0x23, 0xea, 0xad, 0xad, - 0x1f, 0xe3, 0xbe, 0x94, 0x11, 0x45, 0x6c, 0xdc, 0x97, 0x32, 0xaa, 0x3c, 0xdd, 0x92, 0x0f, 0x49, - 0x7d, 0x7d, 0xeb, 0x5e, 0x53, 0x7b, 0xfc, 0x35, 0x21, 0x39, 0x1c, 0xb3, 0xd5, 0xea, 0x0b, 0x52, - 0x49, 0xde, 0xe8, 0xf4, 0x2d, 0x0c, 0x0a, 0xd4, 0x59, 0x59, 0x56, 0x75, 0x92, 0xef, 0x11, 0xee, - 0x84, 0xa5, 0xe2, 0x0a, 0x93, 0x60, 0xc9, 0x18, 0x57, 0x98, 0xd4, 0x14, 0x83, 0xe9, 0xb3, 0x0c, - 0xf2, 0x9b, 0x64, 0x26, 0x39, 0x64, 0xf2, 0x25, 0xc2, 0x3b, 0x02, 0xe5, 0x59, 0xdc, 0x77, 0x3b, - 0xac, 0xc8, 0x8b, 0xfb, 0x6e, 0x87, 0xd6, 0x7d, 0xe9, 0xfd, 0x0c, 0xfe, 0x08, 0x19, 0x0a, 0x85, - 0xcf, 0xeb, 0xbc, 0x99, 0x4b, 0x0f, 0x9e, 0xa6, 0xd0, 0xc3, 0xa7, 0x29, 0xf4, 0xe7, 0xd3, 0x14, - 0xfa, 0x7c, 0x2d, 0xd5, 0xf2, 0x70, 0x2d, 0xd5, 0xf2, 0xfb, 0x5a, 0xaa, 0xe5, 0xda, 0xf1, 0x82, - 0xee, 0x2c, 0x96, 0x73, 0xb2, 0x66, 0x16, 0x15, 0xf8, 0x27, 0x15, 0x3d, 0xa7, 0x1d, 0x2e, 0x98, - 0x4a, 0x65, 0x72, 0x42, 0x29, 0x9a, 0xf9, 0xf2, 0x32, 0xb5, 0xb9, 0xdb, 0x89, 0x23, 0x87, 0x85, - 0x67, 0xe7, 0xb6, 0x45, 0xed, 0x5c, 0x07, 0xfb, 0x73, 0xe1, 0xf4, 0x7f, 0x01, 0x00, 0x00, 0xff, - 0xff, 0x12, 0x70, 0x4d, 0x16, 0x35, 0x23, 0x00, 0x00, + // 1549 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x59, 0xcf, 0x6f, 0x13, 0xc7, + 0x17, 0xcf, 0x38, 0x06, 0x92, 0x07, 0x5f, 0x08, 0x93, 0xe4, 0x4b, 0x58, 0x82, 0x13, 0x5c, 0xb5, + 0x04, 0x54, 0x76, 0xe2, 0x40, 0x29, 0x42, 0x2d, 0x12, 0x89, 0x54, 0x48, 0x55, 0x7e, 0x6d, 0xa0, + 0x05, 0xa4, 0xd6, 0x5d, 0xaf, 0x07, 0x67, 0x95, 0x78, 0xd7, 0x78, 0xd7, 0x06, 0x94, 0xba, 0xaa, + 0x7a, 0xa0, 0x1c, 0xab, 0x72, 0xa8, 0xd4, 0x4b, 0xa5, 0x9e, 0xca, 0xa1, 0x87, 0xfe, 0x05, 0xbd, + 0x72, 0x2b, 0x12, 0x3d, 0x54, 0x42, 0xa2, 0x15, 0x41, 0xa2, 0xd7, 0x5e, 0x7a, 0xae, 0x76, 0x7e, + 0xac, 0x77, 0xed, 0xdd, 0x4d, 0x1c, 0xc7, 0x52, 0xd4, 0x9b, 0x77, 0x66, 0xde, 0x9b, 0xcf, 0xe7, + 0xf3, 0xe6, 0xbd, 0x9d, 0xb7, 0x86, 0x09, 0xb3, 0x60, 0x10, 0xc3, 0xae, 0x52, 0x62, 0x2c, 0xea, + 0x96, 0x45, 0x97, 0x49, 0x3d, 0x47, 0x6e, 0xd7, 0x68, 0xf5, 0x9e, 0x5a, 0xa9, 0xda, 0xae, 0x8d, + 0x87, 0xcd, 0x82, 0xa1, 0x7a, 0x0b, 0x54, 0xb1, 0x40, 0xad, 0xe7, 0x94, 0x80, 0xd5, 0xb2, 0x49, + 0x2d, 0xd7, 0x33, 0xe2, 0xbf, 0xb8, 0x95, 0x72, 0xd4, 0xb0, 0x9d, 0xb2, 0xed, 0x90, 0x82, 0xee, + 0x50, 0xee, 0x8e, 0xd4, 0x73, 0x05, 0xea, 0xea, 0x39, 0x52, 0xd1, 0x4b, 0xa6, 0xa5, 0xbb, 0xa6, + 0x6d, 0x89, 0xb5, 0x87, 0xa2, 0x20, 0xc8, 0xcd, 0xf8, 0x92, 0xf1, 0x92, 0x6d, 0x97, 0x96, 0x29, + 0xd1, 0x2b, 0x26, 0xd1, 0x2d, 0xcb, 0x76, 0x99, 0xbd, 0x23, 0x66, 0xf7, 0x8b, 0x59, 0xf6, 0x54, + 0xa8, 0xdd, 0x22, 0xba, 0x25, 0xd0, 0x2b, 0x23, 0x25, 0xbb, 0x64, 0xb3, 0x9f, 0xc4, 0xfb, 0xc5, + 0x47, 0xb3, 0x17, 0x60, 0xf8, 0x8a, 0x87, 0x69, 0x8e, 0x6f, 0xa2, 0xd1, 0xdb, 0x35, 0xea, 0xb8, + 0x78, 0x1f, 0xec, 0xa8, 0xd8, 0x55, 0x37, 0x6f, 0x16, 0xc7, 0xd0, 0x24, 0x9a, 0x1a, 0xd4, 0xb6, + 0x7b, 0x8f, 0xf3, 0x45, 0x7c, 0x10, 0x40, 0xe0, 0xf1, 0xe6, 0x52, 0x6c, 0x6e, 0x50, 0x8c, 0xcc, + 0x17, 0xb3, 0x8f, 0x10, 0x8c, 0x84, 0xfd, 0x39, 0x15, 0xdb, 0x72, 0x28, 0x3e, 0x09, 0x3b, 0xc4, + 0x2a, 0xe6, 0x70, 0xe7, 0xcc, 0xb8, 0x1a, 0xa1, 0xa6, 0x2a, 0xcd, 0xe4, 0x62, 0x3c, 0x02, 0xdb, + 0x2a, 0x55, 0xdb, 0xbe, 0xc5, 0xb6, 0xda, 0xa5, 0xf1, 0x07, 0x3c, 0x07, 0xbb, 0xd8, 0x8f, 0xfc, + 0x22, 0x35, 0x4b, 0x8b, 0xee, 0x58, 0x3f, 0x73, 0xa9, 0x04, 0x5c, 0xf2, 0x08, 0xd4, 0x73, 0xea, + 0x79, 0xb6, 0x62, 0x36, 0xfd, 0xf8, 0xf9, 0x44, 0x9f, 0xb6, 0x93, 0x59, 0xf1, 0xa1, 0xec, 0x27, + 0x61, 0xa8, 0x8e, 0xe4, 0xfe, 0x1e, 0x40, 0x33, 0x30, 0x02, 0xed, 0x1b, 0x2a, 0x8f, 0xa2, 0xea, + 0x45, 0x51, 0xe5, 0x87, 0x42, 0x44, 0x51, 0xbd, 0xac, 0x97, 0xa8, 0xb0, 0xd5, 0x02, 0x96, 0xd9, + 0xe7, 0x08, 0x46, 0x5b, 0x36, 0x10, 0x62, 0xcc, 0xc2, 0x80, 0xe0, 0xe7, 0x8c, 0xa1, 0xc9, 0x7e, + 0xe6, 0x3f, 0x4a, 0x8d, 0xf9, 0x22, 0xb5, 0x5c, 0xf3, 0x96, 0x49, 0x8b, 0x52, 0x17, 0xdf, 0x0e, + 0x9f, 0x0b, 0xa1, 0x4c, 0x31, 0x94, 0x87, 0xd7, 0x44, 0xc9, 0x01, 0x04, 0x61, 0xe2, 0x53, 0xb0, + 0xbd, 0x43, 0x15, 0xc5, 0xfa, 0xec, 0x03, 0x04, 0x19, 0x4e, 0xd0, 0xb6, 0x2c, 0x6a, 0x78, 0xde, + 0x5a, 0xb5, 0xcc, 0x00, 0x18, 0xfe, 0xa4, 0x38, 0x4a, 0x81, 0x91, 0x16, 0xad, 0x53, 0x1b, 0xd6, + 0xfa, 0x2f, 0x04, 0x13, 0xb1, 0x50, 0xfe, 0x5b, 0xaa, 0x5f, 0x97, 0xa2, 0x73, 0x4c, 0x73, 0x6c, + 0xf5, 0x82, 0xab, 0xbb, 0xb4, 0xdb, 0xe4, 0xfd, 0xc3, 0x17, 0x31, 0xc2, 0xb5, 0x10, 0x51, 0x87, + 0x7d, 0xa6, 0xaf, 0x4f, 0x9e, 0x43, 0xcd, 0x3b, 0xde, 0x12, 0x91, 0x29, 0x47, 0xa2, 0x88, 0x04, + 0x24, 0x0d, 0xf8, 0x1c, 0x35, 0xa3, 0x86, 0x7b, 0x99, 0xf2, 0x3f, 0x21, 0x38, 0x14, 0x62, 0xe8, + 0x71, 0xb2, 0x9c, 0x9a, 0xb3, 0x19, 0xfa, 0xe1, 0xc3, 0xb0, 0xa7, 0x4a, 0xeb, 0xa6, 0x63, 0xda, + 0x56, 0xde, 0xaa, 0x95, 0x0b, 0xb4, 0xca, 0x50, 0xa6, 0xb5, 0xdd, 0x72, 0xf8, 0x22, 0x1b, 0x0d, + 0x2d, 0x14, 0x74, 0xd2, 0xe1, 0x85, 0x02, 0xef, 0x33, 0x04, 0xd9, 0x24, 0xbc, 0x22, 0x28, 0xef, + 0xc2, 0x1e, 0x43, 0xce, 0x84, 0x82, 0x31, 0xa2, 0xf2, 0xf7, 0x81, 0x2a, 0xdf, 0x07, 0xea, 0x59, + 0xeb, 0x9e, 0xb6, 0xdb, 0x08, 0xb9, 0xc1, 0x07, 0x60, 0x50, 0x04, 0xd2, 0x67, 0x35, 0xc0, 0x07, + 0xe6, 0x8b, 0xcd, 0x68, 0xf4, 0x27, 0x45, 0x23, 0xbd, 0x91, 0x68, 0x54, 0x61, 0x9c, 0x91, 0xbb, + 0xac, 0x1b, 0x4b, 0xd4, 0x9d, 0xb3, 0xcb, 0x65, 0xd3, 0x2d, 0x53, 0xcb, 0xed, 0x36, 0x0e, 0x0a, + 0x0c, 0x38, 0x9e, 0x0b, 0xcb, 0xa0, 0x22, 0x00, 0xfe, 0x73, 0xf6, 0x3b, 0x04, 0x07, 0x63, 0x36, + 0x15, 0x62, 0xb2, 0x92, 0x25, 0x47, 0xd9, 0xc6, 0xbb, 0xb4, 0xc0, 0x48, 0x2f, 0x8f, 0xe7, 0xf7, + 0x71, 0xe0, 0x9c, 0x6e, 0x25, 0x09, 0xd7, 0xd9, 0xfe, 0x0d, 0xd7, 0xd9, 0x57, 0xb2, 0xe4, 0x47, + 0x20, 0xf4, 0xcb, 0xec, 0xce, 0xa6, 0x5a, 0xb2, 0xd2, 0x4e, 0x46, 0x56, 0x5a, 0xee, 0x84, 0x9f, + 0xe5, 0xa0, 0xd1, 0x56, 0x28, 0xb3, 0x36, 0xec, 0x0f, 0x10, 0xd5, 0xa8, 0x41, 0xcd, 0x4a, 0x4f, + 0x4f, 0xe6, 0x43, 0x04, 0x4a, 0xd4, 0x8e, 0x42, 0x56, 0x05, 0x06, 0xaa, 0xde, 0x50, 0x9d, 0x72, + 0xbf, 0x03, 0x9a, 0xff, 0xdc, 0xcb, 0x1c, 0xbd, 0x23, 0x0a, 0x26, 0x07, 0x75, 0xd6, 0x58, 0xb2, + 0xec, 0x3b, 0xcb, 0xb4, 0x58, 0xa2, 0xbd, 0x4e, 0xd4, 0x47, 0xb2, 0xf4, 0xc5, 0xec, 0x2c, 0x64, + 0x99, 0x82, 0x3d, 0x7a, 0x78, 0x4a, 0xa4, 0x6c, 0xeb, 0x70, 0x2f, 0xf3, 0xf6, 0x65, 0x22, 0xd6, + 0xad, 0x92, 0xbc, 0xf8, 0x0c, 0x1c, 0xa8, 0x30, 0x80, 0xf9, 0x66, 0xae, 0xe5, 0xa5, 0xe0, 0xce, + 0x58, 0x7a, 0xb2, 0x7f, 0x2a, 0xad, 0xed, 0xaf, 0xb4, 0x64, 0xf6, 0x82, 0x5c, 0x90, 0xfd, 0x07, + 0xc1, 0x6b, 0x89, 0x34, 0x45, 0x4c, 0x3e, 0x80, 0xa1, 0x16, 0xf1, 0xd7, 0x5f, 0x06, 0xda, 0x2c, + 0xb7, 0x42, 0x2d, 0xf8, 0x56, 0xd6, 0xe5, 0x6b, 0x96, 0xcc, 0x39, 0x8e, 0xb9, 0xeb, 0xd0, 0xae, + 0x11, 0x92, 0xfe, 0xb5, 0x42, 0x72, 0x57, 0x94, 0xe3, 0x08, 0x60, 0x22, 0x18, 0xe3, 0x30, 0xd8, + 0xf4, 0x87, 0x98, 0xbf, 0xe6, 0x40, 0x40, 0x93, 0x54, 0x87, 0x9a, 0xdc, 0x97, 0xe5, 0xaa, 0xb9, + 0xf5, 0x59, 0x63, 0xa9, 0x6b, 0x41, 0xa6, 0x61, 0x44, 0x08, 0xa2, 0x1b, 0x4b, 0x6d, 0x4a, 0xe0, + 0x8a, 0x3c, 0x79, 0x4d, 0x09, 0x6a, 0x70, 0x20, 0x12, 0x47, 0x8f, 0xf9, 0xdf, 0x10, 0x77, 0xe5, + 0x8b, 0xf4, 0xae, 0x1f, 0x0f, 0x8d, 0x03, 0xe8, 0xf6, 0x1e, 0xfe, 0x33, 0x82, 0xc9, 0x78, 0xdf, + 0x82, 0xd7, 0x0c, 0x8c, 0x5a, 0xf4, 0x6e, 0xf3, 0xb0, 0xe4, 0x05, 0x7b, 0xb6, 0x55, 0x5a, 0x1b, + 0xb6, 0xda, 0x6d, 0x7b, 0x59, 0x02, 0x3f, 0x14, 0x77, 0xb9, 0x20, 0xe4, 0x05, 0x6a, 0x15, 0xbb, + 0xd5, 0xe2, 0x47, 0x99, 0x7a, 0xed, 0x8e, 0x85, 0x10, 0x6f, 0x02, 0x0e, 0x0b, 0xe1, 0x50, 0xab, + 0x28, 0x54, 0x18, 0xb2, 0x5a, 0xac, 0x7a, 0x28, 0xc1, 0xcc, 0xf3, 0x7d, 0xb0, 0x8d, 0x41, 0xc5, + 0x3f, 0x20, 0xd8, 0x21, 0x6e, 0xec, 0x78, 0x2a, 0xb2, 0xe4, 0x45, 0x7c, 0x73, 0x51, 0x8e, 0xac, + 0x63, 0x25, 0xe7, 0x9c, 0x9d, 0xfd, 0xf2, 0xe9, 0xcb, 0x87, 0xa9, 0x77, 0xf0, 0x69, 0x92, 0xf0, + 0xc1, 0xc8, 0x21, 0x2b, 0x4d, 0x65, 0x1b, 0xc4, 0xd3, 0xdb, 0x21, 0x2b, 0x22, 0x0a, 0x0d, 0xfc, + 0x00, 0xc1, 0x80, 0xec, 0x91, 0xf1, 0xda, 0x7b, 0xcb, 0xcc, 0x56, 0x8e, 0xae, 0x67, 0xa9, 0xc0, + 0xf9, 0x3a, 0xc3, 0x39, 0x81, 0x0f, 0x26, 0xe2, 0xc4, 0xbf, 0x20, 0xc0, 0xed, 0x8d, 0x3b, 0x3e, + 0x9e, 0xb0, 0x53, 0xdc, 0x17, 0x07, 0xe5, 0x44, 0x67, 0x46, 0x02, 0xe8, 0x19, 0x06, 0xf4, 0x14, + 0x3e, 0x19, 0x0d, 0xd4, 0x37, 0xf4, 0x34, 0xf5, 0x1f, 0x1a, 0x4d, 0x06, 0x4f, 0x3c, 0x06, 0x6d, + 0x5d, 0x73, 0x22, 0x83, 0xb8, 0xf6, 0x3d, 0x91, 0x41, 0x6c, 0x63, 0x9e, 0xbd, 0xc4, 0x18, 0xcc, + 0xe3, 0x73, 0x1b, 0x3f, 0x12, 0x24, 0xd8, 0xce, 0xe3, 0x6f, 0x52, 0x30, 0x1a, 0xd9, 0x76, 0xe2, + 0x93, 0x6b, 0x03, 0x8c, 0xea, 0xab, 0x95, 0xb7, 0x3b, 0xb6, 0x13, 0xdc, 0xbe, 0x42, 0x8c, 0xdc, + 0x17, 0x08, 0x7f, 0xde, 0x0d, 0xbb, 0x70, 0x8b, 0x4c, 0x64, 0xaf, 0x4d, 0x56, 0x5a, 0xba, 0xf6, + 0x06, 0xe1, 0x65, 0x20, 0x30, 0xc1, 0x07, 0x1a, 0xf8, 0x19, 0x82, 0xa1, 0xd6, 0xd6, 0x07, 0xe7, + 0xe2, 0x79, 0xc5, 0xb4, 0xb6, 0xca, 0x4c, 0x27, 0x26, 0x42, 0x85, 0x4f, 0x99, 0x08, 0x37, 0xf1, + 0xf5, 0x2e, 0x34, 0x68, 0xbb, 0x6c, 0x38, 0x64, 0x45, 0x16, 0xce, 0x06, 0x7e, 0x8a, 0x60, 0x6f, + 0x5b, 0x63, 0x87, 0x3b, 0xc0, 0xea, 0x67, 0xe1, 0xf1, 0x8e, 0x6c, 0x04, 0xc1, 0x6b, 0x8c, 0xe0, + 0x25, 0x7c, 0x61, 0x53, 0x09, 0xe2, 0x5f, 0x11, 0xfc, 0x2f, 0xd4, 0x53, 0x61, 0x75, 0x2d, 0x74, + 0xe1, 0x76, 0x4f, 0x21, 0xeb, 0x5e, 0x2f, 0x98, 0x7c, 0xcc, 0x98, 0x7c, 0x84, 0xaf, 0x75, 0xcf, + 0xa4, 0xca, 0x5d, 0x87, 0xe2, 0xb4, 0x8a, 0x60, 0x34, 0xf2, 0x0e, 0x9e, 0x94, 0x9a, 0x49, 0x1d, + 0x5c, 0x52, 0x6a, 0x26, 0xf6, 0x5f, 0xd9, 0x1b, 0x8c, 0xe9, 0x02, 0xbe, 0xd2, 0x3d, 0x53, 0xdd, + 0x58, 0x0a, 0xb1, 0x7c, 0x85, 0xe0, 0xff, 0xd1, 0x9d, 0x06, 0xee, 0x14, 0xae, 0x7f, 0x2e, 0x4f, + 0x75, 0x6e, 0x28, 0x88, 0xde, 0x64, 0x44, 0xaf, 0x62, 0x6d, 0x53, 0x88, 0x86, 0xe9, 0xdc, 0x4f, + 0xc1, 0xde, 0xb6, 0x1b, 0x7c, 0x52, 0xde, 0xc5, 0xf5, 0x21, 0x49, 0x79, 0x17, 0xdb, 0x22, 0x6c, + 0x52, 0x79, 0x8d, 0x2a, 0x2d, 0x09, 0xbd, 0x4d, 0x83, 0xd4, 0x7c, 0x40, 0xf9, 0x8a, 0xa0, 0xfc, + 0x37, 0x82, 0xdd, 0xe1, 0x7b, 0x3c, 0x26, 0xeb, 0x61, 0x14, 0xe8, 0x3c, 0x94, 0xe9, 0xf5, 0x1b, + 0x08, 0xfe, 0x9f, 0x31, 0xfa, 0x75, 0xec, 0xf6, 0x86, 0x7d, 0xa8, 0x91, 0x09, 0xd1, 0xf6, 0x4e, + 0x3c, 0xfe, 0x0d, 0xc1, 0x70, 0xc4, 0x45, 0x1f, 0x27, 0x5c, 0x03, 0xe2, 0x7b, 0x0e, 0xe5, 0xad, + 0x0e, 0xad, 0x84, 0x04, 0x97, 0x99, 0x04, 0xef, 0xe3, 0xf3, 0x5d, 0x48, 0x10, 0xba, 0x85, 0x7b, + 0x37, 0xa2, 0xa1, 0xd6, 0x3b, 0x7b, 0xd2, 0x9b, 0x32, 0xa6, 0x71, 0x48, 0x7a, 0x53, 0xc6, 0xb5, + 0x04, 0x9b, 0xf2, 0x22, 0x69, 0xef, 0x29, 0x66, 0xaf, 0x3e, 0x7e, 0x91, 0x41, 0x4f, 0x5e, 0x64, + 0xd0, 0x9f, 0x2f, 0x32, 0xe8, 0xeb, 0xd5, 0x4c, 0xdf, 0x93, 0xd5, 0x4c, 0xdf, 0xef, 0xab, 0x99, + 0xbe, 0x9b, 0xa7, 0x4b, 0xa6, 0xbb, 0x58, 0x2b, 0xa8, 0x86, 0x5d, 0x26, 0xe2, 0xef, 0x5e, 0xb3, + 0x60, 0x1c, 0x2b, 0xd9, 0xa4, 0x9e, 0x9b, 0x26, 0x65, 0xbb, 0x58, 0x5b, 0xa6, 0x0e, 0x07, 0x32, + 0x7d, 0xe2, 0x98, 0xc4, 0xe2, 0xde, 0xab, 0x50, 0xa7, 0xb0, 0x9d, 0x7d, 0x9b, 0x3f, 0xfe, 0x6f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x59, 0x88, 0xd9, 0xeb, 0x7f, 0x1e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2313,12 +1979,6 @@ type QueryClient interface { NextSequenceReceive(ctx context.Context, in *QueryNextSequenceReceiveRequest, opts ...grpc.CallOption) (*QueryNextSequenceReceiveResponse, error) // NextSequenceSend returns the next send sequence for a given channel. NextSequenceSend(ctx context.Context, in *QueryNextSequenceSendRequest, opts ...grpc.CallOption) (*QueryNextSequenceSendResponse, error) - // UpgradeError returns the error receipt if the upgrade handshake failed. - UpgradeError(ctx context.Context, in *QueryUpgradeErrorRequest, opts ...grpc.CallOption) (*QueryUpgradeErrorResponse, error) - // Upgrade returns the upgrade for a given port and channel id. - Upgrade(ctx context.Context, in *QueryUpgradeRequest, opts ...grpc.CallOption) (*QueryUpgradeResponse, error) - // ChannelParams queries all parameters of the ibc channel submodule. - ChannelParams(ctx context.Context, in *QueryChannelParamsRequest, opts ...grpc.CallOption) (*QueryChannelParamsResponse, error) } type queryClient struct { @@ -2455,33 +2115,6 @@ func (c *queryClient) NextSequenceSend(ctx context.Context, in *QueryNextSequenc return out, nil } -func (c *queryClient) UpgradeError(ctx context.Context, in *QueryUpgradeErrorRequest, opts ...grpc.CallOption) (*QueryUpgradeErrorResponse, error) { - out := new(QueryUpgradeErrorResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Query/UpgradeError", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) Upgrade(ctx context.Context, in *QueryUpgradeRequest, opts ...grpc.CallOption) (*QueryUpgradeResponse, error) { - out := new(QueryUpgradeResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Query/Upgrade", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) ChannelParams(ctx context.Context, in *QueryChannelParamsRequest, opts ...grpc.CallOption) (*QueryChannelParamsResponse, error) { - out := new(QueryChannelParamsResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Query/ChannelParams", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // QueryServer is the server API for Query service. type QueryServer interface { // Channel queries an IBC Channel. @@ -2520,12 +2153,6 @@ type QueryServer interface { NextSequenceReceive(context.Context, *QueryNextSequenceReceiveRequest) (*QueryNextSequenceReceiveResponse, error) // NextSequenceSend returns the next send sequence for a given channel. NextSequenceSend(context.Context, *QueryNextSequenceSendRequest) (*QueryNextSequenceSendResponse, error) - // UpgradeError returns the error receipt if the upgrade handshake failed. - UpgradeError(context.Context, *QueryUpgradeErrorRequest) (*QueryUpgradeErrorResponse, error) - // Upgrade returns the upgrade for a given port and channel id. - Upgrade(context.Context, *QueryUpgradeRequest) (*QueryUpgradeResponse, error) - // ChannelParams queries all parameters of the ibc channel submodule. - ChannelParams(context.Context, *QueryChannelParamsRequest) (*QueryChannelParamsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -2574,15 +2201,6 @@ func (*UnimplementedQueryServer) NextSequenceReceive(ctx context.Context, req *Q func (*UnimplementedQueryServer) NextSequenceSend(ctx context.Context, req *QueryNextSequenceSendRequest) (*QueryNextSequenceSendResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method NextSequenceSend not implemented") } -func (*UnimplementedQueryServer) UpgradeError(ctx context.Context, req *QueryUpgradeErrorRequest) (*QueryUpgradeErrorResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpgradeError not implemented") -} -func (*UnimplementedQueryServer) Upgrade(ctx context.Context, req *QueryUpgradeRequest) (*QueryUpgradeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Upgrade not implemented") -} -func (*UnimplementedQueryServer) ChannelParams(ctx context.Context, req *QueryChannelParamsRequest) (*QueryChannelParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelParams not implemented") -} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -2840,60 +2458,6 @@ func _Query_NextSequenceSend_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } -func _Query_UpgradeError_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryUpgradeErrorRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).UpgradeError(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Query/UpgradeError", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).UpgradeError(ctx, req.(*QueryUpgradeErrorRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_Upgrade_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryUpgradeRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Upgrade(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Query/Upgrade", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Upgrade(ctx, req.(*QueryUpgradeRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_ChannelParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryChannelParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ChannelParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Query/ChannelParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ChannelParams(ctx, req.(*QueryChannelParamsRequest)) - } - return interceptor(ctx, in, info, handler) -} - var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.channel.v1.Query", HandlerType: (*QueryServer)(nil), @@ -2954,18 +2518,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "NextSequenceSend", Handler: _Query_NextSequenceSend_Handler, }, - { - MethodName: "UpgradeError", - Handler: _Query_UpgradeError_Handler, - }, - { - MethodName: "Upgrade", - Handler: _Query_Upgrade_Handler, - }, - { - MethodName: "ChannelParams", - Handler: _Query_ChannelParams_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/channel/v1/query.proto", @@ -4330,238 +3882,6 @@ func (m *QueryNextSequenceSendResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryUpgradeErrorRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryUpgradeErrorRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryUpgradeErrorRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryUpgradeErrorResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryUpgradeErrorResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryUpgradeErrorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.Proof) > 0 { - i -= len(m.Proof) - copy(dAtA[i:], m.Proof) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) - i-- - dAtA[i] = 0x12 - } - { - size, err := m.ErrorReceipt.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryUpgradeRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryUpgradeRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryUpgradeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryUpgradeResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryUpgradeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryUpgradeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.Proof) > 0 { - i -= len(m.Proof) - copy(dAtA[i:], m.Proof) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) - i-- - dAtA[i] = 0x12 - } - { - size, err := m.Upgrade.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryChannelParamsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryChannelParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryChannelParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryChannelParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryChannelParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryChannelParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Params != nil { - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -5124,101 +4444,11 @@ func (m *QueryNextSequenceSendResponse) Size() (n int) { return n } -func (m *QueryUpgradeErrorRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 } - -func (m *QueryUpgradeErrorResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ErrorReceipt.Size() - n += 1 + l + sovQuery(uint64(l)) - l = len(m.Proof) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryUpgradeRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryUpgradeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Upgrade.Size() - n += 1 + l + sovQuery(uint64(l)) - l = len(m.Proof) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryChannelParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryChannelParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Params != nil { - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *QueryChannelRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -9319,670 +8549,6 @@ func (m *QueryNextSequenceSendResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryUpgradeErrorRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryUpgradeErrorRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUpgradeErrorRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PortId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryUpgradeErrorResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryUpgradeErrorResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUpgradeErrorResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ErrorReceipt", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ErrorReceipt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) - if m.Proof == nil { - m.Proof = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryUpgradeRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryUpgradeRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUpgradeRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PortId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryUpgradeResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryUpgradeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUpgradeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Upgrade", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Upgrade.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) - if m.Proof == nil { - m.Proof = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryChannelParamsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryChannelParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryChannelParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryChannelParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryChannelParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryChannelParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Params == nil { - m.Params = &Params{} - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/types/query.pb.gw.go b/modules/core/04-channel/types/query.pb.gw.go index bce31252f8b..2f9c58f146d 100644 --- a/modules/core/04-channel/types/query.pb.gw.go +++ b/modules/core/04-channel/types/query.pb.gw.go @@ -1243,176 +1243,6 @@ func local_request_Query_NextSequenceSend_0(ctx context.Context, marshaler runti } -func request_Query_UpgradeError_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryUpgradeErrorRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") - } - - protoReq.ChannelId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) - } - - val, ok = pathParams["port_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id") - } - - protoReq.PortId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err) - } - - msg, err := client.UpgradeError(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_UpgradeError_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryUpgradeErrorRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") - } - - protoReq.ChannelId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) - } - - val, ok = pathParams["port_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id") - } - - protoReq.PortId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err) - } - - msg, err := server.UpgradeError(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_Upgrade_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryUpgradeRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") - } - - protoReq.ChannelId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) - } - - val, ok = pathParams["port_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id") - } - - protoReq.PortId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err) - } - - msg, err := client.Upgrade(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Upgrade_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryUpgradeRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") - } - - protoReq.ChannelId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) - } - - val, ok = pathParams["port_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id") - } - - protoReq.PortId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err) - } - - msg, err := server.Upgrade(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_ChannelParams_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryChannelParamsRequest - var metadata runtime.ServerMetadata - - msg, err := client.ChannelParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_ChannelParams_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryChannelParamsRequest - var metadata runtime.ServerMetadata - - msg, err := server.ChannelParams(ctx, &protoReq) - return msg, metadata, err - -} - // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -1741,75 +1571,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_UpgradeError_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_UpgradeError_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_UpgradeError_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_Upgrade_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Upgrade_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Upgrade_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ChannelParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_ChannelParams_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ChannelParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -2131,66 +1892,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_UpgradeError_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_UpgradeError_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_UpgradeError_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_Upgrade_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Upgrade_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Upgrade_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ChannelParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_ChannelParams_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ChannelParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -2222,12 +1923,6 @@ var ( pattern_Query_NextSequenceReceive_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v1", "channels", "channel_id", "ports", "port_id", "next_sequence"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_NextSequenceSend_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v1", "channels", "channel_id", "ports", "port_id", "next_sequence_send"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_UpgradeError_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v1", "channels", "channel_id", "ports", "port_id", "upgrade_error"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_Upgrade_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v1", "channels", "channel_id", "ports", "port_id", "upgrade"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_ChannelParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "core", "channel", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -2258,10 +1953,4 @@ var ( forward_Query_NextSequenceReceive_0 = runtime.ForwardResponseMessage forward_Query_NextSequenceSend_0 = runtime.ForwardResponseMessage - - forward_Query_UpgradeError_0 = runtime.ForwardResponseMessage - - forward_Query_Upgrade_0 = runtime.ForwardResponseMessage - - forward_Query_ChannelParams_0 = runtime.ForwardResponseMessage ) diff --git a/modules/core/04-channel/types/tx.pb.go b/modules/core/04-channel/types/tx.pb.go index 4db1d9673d5..99cf551455f 100644 --- a/modules/core/04-channel/types/tx.pb.go +++ b/modules/core/04-channel/types/tx.pb.go @@ -235,9 +235,6 @@ var xxx_messageInfo_MsgChannelOpenTryResponse proto.InternalMessageInfo // MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge // the change of channel state to TRYOPEN on Chain B. -// WARNING: a channel upgrade MUST NOT initialize an upgrade for this channel -// in the same block as executing this message otherwise the counterparty will -// be incapable of opening. type MsgChannelOpenAck struct { PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` @@ -480,12 +477,11 @@ var xxx_messageInfo_MsgChannelCloseInitResponse proto.InternalMessageInfo // MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B // to acknowledge the change of channel state to CLOSED on Chain A. type MsgChannelCloseConfirm struct { - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - ProofInit []byte `protobuf:"bytes,3,opt,name=proof_init,json=proofInit,proto3" json:"proof_init,omitempty"` - ProofHeight types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` - Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty"` - CounterpartyUpgradeSequence uint64 `protobuf:"varint,6,opt,name=counterparty_upgrade_sequence,json=counterpartyUpgradeSequence,proto3" json:"counterparty_upgrade_sequence,omitempty"` + PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + ProofInit []byte `protobuf:"bytes,3,opt,name=proof_init,json=proofInit,proto3" json:"proof_init,omitempty"` + ProofHeight types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` + Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty"` } func (m *MsgChannelCloseConfirm) Reset() { *m = MsgChannelCloseConfirm{} } @@ -720,13 +716,12 @@ var xxx_messageInfo_MsgTimeoutResponse proto.InternalMessageInfo // MsgTimeoutOnClose timed-out packet upon counterparty channel closure. type MsgTimeoutOnClose struct { - Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` - ProofUnreceived []byte `protobuf:"bytes,2,opt,name=proof_unreceived,json=proofUnreceived,proto3" json:"proof_unreceived,omitempty"` - ProofClose []byte `protobuf:"bytes,3,opt,name=proof_close,json=proofClose,proto3" json:"proof_close,omitempty"` - ProofHeight types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` - NextSequenceRecv uint64 `protobuf:"varint,5,opt,name=next_sequence_recv,json=nextSequenceRecv,proto3" json:"next_sequence_recv,omitempty"` - Signer string `protobuf:"bytes,6,opt,name=signer,proto3" json:"signer,omitempty"` - CounterpartyUpgradeSequence uint64 `protobuf:"varint,7,opt,name=counterparty_upgrade_sequence,json=counterpartyUpgradeSequence,proto3" json:"counterparty_upgrade_sequence,omitempty"` + Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` + ProofUnreceived []byte `protobuf:"bytes,2,opt,name=proof_unreceived,json=proofUnreceived,proto3" json:"proof_unreceived,omitempty"` + ProofClose []byte `protobuf:"bytes,3,opt,name=proof_close,json=proofClose,proto3" json:"proof_close,omitempty"` + ProofHeight types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` + NextSequenceRecv uint64 `protobuf:"varint,5,opt,name=next_sequence_recv,json=nextSequenceRecv,proto3" json:"next_sequence_recv,omitempty"` + Signer string `protobuf:"bytes,6,opt,name=signer,proto3" json:"signer,omitempty"` } func (m *MsgTimeoutOnClose) Reset() { *m = MsgTimeoutOnClose{} } @@ -880,1697 +875,1246 @@ func (m *MsgAcknowledgementResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgAcknowledgementResponse proto.InternalMessageInfo -// MsgChannelUpgradeInit defines the request type for the ChannelUpgradeInit rpc -// WARNING: Initializing a channel upgrade in the same block as opening the channel -// may result in the counterparty being incapable of opening. -type MsgChannelUpgradeInit struct { - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - Fields UpgradeFields `protobuf:"bytes,3,opt,name=fields,proto3" json:"fields"` - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` +func init() { + proto.RegisterEnum("ibc.core.channel.v1.ResponseResultType", ResponseResultType_name, ResponseResultType_value) + proto.RegisterType((*MsgChannelOpenInit)(nil), "ibc.core.channel.v1.MsgChannelOpenInit") + proto.RegisterType((*MsgChannelOpenInitResponse)(nil), "ibc.core.channel.v1.MsgChannelOpenInitResponse") + proto.RegisterType((*MsgChannelOpenTry)(nil), "ibc.core.channel.v1.MsgChannelOpenTry") + proto.RegisterType((*MsgChannelOpenTryResponse)(nil), "ibc.core.channel.v1.MsgChannelOpenTryResponse") + proto.RegisterType((*MsgChannelOpenAck)(nil), "ibc.core.channel.v1.MsgChannelOpenAck") + proto.RegisterType((*MsgChannelOpenAckResponse)(nil), "ibc.core.channel.v1.MsgChannelOpenAckResponse") + proto.RegisterType((*MsgChannelOpenConfirm)(nil), "ibc.core.channel.v1.MsgChannelOpenConfirm") + proto.RegisterType((*MsgChannelOpenConfirmResponse)(nil), "ibc.core.channel.v1.MsgChannelOpenConfirmResponse") + proto.RegisterType((*MsgChannelCloseInit)(nil), "ibc.core.channel.v1.MsgChannelCloseInit") + proto.RegisterType((*MsgChannelCloseInitResponse)(nil), "ibc.core.channel.v1.MsgChannelCloseInitResponse") + proto.RegisterType((*MsgChannelCloseConfirm)(nil), "ibc.core.channel.v1.MsgChannelCloseConfirm") + proto.RegisterType((*MsgChannelCloseConfirmResponse)(nil), "ibc.core.channel.v1.MsgChannelCloseConfirmResponse") + proto.RegisterType((*MsgRecvPacket)(nil), "ibc.core.channel.v1.MsgRecvPacket") + proto.RegisterType((*MsgRecvPacketResponse)(nil), "ibc.core.channel.v1.MsgRecvPacketResponse") + proto.RegisterType((*MsgTimeout)(nil), "ibc.core.channel.v1.MsgTimeout") + proto.RegisterType((*MsgTimeoutResponse)(nil), "ibc.core.channel.v1.MsgTimeoutResponse") + proto.RegisterType((*MsgTimeoutOnClose)(nil), "ibc.core.channel.v1.MsgTimeoutOnClose") + proto.RegisterType((*MsgTimeoutOnCloseResponse)(nil), "ibc.core.channel.v1.MsgTimeoutOnCloseResponse") + proto.RegisterType((*MsgAcknowledgement)(nil), "ibc.core.channel.v1.MsgAcknowledgement") + proto.RegisterType((*MsgAcknowledgementResponse)(nil), "ibc.core.channel.v1.MsgAcknowledgementResponse") } -func (m *MsgChannelUpgradeInit) Reset() { *m = MsgChannelUpgradeInit{} } -func (m *MsgChannelUpgradeInit) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeInit) ProtoMessage() {} -func (*MsgChannelUpgradeInit) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{20} -} -func (m *MsgChannelUpgradeInit) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgChannelUpgradeInit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeInit.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgChannelUpgradeInit) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeInit.Merge(m, src) -} -func (m *MsgChannelUpgradeInit) XXX_Size() int { - return m.Size() -} -func (m *MsgChannelUpgradeInit) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeInit.DiscardUnknown(m) +func init() { proto.RegisterFile("ibc/core/channel/v1/tx.proto", fileDescriptor_bc4637e0ac3fc7b7) } + +var fileDescriptor_bc4637e0ac3fc7b7 = []byte{ + // 1202 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcd, 0x6f, 0xda, 0x66, + 0x18, 0xc7, 0x40, 0x20, 0x79, 0xc8, 0x0a, 0x75, 0xda, 0x86, 0x3a, 0x09, 0xb0, 0x1c, 0x9a, 0x2c, + 0x5b, 0x20, 0xa1, 0xdb, 0xa4, 0x45, 0x93, 0x26, 0xc2, 0xa8, 0x86, 0xd4, 0x7c, 0xc8, 0x90, 0x49, + 0x6b, 0xa7, 0xa1, 0x60, 0xde, 0x3a, 0x16, 0xe0, 0x97, 0xd9, 0x86, 0x96, 0xdb, 0xb4, 0x53, 0x94, + 0xc3, 0xb4, 0xc3, 0xae, 0x91, 0x26, 0xed, 0x1f, 0xe8, 0xa9, 0xf7, 0xdd, 0x7a, 0xec, 0xb1, 0x9a, + 0xb4, 0x6a, 0x4a, 0x0e, 0xfd, 0x37, 0x26, 0xbf, 0x7e, 0x6d, 0x8c, 0xb1, 0xc1, 0x6d, 0x68, 0x6e, + 0xf6, 0xf3, 0xfc, 0xde, 0xe7, 0xe3, 0xf7, 0x7b, 0xbf, 0x6c, 0x58, 0x96, 0xea, 0x42, 0x4e, 0xc0, + 0x0a, 0xca, 0x09, 0x27, 0xc7, 0xb2, 0x8c, 0x5a, 0xb9, 0xde, 0x76, 0x4e, 0x7b, 0x96, 0xed, 0x28, + 0x58, 0xc3, 0xec, 0x82, 0x54, 0x17, 0xb2, 0xba, 0x37, 0x4b, 0xbd, 0xd9, 0xde, 0x36, 0x77, 0x4b, + 0xc4, 0x22, 0x26, 0xfe, 0x9c, 0xfe, 0x64, 0x40, 0xb9, 0x45, 0x01, 0xab, 0x6d, 0xac, 0xe6, 0xda, + 0xaa, 0xa8, 0x87, 0x68, 0xab, 0x22, 0x75, 0xa4, 0x07, 0x19, 0x5a, 0x12, 0x92, 0x35, 0xdd, 0x6b, + 0x3c, 0x51, 0xc0, 0xc7, 0x6e, 0x25, 0x98, 0xf9, 0x08, 0x64, 0xf5, 0x0f, 0x06, 0xd8, 0x3d, 0x55, + 0x2c, 0x1a, 0xc6, 0x83, 0x0e, 0x92, 0xcb, 0xb2, 0xa4, 0xb1, 0x8b, 0x10, 0xed, 0x60, 0x45, 0xab, + 0x49, 0x8d, 0x24, 0x93, 0x61, 0xd6, 0xe7, 0xf8, 0x88, 0xfe, 0x5a, 0x6e, 0xb0, 0x5f, 0x43, 0x94, + 0x06, 0x48, 0x06, 0x33, 0xcc, 0x7a, 0x2c, 0xbf, 0x9c, 0x75, 0xe9, 0x24, 0x4b, 0xe3, 0xed, 0x86, + 0x5f, 0xbe, 0x49, 0x07, 0x78, 0x73, 0x08, 0x7b, 0x07, 0x22, 0xaa, 0x24, 0xca, 0x48, 0x49, 0x86, + 0x8c, 0xa8, 0xc6, 0xdb, 0x4e, 0xfc, 0xf4, 0xcf, 0x74, 0xe0, 0xd7, 0xb7, 0xcf, 0x37, 0xa8, 0x61, + 0xf5, 0x31, 0x70, 0xa3, 0x55, 0xf1, 0x48, 0xed, 0x60, 0x59, 0x45, 0xec, 0x0a, 0x00, 0x8d, 0x38, + 0x28, 0x70, 0x8e, 0x5a, 0xca, 0x0d, 0x36, 0x09, 0xd1, 0x1e, 0x52, 0x54, 0x09, 0xcb, 0xa4, 0xc6, + 0x39, 0xde, 0x7c, 0xdd, 0x09, 0xeb, 0x79, 0x56, 0xdf, 0x04, 0xe1, 0xe6, 0x70, 0xf4, 0xaa, 0xd2, + 0xf7, 0x6e, 0x39, 0x0f, 0x0b, 0x1d, 0x05, 0xf5, 0x24, 0xdc, 0x55, 0x6b, 0xb6, 0xb4, 0x24, 0xf4, + 0x6e, 0x30, 0xc9, 0xf0, 0x37, 0x4d, 0x77, 0xd1, 0x2a, 0xc1, 0x46, 0x53, 0xe8, 0xdd, 0x69, 0xda, + 0x86, 0x5b, 0x02, 0xee, 0xca, 0x1a, 0x52, 0x3a, 0xc7, 0x8a, 0xd6, 0xaf, 0x99, 0xdd, 0x84, 0x49, + 0x5d, 0x0b, 0x76, 0xdf, 0xf7, 0x86, 0x4b, 0xa7, 0xa4, 0xa3, 0x60, 0xfc, 0xa4, 0x26, 0xc9, 0x92, + 0x96, 0x9c, 0xc9, 0x30, 0xeb, 0xf3, 0xfc, 0x1c, 0xb1, 0x10, 0x3d, 0x8b, 0x30, 0x6f, 0xb8, 0x4f, + 0x90, 0x24, 0x9e, 0x68, 0xc9, 0x08, 0x29, 0x8a, 0xb3, 0x15, 0x65, 0xcc, 0x9b, 0xde, 0x76, 0xf6, + 0x3b, 0x82, 0xa0, 0x25, 0xc5, 0xc8, 0x28, 0xc3, 0x64, 0x53, 0x2f, 0x3a, 0x5e, 0xbd, 0x47, 0x70, + 0x77, 0x84, 0x5f, 0x4b, 0x3c, 0x9b, 0x3a, 0xcc, 0x90, 0x3a, 0x0e, 0x59, 0x83, 0x0e, 0x59, 0xa9, + 0x78, 0x7f, 0x8f, 0x88, 0x57, 0x10, 0x9a, 0xde, 0xe2, 0x8d, 0x8f, 0xc9, 0x7e, 0x09, 0x8b, 0x43, + 0x4c, 0xdb, 0xb0, 0xc6, 0x0c, 0xbd, 0x6d, 0x77, 0x0f, 0xf4, 0x7d, 0x0f, 0x85, 0x96, 0xc0, 0xd0, + 0xa3, 0xa6, 0x29, 0x7d, 0x2a, 0xd0, 0x2c, 0x31, 0xe8, 0x93, 0xef, 0x7a, 0xf5, 0x59, 0x72, 0xea, + 0x53, 0x10, 0x9a, 0xa6, 0x3e, 0xab, 0xff, 0x30, 0x70, 0x7b, 0xd8, 0x5b, 0xc4, 0xf2, 0x13, 0x49, + 0x69, 0xbf, 0x37, 0xc9, 0x56, 0xe7, 0xc7, 0x42, 0x93, 0xd0, 0x6a, 0x76, 0xae, 0x2b, 0xe7, 0xec, + 0x3c, 0x7c, 0xb5, 0xce, 0x67, 0xc6, 0x77, 0x9e, 0x86, 0x15, 0xd7, 0xde, 0xac, 0xee, 0x7b, 0xb0, + 0x30, 0x00, 0x14, 0x5b, 0x58, 0x45, 0xe3, 0xf7, 0xc3, 0x09, 0xad, 0xfb, 0xde, 0xf0, 0x56, 0x60, + 0xc9, 0x25, 0xaf, 0x55, 0xd6, 0xbf, 0x0c, 0xdc, 0x71, 0xf8, 0xaf, 0xaa, 0xca, 0xf0, 0x8e, 0x11, + 0x9a, 0xb4, 0x63, 0x7c, 0x58, 0x5d, 0x32, 0x90, 0x72, 0x6f, 0xcf, 0x62, 0xe0, 0x92, 0x81, 0x8f, + 0xf6, 0x54, 0x91, 0x47, 0x42, 0xef, 0xf0, 0x58, 0x68, 0x22, 0x8d, 0xfd, 0x0a, 0x22, 0x1d, 0xf2, + 0x44, 0xfa, 0x8e, 0xe5, 0x97, 0x5c, 0xb7, 0x58, 0x03, 0x4c, 0x8b, 0xa3, 0x03, 0xd8, 0x4f, 0x20, + 0x61, 0x34, 0x27, 0xe0, 0x76, 0x5b, 0xd2, 0xda, 0x48, 0xd6, 0x08, 0x41, 0xf3, 0x7c, 0x9c, 0xd8, + 0x8b, 0x96, 0x79, 0x84, 0x87, 0xd0, 0xd5, 0x78, 0x08, 0x8f, 0xe7, 0xe1, 0x27, 0xb2, 0xf6, 0x06, + 0x4d, 0x5a, 0xbb, 0xe6, 0x37, 0x10, 0x51, 0x90, 0xda, 0x6d, 0x19, 0xcd, 0xde, 0xc8, 0xaf, 0xb9, + 0x36, 0x6b, 0xc2, 0x79, 0x02, 0xad, 0xf6, 0x3b, 0x88, 0xa7, 0xc3, 0xe8, 0xee, 0xf9, 0x5b, 0x10, + 0x60, 0x4f, 0x15, 0xab, 0x52, 0x1b, 0xe1, 0xee, 0x74, 0x28, 0xec, 0xca, 0x0a, 0x12, 0x90, 0xd4, + 0x43, 0x8d, 0x21, 0x0a, 0x8f, 0x2c, 0xf3, 0x74, 0x28, 0xfc, 0x0c, 0x58, 0x19, 0x3d, 0xd3, 0x6a, + 0x2a, 0xfa, 0xb9, 0x8b, 0x64, 0x01, 0xd5, 0x14, 0x24, 0xf4, 0x08, 0x9d, 0x61, 0x3e, 0xa1, 0x7b, + 0x2a, 0xd4, 0xa1, 0x93, 0xe7, 0x7f, 0xe2, 0x3d, 0x26, 0xd7, 0x1f, 0xca, 0xc7, 0xb4, 0xd9, 0x7e, + 0x61, 0x9c, 0x55, 0x34, 0xfa, 0x81, 0x4c, 0x26, 0xf6, 0x35, 0x91, 0x9e, 0x86, 0x18, 0x9d, 0xe2, + 0x7a, 0x52, 0xba, 0xbe, 0x8d, 0x15, 0x6f, 0x94, 0x31, 0x95, 0x05, 0xee, 0xae, 0xca, 0xcc, 0x44, + 0x55, 0x22, 0xe3, 0x55, 0xa9, 0x93, 0x03, 0x6a, 0x98, 0xb7, 0x69, 0x8b, 0x73, 0x1a, 0x24, 0xd2, + 0x17, 0x84, 0xa6, 0x8c, 0x9f, 0xb6, 0x50, 0x43, 0x44, 0x64, 0xbd, 0x5f, 0x41, 0x9d, 0x75, 0x88, + 0x1f, 0x0f, 0x47, 0x33, 0xc5, 0x71, 0x98, 0x07, 0xe2, 0xe8, 0x03, 0x1b, 0x43, 0xe2, 0x14, 0x74, + 0xcb, 0x35, 0xef, 0xbe, 0x02, 0xb9, 0x6d, 0x3b, 0x98, 0x98, 0x32, 0xdf, 0x1b, 0xaf, 0x19, 0x60, + 0x47, 0x41, 0xec, 0x17, 0x90, 0xe1, 0x4b, 0x95, 0xc3, 0x83, 0xfd, 0x4a, 0xa9, 0xc6, 0x97, 0x2a, + 0x47, 0x0f, 0xab, 0xb5, 0xea, 0x0f, 0x87, 0xa5, 0xda, 0xd1, 0x7e, 0xe5, 0xb0, 0x54, 0x2c, 0x3f, + 0x28, 0x97, 0xbe, 0x4d, 0x04, 0xb8, 0xf8, 0xd9, 0x79, 0x26, 0x66, 0x33, 0xb1, 0x6b, 0x70, 0xd7, + 0x75, 0xd8, 0xfe, 0xc1, 0xc1, 0x61, 0x82, 0xe1, 0x66, 0xcf, 0xce, 0x33, 0x61, 0xfd, 0x99, 0xdd, + 0x84, 0x65, 0x57, 0x60, 0xe5, 0xa8, 0x58, 0x2c, 0x55, 0x2a, 0x89, 0x20, 0x17, 0x3b, 0x3b, 0xcf, + 0x44, 0xe9, 0xab, 0x27, 0xfc, 0x41, 0xa1, 0xfc, 0xf0, 0x88, 0x2f, 0x25, 0x42, 0x06, 0x9c, 0xbe, + 0x72, 0xe1, 0xd3, 0xbf, 0x52, 0x81, 0xfc, 0x8b, 0x59, 0x08, 0xed, 0xa9, 0x22, 0xdb, 0x84, 0xb8, + 0xf3, 0x43, 0xca, 0x9d, 0xac, 0xd1, 0x6f, 0x1b, 0x2e, 0xe7, 0x13, 0x68, 0xc9, 0x72, 0x02, 0x37, + 0x1c, 0x5f, 0x30, 0xf7, 0x7c, 0x84, 0xa8, 0x2a, 0x7d, 0x2e, 0xeb, 0x0f, 0xe7, 0x91, 0x49, 0xbf, + 0xb4, 0xf9, 0xc9, 0x54, 0x10, 0x9a, 0xbe, 0x32, 0xd9, 0xee, 0x9e, 0xac, 0x06, 0xac, 0xcb, 0xbd, + 0x73, 0xc3, 0x47, 0x14, 0x8a, 0xe5, 0xf2, 0xfe, 0xb1, 0x56, 0x56, 0x19, 0x12, 0x23, 0x17, 0xbe, + 0xf5, 0x09, 0x71, 0x2c, 0x24, 0xb7, 0xe5, 0x17, 0x69, 0xe5, 0x7b, 0x0a, 0x0b, 0x6e, 0x17, 0xb9, + 0x4f, 0xfd, 0x04, 0x32, 0xfb, 0xbc, 0xff, 0x0e, 0x60, 0x2b, 0xf1, 0x8f, 0x00, 0xb6, 0xfb, 0xd3, + 0xaa, 0x57, 0x88, 0x01, 0x86, 0xdb, 0x98, 0x8c, 0xb1, 0xa2, 0x57, 0x20, 0x6a, 0xde, 0x2b, 0xd2, + 0x5e, 0xc3, 0x28, 0x80, 0x5b, 0x9b, 0x00, 0xb0, 0xcf, 0x3d, 0xc7, 0xf1, 0x79, 0x6f, 0xc2, 0x50, + 0x8a, 0xf3, 0x9e, 0x7b, 0x1e, 0xc7, 0x4a, 0x13, 0xe2, 0xce, 0xb3, 0xc0, 0xb3, 0x4a, 0x07, 0xd0, + 0x7b, 0xf1, 0x7a, 0xec, 0xa9, 0xdc, 0xcc, 0x2f, 0x6f, 0x9f, 0x6f, 0x30, 0xbb, 0xd5, 0x97, 0x17, + 0x29, 0xe6, 0xd5, 0x45, 0x8a, 0xf9, 0xef, 0x22, 0xc5, 0xfc, 0x7e, 0x99, 0x0a, 0xbc, 0xba, 0x4c, + 0x05, 0x5e, 0x5f, 0xa6, 0x02, 0x8f, 0x76, 0x44, 0x49, 0x3b, 0xe9, 0xd6, 0xb3, 0x02, 0x6e, 0xe7, + 0xe8, 0xff, 0x1f, 0xa9, 0x2e, 0x6c, 0x8a, 0x38, 0xd7, 0xdb, 0xde, 0xca, 0xb5, 0x71, 0xa3, 0xdb, + 0x42, 0xaa, 0xf1, 0x6f, 0x67, 0xeb, 0xf3, 0x4d, 0xf3, 0xf7, 0x8e, 0xd6, 0xef, 0x20, 0xb5, 0x1e, + 0x21, 0xbf, 0x76, 0xee, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x98, 0x44, 0xff, 0x9f, 0x82, 0x12, + 0x00, 0x00, } -var xxx_messageInfo_MsgChannelUpgradeInit proto.InternalMessageInfo +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 -// MsgChannelUpgradeInitResponse defines the MsgChannelUpgradeInit response type -type MsgChannelUpgradeInitResponse struct { - Upgrade Upgrade `protobuf:"bytes,1,opt,name=upgrade,proto3" json:"upgrade"` - UpgradeSequence uint64 `protobuf:"varint,2,opt,name=upgrade_sequence,json=upgradeSequence,proto3" json:"upgrade_sequence,omitempty"` +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit. + ChannelOpenInit(ctx context.Context, in *MsgChannelOpenInit, opts ...grpc.CallOption) (*MsgChannelOpenInitResponse, error) + // ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry. + ChannelOpenTry(ctx context.Context, in *MsgChannelOpenTry, opts ...grpc.CallOption) (*MsgChannelOpenTryResponse, error) + // ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck. + ChannelOpenAck(ctx context.Context, in *MsgChannelOpenAck, opts ...grpc.CallOption) (*MsgChannelOpenAckResponse, error) + // ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm. + ChannelOpenConfirm(ctx context.Context, in *MsgChannelOpenConfirm, opts ...grpc.CallOption) (*MsgChannelOpenConfirmResponse, error) + // ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit. + ChannelCloseInit(ctx context.Context, in *MsgChannelCloseInit, opts ...grpc.CallOption) (*MsgChannelCloseInitResponse, error) + // ChannelCloseConfirm defines a rpc handler method for + // MsgChannelCloseConfirm. + ChannelCloseConfirm(ctx context.Context, in *MsgChannelCloseConfirm, opts ...grpc.CallOption) (*MsgChannelCloseConfirmResponse, error) + // RecvPacket defines a rpc handler method for MsgRecvPacket. + RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) + // Timeout defines a rpc handler method for MsgTimeout. + Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) + // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. + TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, opts ...grpc.CallOption) (*MsgTimeoutOnCloseResponse, error) + // Acknowledgement defines a rpc handler method for MsgAcknowledgement. + Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) } -func (m *MsgChannelUpgradeInitResponse) Reset() { *m = MsgChannelUpgradeInitResponse{} } -func (m *MsgChannelUpgradeInitResponse) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeInitResponse) ProtoMessage() {} -func (*MsgChannelUpgradeInitResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{21} +type msgClient struct { + cc grpc1.ClientConn } -func (m *MsgChannelUpgradeInitResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} } -func (m *MsgChannelUpgradeInitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeInitResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil + +func (c *msgClient) ChannelOpenInit(ctx context.Context, in *MsgChannelOpenInit, opts ...grpc.CallOption) (*MsgChannelOpenInitResponse, error) { + out := new(MsgChannelOpenInitResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelOpenInit", in, out, opts...) + if err != nil { + return nil, err } -} -func (m *MsgChannelUpgradeInitResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeInitResponse.Merge(m, src) -} -func (m *MsgChannelUpgradeInitResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgChannelUpgradeInitResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeInitResponse.DiscardUnknown(m) + return out, nil } -var xxx_messageInfo_MsgChannelUpgradeInitResponse proto.InternalMessageInfo - -// MsgChannelUpgradeTry defines the request type for the ChannelUpgradeTry rpc -type MsgChannelUpgradeTry struct { - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - ProposedUpgradeConnectionHops []string `protobuf:"bytes,3,rep,name=proposed_upgrade_connection_hops,json=proposedUpgradeConnectionHops,proto3" json:"proposed_upgrade_connection_hops,omitempty"` - CounterpartyUpgradeFields UpgradeFields `protobuf:"bytes,4,opt,name=counterparty_upgrade_fields,json=counterpartyUpgradeFields,proto3" json:"counterparty_upgrade_fields"` - CounterpartyUpgradeSequence uint64 `protobuf:"varint,5,opt,name=counterparty_upgrade_sequence,json=counterpartyUpgradeSequence,proto3" json:"counterparty_upgrade_sequence,omitempty"` - ProofChannel []byte `protobuf:"bytes,6,opt,name=proof_channel,json=proofChannel,proto3" json:"proof_channel,omitempty"` - ProofUpgrade []byte `protobuf:"bytes,7,opt,name=proof_upgrade,json=proofUpgrade,proto3" json:"proof_upgrade,omitempty"` - ProofHeight types.Height `protobuf:"bytes,8,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` - Signer string `protobuf:"bytes,9,opt,name=signer,proto3" json:"signer,omitempty"` +func (c *msgClient) ChannelOpenTry(ctx context.Context, in *MsgChannelOpenTry, opts ...grpc.CallOption) (*MsgChannelOpenTryResponse, error) { + out := new(MsgChannelOpenTryResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelOpenTry", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgChannelUpgradeTry) Reset() { *m = MsgChannelUpgradeTry{} } -func (m *MsgChannelUpgradeTry) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeTry) ProtoMessage() {} -func (*MsgChannelUpgradeTry) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{22} -} -func (m *MsgChannelUpgradeTry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgChannelUpgradeTry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeTry.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func (c *msgClient) ChannelOpenAck(ctx context.Context, in *MsgChannelOpenAck, opts ...grpc.CallOption) (*MsgChannelOpenAckResponse, error) { + out := new(MsgChannelOpenAckResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelOpenAck", in, out, opts...) + if err != nil { + return nil, err } + return out, nil } -func (m *MsgChannelUpgradeTry) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeTry.Merge(m, src) -} -func (m *MsgChannelUpgradeTry) XXX_Size() int { - return m.Size() -} -func (m *MsgChannelUpgradeTry) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeTry.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgChannelUpgradeTry proto.InternalMessageInfo -// MsgChannelUpgradeTryResponse defines the MsgChannelUpgradeTry response type -type MsgChannelUpgradeTryResponse struct { - Upgrade Upgrade `protobuf:"bytes,1,opt,name=upgrade,proto3" json:"upgrade"` - UpgradeSequence uint64 `protobuf:"varint,2,opt,name=upgrade_sequence,json=upgradeSequence,proto3" json:"upgrade_sequence,omitempty"` - Result ResponseResultType `protobuf:"varint,3,opt,name=result,proto3,enum=ibc.core.channel.v1.ResponseResultType" json:"result,omitempty"` +func (c *msgClient) ChannelOpenConfirm(ctx context.Context, in *MsgChannelOpenConfirm, opts ...grpc.CallOption) (*MsgChannelOpenConfirmResponse, error) { + out := new(MsgChannelOpenConfirmResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelOpenConfirm", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgChannelUpgradeTryResponse) Reset() { *m = MsgChannelUpgradeTryResponse{} } -func (m *MsgChannelUpgradeTryResponse) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeTryResponse) ProtoMessage() {} -func (*MsgChannelUpgradeTryResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{23} +func (c *msgClient) ChannelCloseInit(ctx context.Context, in *MsgChannelCloseInit, opts ...grpc.CallOption) (*MsgChannelCloseInitResponse, error) { + out := new(MsgChannelCloseInitResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelCloseInit", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgChannelUpgradeTryResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) + +func (c *msgClient) ChannelCloseConfirm(ctx context.Context, in *MsgChannelCloseConfirm, opts ...grpc.CallOption) (*MsgChannelCloseConfirmResponse, error) { + out := new(MsgChannelCloseConfirmResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelCloseConfirm", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgChannelUpgradeTryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeTryResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil + +func (c *msgClient) RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) { + out := new(MsgRecvPacketResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/RecvPacket", in, out, opts...) + if err != nil { + return nil, err } + return out, nil } -func (m *MsgChannelUpgradeTryResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeTryResponse.Merge(m, src) + +func (c *msgClient) Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) { + out := new(MsgTimeoutResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/Timeout", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgChannelUpgradeTryResponse) XXX_Size() int { - return m.Size() + +func (c *msgClient) TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, opts ...grpc.CallOption) (*MsgTimeoutOnCloseResponse, error) { + out := new(MsgTimeoutOnCloseResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/TimeoutOnClose", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgChannelUpgradeTryResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeTryResponse.DiscardUnknown(m) + +func (c *msgClient) Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) { + out := new(MsgAcknowledgementResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/Acknowledgement", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -var xxx_messageInfo_MsgChannelUpgradeTryResponse proto.InternalMessageInfo +// MsgServer is the server API for Msg service. +type MsgServer interface { + // ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit. + ChannelOpenInit(context.Context, *MsgChannelOpenInit) (*MsgChannelOpenInitResponse, error) + // ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry. + ChannelOpenTry(context.Context, *MsgChannelOpenTry) (*MsgChannelOpenTryResponse, error) + // ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck. + ChannelOpenAck(context.Context, *MsgChannelOpenAck) (*MsgChannelOpenAckResponse, error) + // ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm. + ChannelOpenConfirm(context.Context, *MsgChannelOpenConfirm) (*MsgChannelOpenConfirmResponse, error) + // ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit. + ChannelCloseInit(context.Context, *MsgChannelCloseInit) (*MsgChannelCloseInitResponse, error) + // ChannelCloseConfirm defines a rpc handler method for + // MsgChannelCloseConfirm. + ChannelCloseConfirm(context.Context, *MsgChannelCloseConfirm) (*MsgChannelCloseConfirmResponse, error) + // RecvPacket defines a rpc handler method for MsgRecvPacket. + RecvPacket(context.Context, *MsgRecvPacket) (*MsgRecvPacketResponse, error) + // Timeout defines a rpc handler method for MsgTimeout. + Timeout(context.Context, *MsgTimeout) (*MsgTimeoutResponse, error) + // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. + TimeoutOnClose(context.Context, *MsgTimeoutOnClose) (*MsgTimeoutOnCloseResponse, error) + // Acknowledgement defines a rpc handler method for MsgAcknowledgement. + Acknowledgement(context.Context, *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) +} -// MsgChannelUpgradeAck defines the request type for the ChannelUpgradeAck rpc -type MsgChannelUpgradeAck struct { - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - CounterpartyUpgrade Upgrade `protobuf:"bytes,3,opt,name=counterparty_upgrade,json=counterpartyUpgrade,proto3" json:"counterparty_upgrade"` - ProofChannel []byte `protobuf:"bytes,4,opt,name=proof_channel,json=proofChannel,proto3" json:"proof_channel,omitempty"` - ProofUpgrade []byte `protobuf:"bytes,5,opt,name=proof_upgrade,json=proofUpgrade,proto3" json:"proof_upgrade,omitempty"` - ProofHeight types.Height `protobuf:"bytes,6,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` - Signer string `protobuf:"bytes,7,opt,name=signer,proto3" json:"signer,omitempty"` +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { } -func (m *MsgChannelUpgradeAck) Reset() { *m = MsgChannelUpgradeAck{} } -func (m *MsgChannelUpgradeAck) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeAck) ProtoMessage() {} -func (*MsgChannelUpgradeAck) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{24} +func (*UnimplementedMsgServer) ChannelOpenInit(ctx context.Context, req *MsgChannelOpenInit) (*MsgChannelOpenInitResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChannelOpenInit not implemented") } -func (m *MsgChannelUpgradeAck) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) +func (*UnimplementedMsgServer) ChannelOpenTry(ctx context.Context, req *MsgChannelOpenTry) (*MsgChannelOpenTryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChannelOpenTry not implemented") } -func (m *MsgChannelUpgradeAck) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeAck.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } +func (*UnimplementedMsgServer) ChannelOpenAck(ctx context.Context, req *MsgChannelOpenAck) (*MsgChannelOpenAckResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChannelOpenAck not implemented") } -func (m *MsgChannelUpgradeAck) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeAck.Merge(m, src) +func (*UnimplementedMsgServer) ChannelOpenConfirm(ctx context.Context, req *MsgChannelOpenConfirm) (*MsgChannelOpenConfirmResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChannelOpenConfirm not implemented") } -func (m *MsgChannelUpgradeAck) XXX_Size() int { - return m.Size() +func (*UnimplementedMsgServer) ChannelCloseInit(ctx context.Context, req *MsgChannelCloseInit) (*MsgChannelCloseInitResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChannelCloseInit not implemented") } -func (m *MsgChannelUpgradeAck) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeAck.DiscardUnknown(m) +func (*UnimplementedMsgServer) ChannelCloseConfirm(ctx context.Context, req *MsgChannelCloseConfirm) (*MsgChannelCloseConfirmResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChannelCloseConfirm not implemented") } - -var xxx_messageInfo_MsgChannelUpgradeAck proto.InternalMessageInfo - -// MsgChannelUpgradeAckResponse defines MsgChannelUpgradeAck response type -type MsgChannelUpgradeAckResponse struct { - Result ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v1.ResponseResultType" json:"result,omitempty"` +func (*UnimplementedMsgServer) RecvPacket(ctx context.Context, req *MsgRecvPacket) (*MsgRecvPacketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecvPacket not implemented") } - -func (m *MsgChannelUpgradeAckResponse) Reset() { *m = MsgChannelUpgradeAckResponse{} } -func (m *MsgChannelUpgradeAckResponse) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeAckResponse) ProtoMessage() {} -func (*MsgChannelUpgradeAckResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{25} +func (*UnimplementedMsgServer) Timeout(ctx context.Context, req *MsgTimeout) (*MsgTimeoutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Timeout not implemented") } -func (m *MsgChannelUpgradeAckResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgChannelUpgradeAckResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeAckResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgChannelUpgradeAckResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeAckResponse.Merge(m, src) -} -func (m *MsgChannelUpgradeAckResponse) XXX_Size() int { - return m.Size() +func (*UnimplementedMsgServer) TimeoutOnClose(ctx context.Context, req *MsgTimeoutOnClose) (*MsgTimeoutOnCloseResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TimeoutOnClose not implemented") } -func (m *MsgChannelUpgradeAckResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeAckResponse.DiscardUnknown(m) +func (*UnimplementedMsgServer) Acknowledgement(ctx context.Context, req *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Acknowledgement not implemented") } -var xxx_messageInfo_MsgChannelUpgradeAckResponse proto.InternalMessageInfo - -// MsgChannelUpgradeConfirm defines the request type for the ChannelUpgradeConfirm rpc -type MsgChannelUpgradeConfirm struct { - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - CounterpartyChannelState State `protobuf:"varint,3,opt,name=counterparty_channel_state,json=counterpartyChannelState,proto3,enum=ibc.core.channel.v1.State" json:"counterparty_channel_state,omitempty"` - CounterpartyUpgrade Upgrade `protobuf:"bytes,4,opt,name=counterparty_upgrade,json=counterpartyUpgrade,proto3" json:"counterparty_upgrade"` - ProofChannel []byte `protobuf:"bytes,5,opt,name=proof_channel,json=proofChannel,proto3" json:"proof_channel,omitempty"` - ProofUpgrade []byte `protobuf:"bytes,6,opt,name=proof_upgrade,json=proofUpgrade,proto3" json:"proof_upgrade,omitempty"` - ProofHeight types.Height `protobuf:"bytes,7,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` - Signer string `protobuf:"bytes,8,opt,name=signer,proto3" json:"signer,omitempty"` +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) } -func (m *MsgChannelUpgradeConfirm) Reset() { *m = MsgChannelUpgradeConfirm{} } -func (m *MsgChannelUpgradeConfirm) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeConfirm) ProtoMessage() {} -func (*MsgChannelUpgradeConfirm) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{26} -} -func (m *MsgChannelUpgradeConfirm) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgChannelUpgradeConfirm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeConfirm.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func _Msg_ChannelOpenInit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgChannelOpenInit) + if err := dec(in); err != nil { + return nil, err } + if interceptor == nil { + return srv.(MsgServer).ChannelOpenInit(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.Msg/ChannelOpenInit", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ChannelOpenInit(ctx, req.(*MsgChannelOpenInit)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgChannelUpgradeConfirm) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeConfirm.Merge(m, src) -} -func (m *MsgChannelUpgradeConfirm) XXX_Size() int { - return m.Size() -} -func (m *MsgChannelUpgradeConfirm) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeConfirm.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgChannelUpgradeConfirm proto.InternalMessageInfo -// MsgChannelUpgradeConfirmResponse defines MsgChannelUpgradeConfirm response type -type MsgChannelUpgradeConfirmResponse struct { - Result ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v1.ResponseResultType" json:"result,omitempty"` +func _Msg_ChannelOpenTry_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgChannelOpenTry) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ChannelOpenTry(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.Msg/ChannelOpenTry", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ChannelOpenTry(ctx, req.(*MsgChannelOpenTry)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgChannelUpgradeConfirmResponse) Reset() { *m = MsgChannelUpgradeConfirmResponse{} } -func (m *MsgChannelUpgradeConfirmResponse) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeConfirmResponse) ProtoMessage() {} -func (*MsgChannelUpgradeConfirmResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{27} -} -func (m *MsgChannelUpgradeConfirmResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgChannelUpgradeConfirmResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeConfirmResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func _Msg_ChannelOpenAck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgChannelOpenAck) + if err := dec(in); err != nil { + return nil, err } + if interceptor == nil { + return srv.(MsgServer).ChannelOpenAck(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.Msg/ChannelOpenAck", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ChannelOpenAck(ctx, req.(*MsgChannelOpenAck)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgChannelUpgradeConfirmResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeConfirmResponse.Merge(m, src) -} -func (m *MsgChannelUpgradeConfirmResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgChannelUpgradeConfirmResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeConfirmResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgChannelUpgradeConfirmResponse proto.InternalMessageInfo -// MsgChannelUpgradeOpen defines the request type for the ChannelUpgradeOpen rpc -type MsgChannelUpgradeOpen struct { - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - CounterpartyChannelState State `protobuf:"varint,3,opt,name=counterparty_channel_state,json=counterpartyChannelState,proto3,enum=ibc.core.channel.v1.State" json:"counterparty_channel_state,omitempty"` - CounterpartyUpgradeSequence uint64 `protobuf:"varint,4,opt,name=counterparty_upgrade_sequence,json=counterpartyUpgradeSequence,proto3" json:"counterparty_upgrade_sequence,omitempty"` - ProofChannel []byte `protobuf:"bytes,5,opt,name=proof_channel,json=proofChannel,proto3" json:"proof_channel,omitempty"` - ProofHeight types.Height `protobuf:"bytes,6,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` - Signer string `protobuf:"bytes,7,opt,name=signer,proto3" json:"signer,omitempty"` +func _Msg_ChannelOpenConfirm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgChannelOpenConfirm) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ChannelOpenConfirm(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.Msg/ChannelOpenConfirm", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ChannelOpenConfirm(ctx, req.(*MsgChannelOpenConfirm)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgChannelUpgradeOpen) Reset() { *m = MsgChannelUpgradeOpen{} } -func (m *MsgChannelUpgradeOpen) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeOpen) ProtoMessage() {} -func (*MsgChannelUpgradeOpen) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{28} -} -func (m *MsgChannelUpgradeOpen) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgChannelUpgradeOpen) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeOpen.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func _Msg_ChannelCloseInit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgChannelCloseInit) + if err := dec(in); err != nil { + return nil, err } -} -func (m *MsgChannelUpgradeOpen) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeOpen.Merge(m, src) -} -func (m *MsgChannelUpgradeOpen) XXX_Size() int { - return m.Size() -} -func (m *MsgChannelUpgradeOpen) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeOpen.DiscardUnknown(m) + if interceptor == nil { + return srv.(MsgServer).ChannelCloseInit(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.Msg/ChannelCloseInit", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ChannelCloseInit(ctx, req.(*MsgChannelCloseInit)) + } + return interceptor(ctx, in, info, handler) } -var xxx_messageInfo_MsgChannelUpgradeOpen proto.InternalMessageInfo - -// MsgChannelUpgradeOpenResponse defines the MsgChannelUpgradeOpen response type -type MsgChannelUpgradeOpenResponse struct { +func _Msg_ChannelCloseConfirm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgChannelCloseConfirm) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ChannelCloseConfirm(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.Msg/ChannelCloseConfirm", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ChannelCloseConfirm(ctx, req.(*MsgChannelCloseConfirm)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgChannelUpgradeOpenResponse) Reset() { *m = MsgChannelUpgradeOpenResponse{} } -func (m *MsgChannelUpgradeOpenResponse) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeOpenResponse) ProtoMessage() {} -func (*MsgChannelUpgradeOpenResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{29} -} -func (m *MsgChannelUpgradeOpenResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgChannelUpgradeOpenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeOpenResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func _Msg_RecvPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRecvPacket) + if err := dec(in); err != nil { + return nil, err } + if interceptor == nil { + return srv.(MsgServer).RecvPacket(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.Msg/RecvPacket", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RecvPacket(ctx, req.(*MsgRecvPacket)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgChannelUpgradeOpenResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeOpenResponse.Merge(m, src) -} -func (m *MsgChannelUpgradeOpenResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgChannelUpgradeOpenResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeOpenResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgChannelUpgradeOpenResponse proto.InternalMessageInfo -// MsgChannelUpgradeTimeout defines the request type for the ChannelUpgradeTimeout rpc -type MsgChannelUpgradeTimeout struct { - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - CounterpartyChannel Channel `protobuf:"bytes,3,opt,name=counterparty_channel,json=counterpartyChannel,proto3" json:"counterparty_channel"` - ProofChannel []byte `protobuf:"bytes,4,opt,name=proof_channel,json=proofChannel,proto3" json:"proof_channel,omitempty"` - ProofHeight types.Height `protobuf:"bytes,5,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` - Signer string `protobuf:"bytes,6,opt,name=signer,proto3" json:"signer,omitempty"` +func _Msg_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgTimeout) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Timeout(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.Msg/Timeout", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Timeout(ctx, req.(*MsgTimeout)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgChannelUpgradeTimeout) Reset() { *m = MsgChannelUpgradeTimeout{} } -func (m *MsgChannelUpgradeTimeout) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeTimeout) ProtoMessage() {} -func (*MsgChannelUpgradeTimeout) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{30} -} -func (m *MsgChannelUpgradeTimeout) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgChannelUpgradeTimeout) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeTimeout.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func _Msg_TimeoutOnClose_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgTimeoutOnClose) + if err := dec(in); err != nil { + return nil, err } + if interceptor == nil { + return srv.(MsgServer).TimeoutOnClose(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.Msg/TimeoutOnClose", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).TimeoutOnClose(ctx, req.(*MsgTimeoutOnClose)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgChannelUpgradeTimeout) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeTimeout.Merge(m, src) -} -func (m *MsgChannelUpgradeTimeout) XXX_Size() int { - return m.Size() -} -func (m *MsgChannelUpgradeTimeout) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeTimeout.DiscardUnknown(m) + +func _Msg_Acknowledgement_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAcknowledgement) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Acknowledgement(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v1.Msg/Acknowledgement", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Acknowledgement(ctx, req.(*MsgAcknowledgement)) + } + return interceptor(ctx, in, info, handler) } -var xxx_messageInfo_MsgChannelUpgradeTimeout proto.InternalMessageInfo - -// MsgChannelUpgradeTimeoutResponse defines the MsgChannelUpgradeTimeout response type -type MsgChannelUpgradeTimeoutResponse struct { +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.core.channel.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ChannelOpenInit", + Handler: _Msg_ChannelOpenInit_Handler, + }, + { + MethodName: "ChannelOpenTry", + Handler: _Msg_ChannelOpenTry_Handler, + }, + { + MethodName: "ChannelOpenAck", + Handler: _Msg_ChannelOpenAck_Handler, + }, + { + MethodName: "ChannelOpenConfirm", + Handler: _Msg_ChannelOpenConfirm_Handler, + }, + { + MethodName: "ChannelCloseInit", + Handler: _Msg_ChannelCloseInit_Handler, + }, + { + MethodName: "ChannelCloseConfirm", + Handler: _Msg_ChannelCloseConfirm_Handler, + }, + { + MethodName: "RecvPacket", + Handler: _Msg_RecvPacket_Handler, + }, + { + MethodName: "Timeout", + Handler: _Msg_Timeout_Handler, + }, + { + MethodName: "TimeoutOnClose", + Handler: _Msg_TimeoutOnClose_Handler, + }, + { + MethodName: "Acknowledgement", + Handler: _Msg_Acknowledgement_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/core/channel/v1/tx.proto", } -func (m *MsgChannelUpgradeTimeoutResponse) Reset() { *m = MsgChannelUpgradeTimeoutResponse{} } -func (m *MsgChannelUpgradeTimeoutResponse) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeTimeoutResponse) ProtoMessage() {} -func (*MsgChannelUpgradeTimeoutResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{31} -} -func (m *MsgChannelUpgradeTimeoutResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgChannelUpgradeTimeoutResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeTimeoutResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func (m *MsgChannelOpenInit) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } -} -func (m *MsgChannelUpgradeTimeoutResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeTimeoutResponse.Merge(m, src) -} -func (m *MsgChannelUpgradeTimeoutResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgChannelUpgradeTimeoutResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeTimeoutResponse.DiscardUnknown(m) + return dAtA[:n], nil } -var xxx_messageInfo_MsgChannelUpgradeTimeoutResponse proto.InternalMessageInfo - -// MsgChannelUpgradeCancel defines the request type for the ChannelUpgradeCancel rpc -type MsgChannelUpgradeCancel struct { - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - ErrorReceipt ErrorReceipt `protobuf:"bytes,3,opt,name=error_receipt,json=errorReceipt,proto3" json:"error_receipt"` - ProofErrorReceipt []byte `protobuf:"bytes,4,opt,name=proof_error_receipt,json=proofErrorReceipt,proto3" json:"proof_error_receipt,omitempty"` - ProofHeight types.Height `protobuf:"bytes,5,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` - Signer string `protobuf:"bytes,6,opt,name=signer,proto3" json:"signer,omitempty"` +func (m *MsgChannelOpenInit) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgChannelUpgradeCancel) Reset() { *m = MsgChannelUpgradeCancel{} } -func (m *MsgChannelUpgradeCancel) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeCancel) ProtoMessage() {} -func (*MsgChannelUpgradeCancel) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{32} -} -func (m *MsgChannelUpgradeCancel) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgChannelUpgradeCancel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeCancel.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func (m *MsgChannelOpenInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a } -} -func (m *MsgChannelUpgradeCancel) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeCancel.Merge(m, src) -} -func (m *MsgChannelUpgradeCancel) XXX_Size() int { - return m.Size() -} -func (m *MsgChannelUpgradeCancel) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeCancel.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgChannelUpgradeCancel proto.InternalMessageInfo - -// MsgChannelUpgradeCancelResponse defines the MsgChannelUpgradeCancel response type -type MsgChannelUpgradeCancelResponse struct { -} - -func (m *MsgChannelUpgradeCancelResponse) Reset() { *m = MsgChannelUpgradeCancelResponse{} } -func (m *MsgChannelUpgradeCancelResponse) String() string { return proto.CompactTextString(m) } -func (*MsgChannelUpgradeCancelResponse) ProtoMessage() {} -func (*MsgChannelUpgradeCancelResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{33} -} -func (m *MsgChannelUpgradeCancelResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgChannelUpgradeCancelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgChannelUpgradeCancelResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) + { + size, err := m.Channel.MarshalToSizedBuffer(dAtA[:i]) if err != nil { - return nil, err + return 0, err } - return b[:n], nil + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } -} -func (m *MsgChannelUpgradeCancelResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgChannelUpgradeCancelResponse.Merge(m, src) -} -func (m *MsgChannelUpgradeCancelResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgChannelUpgradeCancelResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgChannelUpgradeCancelResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgChannelUpgradeCancelResponse proto.InternalMessageInfo - -// MsgUpdateParams is the MsgUpdateParams request type. -type MsgUpdateParams struct { - // authority is the address that controls the module (defaults to x/gov unless overwritten). - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // params defines the channel parameters to update. - // - // NOTE: All parameters must be supplied. - Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` + i-- + dAtA[i] = 0x12 + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } -func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParams) ProtoMessage() {} -func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{34} -} -func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func (m *MsgChannelOpenInitResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } -} -func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParams.Merge(m, src) -} -func (m *MsgUpdateParams) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParams) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) + return dAtA[:n], nil } -var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo - -// MsgUpdateParamsResponse defines the MsgUpdateParams response type. -type MsgUpdateParamsResponse struct { +func (m *MsgChannelOpenInitResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } -func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParamsResponse) ProtoMessage() {} -func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{35} -} -func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func (m *MsgChannelOpenInitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintTx(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0x12 } -} -func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) -} -func (m *MsgUpdateParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo - -// MsgPruneAcknowledgements defines the request type for the PruneAcknowledgements rpc. -type MsgPruneAcknowledgements struct { - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - Limit uint64 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *MsgPruneAcknowledgements) Reset() { *m = MsgPruneAcknowledgements{} } -func (m *MsgPruneAcknowledgements) String() string { return proto.CompactTextString(m) } -func (*MsgPruneAcknowledgements) ProtoMessage() {} -func (*MsgPruneAcknowledgements) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{36} -} -func (m *MsgPruneAcknowledgements) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgPruneAcknowledgements) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgPruneAcknowledgements.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func (m *MsgChannelOpenTry) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil } -func (m *MsgPruneAcknowledgements) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgPruneAcknowledgements.Merge(m, src) -} -func (m *MsgPruneAcknowledgements) XXX_Size() int { - return m.Size() -} -func (m *MsgPruneAcknowledgements) XXX_DiscardUnknown() { - xxx_messageInfo_MsgPruneAcknowledgements.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgPruneAcknowledgements proto.InternalMessageInfo -// MsgPruneAcknowledgementsResponse defines the response type for the PruneAcknowledgements rpc. -type MsgPruneAcknowledgementsResponse struct { - // Number of sequences pruned (includes both packet acknowledgements and packet receipts where appropriate). - TotalPrunedSequences uint64 `protobuf:"varint,1,opt,name=total_pruned_sequences,json=totalPrunedSequences,proto3" json:"total_pruned_sequences,omitempty"` - // Number of sequences left after pruning. - TotalRemainingSequences uint64 `protobuf:"varint,2,opt,name=total_remaining_sequences,json=totalRemainingSequences,proto3" json:"total_remaining_sequences,omitempty"` +func (m *MsgChannelOpenTry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgPruneAcknowledgementsResponse) Reset() { *m = MsgPruneAcknowledgementsResponse{} } -func (m *MsgPruneAcknowledgementsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgPruneAcknowledgementsResponse) ProtoMessage() {} -func (*MsgPruneAcknowledgementsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bc4637e0ac3fc7b7, []int{37} -} -func (m *MsgPruneAcknowledgementsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgPruneAcknowledgementsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgPruneAcknowledgementsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) +func (m *MsgChannelOpenTry) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x3a + } + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) if err != nil { - return nil, err + return 0, err } - return b[:n], nil + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } -} -func (m *MsgPruneAcknowledgementsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgPruneAcknowledgementsResponse.Merge(m, src) -} -func (m *MsgPruneAcknowledgementsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgPruneAcknowledgementsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgPruneAcknowledgementsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgPruneAcknowledgementsResponse proto.InternalMessageInfo - -func (m *MsgPruneAcknowledgementsResponse) GetTotalPrunedSequences() uint64 { - if m != nil { - return m.TotalPrunedSequences + i-- + dAtA[i] = 0x32 + if len(m.ProofInit) > 0 { + i -= len(m.ProofInit) + copy(dAtA[i:], m.ProofInit) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofInit))) + i-- + dAtA[i] = 0x2a + } + if len(m.CounterpartyVersion) > 0 { + i -= len(m.CounterpartyVersion) + copy(dAtA[i:], m.CounterpartyVersion) + i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyVersion))) + i-- + dAtA[i] = 0x22 + } + { + size, err := m.Channel.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.PreviousChannelId) > 0 { + i -= len(m.PreviousChannelId) + copy(dAtA[i:], m.PreviousChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.PreviousChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa } - return 0 + return len(dAtA) - i, nil } -func (m *MsgPruneAcknowledgementsResponse) GetTotalRemainingSequences() uint64 { - if m != nil { - return m.TotalRemainingSequences +func (m *MsgChannelOpenTryResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - return 0 + return dAtA[:n], nil } -func init() { - proto.RegisterEnum("ibc.core.channel.v1.ResponseResultType", ResponseResultType_name, ResponseResultType_value) - proto.RegisterType((*MsgChannelOpenInit)(nil), "ibc.core.channel.v1.MsgChannelOpenInit") - proto.RegisterType((*MsgChannelOpenInitResponse)(nil), "ibc.core.channel.v1.MsgChannelOpenInitResponse") - proto.RegisterType((*MsgChannelOpenTry)(nil), "ibc.core.channel.v1.MsgChannelOpenTry") - proto.RegisterType((*MsgChannelOpenTryResponse)(nil), "ibc.core.channel.v1.MsgChannelOpenTryResponse") - proto.RegisterType((*MsgChannelOpenAck)(nil), "ibc.core.channel.v1.MsgChannelOpenAck") - proto.RegisterType((*MsgChannelOpenAckResponse)(nil), "ibc.core.channel.v1.MsgChannelOpenAckResponse") - proto.RegisterType((*MsgChannelOpenConfirm)(nil), "ibc.core.channel.v1.MsgChannelOpenConfirm") - proto.RegisterType((*MsgChannelOpenConfirmResponse)(nil), "ibc.core.channel.v1.MsgChannelOpenConfirmResponse") - proto.RegisterType((*MsgChannelCloseInit)(nil), "ibc.core.channel.v1.MsgChannelCloseInit") - proto.RegisterType((*MsgChannelCloseInitResponse)(nil), "ibc.core.channel.v1.MsgChannelCloseInitResponse") - proto.RegisterType((*MsgChannelCloseConfirm)(nil), "ibc.core.channel.v1.MsgChannelCloseConfirm") - proto.RegisterType((*MsgChannelCloseConfirmResponse)(nil), "ibc.core.channel.v1.MsgChannelCloseConfirmResponse") - proto.RegisterType((*MsgRecvPacket)(nil), "ibc.core.channel.v1.MsgRecvPacket") - proto.RegisterType((*MsgRecvPacketResponse)(nil), "ibc.core.channel.v1.MsgRecvPacketResponse") - proto.RegisterType((*MsgTimeout)(nil), "ibc.core.channel.v1.MsgTimeout") - proto.RegisterType((*MsgTimeoutResponse)(nil), "ibc.core.channel.v1.MsgTimeoutResponse") - proto.RegisterType((*MsgTimeoutOnClose)(nil), "ibc.core.channel.v1.MsgTimeoutOnClose") - proto.RegisterType((*MsgTimeoutOnCloseResponse)(nil), "ibc.core.channel.v1.MsgTimeoutOnCloseResponse") - proto.RegisterType((*MsgAcknowledgement)(nil), "ibc.core.channel.v1.MsgAcknowledgement") - proto.RegisterType((*MsgAcknowledgementResponse)(nil), "ibc.core.channel.v1.MsgAcknowledgementResponse") - proto.RegisterType((*MsgChannelUpgradeInit)(nil), "ibc.core.channel.v1.MsgChannelUpgradeInit") - proto.RegisterType((*MsgChannelUpgradeInitResponse)(nil), "ibc.core.channel.v1.MsgChannelUpgradeInitResponse") - proto.RegisterType((*MsgChannelUpgradeTry)(nil), "ibc.core.channel.v1.MsgChannelUpgradeTry") - proto.RegisterType((*MsgChannelUpgradeTryResponse)(nil), "ibc.core.channel.v1.MsgChannelUpgradeTryResponse") - proto.RegisterType((*MsgChannelUpgradeAck)(nil), "ibc.core.channel.v1.MsgChannelUpgradeAck") - proto.RegisterType((*MsgChannelUpgradeAckResponse)(nil), "ibc.core.channel.v1.MsgChannelUpgradeAckResponse") - proto.RegisterType((*MsgChannelUpgradeConfirm)(nil), "ibc.core.channel.v1.MsgChannelUpgradeConfirm") - proto.RegisterType((*MsgChannelUpgradeConfirmResponse)(nil), "ibc.core.channel.v1.MsgChannelUpgradeConfirmResponse") - proto.RegisterType((*MsgChannelUpgradeOpen)(nil), "ibc.core.channel.v1.MsgChannelUpgradeOpen") - proto.RegisterType((*MsgChannelUpgradeOpenResponse)(nil), "ibc.core.channel.v1.MsgChannelUpgradeOpenResponse") - proto.RegisterType((*MsgChannelUpgradeTimeout)(nil), "ibc.core.channel.v1.MsgChannelUpgradeTimeout") - proto.RegisterType((*MsgChannelUpgradeTimeoutResponse)(nil), "ibc.core.channel.v1.MsgChannelUpgradeTimeoutResponse") - proto.RegisterType((*MsgChannelUpgradeCancel)(nil), "ibc.core.channel.v1.MsgChannelUpgradeCancel") - proto.RegisterType((*MsgChannelUpgradeCancelResponse)(nil), "ibc.core.channel.v1.MsgChannelUpgradeCancelResponse") - proto.RegisterType((*MsgUpdateParams)(nil), "ibc.core.channel.v1.MsgUpdateParams") - proto.RegisterType((*MsgUpdateParamsResponse)(nil), "ibc.core.channel.v1.MsgUpdateParamsResponse") - proto.RegisterType((*MsgPruneAcknowledgements)(nil), "ibc.core.channel.v1.MsgPruneAcknowledgements") - proto.RegisterType((*MsgPruneAcknowledgementsResponse)(nil), "ibc.core.channel.v1.MsgPruneAcknowledgementsResponse") +func (m *MsgChannelOpenTryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func init() { proto.RegisterFile("ibc/core/channel/v1/tx.proto", fileDescriptor_bc4637e0ac3fc7b7) } - -var fileDescriptor_bc4637e0ac3fc7b7 = []byte{ - // 1975 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0xcf, 0x6f, 0xdb, 0xc8, - 0x15, 0x36, 0xf5, 0x33, 0x7e, 0x4e, 0xd6, 0x0e, 0xe5, 0xc4, 0x32, 0x6d, 0x4b, 0x8a, 0x5a, 0x6c, - 0xbc, 0x6e, 0x22, 0xc5, 0xde, 0xa4, 0x40, 0x8d, 0x05, 0x5a, 0x47, 0x55, 0xba, 0x06, 0xe2, 0xd8, - 0xa0, 0xac, 0xa2, 0xdd, 0x2d, 0x2a, 0xc8, 0xd4, 0x84, 0x22, 0x24, 0x91, 0x5c, 0x92, 0xd2, 0xae, - 0x0b, 0xb4, 0x58, 0xf4, 0x14, 0xe4, 0xb0, 0x68, 0x81, 0xbd, 0x06, 0x68, 0xd1, 0x7f, 0x60, 0xcf, - 0xfd, 0x71, 0xe8, 0x6d, 0x4f, 0xc5, 0x1e, 0x17, 0x05, 0xba, 0x28, 0xe2, 0x43, 0x2e, 0xfd, 0x0b, - 0x0a, 0x14, 0x28, 0x38, 0x33, 0xa4, 0x28, 0x72, 0x28, 0x51, 0x96, 0x6a, 0xf4, 0x26, 0xce, 0x7c, - 0xf3, 0xde, 0x9b, 0xef, 0x7b, 0xf3, 0x38, 0x33, 0x14, 0x6c, 0x2a, 0x67, 0x52, 0x59, 0xd2, 0x0c, - 0x54, 0x96, 0xda, 0x4d, 0x55, 0x45, 0xdd, 0xf2, 0x60, 0xb7, 0x6c, 0x7d, 0x52, 0xd2, 0x0d, 0xcd, - 0xd2, 0xf8, 0x8c, 0x72, 0x26, 0x95, 0xec, 0xde, 0x12, 0xed, 0x2d, 0x0d, 0x76, 0x85, 0x55, 0x59, - 0x93, 0x35, 0xdc, 0x5f, 0xb6, 0x7f, 0x11, 0xa8, 0xb0, 0x26, 0x69, 0x66, 0x4f, 0x33, 0xcb, 0x3d, - 0x53, 0xb6, 0x4d, 0xf4, 0x4c, 0x99, 0x76, 0xe4, 0x87, 0x1e, 0xba, 0x0a, 0x52, 0x2d, 0xbb, 0x97, - 0xfc, 0xa2, 0x80, 0x3b, 0xac, 0x10, 0x1c, 0x7f, 0x63, 0x20, 0x7d, 0x5d, 0x36, 0x9a, 0x2d, 0x44, - 0x20, 0xc5, 0xcf, 0x39, 0xe0, 0x8f, 0x4c, 0xb9, 0x42, 0xfa, 0x8f, 0x75, 0xa4, 0x1e, 0xaa, 0x8a, - 0xc5, 0xaf, 0x41, 0x5a, 0xd7, 0x0c, 0xab, 0xa1, 0xb4, 0xb2, 0x5c, 0x81, 0xdb, 0x5e, 0x14, 0x53, - 0xf6, 0xe3, 0x61, 0x8b, 0x7f, 0x0f, 0xd2, 0xd4, 0x56, 0x36, 0x56, 0xe0, 0xb6, 0x97, 0xf6, 0x36, - 0x4b, 0x8c, 0xc9, 0x96, 0xa8, 0xbd, 0xc7, 0x89, 0x2f, 0xbf, 0xc9, 0x2f, 0x88, 0xce, 0x10, 0xfe, - 0x36, 0xa4, 0x4c, 0x45, 0x56, 0x91, 0x91, 0x8d, 0x13, 0xab, 0xe4, 0x69, 0x7f, 0xf9, 0xc5, 0xef, - 0xf2, 0x0b, 0xbf, 0x7e, 0xf3, 0xc5, 0x0e, 0x6d, 0x28, 0x7e, 0x08, 0x42, 0x30, 0x2a, 0x11, 0x99, - 0xba, 0xa6, 0x9a, 0x88, 0xdf, 0x02, 0xa0, 0x16, 0x87, 0x01, 0x2e, 0xd2, 0x96, 0xc3, 0x16, 0x9f, - 0x85, 0xf4, 0x00, 0x19, 0xa6, 0xa2, 0xa9, 0x38, 0xc6, 0x45, 0xd1, 0x79, 0xdc, 0x4f, 0xd8, 0x7e, - 0x8a, 0xdf, 0xc4, 0xe0, 0xe6, 0xa8, 0xf5, 0x53, 0xe3, 0x3c, 0x7c, 0xca, 0x7b, 0x90, 0xd1, 0x0d, - 0x34, 0x50, 0xb4, 0xbe, 0xd9, 0xf0, 0xb8, 0xc5, 0xa6, 0x1f, 0xc7, 0xb2, 0x9c, 0x78, 0xd3, 0xe9, - 0xae, 0xb8, 0x21, 0x78, 0x68, 0x8a, 0x4f, 0x4f, 0xd3, 0x2e, 0xac, 0x4a, 0x5a, 0x5f, 0xb5, 0x90, - 0xa1, 0x37, 0x0d, 0xeb, 0xbc, 0xe1, 0xcc, 0x26, 0x81, 0xe3, 0xca, 0x78, 0xfb, 0x7e, 0x4c, 0xba, - 0x6c, 0x4a, 0x74, 0x43, 0xd3, 0x9e, 0x37, 0x14, 0x55, 0xb1, 0xb2, 0xc9, 0x02, 0xb7, 0x7d, 0x5d, - 0x5c, 0xc4, 0x2d, 0x58, 0xcf, 0x0a, 0x5c, 0x27, 0xdd, 0x6d, 0xa4, 0xc8, 0x6d, 0x2b, 0x9b, 0xc2, - 0x41, 0x09, 0x9e, 0xa0, 0x48, 0x6a, 0x0d, 0x76, 0x4b, 0xef, 0x63, 0x04, 0x0d, 0x69, 0x09, 0x8f, - 0x22, 0x4d, 0x1e, 0xf5, 0xd2, 0xe3, 0xd5, 0xfb, 0x00, 0xd6, 0x03, 0xfc, 0xba, 0xe2, 0x79, 0xd4, - 0xe1, 0x46, 0xd4, 0xf1, 0xc9, 0x1a, 0xf3, 0xc9, 0x4a, 0xc5, 0xfb, 0x6b, 0x40, 0xbc, 0x03, 0xa9, - 0x13, 0x2e, 0xde, 0x78, 0x9b, 0xfc, 0x77, 0x61, 0x6d, 0x84, 0x69, 0x0f, 0x96, 0x64, 0xe8, 0x2d, - 0x6f, 0xf7, 0x50, 0xdf, 0x4b, 0x28, 0xb4, 0x01, 0x44, 0x8f, 0x86, 0x65, 0x9c, 0x53, 0x81, 0xae, - 0xe1, 0x06, 0x3b, 0xf9, 0xae, 0x56, 0x9f, 0x0d, 0xbf, 0x3e, 0x07, 0x52, 0xc7, 0xd1, 0xa7, 0xf8, - 0x77, 0x0e, 0x6e, 0x8d, 0xf6, 0x56, 0x34, 0xf5, 0xb9, 0x62, 0xf4, 0x2e, 0x4d, 0xb2, 0x3b, 0xf3, - 0xa6, 0xd4, 0xc1, 0xb4, 0x3a, 0x33, 0xb7, 0x95, 0xf3, 0xcf, 0x3c, 0x31, 0xdb, 0xcc, 0x93, 0xe3, - 0x67, 0x9e, 0x87, 0x2d, 0xe6, 0xdc, 0xdc, 0xd9, 0x0f, 0x20, 0x33, 0x04, 0x54, 0xba, 0x9a, 0x89, - 0xc6, 0xd7, 0xc3, 0x09, 0x53, 0x8f, 0x5c, 0xf0, 0xb6, 0x60, 0x83, 0xe1, 0xd7, 0x0d, 0xeb, 0xf7, - 0x31, 0xb8, 0xed, 0xeb, 0x9f, 0x55, 0x95, 0xd1, 0x8a, 0x11, 0x9f, 0x54, 0x31, 0xe6, 0xa9, 0x0b, - 0xff, 0x18, 0xb6, 0x46, 0x96, 0x0f, 0x7d, 0x27, 0x35, 0x4c, 0xf4, 0x51, 0x1f, 0xa9, 0x12, 0xc2, - 0xf9, 0x9f, 0x10, 0x37, 0xbc, 0xa0, 0x3a, 0xc1, 0xd4, 0x28, 0x24, 0x48, 0x61, 0x01, 0x72, 0x6c, - 0x8a, 0x5c, 0x16, 0x2f, 0x38, 0xb8, 0x71, 0x64, 0xca, 0x22, 0x92, 0x06, 0x27, 0x4d, 0xa9, 0x83, - 0x2c, 0xfe, 0x7b, 0x90, 0xd2, 0xf1, 0x2f, 0xcc, 0xdd, 0xd2, 0xde, 0x06, 0xb3, 0x4c, 0x13, 0x30, - 0x9d, 0x20, 0x1d, 0xc0, 0xbf, 0x03, 0x2b, 0x84, 0x20, 0x49, 0xeb, 0xf5, 0x14, 0xab, 0x87, 0x54, - 0x0b, 0x93, 0x7c, 0x5d, 0x5c, 0xc6, 0xed, 0x15, 0xb7, 0x39, 0xc0, 0x65, 0x7c, 0x36, 0x2e, 0x13, - 0xe3, 0x53, 0xe9, 0xe7, 0x78, 0xfd, 0x0e, 0x27, 0xe9, 0x56, 0xde, 0xef, 0x43, 0xca, 0x40, 0x66, - 0xbf, 0x4b, 0x26, 0xfb, 0xd6, 0xde, 0x5d, 0xe6, 0x64, 0x1d, 0xb8, 0x88, 0xa1, 0xa7, 0xe7, 0x3a, - 0x12, 0xe9, 0x30, 0x5a, 0x81, 0x3f, 0x8b, 0x01, 0x1c, 0x99, 0xf2, 0xa9, 0xd2, 0x43, 0x5a, 0x7f, - 0x3e, 0x14, 0xf6, 0x55, 0x03, 0x49, 0x48, 0x19, 0xa0, 0xd6, 0x08, 0x85, 0x75, 0xb7, 0x79, 0x3e, - 0x14, 0xde, 0x03, 0x5e, 0x45, 0x9f, 0x58, 0x6e, 0x9a, 0x35, 0x0c, 0x24, 0x0d, 0x30, 0x9d, 0x09, - 0x71, 0xc5, 0xee, 0x71, 0x92, 0xcb, 0x26, 0x2f, 0x7a, 0x51, 0xf9, 0x10, 0x6f, 0xa1, 0x28, 0x1f, - 0xf3, 0x66, 0xfb, 0xdf, 0xe4, 0x7d, 0x47, 0xad, 0x1f, 0xab, 0x38, 0xb1, 0xaf, 0x88, 0xf4, 0x3c, - 0x2c, 0xd1, 0x14, 0xb7, 0x9d, 0xd2, 0x1a, 0x41, 0xaa, 0x06, 0x09, 0x63, 0x2e, 0x45, 0x82, 0xad, - 0x4a, 0x72, 0xa2, 0x2a, 0xa9, 0xe9, 0x4a, 0x4a, 0xfa, 0x12, 0x25, 0xe5, 0x0c, 0xbf, 0x28, 0x47, - 0xb9, 0x9f, 0xb7, 0xc0, 0x2f, 0x62, 0x38, 0x7d, 0x0e, 0xa4, 0x8e, 0xaa, 0x7d, 0xdc, 0x45, 0x2d, - 0x19, 0xe1, 0x9a, 0x31, 0x83, 0xc2, 0xdb, 0xb0, 0xdc, 0x1c, 0xb5, 0xe6, 0x08, 0xec, 0x6b, 0x1e, - 0x0a, 0x6c, 0x0f, 0x6c, 0x8d, 0x08, 0x7c, 0x60, 0xb7, 0x5c, 0xf1, 0xdb, 0x59, 0xc2, 0xbb, 0x7e, - 0x1f, 0x13, 0xf3, 0xe6, 0xfb, 0x8f, 0x23, 0xfb, 0x1b, 0x9a, 0x02, 0x33, 0xbd, 0xe4, 0x7f, 0x00, - 0xa9, 0xe7, 0x0a, 0xea, 0xb6, 0x4c, 0x5a, 0x95, 0x8a, 0xcc, 0xc0, 0xa8, 0xa7, 0x27, 0x18, 0xe9, - 0x28, 0x46, 0xc6, 0x45, 0xaf, 0xed, 0x9f, 0x71, 0xde, 0x0d, 0x8c, 0x27, 0x78, 0x97, 0xa5, 0xf7, - 0x20, 0x4d, 0x53, 0x9f, 0x26, 0xce, 0xe6, 0xb8, 0x68, 0x9c, 0x93, 0x07, 0x1d, 0x62, 0x17, 0x87, - 0xc0, 0xc2, 0x89, 0xe1, 0x85, 0xb3, 0xdc, 0xf7, 0x2d, 0x16, 0xc2, 0xe6, 0x7f, 0xe2, 0xb0, 0x1a, - 0x08, 0x68, 0xec, 0x71, 0x6a, 0x02, 0x99, 0x3f, 0x82, 0x82, 0x6e, 0x68, 0xba, 0x66, 0xa2, 0x96, - 0xbb, 0x86, 0x25, 0x4d, 0x55, 0x91, 0x64, 0x29, 0x9a, 0xda, 0x68, 0x6b, 0xba, 0x4d, 0x73, 0x7c, - 0x7b, 0x51, 0xdc, 0x72, 0x70, 0xd4, 0x6b, 0xc5, 0x45, 0xbd, 0xaf, 0xe9, 0x26, 0xdf, 0x86, 0x0d, - 0x66, 0x41, 0xa0, 0x52, 0x25, 0xa6, 0x94, 0x6a, 0x9d, 0x51, 0x38, 0x08, 0x60, 0x72, 0xe9, 0x49, - 0x4e, 0x2c, 0x3d, 0xfc, 0xb7, 0xe0, 0x06, 0x2d, 0xb5, 0xf4, 0xd8, 0x98, 0xc2, 0x6b, 0x91, 0xac, - 0x3e, 0xca, 0xee, 0x10, 0xe4, 0x28, 0x9c, 0xf6, 0x80, 0xa8, 0xc5, 0xc0, 0x92, 0xbd, 0x36, 0xdb, - 0x92, 0x5d, 0x1c, 0x9f, 0x90, 0x7f, 0xe3, 0x60, 0x93, 0xa5, 0xff, 0x95, 0xe7, 0xa3, 0xa7, 0x3c, - 0xc4, 0x67, 0x29, 0x0f, 0xff, 0x88, 0x31, 0x12, 0x7a, 0x96, 0x23, 0x66, 0xdd, 0x77, 0x54, 0x74, - 0xd8, 0x88, 0x47, 0x66, 0x23, 0xc3, 0x48, 0x9c, 0x60, 0xc2, 0x24, 0xa2, 0x24, 0x4c, 0x32, 0x42, - 0xc2, 0xfc, 0x6f, 0xcf, 0x9e, 0x88, 0x91, 0x2f, 0x9e, 0xe3, 0xe7, 0xbc, 0xaa, 0xfc, 0x9f, 0xe2, - 0x90, 0x0d, 0xf8, 0x99, 0xf5, 0xc8, 0xf4, 0x13, 0x10, 0x98, 0xb7, 0x05, 0xa6, 0xd5, 0xb4, 0x10, - 0x4d, 0x3b, 0x81, 0x19, 0x6f, 0xcd, 0x46, 0x88, 0x59, 0xc6, 0x65, 0x02, 0xee, 0x09, 0x4d, 0x92, - 0xc4, 0x9c, 0x93, 0x24, 0x19, 0x25, 0x49, 0x52, 0x11, 0x92, 0x24, 0x3d, 0x5b, 0x92, 0x5c, 0x1b, - 0x9f, 0x24, 0x0a, 0x14, 0xc2, 0xc4, 0x9b, 0x77, 0xa2, 0x7c, 0x1a, 0x67, 0x6c, 0x07, 0x8e, 0x75, - 0xa4, 0xfe, 0x1f, 0x66, 0xc9, 0xc4, 0x17, 0x4d, 0xe2, 0x12, 0x2f, 0x1a, 0x56, 0x4a, 0x5c, 0x6d, - 0x49, 0xc8, 0x33, 0xf6, 0x34, 0xb6, 0x02, 0xee, 0xb9, 0xfd, 0xcf, 0x31, 0xc6, 0x62, 0x76, 0xce, - 0x9f, 0xf3, 0xaa, 0xcb, 0xd3, 0xdf, 0xd7, 0x66, 0x18, 0x42, 0x45, 0xab, 0xcb, 0x7e, 0x7e, 0x93, - 0xb3, 0xf1, 0x9b, 0x1a, 0xcf, 0x6f, 0x91, 0xb1, 0x9a, 0x7c, 0xa7, 0xd5, 0xe2, 0x5f, 0x62, 0xb0, - 0x16, 0x5c, 0x72, 0x4d, 0x55, 0x42, 0xdd, 0x4b, 0x33, 0xfc, 0x14, 0x6e, 0x20, 0xc3, 0xd0, 0x8c, - 0x06, 0x3e, 0x50, 0xea, 0xce, 0xa1, 0xfd, 0x0e, 0x93, 0xda, 0xaa, 0x8d, 0x14, 0x09, 0x90, 0xce, - 0xf6, 0x3a, 0xf2, 0xb4, 0xf1, 0x25, 0xc8, 0x10, 0xce, 0x46, 0x6d, 0x12, 0x7a, 0x6f, 0xe2, 0x2e, - 0xaf, 0x8d, 0x2b, 0xe6, 0xf8, 0x0e, 0xe4, 0x43, 0xe8, 0x73, 0x29, 0xfe, 0x15, 0x2c, 0x1f, 0x99, - 0x72, 0x5d, 0x6f, 0x35, 0x2d, 0x74, 0xd2, 0x34, 0x9a, 0x3d, 0x93, 0xdf, 0x84, 0xc5, 0x66, 0xdf, - 0x6a, 0x6b, 0x86, 0x62, 0x9d, 0x3b, 0xdf, 0x31, 0xdc, 0x06, 0x72, 0x04, 0xb4, 0x71, 0xf4, 0x53, - 0x4b, 0xd8, 0x11, 0xd0, 0x86, 0x0c, 0x8f, 0x80, 0xf6, 0xd3, 0x3e, 0xef, 0xc4, 0x37, 0x34, 0x57, - 0x5c, 0xc7, 0x0a, 0x7b, 0xfd, 0xbb, 0xa1, 0xfd, 0x96, 0xc3, 0x0b, 0xec, 0xc4, 0xe8, 0xab, 0xc8, - 0x77, 0xfc, 0x32, 0x2f, 0x2d, 0xff, 0x2a, 0x24, 0xbb, 0x4a, 0x8f, 0xde, 0x2d, 0x26, 0x44, 0xf2, - 0x10, 0xfd, 0xa8, 0xf3, 0x39, 0x87, 0xd3, 0x96, 0x19, 0x93, 0xfb, 0x12, 0x78, 0x08, 0xb7, 0x2d, - 0xcd, 0x6a, 0x76, 0x1b, 0xba, 0x0d, 0x6b, 0xb9, 0x95, 0xd0, 0xc4, 0xa1, 0x26, 0xc4, 0x55, 0xdc, - 0x8b, 0x6d, 0xb4, 0x9c, 0x12, 0x68, 0xf2, 0xfb, 0xb0, 0x4e, 0x46, 0x19, 0xa8, 0xd7, 0x54, 0x54, - 0x45, 0x95, 0x3d, 0x03, 0xc9, 0xf6, 0x72, 0x0d, 0x03, 0x44, 0xa7, 0xdf, 0x1d, 0xbb, 0xf3, 0x35, - 0x07, 0x7c, 0xf0, 0xa5, 0xc2, 0x3f, 0x82, 0x82, 0x58, 0xad, 0x9d, 0x1c, 0x3f, 0xab, 0x55, 0x1b, - 0x62, 0xb5, 0x56, 0x7f, 0x7a, 0xda, 0x38, 0xfd, 0xe9, 0x49, 0xb5, 0x51, 0x7f, 0x56, 0x3b, 0xa9, - 0x56, 0x0e, 0x9f, 0x1c, 0x56, 0x7f, 0xb8, 0xb2, 0x20, 0x2c, 0xbf, 0x7c, 0x55, 0x58, 0xf2, 0x34, - 0xf1, 0x77, 0x61, 0x9d, 0x39, 0xec, 0xd9, 0xf1, 0xf1, 0xc9, 0x0a, 0x27, 0x5c, 0x7b, 0xf9, 0xaa, - 0x90, 0xb0, 0x7f, 0xf3, 0xf7, 0x61, 0x93, 0x09, 0xac, 0xd5, 0x2b, 0x95, 0x6a, 0xad, 0xb6, 0x12, - 0x13, 0x96, 0x5e, 0xbe, 0x2a, 0xa4, 0xe9, 0x63, 0x28, 0xfc, 0xc9, 0xc1, 0xe1, 0xd3, 0xba, 0x58, - 0x5d, 0x89, 0x13, 0x38, 0x7d, 0x14, 0x12, 0x2f, 0xfe, 0x90, 0x5b, 0xd8, 0xfb, 0xd7, 0x0a, 0xc4, - 0x8f, 0x4c, 0x99, 0xef, 0xc0, 0xb2, 0xff, 0x7b, 0x20, 0xfb, 0xe5, 0x1a, 0xfc, 0x44, 0x27, 0x94, - 0x23, 0x02, 0x5d, 0x05, 0xdb, 0xf0, 0x96, 0xef, 0x43, 0xdc, 0xdb, 0x11, 0x4c, 0x9c, 0x1a, 0xe7, - 0x42, 0x29, 0x1a, 0x2e, 0xc4, 0x93, 0xbd, 0xa5, 0x8f, 0xe2, 0xe9, 0x40, 0xea, 0x44, 0xf2, 0xe4, - 0xdd, 0xc3, 0x5a, 0xc0, 0x33, 0x3e, 0x9f, 0xec, 0x44, 0xb0, 0x42, 0xb1, 0xc2, 0x5e, 0x74, 0xac, - 0xeb, 0x55, 0x85, 0x95, 0xc0, 0x77, 0x8b, 0xed, 0x09, 0x76, 0x5c, 0xa4, 0xf0, 0x20, 0x2a, 0xd2, - 0xf5, 0xf7, 0x31, 0x64, 0x58, 0xdf, 0x23, 0xbe, 0x13, 0xc5, 0x90, 0x33, 0xcf, 0x77, 0xa7, 0x00, - 0xbb, 0x8e, 0x7f, 0x06, 0xe0, 0xb9, 0xc2, 0x2f, 0x86, 0x99, 0x18, 0x62, 0x84, 0x9d, 0xc9, 0x18, - 0xd7, 0x7a, 0x0d, 0xd2, 0xce, 0xd6, 0x22, 0x1f, 0x36, 0x8c, 0x02, 0x84, 0xbb, 0x13, 0x00, 0xde, - 0xdc, 0xf3, 0xdd, 0xe0, 0xbe, 0x3d, 0x61, 0x28, 0xc5, 0x85, 0xe7, 0x5e, 0xc8, 0xad, 0x64, 0x07, - 0x96, 0xfd, 0x57, 0x89, 0xa1, 0x51, 0xfa, 0x80, 0xe1, 0x8b, 0x37, 0xec, 0x4a, 0x6e, 0x98, 0xe8, - 0xde, 0x7b, 0xb4, 0x49, 0x89, 0xee, 0xc1, 0x4e, 0x4c, 0x74, 0xd6, 0x15, 0xd7, 0x47, 0x70, 0x33, - 0x78, 0xdf, 0xf4, 0x4e, 0x34, 0x43, 0x76, 0xe1, 0xd8, 0x8d, 0x0c, 0x0d, 0x77, 0x69, 0x97, 0x8f, - 0x88, 0x2e, 0xed, 0x0a, 0xb2, 0x1b, 0x19, 0xea, 0xba, 0xfc, 0x25, 0xdc, 0x62, 0x9f, 0x5e, 0xef, - 0x47, 0xb3, 0xe5, 0x2c, 0xb1, 0x47, 0x53, 0xc1, 0xc3, 0xa5, 0xc5, 0x67, 0xa2, 0x88, 0xd2, 0xda, - 0xd8, 0xa8, 0xd2, 0x7a, 0x77, 0xfa, 0xc1, 0x49, 0x3b, 0x4b, 0x31, 0xe2, 0xa4, 0x9d, 0x85, 0xf9, - 0x68, 0x2a, 0xb8, 0xeb, 0xfe, 0x17, 0xb0, 0xca, 0xdc, 0x01, 0xdf, 0x8b, 0xc8, 0x21, 0x46, 0x0b, - 0x0f, 0xa7, 0x41, 0xbb, 0xbe, 0x15, 0xc8, 0x90, 0xbd, 0x19, 0x45, 0xd1, 0x2d, 0xe2, 0xb7, 0xc3, - 0x8c, 0x79, 0x37, 0x72, 0xc2, 0xbd, 0x28, 0x28, 0x2f, 0xcb, 0xec, 0xad, 0x5e, 0x28, 0xcb, 0x4c, - 0x78, 0x38, 0xcb, 0x63, 0x37, 0x6d, 0x42, 0xf2, 0xd3, 0x37, 0x5f, 0xec, 0x70, 0x8f, 0x4f, 0xbf, - 0x7c, 0x9d, 0xe3, 0xbe, 0x7a, 0x9d, 0xe3, 0xfe, 0xf9, 0x3a, 0xc7, 0xfd, 0xe6, 0x22, 0xb7, 0xf0, - 0xd5, 0x45, 0x6e, 0xe1, 0xeb, 0x8b, 0xdc, 0xc2, 0x07, 0xfb, 0xb2, 0x62, 0xb5, 0xfb, 0x67, 0x25, - 0x49, 0xeb, 0x95, 0xe9, 0xff, 0xa3, 0x94, 0x33, 0xe9, 0xbe, 0xac, 0x95, 0x07, 0xbb, 0x0f, 0xca, - 0x3d, 0xad, 0xd5, 0xef, 0x22, 0x93, 0xfc, 0xb1, 0xe9, 0xc1, 0xc3, 0xfb, 0xce, 0x7f, 0x9b, 0xac, - 0x73, 0x1d, 0x99, 0x67, 0x29, 0xfc, 0xbf, 0xa6, 0x77, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x65, - 0x5b, 0xa8, 0xe5, 0xa2, 0x25, 0x00, 0x00, +func (m *MsgChannelOpenTryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintTx(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// MsgClient is the client API for Msg service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MsgClient interface { - // ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit. - ChannelOpenInit(ctx context.Context, in *MsgChannelOpenInit, opts ...grpc.CallOption) (*MsgChannelOpenInitResponse, error) - // ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry. - ChannelOpenTry(ctx context.Context, in *MsgChannelOpenTry, opts ...grpc.CallOption) (*MsgChannelOpenTryResponse, error) - // ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck. - ChannelOpenAck(ctx context.Context, in *MsgChannelOpenAck, opts ...grpc.CallOption) (*MsgChannelOpenAckResponse, error) - // ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm. - ChannelOpenConfirm(ctx context.Context, in *MsgChannelOpenConfirm, opts ...grpc.CallOption) (*MsgChannelOpenConfirmResponse, error) - // ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit. - ChannelCloseInit(ctx context.Context, in *MsgChannelCloseInit, opts ...grpc.CallOption) (*MsgChannelCloseInitResponse, error) - // ChannelCloseConfirm defines a rpc handler method for - // MsgChannelCloseConfirm. - ChannelCloseConfirm(ctx context.Context, in *MsgChannelCloseConfirm, opts ...grpc.CallOption) (*MsgChannelCloseConfirmResponse, error) - // RecvPacket defines a rpc handler method for MsgRecvPacket. - RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) - // Timeout defines a rpc handler method for MsgTimeout. - Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) - // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. - TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, opts ...grpc.CallOption) (*MsgTimeoutOnCloseResponse, error) - // Acknowledgement defines a rpc handler method for MsgAcknowledgement. - Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) - // ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit. - ChannelUpgradeInit(ctx context.Context, in *MsgChannelUpgradeInit, opts ...grpc.CallOption) (*MsgChannelUpgradeInitResponse, error) - // ChannelUpgradeTry defines a rpc handler method for MsgChannelUpgradeTry. - ChannelUpgradeTry(ctx context.Context, in *MsgChannelUpgradeTry, opts ...grpc.CallOption) (*MsgChannelUpgradeTryResponse, error) - // ChannelUpgradeAck defines a rpc handler method for MsgChannelUpgradeAck. - ChannelUpgradeAck(ctx context.Context, in *MsgChannelUpgradeAck, opts ...grpc.CallOption) (*MsgChannelUpgradeAckResponse, error) - // ChannelUpgradeConfirm defines a rpc handler method for MsgChannelUpgradeConfirm. - ChannelUpgradeConfirm(ctx context.Context, in *MsgChannelUpgradeConfirm, opts ...grpc.CallOption) (*MsgChannelUpgradeConfirmResponse, error) - // ChannelUpgradeOpen defines a rpc handler method for MsgChannelUpgradeOpen. - ChannelUpgradeOpen(ctx context.Context, in *MsgChannelUpgradeOpen, opts ...grpc.CallOption) (*MsgChannelUpgradeOpenResponse, error) - // ChannelUpgradeTimeout defines a rpc handler method for MsgChannelUpgradeTimeout. - ChannelUpgradeTimeout(ctx context.Context, in *MsgChannelUpgradeTimeout, opts ...grpc.CallOption) (*MsgChannelUpgradeTimeoutResponse, error) - // ChannelUpgradeCancel defines a rpc handler method for MsgChannelUpgradeCancel. - ChannelUpgradeCancel(ctx context.Context, in *MsgChannelUpgradeCancel, opts ...grpc.CallOption) (*MsgChannelUpgradeCancelResponse, error) - // UpdateChannelParams defines a rpc handler method for MsgUpdateParams. - UpdateChannelParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) - // PruneAcknowledgements defines a rpc handler method for MsgPruneAcknowledgements. - PruneAcknowledgements(ctx context.Context, in *MsgPruneAcknowledgements, opts ...grpc.CallOption) (*MsgPruneAcknowledgementsResponse, error) +func (m *MsgChannelOpenAck) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil } -type msgClient struct { - cc grpc1.ClientConn +func (m *MsgChannelOpenAck) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} +func (m *MsgChannelOpenAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x3a + } + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + if len(m.ProofTry) > 0 { + i -= len(m.ProofTry) + copy(dAtA[i:], m.ProofTry) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofTry))) + i-- + dAtA[i] = 0x2a + } + if len(m.CounterpartyVersion) > 0 { + i -= len(m.CounterpartyVersion) + copy(dAtA[i:], m.CounterpartyVersion) + i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyVersion))) + i-- + dAtA[i] = 0x22 + } + if len(m.CounterpartyChannelId) > 0 { + i -= len(m.CounterpartyChannelId) + copy(dAtA[i:], m.CounterpartyChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyChannelId))) + i-- + dAtA[i] = 0x1a + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (c *msgClient) ChannelOpenInit(ctx context.Context, in *MsgChannelOpenInit, opts ...grpc.CallOption) (*MsgChannelOpenInitResponse, error) { - out := new(MsgChannelOpenInitResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelOpenInit", in, out, opts...) +func (m *MsgChannelOpenAckResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } - return out, nil + return dAtA[:n], nil } -func (c *msgClient) ChannelOpenTry(ctx context.Context, in *MsgChannelOpenTry, opts ...grpc.CallOption) (*MsgChannelOpenTryResponse, error) { - out := new(MsgChannelOpenTryResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelOpenTry", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *MsgChannelOpenAckResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (c *msgClient) ChannelOpenAck(ctx context.Context, in *MsgChannelOpenAck, opts ...grpc.CallOption) (*MsgChannelOpenAckResponse, error) { - out := new(MsgChannelOpenAckResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelOpenAck", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *MsgChannelOpenAckResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil } -func (c *msgClient) ChannelOpenConfirm(ctx context.Context, in *MsgChannelOpenConfirm, opts ...grpc.CallOption) (*MsgChannelOpenConfirmResponse, error) { - out := new(MsgChannelOpenConfirmResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelOpenConfirm", in, out, opts...) +func (m *MsgChannelOpenConfirm) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } - return out, nil + return dAtA[:n], nil } -func (c *msgClient) ChannelCloseInit(ctx context.Context, in *MsgChannelCloseInit, opts ...grpc.CallOption) (*MsgChannelCloseInitResponse, error) { - out := new(MsgChannelCloseInitResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelCloseInit", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *MsgChannelOpenConfirm) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (c *msgClient) ChannelCloseConfirm(ctx context.Context, in *MsgChannelCloseConfirm, opts ...grpc.CallOption) (*MsgChannelCloseConfirmResponse, error) { - out := new(MsgChannelCloseConfirmResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelCloseConfirm", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgChannelOpenConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a } - return out, nil + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.ProofAck) > 0 { + i -= len(m.ProofAck) + copy(dAtA[i:], m.ProofAck) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofAck))) + i-- + dAtA[i] = 0x1a + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (c *msgClient) RecvPacket(ctx context.Context, in *MsgRecvPacket, opts ...grpc.CallOption) (*MsgRecvPacketResponse, error) { - out := new(MsgRecvPacketResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/RecvPacket", in, out, opts...) +func (m *MsgChannelOpenConfirmResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } - return out, nil + return dAtA[:n], nil } -func (c *msgClient) Timeout(ctx context.Context, in *MsgTimeout, opts ...grpc.CallOption) (*MsgTimeoutResponse, error) { - out := new(MsgTimeoutResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/Timeout", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *MsgChannelOpenConfirmResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (c *msgClient) TimeoutOnClose(ctx context.Context, in *MsgTimeoutOnClose, opts ...grpc.CallOption) (*MsgTimeoutOnCloseResponse, error) { - out := new(MsgTimeoutOnCloseResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/TimeoutOnClose", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *MsgChannelOpenConfirmResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil } -func (c *msgClient) Acknowledgement(ctx context.Context, in *MsgAcknowledgement, opts ...grpc.CallOption) (*MsgAcknowledgementResponse, error) { - out := new(MsgAcknowledgementResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/Acknowledgement", in, out, opts...) +func (m *MsgChannelCloseInit) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } - return out, nil + return dAtA[:n], nil } -func (c *msgClient) ChannelUpgradeInit(ctx context.Context, in *MsgChannelUpgradeInit, opts ...grpc.CallOption) (*MsgChannelUpgradeInitResponse, error) { - out := new(MsgChannelUpgradeInitResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelUpgradeInit", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *MsgChannelCloseInit) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (c *msgClient) ChannelUpgradeTry(ctx context.Context, in *MsgChannelUpgradeTry, opts ...grpc.CallOption) (*MsgChannelUpgradeTryResponse, error) { - out := new(MsgChannelUpgradeTryResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelUpgradeTry", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgChannelCloseInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a } - return out, nil + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (c *msgClient) ChannelUpgradeAck(ctx context.Context, in *MsgChannelUpgradeAck, opts ...grpc.CallOption) (*MsgChannelUpgradeAckResponse, error) { - out := new(MsgChannelUpgradeAckResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelUpgradeAck", in, out, opts...) +func (m *MsgChannelCloseInitResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } - return out, nil + return dAtA[:n], nil } -func (c *msgClient) ChannelUpgradeConfirm(ctx context.Context, in *MsgChannelUpgradeConfirm, opts ...grpc.CallOption) (*MsgChannelUpgradeConfirmResponse, error) { - out := new(MsgChannelUpgradeConfirmResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelUpgradeConfirm", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *MsgChannelCloseInitResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (c *msgClient) ChannelUpgradeOpen(ctx context.Context, in *MsgChannelUpgradeOpen, opts ...grpc.CallOption) (*MsgChannelUpgradeOpenResponse, error) { - out := new(MsgChannelUpgradeOpenResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelUpgradeOpen", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *MsgChannelCloseInitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil } -func (c *msgClient) ChannelUpgradeTimeout(ctx context.Context, in *MsgChannelUpgradeTimeout, opts ...grpc.CallOption) (*MsgChannelUpgradeTimeoutResponse, error) { - out := new(MsgChannelUpgradeTimeoutResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelUpgradeTimeout", in, out, opts...) +func (m *MsgChannelCloseConfirm) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } - return out, nil + return dAtA[:n], nil } -func (c *msgClient) ChannelUpgradeCancel(ctx context.Context, in *MsgChannelUpgradeCancel, opts ...grpc.CallOption) (*MsgChannelUpgradeCancelResponse, error) { - out := new(MsgChannelUpgradeCancelResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/ChannelUpgradeCancel", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *MsgChannelCloseConfirm) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (c *msgClient) UpdateChannelParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { - out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/UpdateChannelParams", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgChannelCloseConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a } - return out, nil + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.ProofInit) > 0 { + i -= len(m.ProofInit) + copy(dAtA[i:], m.ProofInit) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofInit))) + i-- + dAtA[i] = 0x1a + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (c *msgClient) PruneAcknowledgements(ctx context.Context, in *MsgPruneAcknowledgements, opts ...grpc.CallOption) (*MsgPruneAcknowledgementsResponse, error) { - out := new(MsgPruneAcknowledgementsResponse) - err := c.cc.Invoke(ctx, "/ibc.core.channel.v1.Msg/PruneAcknowledgements", in, out, opts...) +func (m *MsgChannelCloseConfirmResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } - return out, nil + return dAtA[:n], nil } -// MsgServer is the server API for Msg service. -type MsgServer interface { - // ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit. - ChannelOpenInit(context.Context, *MsgChannelOpenInit) (*MsgChannelOpenInitResponse, error) - // ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry. - ChannelOpenTry(context.Context, *MsgChannelOpenTry) (*MsgChannelOpenTryResponse, error) - // ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck. - ChannelOpenAck(context.Context, *MsgChannelOpenAck) (*MsgChannelOpenAckResponse, error) - // ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm. - ChannelOpenConfirm(context.Context, *MsgChannelOpenConfirm) (*MsgChannelOpenConfirmResponse, error) - // ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit. - ChannelCloseInit(context.Context, *MsgChannelCloseInit) (*MsgChannelCloseInitResponse, error) - // ChannelCloseConfirm defines a rpc handler method for - // MsgChannelCloseConfirm. - ChannelCloseConfirm(context.Context, *MsgChannelCloseConfirm) (*MsgChannelCloseConfirmResponse, error) - // RecvPacket defines a rpc handler method for MsgRecvPacket. - RecvPacket(context.Context, *MsgRecvPacket) (*MsgRecvPacketResponse, error) - // Timeout defines a rpc handler method for MsgTimeout. - Timeout(context.Context, *MsgTimeout) (*MsgTimeoutResponse, error) - // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. - TimeoutOnClose(context.Context, *MsgTimeoutOnClose) (*MsgTimeoutOnCloseResponse, error) - // Acknowledgement defines a rpc handler method for MsgAcknowledgement. - Acknowledgement(context.Context, *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) - // ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit. - ChannelUpgradeInit(context.Context, *MsgChannelUpgradeInit) (*MsgChannelUpgradeInitResponse, error) - // ChannelUpgradeTry defines a rpc handler method for MsgChannelUpgradeTry. - ChannelUpgradeTry(context.Context, *MsgChannelUpgradeTry) (*MsgChannelUpgradeTryResponse, error) - // ChannelUpgradeAck defines a rpc handler method for MsgChannelUpgradeAck. - ChannelUpgradeAck(context.Context, *MsgChannelUpgradeAck) (*MsgChannelUpgradeAckResponse, error) - // ChannelUpgradeConfirm defines a rpc handler method for MsgChannelUpgradeConfirm. - ChannelUpgradeConfirm(context.Context, *MsgChannelUpgradeConfirm) (*MsgChannelUpgradeConfirmResponse, error) - // ChannelUpgradeOpen defines a rpc handler method for MsgChannelUpgradeOpen. - ChannelUpgradeOpen(context.Context, *MsgChannelUpgradeOpen) (*MsgChannelUpgradeOpenResponse, error) - // ChannelUpgradeTimeout defines a rpc handler method for MsgChannelUpgradeTimeout. - ChannelUpgradeTimeout(context.Context, *MsgChannelUpgradeTimeout) (*MsgChannelUpgradeTimeoutResponse, error) - // ChannelUpgradeCancel defines a rpc handler method for MsgChannelUpgradeCancel. - ChannelUpgradeCancel(context.Context, *MsgChannelUpgradeCancel) (*MsgChannelUpgradeCancelResponse, error) - // UpdateChannelParams defines a rpc handler method for MsgUpdateParams. - UpdateChannelParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) - // PruneAcknowledgements defines a rpc handler method for MsgPruneAcknowledgements. - PruneAcknowledgements(context.Context, *MsgPruneAcknowledgements) (*MsgPruneAcknowledgementsResponse, error) +func (m *MsgChannelCloseConfirmResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { +func (m *MsgChannelCloseConfirmResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil } -func (*UnimplementedMsgServer) ChannelOpenInit(ctx context.Context, req *MsgChannelOpenInit) (*MsgChannelOpenInitResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelOpenInit not implemented") -} -func (*UnimplementedMsgServer) ChannelOpenTry(ctx context.Context, req *MsgChannelOpenTry) (*MsgChannelOpenTryResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelOpenTry not implemented") -} -func (*UnimplementedMsgServer) ChannelOpenAck(ctx context.Context, req *MsgChannelOpenAck) (*MsgChannelOpenAckResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelOpenAck not implemented") -} -func (*UnimplementedMsgServer) ChannelOpenConfirm(ctx context.Context, req *MsgChannelOpenConfirm) (*MsgChannelOpenConfirmResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelOpenConfirm not implemented") -} -func (*UnimplementedMsgServer) ChannelCloseInit(ctx context.Context, req *MsgChannelCloseInit) (*MsgChannelCloseInitResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelCloseInit not implemented") -} -func (*UnimplementedMsgServer) ChannelCloseConfirm(ctx context.Context, req *MsgChannelCloseConfirm) (*MsgChannelCloseConfirmResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelCloseConfirm not implemented") -} -func (*UnimplementedMsgServer) RecvPacket(ctx context.Context, req *MsgRecvPacket) (*MsgRecvPacketResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RecvPacket not implemented") -} -func (*UnimplementedMsgServer) Timeout(ctx context.Context, req *MsgTimeout) (*MsgTimeoutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Timeout not implemented") -} -func (*UnimplementedMsgServer) TimeoutOnClose(ctx context.Context, req *MsgTimeoutOnClose) (*MsgTimeoutOnCloseResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method TimeoutOnClose not implemented") -} -func (*UnimplementedMsgServer) Acknowledgement(ctx context.Context, req *MsgAcknowledgement) (*MsgAcknowledgementResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Acknowledgement not implemented") -} -func (*UnimplementedMsgServer) ChannelUpgradeInit(ctx context.Context, req *MsgChannelUpgradeInit) (*MsgChannelUpgradeInitResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelUpgradeInit not implemented") -} -func (*UnimplementedMsgServer) ChannelUpgradeTry(ctx context.Context, req *MsgChannelUpgradeTry) (*MsgChannelUpgradeTryResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelUpgradeTry not implemented") -} -func (*UnimplementedMsgServer) ChannelUpgradeAck(ctx context.Context, req *MsgChannelUpgradeAck) (*MsgChannelUpgradeAckResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelUpgradeAck not implemented") -} -func (*UnimplementedMsgServer) ChannelUpgradeConfirm(ctx context.Context, req *MsgChannelUpgradeConfirm) (*MsgChannelUpgradeConfirmResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelUpgradeConfirm not implemented") -} -func (*UnimplementedMsgServer) ChannelUpgradeOpen(ctx context.Context, req *MsgChannelUpgradeOpen) (*MsgChannelUpgradeOpenResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelUpgradeOpen not implemented") -} -func (*UnimplementedMsgServer) ChannelUpgradeTimeout(ctx context.Context, req *MsgChannelUpgradeTimeout) (*MsgChannelUpgradeTimeoutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelUpgradeTimeout not implemented") -} -func (*UnimplementedMsgServer) ChannelUpgradeCancel(ctx context.Context, req *MsgChannelUpgradeCancel) (*MsgChannelUpgradeCancelResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChannelUpgradeCancel not implemented") -} -func (*UnimplementedMsgServer) UpdateChannelParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateChannelParams not implemented") -} -func (*UnimplementedMsgServer) PruneAcknowledgements(ctx context.Context, req *MsgPruneAcknowledgements) (*MsgPruneAcknowledgementsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method PruneAcknowledgements not implemented") +func (m *MsgRecvPacket) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil } -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) +func (m *MsgRecvPacket) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func _Msg_ChannelOpenInit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgChannelOpenInit) - if err := dec(in); err != nil { - return nil, err +func (m *MsgRecvPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 } - if interceptor == nil { - return srv.(MsgServer).ChannelOpenInit(ctx, in) + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/ChannelOpenInit", + i-- + dAtA[i] = 0x1a + if len(m.ProofCommitment) > 0 { + i -= len(m.ProofCommitment) + copy(dAtA[i:], m.ProofCommitment) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofCommitment))) + i-- + dAtA[i] = 0x12 } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ChannelOpenInit(ctx, req.(*MsgChannelOpenInit)) + { + size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - return interceptor(ctx, in, info, handler) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil } -func _Msg_ChannelOpenTry_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgChannelOpenTry) - if err := dec(in); err != nil { +func (m *MsgRecvPacketResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { return nil, err } - if interceptor == nil { - return srv.(MsgServer).ChannelOpenTry(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/ChannelOpenTry", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ChannelOpenTry(ctx, req.(*MsgChannelOpenTry)) - } - return interceptor(ctx, in, info, handler) + return dAtA[:n], nil } -func _Msg_ChannelOpenAck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgChannelOpenAck) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ChannelOpenAck(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/ChannelOpenAck", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ChannelOpenAck(ctx, req.(*MsgChannelOpenAck)) - } - return interceptor(ctx, in, info, handler) +func (m *MsgRecvPacketResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func _Msg_ChannelOpenConfirm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgChannelOpenConfirm) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ChannelOpenConfirm(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/ChannelOpenConfirm", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ChannelOpenConfirm(ctx, req.(*MsgChannelOpenConfirm)) +func (m *MsgRecvPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Result != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Result)) + i-- + dAtA[i] = 0x8 } - return interceptor(ctx, in, info, handler) + return len(dAtA) - i, nil } -func _Msg_ChannelCloseInit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgChannelCloseInit) - if err := dec(in); err != nil { +func (m *MsgTimeout) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { return nil, err } - if interceptor == nil { - return srv.(MsgServer).ChannelCloseInit(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/ChannelCloseInit", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ChannelCloseInit(ctx, req.(*MsgChannelCloseInit)) - } - return interceptor(ctx, in, info, handler) + return dAtA[:n], nil } -func _Msg_ChannelCloseConfirm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgChannelCloseConfirm) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ChannelCloseConfirm(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/ChannelCloseConfirm", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ChannelCloseConfirm(ctx, req.(*MsgChannelCloseConfirm)) - } - return interceptor(ctx, in, info, handler) +func (m *MsgTimeout) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func _Msg_RecvPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRecvPacket) - if err := dec(in); err != nil { - return nil, err +func (m *MsgTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a } - if interceptor == nil { - return srv.(MsgServer).RecvPacket(ctx, in) + if m.NextSequenceRecv != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.NextSequenceRecv)) + i-- + dAtA[i] = 0x20 } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/RecvPacket", + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RecvPacket(ctx, req.(*MsgRecvPacket)) + i-- + dAtA[i] = 0x1a + if len(m.ProofUnreceived) > 0 { + i -= len(m.ProofUnreceived) + copy(dAtA[i:], m.ProofUnreceived) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUnreceived))) + i-- + dAtA[i] = 0x12 } - return interceptor(ctx, in, info, handler) + { + size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil } -func _Msg_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgTimeout) - if err := dec(in); err != nil { +func (m *MsgTimeoutResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { return nil, err } - if interceptor == nil { - return srv.(MsgServer).Timeout(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/Timeout", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Timeout(ctx, req.(*MsgTimeout)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_TimeoutOnClose_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgTimeoutOnClose) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).TimeoutOnClose(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/TimeoutOnClose", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).TimeoutOnClose(ctx, req.(*MsgTimeoutOnClose)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_Acknowledgement_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAcknowledgement) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).Acknowledgement(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/Acknowledgement", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Acknowledgement(ctx, req.(*MsgAcknowledgement)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_ChannelUpgradeInit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgChannelUpgradeInit) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ChannelUpgradeInit(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/ChannelUpgradeInit", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ChannelUpgradeInit(ctx, req.(*MsgChannelUpgradeInit)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_ChannelUpgradeTry_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgChannelUpgradeTry) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ChannelUpgradeTry(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/ChannelUpgradeTry", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ChannelUpgradeTry(ctx, req.(*MsgChannelUpgradeTry)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_ChannelUpgradeAck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgChannelUpgradeAck) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ChannelUpgradeAck(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/ChannelUpgradeAck", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ChannelUpgradeAck(ctx, req.(*MsgChannelUpgradeAck)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_ChannelUpgradeConfirm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgChannelUpgradeConfirm) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ChannelUpgradeConfirm(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/ChannelUpgradeConfirm", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ChannelUpgradeConfirm(ctx, req.(*MsgChannelUpgradeConfirm)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_ChannelUpgradeOpen_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgChannelUpgradeOpen) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ChannelUpgradeOpen(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/ChannelUpgradeOpen", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ChannelUpgradeOpen(ctx, req.(*MsgChannelUpgradeOpen)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_ChannelUpgradeTimeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgChannelUpgradeTimeout) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ChannelUpgradeTimeout(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/ChannelUpgradeTimeout", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ChannelUpgradeTimeout(ctx, req.(*MsgChannelUpgradeTimeout)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_ChannelUpgradeCancel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgChannelUpgradeCancel) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ChannelUpgradeCancel(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/ChannelUpgradeCancel", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ChannelUpgradeCancel(ctx, req.(*MsgChannelUpgradeCancel)) - } - return interceptor(ctx, in, info, handler) + return dAtA[:n], nil } -func _Msg_UpdateChannelParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateParams) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateChannelParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/UpdateChannelParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateChannelParams(ctx, req.(*MsgUpdateParams)) - } - return interceptor(ctx, in, info, handler) +func (m *MsgTimeoutResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func _Msg_PruneAcknowledgements_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgPruneAcknowledgements) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).PruneAcknowledgements(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.channel.v1.Msg/PruneAcknowledgements", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).PruneAcknowledgements(ctx, req.(*MsgPruneAcknowledgements)) +func (m *MsgTimeoutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Result != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Result)) + i-- + dAtA[i] = 0x8 } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "ibc.core.channel.v1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ChannelOpenInit", - Handler: _Msg_ChannelOpenInit_Handler, - }, - { - MethodName: "ChannelOpenTry", - Handler: _Msg_ChannelOpenTry_Handler, - }, - { - MethodName: "ChannelOpenAck", - Handler: _Msg_ChannelOpenAck_Handler, - }, - { - MethodName: "ChannelOpenConfirm", - Handler: _Msg_ChannelOpenConfirm_Handler, - }, - { - MethodName: "ChannelCloseInit", - Handler: _Msg_ChannelCloseInit_Handler, - }, - { - MethodName: "ChannelCloseConfirm", - Handler: _Msg_ChannelCloseConfirm_Handler, - }, - { - MethodName: "RecvPacket", - Handler: _Msg_RecvPacket_Handler, - }, - { - MethodName: "Timeout", - Handler: _Msg_Timeout_Handler, - }, - { - MethodName: "TimeoutOnClose", - Handler: _Msg_TimeoutOnClose_Handler, - }, - { - MethodName: "Acknowledgement", - Handler: _Msg_Acknowledgement_Handler, - }, - { - MethodName: "ChannelUpgradeInit", - Handler: _Msg_ChannelUpgradeInit_Handler, - }, - { - MethodName: "ChannelUpgradeTry", - Handler: _Msg_ChannelUpgradeTry_Handler, - }, - { - MethodName: "ChannelUpgradeAck", - Handler: _Msg_ChannelUpgradeAck_Handler, - }, - { - MethodName: "ChannelUpgradeConfirm", - Handler: _Msg_ChannelUpgradeConfirm_Handler, - }, - { - MethodName: "ChannelUpgradeOpen", - Handler: _Msg_ChannelUpgradeOpen_Handler, - }, - { - MethodName: "ChannelUpgradeTimeout", - Handler: _Msg_ChannelUpgradeTimeout_Handler, - }, - { - MethodName: "ChannelUpgradeCancel", - Handler: _Msg_ChannelUpgradeCancel_Handler, - }, - { - MethodName: "UpdateChannelParams", - Handler: _Msg_UpdateChannelParams_Handler, - }, - { - MethodName: "PruneAcknowledgements", - Handler: _Msg_PruneAcknowledgements_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "ibc/core/channel/v1/tx.proto", + return len(dAtA) - i, nil } -func (m *MsgChannelOpenInit) Marshal() (dAtA []byte, err error) { +func (m *MsgTimeoutOnClose) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2580,12 +2124,12 @@ func (m *MsgChannelOpenInit) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgChannelOpenInit) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgTimeoutOnClose) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgChannelOpenInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgTimeoutOnClose) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2595,10 +2139,15 @@ func (m *MsgChannelOpenInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x32 + } + if m.NextSequenceRecv != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.NextSequenceRecv)) + i-- + dAtA[i] = 0x28 } { - size, err := m.Channel.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2606,18 +2155,35 @@ func (m *MsgChannelOpenInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) + dAtA[i] = 0x22 + if len(m.ProofClose) > 0 { + i -= len(m.ProofClose) + copy(dAtA[i:], m.ProofClose) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofClose))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x1a + } + if len(m.ProofUnreceived) > 0 { + i -= len(m.ProofUnreceived) + copy(dAtA[i:], m.ProofUnreceived) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUnreceived))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *MsgChannelOpenInitResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgTimeoutOnCloseResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2627,34 +2193,25 @@ func (m *MsgChannelOpenInitResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgChannelOpenInitResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgTimeoutOnCloseResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgChannelOpenInitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgTimeoutOnCloseResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Version) > 0 { - i -= len(m.Version) - copy(dAtA[i:], m.Version) - i = encodeVarintTx(dAtA, i, uint64(len(m.Version))) - i-- - dAtA[i] = 0x12 - } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + if m.Result != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Result)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *MsgChannelOpenTry) Marshal() (dAtA []byte, err error) { +func (m *MsgAcknowledgement) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2664,12 +2221,12 @@ func (m *MsgChannelOpenTry) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgChannelOpenTry) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAcknowledgement) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgChannelOpenTry) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2679,7 +2236,7 @@ func (m *MsgChannelOpenTry) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x2a } { size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) @@ -2690,23 +2247,23 @@ func (m *MsgChannelOpenTry) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 - if len(m.ProofInit) > 0 { - i -= len(m.ProofInit) - copy(dAtA[i:], m.ProofInit) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofInit))) + dAtA[i] = 0x22 + if len(m.ProofAcked) > 0 { + i -= len(m.ProofAcked) + copy(dAtA[i:], m.ProofAcked) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofAcked))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x1a } - if len(m.CounterpartyVersion) > 0 { - i -= len(m.CounterpartyVersion) - copy(dAtA[i:], m.CounterpartyVersion) - i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyVersion))) + if len(m.Acknowledgement) > 0 { + i -= len(m.Acknowledgement) + copy(dAtA[i:], m.Acknowledgement) + i = encodeVarintTx(dAtA, i, uint64(len(m.Acknowledgement))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x12 } { - size, err := m.Channel.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2714,25 +2271,11 @@ func (m *MsgChannelOpenTry) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a - if len(m.PreviousChannelId) > 0 { - i -= len(m.PreviousChannelId) - copy(dAtA[i:], m.PreviousChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PreviousChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa - } + dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *MsgChannelOpenTryResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgAcknowledgementResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2742,4948 +2285,420 @@ func (m *MsgChannelOpenTryResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgChannelOpenTryResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAcknowledgementResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgChannelOpenTryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAcknowledgementResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.Version) > 0 { - i -= len(m.Version) - copy(dAtA[i:], m.Version) - i = encodeVarintTx(dAtA, i, uint64(len(m.Version))) + if m.Result != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Result)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *MsgChannelOpenAck) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ } - return dAtA[:n], nil -} - -func (m *MsgChannelOpenAck) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + dAtA[offset] = uint8(v) + return base } - -func (m *MsgChannelOpenAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *MsgChannelOpenInit) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x3a - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - if len(m.ProofTry) > 0 { - i -= len(m.ProofTry) - copy(dAtA[i:], m.ProofTry) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofTry))) - i-- - dAtA[i] = 0x2a - } - if len(m.CounterpartyVersion) > 0 { - i -= len(m.CounterpartyVersion) - copy(dAtA[i:], m.CounterpartyVersion) - i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyVersion))) - i-- - dAtA[i] = 0x22 - } - if len(m.CounterpartyChannelId) > 0 { - i -= len(m.CounterpartyChannelId) - copy(dAtA[i:], m.CounterpartyChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyChannelId))) - i-- - dAtA[i] = 0x1a - } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa + l = m.Channel.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - return len(dAtA) - i, nil + return n } -func (m *MsgChannelOpenAckResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgChannelOpenInitResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *MsgChannelOpenAckResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelOpenAckResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - return len(dAtA) - i, nil -} - -func (m *MsgChannelOpenConfirm) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - return dAtA[:n], nil -} - -func (m *MsgChannelOpenConfirm) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + l = len(m.Version) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n } -func (m *MsgChannelOpenConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *MsgChannelOpenTry) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x2a + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + l = len(m.PreviousChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - i-- - dAtA[i] = 0x22 - if len(m.ProofAck) > 0 { - i -= len(m.ProofAck) - copy(dAtA[i:], m.ProofAck) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofAck))) - i-- - dAtA[i] = 0x1a + l = m.Channel.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.CounterpartyVersion) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 + l = len(m.ProofInit) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa + l = m.ProofHeight.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - return len(dAtA) - i, nil + return n } -func (m *MsgChannelOpenConfirmResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgChannelOpenTryResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *MsgChannelOpenConfirmResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelOpenConfirmResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - return len(dAtA) - i, nil -} - -func (m *MsgChannelCloseInit) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + l = len(m.Version) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - return dAtA[:n], nil -} - -func (m *MsgChannelCloseInit) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n } -func (m *MsgChannelCloseInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *MsgChannelOpenAck) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x1a + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa + l = len(m.CounterpartyChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - return len(dAtA) - i, nil + l = len(m.CounterpartyVersion) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ProofTry) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.ProofHeight.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n } -func (m *MsgChannelCloseInitResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgChannelOpenAckResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil + var l int + _ = l + return n } -func (m *MsgChannelCloseInitResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *MsgChannelOpenConfirm) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ProofAck) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.ProofHeight.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n } -func (m *MsgChannelCloseInitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *MsgChannelOpenConfirmResponse) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - return len(dAtA) - i, nil + return n } -func (m *MsgChannelCloseConfirm) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgChannelCloseInit) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil + var l int + _ = l + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n } -func (m *MsgChannelCloseConfirm) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *MsgChannelCloseInitResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n } -func (m *MsgChannelCloseConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *MsgChannelCloseConfirm) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if m.CounterpartyUpgradeSequence != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.CounterpartyUpgradeSequence)) - i-- - dAtA[i] = 0x30 + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x2a + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if len(m.ProofInit) > 0 { - i -= len(m.ProofInit) - copy(dAtA[i:], m.ProofInit) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofInit))) - i-- - dAtA[i] = 0x1a - } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 + l = len(m.ProofInit) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa + l = m.ProofHeight.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - return len(dAtA) - i, nil + return n } -func (m *MsgChannelCloseConfirmResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgChannelCloseConfirmResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *MsgChannelCloseConfirmResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelCloseConfirmResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - return len(dAtA) - i, nil + return n } -func (m *MsgRecvPacket) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgRecvPacket) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *MsgRecvPacket) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRecvPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x22 - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.ProofCommitment) > 0 { - i -= len(m.ProofCommitment) - copy(dAtA[i:], m.ProofCommitment) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofCommitment))) - i-- - dAtA[i] = 0x12 + l = m.Packet.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.ProofCommitment) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - { - size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + l = m.ProofHeight.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil + return n } -func (m *MsgRecvPacketResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgRecvPacketResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *MsgRecvPacketResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRecvPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l if m.Result != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Result)) - i-- - dAtA[i] = 0x8 + n += 1 + sovTx(uint64(m.Result)) } - return len(dAtA) - i, nil + return n } -func (m *MsgTimeout) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgTimeout) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *MsgTimeout) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x2a + l = m.Packet.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.ProofUnreceived) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } + l = m.ProofHeight.Size() + n += 1 + l + sovTx(uint64(l)) if m.NextSequenceRecv != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.NextSequenceRecv)) - i-- - dAtA[i] = 0x20 - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.ProofUnreceived) > 0 { - i -= len(m.ProofUnreceived) - copy(dAtA[i:], m.ProofUnreceived) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUnreceived))) - i-- - dAtA[i] = 0x12 + n += 1 + sovTx(uint64(m.NextSequenceRecv)) } - { - size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil + return n } -func (m *MsgTimeoutResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgTimeoutResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *MsgTimeoutResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgTimeoutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l if m.Result != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Result)) - i-- - dAtA[i] = 0x8 + n += 1 + sovTx(uint64(m.Result)) } - return len(dAtA) - i, nil + return n } -func (m *MsgTimeoutOnClose) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgTimeoutOnClose) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *MsgTimeoutOnClose) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgTimeoutOnClose) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - if m.CounterpartyUpgradeSequence != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.CounterpartyUpgradeSequence)) - i-- - dAtA[i] = 0x38 + l = m.Packet.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.ProofUnreceived) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x32 + l = len(m.ProofClose) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } + l = m.ProofHeight.Size() + n += 1 + l + sovTx(uint64(l)) if m.NextSequenceRecv != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.NextSequenceRecv)) - i-- - dAtA[i] = 0x28 - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if len(m.ProofClose) > 0 { - i -= len(m.ProofClose) - copy(dAtA[i:], m.ProofClose) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofClose))) - i-- - dAtA[i] = 0x1a - } - if len(m.ProofUnreceived) > 0 { - i -= len(m.ProofUnreceived) - copy(dAtA[i:], m.ProofUnreceived) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUnreceived))) - i-- - dAtA[i] = 0x12 + n += 1 + sovTx(uint64(m.NextSequenceRecv)) } - { - size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil + return n } -func (m *MsgTimeoutOnCloseResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgTimeoutOnCloseResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *MsgTimeoutOnCloseResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgTimeoutOnCloseResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l if m.Result != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Result)) - i-- - dAtA[i] = 0x8 + n += 1 + sovTx(uint64(m.Result)) } - return len(dAtA) - i, nil + return n } -func (m *MsgAcknowledgement) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgAcknowledgement) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *MsgAcknowledgement) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x2a - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if len(m.ProofAcked) > 0 { - i -= len(m.ProofAcked) - copy(dAtA[i:], m.ProofAcked) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofAcked))) - i-- - dAtA[i] = 0x1a + l = m.Packet.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Acknowledgement) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - if len(m.Acknowledgement) > 0 { - i -= len(m.Acknowledgement) - copy(dAtA[i:], m.Acknowledgement) - i = encodeVarintTx(dAtA, i, uint64(len(m.Acknowledgement))) - i-- - dAtA[i] = 0x12 + l = len(m.ProofAcked) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - { - size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + l = m.ProofHeight.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil + return n } -func (m *MsgAcknowledgementResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgAcknowledgementResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *MsgAcknowledgementResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgAcknowledgementResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l if m.Result != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Result)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeInit) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgChannelUpgradeInit) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelUpgradeInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x22 - } - { - size, err := m.Fields.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeInitResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + n += 1 + sovTx(uint64(m.Result)) } - return dAtA[:n], nil + return n } -func (m *MsgChannelUpgradeInitResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 } - -func (m *MsgChannelUpgradeInitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.UpgradeSequence != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.UpgradeSequence)) - i-- - dAtA[i] = 0x10 - } - { - size, err := m.Upgrade.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeTry) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgChannelUpgradeTry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelUpgradeTry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x4a - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - if len(m.ProofUpgrade) > 0 { - i -= len(m.ProofUpgrade) - copy(dAtA[i:], m.ProofUpgrade) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUpgrade))) - i-- - dAtA[i] = 0x3a - } - if len(m.ProofChannel) > 0 { - i -= len(m.ProofChannel) - copy(dAtA[i:], m.ProofChannel) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofChannel))) - i-- - dAtA[i] = 0x32 - } - if m.CounterpartyUpgradeSequence != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.CounterpartyUpgradeSequence)) - i-- - dAtA[i] = 0x28 - } - { - size, err := m.CounterpartyUpgradeFields.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if len(m.ProposedUpgradeConnectionHops) > 0 { - for iNdEx := len(m.ProposedUpgradeConnectionHops) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.ProposedUpgradeConnectionHops[iNdEx]) - copy(dAtA[i:], m.ProposedUpgradeConnectionHops[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProposedUpgradeConnectionHops[iNdEx]))) - i-- - dAtA[i] = 0x1a - } - } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeTryResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgChannelUpgradeTryResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelUpgradeTryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Result != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Result)) - i-- - dAtA[i] = 0x18 - } - if m.UpgradeSequence != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.UpgradeSequence)) - i-- - dAtA[i] = 0x10 - } - { - size, err := m.Upgrade.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeAck) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgChannelUpgradeAck) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelUpgradeAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x3a - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - if len(m.ProofUpgrade) > 0 { - i -= len(m.ProofUpgrade) - copy(dAtA[i:], m.ProofUpgrade) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUpgrade))) - i-- - dAtA[i] = 0x2a - } - if len(m.ProofChannel) > 0 { - i -= len(m.ProofChannel) - copy(dAtA[i:], m.ProofChannel) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofChannel))) - i-- - dAtA[i] = 0x22 - } - { - size, err := m.CounterpartyUpgrade.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeAckResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgChannelUpgradeAckResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelUpgradeAckResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Result != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Result)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeConfirm) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgChannelUpgradeConfirm) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelUpgradeConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x42 - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - if len(m.ProofUpgrade) > 0 { - i -= len(m.ProofUpgrade) - copy(dAtA[i:], m.ProofUpgrade) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUpgrade))) - i-- - dAtA[i] = 0x32 - } - if len(m.ProofChannel) > 0 { - i -= len(m.ProofChannel) - copy(dAtA[i:], m.ProofChannel) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofChannel))) - i-- - dAtA[i] = 0x2a - } - { - size, err := m.CounterpartyUpgrade.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if m.CounterpartyChannelState != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.CounterpartyChannelState)) - i-- - dAtA[i] = 0x18 - } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeConfirmResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgChannelUpgradeConfirmResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelUpgradeConfirmResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Result != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Result)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeOpen) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgChannelUpgradeOpen) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelUpgradeOpen) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x3a - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - if len(m.ProofChannel) > 0 { - i -= len(m.ProofChannel) - copy(dAtA[i:], m.ProofChannel) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofChannel))) - i-- - dAtA[i] = 0x2a - } - if m.CounterpartyUpgradeSequence != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.CounterpartyUpgradeSequence)) - i-- - dAtA[i] = 0x20 - } - if m.CounterpartyChannelState != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.CounterpartyChannelState)) - i-- - dAtA[i] = 0x18 - } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeOpenResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgChannelUpgradeOpenResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelUpgradeOpenResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeTimeout) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgChannelUpgradeTimeout) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelUpgradeTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x32 - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if len(m.ProofChannel) > 0 { - i -= len(m.ProofChannel) - copy(dAtA[i:], m.ProofChannel) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofChannel))) - i-- - dAtA[i] = 0x22 - } - { - size, err := m.CounterpartyChannel.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeTimeoutResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgChannelUpgradeTimeoutResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelUpgradeTimeoutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeCancel) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgChannelUpgradeCancel) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelUpgradeCancel) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x32 - } - { - size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if len(m.ProofErrorReceipt) > 0 { - i -= len(m.ProofErrorReceipt) - copy(dAtA[i:], m.ProofErrorReceipt) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProofErrorReceipt))) - i-- - dAtA[i] = 0x22 - } - { - size, err := m.ErrorReceipt.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgChannelUpgradeCancelResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgChannelUpgradeCancelResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgChannelUpgradeCancelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgPruneAcknowledgements) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgPruneAcknowledgements) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgPruneAcknowledgements) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x22 - } - if m.Limit != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Limit)) - i-- - dAtA[i] = 0x18 - } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) - i-- - dAtA[i] = 0x12 - } - if len(m.PortId) > 0 { - i -= len(m.PortId) - copy(dAtA[i:], m.PortId) - i = encodeVarintTx(dAtA, i, uint64(len(m.PortId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgPruneAcknowledgementsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgPruneAcknowledgementsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgPruneAcknowledgementsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.TotalRemainingSequences != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.TotalRemainingSequences)) - i-- - dAtA[i] = 0x10 - } - if m.TotalPrunedSequences != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.TotalPrunedSequences)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgChannelOpenInit) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Channel.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelOpenInitResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Version) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelOpenTry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.PreviousChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Channel.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.CounterpartyVersion) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ProofInit) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelOpenTryResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Version) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelOpenAck) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.CounterpartyChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.CounterpartyVersion) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ProofTry) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelOpenAckResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgChannelOpenConfirm) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ProofAck) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelOpenConfirmResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgChannelCloseInit) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelCloseInitResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgChannelCloseConfirm) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ProofInit) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.CounterpartyUpgradeSequence != 0 { - n += 1 + sovTx(uint64(m.CounterpartyUpgradeSequence)) - } - return n -} - -func (m *MsgChannelCloseConfirmResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgRecvPacket) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Packet.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.ProofCommitment) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgRecvPacketResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Result != 0 { - n += 1 + sovTx(uint64(m.Result)) - } - return n -} - -func (m *MsgTimeout) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Packet.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.ProofUnreceived) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - if m.NextSequenceRecv != 0 { - n += 1 + sovTx(uint64(m.NextSequenceRecv)) - } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgTimeoutResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Result != 0 { - n += 1 + sovTx(uint64(m.Result)) - } - return n -} - -func (m *MsgTimeoutOnClose) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Packet.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.ProofUnreceived) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ProofClose) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - if m.NextSequenceRecv != 0 { - n += 1 + sovTx(uint64(m.NextSequenceRecv)) - } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.CounterpartyUpgradeSequence != 0 { - n += 1 + sovTx(uint64(m.CounterpartyUpgradeSequence)) - } - return n -} - -func (m *MsgTimeoutOnCloseResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Result != 0 { - n += 1 + sovTx(uint64(m.Result)) - } - return n -} - -func (m *MsgAcknowledgement) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Packet.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Acknowledgement) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ProofAcked) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgAcknowledgementResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Result != 0 { - n += 1 + sovTx(uint64(m.Result)) - } - return n -} - -func (m *MsgChannelUpgradeInit) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Fields.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelUpgradeInitResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Upgrade.Size() - n += 1 + l + sovTx(uint64(l)) - if m.UpgradeSequence != 0 { - n += 1 + sovTx(uint64(m.UpgradeSequence)) - } - return n -} - -func (m *MsgChannelUpgradeTry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.ProposedUpgradeConnectionHops) > 0 { - for _, s := range m.ProposedUpgradeConnectionHops { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - l = m.CounterpartyUpgradeFields.Size() - n += 1 + l + sovTx(uint64(l)) - if m.CounterpartyUpgradeSequence != 0 { - n += 1 + sovTx(uint64(m.CounterpartyUpgradeSequence)) - } - l = len(m.ProofChannel) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ProofUpgrade) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelUpgradeTryResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Upgrade.Size() - n += 1 + l + sovTx(uint64(l)) - if m.UpgradeSequence != 0 { - n += 1 + sovTx(uint64(m.UpgradeSequence)) - } - if m.Result != 0 { - n += 1 + sovTx(uint64(m.Result)) - } - return n -} - -func (m *MsgChannelUpgradeAck) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.CounterpartyUpgrade.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.ProofChannel) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ProofUpgrade) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelUpgradeAckResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Result != 0 { - n += 1 + sovTx(uint64(m.Result)) - } - return n -} - -func (m *MsgChannelUpgradeConfirm) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.CounterpartyChannelState != 0 { - n += 1 + sovTx(uint64(m.CounterpartyChannelState)) - } - l = m.CounterpartyUpgrade.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.ProofChannel) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ProofUpgrade) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelUpgradeConfirmResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Result != 0 { - n += 1 + sovTx(uint64(m.Result)) - } - return n -} - -func (m *MsgChannelUpgradeOpen) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.CounterpartyChannelState != 0 { - n += 1 + sovTx(uint64(m.CounterpartyChannelState)) - } - if m.CounterpartyUpgradeSequence != 0 { - n += 1 + sovTx(uint64(m.CounterpartyUpgradeSequence)) - } - l = len(m.ProofChannel) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelUpgradeOpenResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgChannelUpgradeTimeout) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.CounterpartyChannel.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.ProofChannel) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelUpgradeTimeoutResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgChannelUpgradeCancel) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ErrorReceipt.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.ProofErrorReceipt) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.ProofHeight.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgChannelUpgradeCancelResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgUpdateParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Params.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgUpdateParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgPruneAcknowledgements) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PortId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChannelId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Limit != 0 { - n += 1 + sovTx(uint64(m.Limit)) - } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgPruneAcknowledgementsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.TotalPrunedSequences != 0 { - n += 1 + sovTx(uint64(m.TotalPrunedSequences)) - } - if m.TotalRemainingSequences != 0 { - n += 1 + sovTx(uint64(m.TotalRemainingSequences)) - } - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgChannelOpenInit) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgChannelOpenInit: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelOpenInit: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PortId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Channel", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Channel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgChannelOpenInitResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgChannelOpenInitResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelOpenInitResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Version = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgChannelOpenTry) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgChannelOpenTry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelOpenTry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PortId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PreviousChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PreviousChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Channel", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Channel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyVersion", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CounterpartyVersion = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofInit", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofInit = append(m.ProofInit[:0], dAtA[iNdEx:postIndex]...) - if m.ProofInit == nil { - m.ProofInit = []byte{} - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgChannelOpenTryResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgChannelOpenTryResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelOpenTryResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Version = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgChannelOpenAck) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgChannelOpenAck: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelOpenAck: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PortId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyVersion", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CounterpartyVersion = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofTry", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofTry = append(m.ProofTry[:0], dAtA[iNdEx:postIndex]...) - if m.ProofTry == nil { - m.ProofTry = []byte{} - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgChannelOpenAckResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgChannelOpenAckResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelOpenAckResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgChannelOpenConfirm) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgChannelOpenConfirm: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelOpenConfirm: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PortId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofAck", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofAck = append(m.ProofAck[:0], dAtA[iNdEx:postIndex]...) - if m.ProofAck == nil { - m.ProofAck = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgChannelOpenConfirmResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgChannelOpenConfirmResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelOpenConfirmResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgChannelCloseInit) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgChannelCloseInit: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelCloseInit: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PortId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgChannelCloseInitResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgChannelCloseInitResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelCloseInitResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgChannelCloseConfirm) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgChannelCloseConfirm: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelCloseConfirm: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PortId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofInit", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofInit = append(m.ProofInit[:0], dAtA[iNdEx:postIndex]...) - if m.ProofInit == nil { - m.ProofInit = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyUpgradeSequence", wireType) - } - m.CounterpartyUpgradeSequence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CounterpartyUpgradeSequence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgChannelCloseConfirmResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgChannelCloseConfirmResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelCloseConfirmResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgRecvPacket) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgRecvPacket: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRecvPacket: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofCommitment", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofCommitment = append(m.ProofCommitment[:0], dAtA[iNdEx:postIndex]...) - if m.ProofCommitment == nil { - m.ProofCommitment = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgRecvPacketResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgRecvPacketResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRecvPacketResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) - } - m.Result = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Result |= ResponseResultType(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgTimeout) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgTimeout: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgTimeout: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofUnreceived", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofUnreceived = append(m.ProofUnreceived[:0], dAtA[iNdEx:postIndex]...) - if m.ProofUnreceived == nil { - m.ProofUnreceived = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NextSequenceRecv", wireType) - } - m.NextSequenceRecv = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NextSequenceRecv |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgTimeoutResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgTimeoutResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgTimeoutResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) - } - m.Result = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Result |= ResponseResultType(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgTimeoutOnClose) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgTimeoutOnClose: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgTimeoutOnClose: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofUnreceived", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofUnreceived = append(m.ProofUnreceived[:0], dAtA[iNdEx:postIndex]...) - if m.ProofUnreceived == nil { - m.ProofUnreceived = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofClose", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofClose = append(m.ProofClose[:0], dAtA[iNdEx:postIndex]...) - if m.ProofClose == nil { - m.ProofClose = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NextSequenceRecv", wireType) - } - m.NextSequenceRecv = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NextSequenceRecv |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyUpgradeSequence", wireType) - } - m.CounterpartyUpgradeSequence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CounterpartyUpgradeSequence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgTimeoutOnCloseResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgTimeoutOnCloseResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgTimeoutOnCloseResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) - } - m.Result = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Result |= ResponseResultType(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { +func (m *MsgChannelOpenInit) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7706,17 +2721,17 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAcknowledgement: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChannelOpenInit: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAcknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChannelOpenInit: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -7726,96 +2741,27 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.PortId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Acknowledgement", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Acknowledgement = append(m.Acknowledgement[:0], dAtA[iNdEx:postIndex]...) - if m.Acknowledgement == nil { - m.Acknowledgement = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofAcked", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofAcked = append(m.ProofAcked[:0], dAtA[iNdEx:postIndex]...) - if m.ProofAcked == nil { - m.ProofAcked = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Channel", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -7842,11 +2788,11 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Channel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 5: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -7899,7 +2845,7 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgAcknowledgementResponse) Unmarshal(dAtA []byte) error { +func (m *MsgChannelOpenInitResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7922,17 +2868,17 @@ func (m *MsgAcknowledgementResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAcknowledgementResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChannelOpenInitResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAcknowledgementResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChannelOpenInitResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) } - m.Result = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -7942,11 +2888,56 @@ func (m *MsgAcknowledgementResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Result |= ResponseResultType(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -7968,7 +2959,7 @@ func (m *MsgAcknowledgementResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeInit) Unmarshal(dAtA []byte) error { +func (m *MsgChannelOpenTry) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7991,10 +2982,10 @@ func (m *MsgChannelUpgradeInit) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeInit: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChannelOpenTry: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeInit: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChannelOpenTry: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -8031,7 +3022,72 @@ func (m *MsgChannelUpgradeInit) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PreviousChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PreviousChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Channel", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Channel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyVersion", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -8043,27 +3099,61 @@ func (m *MsgChannelUpgradeInit) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyVersion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofInit", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ProofInit = append(m.ProofInit[:0], dAtA[iNdEx:postIndex]...) + if m.ProofInit == nil { + m.ProofInit = []byte{} + } iNdEx = postIndex - case 3: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Fields", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -8090,11 +3180,11 @@ func (m *MsgChannelUpgradeInit) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Fields.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 4: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -8147,7 +3237,7 @@ func (m *MsgChannelUpgradeInit) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeInitResponse) Unmarshal(dAtA []byte) error { +func (m *MsgChannelOpenTryResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8170,17 +3260,17 @@ func (m *MsgChannelUpgradeInitResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeInitResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChannelOpenTryResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeInitResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChannelOpenTryResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Upgrade", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -8190,30 +3280,29 @@ func (m *MsgChannelUpgradeInitResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Upgrade.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Version = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UpgradeSequence", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) } - m.UpgradeSequence = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -8223,11 +3312,24 @@ func (m *MsgChannelUpgradeInitResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.UpgradeSequence |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -8249,7 +3351,7 @@ func (m *MsgChannelUpgradeInitResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeTry) Unmarshal(dAtA []byte) error { +func (m *MsgChannelOpenAck) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8272,10 +3374,10 @@ func (m *MsgChannelUpgradeTry) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeTry: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChannelOpenAck: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeTry: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChannelOpenAck: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -8344,7 +3446,7 @@ func (m *MsgChannelUpgradeTry) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposedUpgradeConnectionHops", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannelId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -8372,13 +3474,13 @@ func (m *MsgChannelUpgradeTry) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProposedUpgradeConnectionHops = append(m.ProposedUpgradeConnectionHops, string(dAtA[iNdEx:postIndex])) + m.CounterpartyChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyUpgradeFields", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyVersion", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -8388,81 +3490,27 @@ func (m *MsgChannelUpgradeTry) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.CounterpartyUpgradeFields.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.CounterpartyVersion = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyUpgradeSequence", wireType) - } - m.CounterpartyUpgradeSequence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CounterpartyUpgradeSequence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofChannel", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofChannel = append(m.ProofChannel[:0], dAtA[iNdEx:postIndex]...) - if m.ProofChannel == nil { - m.ProofChannel = []byte{} - } - iNdEx = postIndex - case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofUpgrade", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofTry", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -8489,12 +3537,12 @@ func (m *MsgChannelUpgradeTry) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProofUpgrade = append(m.ProofUpgrade[:0], dAtA[iNdEx:postIndex]...) - if m.ProofUpgrade == nil { - m.ProofUpgrade = []byte{} + m.ProofTry = append(m.ProofTry[:0], dAtA[iNdEx:postIndex]...) + if m.ProofTry == nil { + m.ProofTry = []byte{} } iNdEx = postIndex - case 8: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } @@ -8527,7 +3575,7 @@ func (m *MsgChannelUpgradeTry) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -8580,7 +3628,7 @@ func (m *MsgChannelUpgradeTry) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeTryResponse) Unmarshal(dAtA []byte) error { +func (m *MsgChannelOpenAckResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8603,83 +3651,12 @@ func (m *MsgChannelUpgradeTryResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeTryResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChannelOpenAckResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeTryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChannelOpenAckResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Upgrade", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Upgrade.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UpgradeSequence", wireType) - } - m.UpgradeSequence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UpgradeSequence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) - } - m.Result = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Result |= ResponseResultType(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -8701,7 +3678,7 @@ func (m *MsgChannelUpgradeTryResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeAck) Unmarshal(dAtA []byte) error { +func (m *MsgChannelOpenConfirm) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8724,10 +3701,10 @@ func (m *MsgChannelUpgradeAck) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeAck: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChannelOpenConfirm: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeAck: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChannelOpenConfirm: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -8794,76 +3771,9 @@ func (m *MsgChannelUpgradeAck) Unmarshal(dAtA []byte) error { } m.ChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyUpgrade", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CounterpartyUpgrade.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofChannel", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofChannel = append(m.ProofChannel[:0], dAtA[iNdEx:postIndex]...) - if m.ProofChannel == nil { - m.ProofChannel = []byte{} - } - iNdEx = postIndex - case 5: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofUpgrade", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofAck", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -8890,12 +3800,12 @@ func (m *MsgChannelUpgradeAck) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProofUpgrade = append(m.ProofUpgrade[:0], dAtA[iNdEx:postIndex]...) - if m.ProofUpgrade == nil { - m.ProofUpgrade = []byte{} + m.ProofAck = append(m.ProofAck[:0], dAtA[iNdEx:postIndex]...) + if m.ProofAck == nil { + m.ProofAck = []byte{} } iNdEx = postIndex - case 6: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } @@ -8928,7 +3838,7 @@ func (m *MsgChannelUpgradeAck) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -8981,7 +3891,7 @@ func (m *MsgChannelUpgradeAck) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeAckResponse) Unmarshal(dAtA []byte) error { +func (m *MsgChannelOpenConfirmResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9004,31 +3914,12 @@ func (m *MsgChannelUpgradeAckResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeAckResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChannelOpenConfirmResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeAckResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChannelOpenConfirmResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) - } - m.Result = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Result |= ResponseResultType(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -9050,7 +3941,7 @@ func (m *MsgChannelUpgradeAckResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeConfirm) Unmarshal(dAtA []byte) error { +func (m *MsgChannelCloseInit) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9073,10 +3964,10 @@ func (m *MsgChannelUpgradeConfirm) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeConfirm: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChannelCloseInit: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeConfirm: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChannelCloseInit: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -9144,10 +4035,10 @@ func (m *MsgChannelUpgradeConfirm) Unmarshal(dAtA []byte) error { m.ChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannelState", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } - m.CounterpartyChannelState = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -9157,16 +4048,129 @@ func (m *MsgChannelUpgradeConfirm) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CounterpartyChannelState |= State(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 4: + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgChannelCloseInitResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgChannelCloseInitResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgChannelCloseInitResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgChannelCloseConfirm) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgChannelCloseConfirm: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgChannelCloseConfirm: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyUpgrade", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -9176,30 +4180,29 @@ func (m *MsgChannelUpgradeConfirm) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.CounterpartyUpgrade.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.PortId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofChannel", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -9209,29 +4212,27 @@ func (m *MsgChannelUpgradeConfirm) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.ProofChannel = append(m.ProofChannel[:0], dAtA[iNdEx:postIndex]...) - if m.ProofChannel == nil { - m.ProofChannel = []byte{} - } + m.ChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofUpgrade", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofInit", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -9258,12 +4259,12 @@ func (m *MsgChannelUpgradeConfirm) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProofUpgrade = append(m.ProofUpgrade[:0], dAtA[iNdEx:postIndex]...) - if m.ProofUpgrade == nil { - m.ProofUpgrade = []byte{} + m.ProofInit = append(m.ProofInit[:0], dAtA[iNdEx:postIndex]...) + if m.ProofInit == nil { + m.ProofInit = []byte{} } iNdEx = postIndex - case 7: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } @@ -9296,7 +4297,7 @@ func (m *MsgChannelUpgradeConfirm) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -9349,7 +4350,7 @@ func (m *MsgChannelUpgradeConfirm) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeConfirmResponse) Unmarshal(dAtA []byte) error { +func (m *MsgChannelCloseConfirmResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9372,31 +4373,12 @@ func (m *MsgChannelUpgradeConfirmResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeConfirmResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChannelCloseConfirmResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeConfirmResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChannelCloseConfirmResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) - } - m.Result = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Result |= ResponseResultType(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -9418,7 +4400,7 @@ func (m *MsgChannelUpgradeConfirmResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeOpen) Unmarshal(dAtA []byte) error { +func (m *MsgRecvPacket) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9435,55 +4417,23 @@ func (m *MsgChannelUpgradeOpen) Unmarshal(dAtA []byte) error { iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeOpen: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeOpen: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PortId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRecvPacket: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRecvPacket: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -9493,65 +4443,28 @@ func (m *MsgChannelUpgradeOpen) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannelState", wireType) - } - m.CounterpartyChannelState = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CounterpartyChannelState |= State(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyUpgradeSequence", wireType) - } - m.CounterpartyUpgradeSequence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CounterpartyUpgradeSequence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - case 5: + iNdEx = postIndex + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofChannel", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofCommitment", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -9578,12 +4491,12 @@ func (m *MsgChannelUpgradeOpen) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProofChannel = append(m.ProofChannel[:0], dAtA[iNdEx:postIndex]...) - if m.ProofChannel == nil { - m.ProofChannel = []byte{} + m.ProofCommitment = append(m.ProofCommitment[:0], dAtA[iNdEx:postIndex]...) + if m.ProofCommitment == nil { + m.ProofCommitment = []byte{} } iNdEx = postIndex - case 6: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } @@ -9616,7 +4529,7 @@ func (m *MsgChannelUpgradeOpen) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -9669,7 +4582,7 @@ func (m *MsgChannelUpgradeOpen) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeOpenResponse) Unmarshal(dAtA []byte) error { +func (m *MsgRecvPacketResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9692,12 +4605,31 @@ func (m *MsgChannelUpgradeOpenResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeOpenResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRecvPacketResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeOpenResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRecvPacketResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + m.Result = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Result |= ResponseResultType(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -9719,7 +4651,7 @@ func (m *MsgChannelUpgradeOpenResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeTimeout) Unmarshal(dAtA []byte) error { +func (m *MsgTimeout) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9742,17 +4674,17 @@ func (m *MsgChannelUpgradeTimeout) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeTimeout: wiretype end group for non-group") + return fmt.Errorf("proto: MsgTimeout: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeTimeout: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgTimeout: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -9762,29 +4694,30 @@ func (m *MsgChannelUpgradeTimeout) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.PortId = string(dAtA[iNdEx:postIndex]) + if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofUnreceived", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -9794,27 +4727,29 @@ func (m *MsgChannelUpgradeTimeout) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ProofUnreceived = append(m.ProofUnreceived[:0], dAtA[iNdEx:postIndex]...) + if m.ProofUnreceived == nil { + m.ProofUnreceived = []byte{} + } iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyChannel", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -9841,15 +4776,15 @@ func (m *MsgChannelUpgradeTimeout) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.CounterpartyChannel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofChannel", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextSequenceRecv", wireType) } - var byteLen int + m.NextSequenceRecv = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -9859,60 +4794,12 @@ func (m *MsgChannelUpgradeTimeout) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + m.NextSequenceRecv |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofChannel = append(m.ProofChannel[:0], dAtA[iNdEx:postIndex]...) - if m.ProofChannel == nil { - m.ProofChannel = []byte{} - } - iNdEx = postIndex case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -9965,7 +4852,7 @@ func (m *MsgChannelUpgradeTimeout) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeTimeoutResponse) Unmarshal(dAtA []byte) error { +func (m *MsgTimeoutResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9988,12 +4875,31 @@ func (m *MsgChannelUpgradeTimeoutResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeTimeoutResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgTimeoutResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeTimeoutResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgTimeoutResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + m.Result = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Result |= ResponseResultType(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -10015,7 +4921,7 @@ func (m *MsgChannelUpgradeTimeoutResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeCancel) Unmarshal(dAtA []byte) error { +func (m *MsgTimeoutOnClose) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -10038,17 +4944,17 @@ func (m *MsgChannelUpgradeCancel) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeCancel: wiretype end group for non-group") + return fmt.Errorf("proto: MsgTimeoutOnClose: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeCancel: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgTimeoutOnClose: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -10058,61 +4964,30 @@ func (m *MsgChannelUpgradeCancel) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.PortId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF + if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - m.ChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ErrorReceipt", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofUnreceived", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -10122,28 +4997,29 @@ func (m *MsgChannelUpgradeCancel) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ErrorReceipt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.ProofUnreceived = append(m.ProofUnreceived[:0], dAtA[iNdEx:postIndex]...) + if m.ProofUnreceived == nil { + m.ProofUnreceived = []byte{} } iNdEx = postIndex - case 4: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofErrorReceipt", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofClose", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -10170,12 +5046,12 @@ func (m *MsgChannelUpgradeCancel) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProofErrorReceipt = append(m.ProofErrorReceipt[:0], dAtA[iNdEx:postIndex]...) - if m.ProofErrorReceipt == nil { - m.ProofErrorReceipt = []byte{} + m.ProofClose = append(m.ProofClose[:0], dAtA[iNdEx:postIndex]...) + if m.ProofClose == nil { + m.ProofClose = []byte{} } iNdEx = postIndex - case 5: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } @@ -10208,6 +5084,25 @@ func (m *MsgChannelUpgradeCancel) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextSequenceRecv", wireType) + } + m.NextSequenceRecv = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextSequenceRecv |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) @@ -10261,7 +5156,7 @@ func (m *MsgChannelUpgradeCancel) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChannelUpgradeCancelResponse) Unmarshal(dAtA []byte) error { +func (m *MsgTimeoutOnCloseResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -10284,12 +5179,31 @@ func (m *MsgChannelUpgradeCancelResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChannelUpgradeCancelResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgTimeoutOnCloseResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChannelUpgradeCancelResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgTimeoutOnCloseResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + m.Result = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Result |= ResponseResultType(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -10311,7 +5225,7 @@ func (m *MsgChannelUpgradeCancelResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { +func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -10334,17 +5248,17 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAcknowledgement: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgAcknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -10354,29 +5268,30 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Authority = string(dAtA[iNdEx:postIndex]) + if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Acknowledgement", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -10386,130 +5301,31 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Acknowledgement = append(m.Acknowledgement[:0], dAtA[iNdEx:postIndex]...) + if m.Acknowledgement == nil { + m.Acknowledgement = []byte{} } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgPruneAcknowledgements) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgPruneAcknowledgements: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgPruneAcknowledgements: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofAcked", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -10519,29 +5335,31 @@ func (m *MsgPruneAcknowledgements) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.PortId = string(dAtA[iNdEx:postIndex]) + m.ProofAcked = append(m.ProofAcked[:0], dAtA[iNdEx:postIndex]...) + if m.ProofAcked == nil { + m.ProofAcked = []byte{} + } iNdEx = postIndex - case 2: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -10551,44 +5369,26 @@ func (m *MsgPruneAcknowledgements) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) - } - m.Limit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Limit |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + if err := m.ProofHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - case 4: + iNdEx = postIndex + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -10641,7 +5441,7 @@ func (m *MsgPruneAcknowledgements) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgPruneAcknowledgementsResponse) Unmarshal(dAtA []byte) error { +func (m *MsgAcknowledgementResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -10664,36 +5464,17 @@ func (m *MsgPruneAcknowledgementsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgPruneAcknowledgementsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAcknowledgementResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgPruneAcknowledgementsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgAcknowledgementResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalPrunedSequences", wireType) - } - m.TotalPrunedSequences = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TotalPrunedSequences |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalRemainingSequences", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) } - m.TotalRemainingSequences = 0 + m.Result = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -10703,7 +5484,7 @@ func (m *MsgPruneAcknowledgementsResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.TotalRemainingSequences |= uint64(b&0x7F) << shift + m.Result |= ResponseResultType(b&0x7F) << shift if b < 0x80 { break } diff --git a/modules/core/04-channel/types/upgrade.go b/modules/core/04-channel/types/upgrade.go deleted file mode 100644 index 72fa8af9ac5..00000000000 --- a/modules/core/04-channel/types/upgrade.go +++ /dev/null @@ -1,128 +0,0 @@ -package types - -import ( - "errors" - "fmt" - "slices" - "strings" - - errorsmod "cosmossdk.io/errors" - - connectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types" -) - -// NewUpgrade creates a new Upgrade instance. -func NewUpgrade(upgradeFields UpgradeFields, timeout Timeout, nextSequenceSend uint64) Upgrade { - return Upgrade{ - Fields: upgradeFields, - Timeout: timeout, - NextSequenceSend: nextSequenceSend, - } -} - -// NewUpgradeFields returns a new ModifiableUpgradeFields instance. -func NewUpgradeFields(ordering Order, connectionHops []string, version string) UpgradeFields { - return UpgradeFields{ - Ordering: ordering, - ConnectionHops: connectionHops, - Version: version, - } -} - -// ValidateBasic performs a basic validation of the upgrade fields -func (u Upgrade) ValidateBasic() error { - if err := u.Fields.ValidateBasic(); err != nil { - return errorsmod.Wrap(err, "proposed upgrade fields are invalid") - } - - if !u.Timeout.IsValid() { - return errorsmod.Wrap(ErrInvalidUpgrade, "upgrade timeout height and upgrade timeout timestamp cannot both be 0") - } - - return nil -} - -// ValidateBasic performs a basic validation of the proposed upgrade fields -func (uf UpgradeFields) ValidateBasic() error { - if !slices.Contains(connectiontypes.SupportedOrderings, uf.Ordering.String()) { - return errorsmod.Wrap(ErrInvalidChannelOrdering, uf.Ordering.String()) - } - - if len(uf.ConnectionHops) != 1 { - return errorsmod.Wrap(ErrTooManyConnectionHops, "current IBC version only supports one connection hop") - } - - if strings.TrimSpace(uf.Version) == "" { - return errorsmod.Wrap(ErrInvalidChannelVersion, "version cannot be empty") - } - - return nil -} - -// UpgradeError defines an error that occurs during an upgrade. -type UpgradeError struct { - // err is the underlying error that caused the upgrade to fail. - // this error should not be written to state. - err error - // sequence is the upgrade sequence number of the upgrade that failed. - sequence uint64 -} - -var _ error = &UpgradeError{} - -// NewUpgradeError returns a new UpgradeError instance. -func NewUpgradeError(upgradeSequence uint64, err error) *UpgradeError { - return &UpgradeError{ - err: err, - sequence: upgradeSequence, - } -} - -// Error implements the error interface, returning the underlying error which caused the upgrade to fail. -func (u *UpgradeError) Error() string { - return u.err.Error() -} - -// Is returns true if the of the provided error is an upgrade error. -func (*UpgradeError) Is(err error) bool { - _, ok := err.(*UpgradeError) - return ok -} - -// Unwrap returns the next error in the error chain. -// If there is no next error, Unwrap returns nil. -func (u *UpgradeError) Unwrap() error { - return u.err -} - -// Cause implements the sdk error interface which uses this function to unwrap the error in various functions such as `wrappedError.Is()`. -// Cause returns the underlying error which caused the upgrade to fail. -func (u *UpgradeError) Cause() error { - baseError := u.err - for { - if err := errors.Unwrap(baseError); err != nil { - baseError = err - } else { - return baseError - } - } -} - -// GetErrorReceipt returns an error receipt with the code from the underlying error type stripped. -func (u *UpgradeError) GetErrorReceipt() ErrorReceipt { - // restoreErrorString defines a string constant included in error receipts. - // NOTE: Changing this const is state machine breaking as it is written into state. - const restoreErrorString = "restored channel to pre-upgrade state" - - _, code, _ := errorsmod.ABCIInfo(u, false) // discard non-deterministic codespace and log values - return ErrorReceipt{ - Sequence: u.sequence, - Message: fmt.Sprintf("ABCI code: %d: %s", code, restoreErrorString), - } -} - -// IsUpgradeError returns true if err is of type UpgradeError or contained -// in the error chain of err and false otherwise. -func IsUpgradeError(err error) bool { - return errors.Is(err, &UpgradeError{}) -} diff --git a/modules/core/04-channel/types/upgrade_test.go b/modules/core/04-channel/types/upgrade_test.go deleted file mode 100644 index b6b4dfe2d62..00000000000 --- a/modules/core/04-channel/types/upgrade_test.go +++ /dev/null @@ -1,262 +0,0 @@ -package types_test - -import ( - "errors" - "fmt" - - errorsmod "cosmossdk.io/errors" - - clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" - "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/v10/testing" - "github.com/cosmos/ibc-go/v10/testing/mock" -) - -func (suite *TypesTestSuite) TestUpgradeValidateBasic() { - var upgrade types.Upgrade - - testCases := []struct { - name string - malleate func() - expErr error - }{ - { - "success", - func() {}, - nil, - }, - { - "invalid ordering", - func() { - upgrade.Fields.Ordering = types.NONE - }, - types.ErrInvalidChannelOrdering, - }, - { - "connection hops length not equal to 1", - func() { - upgrade.Fields.ConnectionHops = []string{"connection-0", "connection-1"} - }, - types.ErrTooManyConnectionHops, - }, - { - "empty version", - func() { - upgrade.Fields.Version = " " - }, - types.ErrInvalidChannelVersion, - }, - { - "invalid timeout", - func() { - upgrade.Timeout.Height = clienttypes.ZeroHeight() - upgrade.Timeout.Timestamp = 0 - }, - types.ErrInvalidUpgrade, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - upgrade = types.NewUpgrade( - types.NewUpgradeFields(types.ORDERED, []string{ibctesting.FirstConnectionID}, mock.Version), - types.NewTimeout(clienttypes.NewHeight(0, 100), 0), - 0, - ) - - tc.malleate() - - err := upgrade.ValidateBasic() - - if tc.expErr == nil { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - suite.Require().ErrorIs(err, tc.expErr) - } - }) - } -} - -func (suite *TypesTestSuite) TestUpgradeErrorIsOf() { - var ( - upgradeError *types.UpgradeError - inputErr error - ) - - testCases := []struct { - msg string - malleate func() - expPass bool - }{ - { - msg: "standard sdk error", - malleate: func() {}, - expPass: true, - }, - { - msg: "input is upgrade error", - malleate: func() { - inputErr = types.NewUpgradeError(1, types.ErrInvalidChannel) - }, - expPass: true, - }, - { - msg: "input has wrapped upgrade error", - malleate: func() { - wrappedErr := errorsmod.Wrap(types.ErrInvalidChannel, "wrapped upgrade error") - inputErr = types.NewUpgradeError(1, wrappedErr) - }, - expPass: true, - }, - { - msg: "not equal to nil error", - malleate: func() { - upgradeError = &types.UpgradeError{} - }, - expPass: false, - }, - { - msg: "wrapped upgrade error", - malleate: func() { - wrappedErr := errorsmod.Wrap(upgradeError, "wrapped upgrade error") - upgradeError = types.NewUpgradeError(1, wrappedErr) - }, - expPass: true, - }, - { - msg: "empty upgrade and non nil target", - malleate: func() { - upgradeError = &types.UpgradeError{} - }, - expPass: false, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { - upgradeError = types.NewUpgradeError(1, types.ErrInvalidChannel) - inputErr = types.ErrInvalidChannel - - tc.malleate() - - res := errorsmod.IsOf(upgradeError, inputErr) - suite.Require().Equal(tc.expPass, res) - }) - } -} - -// TestGetErrorReceipt tests that the error receipt message is the same for both wrapped and unwrapped errors. -func (suite *TypesTestSuite) TestGetErrorReceipt() { - upgradeError := types.NewUpgradeError(1, types.ErrInvalidChannel) - - wrappedErr := errorsmod.Wrap(upgradeError, "wrapped upgrade error") - suite.Require().True(errorsmod.IsOf(wrappedErr, types.ErrInvalidChannel)) - - upgradeError2 := types.NewUpgradeError(1, wrappedErr) - - suite.Require().Equal(upgradeError2.GetErrorReceipt().Message, upgradeError.GetErrorReceipt().Message) -} - -// TestUpgradeErrorUnwrap tests that the underlying error is returned by Unwrap. -func (suite *TypesTestSuite) TestUpgradeErrorUnwrap() { - testCases := []struct { - msg string - upgradeError *types.UpgradeError - expError error - }{ - { - msg: "no underlying error", - upgradeError: types.NewUpgradeError(1, nil), - expError: nil, - }, - { - msg: "underlying error", - upgradeError: types.NewUpgradeError(1, types.ErrInvalidUpgrade), - expError: types.ErrInvalidUpgrade, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { - upgradeError := tc.upgradeError - err := upgradeError.Unwrap() - suite.Require().Equal(tc.expError, err) - }) - } -} - -func (suite *TypesTestSuite) TestIsUpgradeError() { - var err error - - testCases := []struct { - msg string - malleate func() - expPass bool - }{ - { - "true", - func() {}, - true, - }, - { - "true with wrapped upgrade err", - func() { - upgradeError := types.NewUpgradeError(1, types.ErrInvalidChannel) - err = errorsmod.Wrap(upgradeError, "wrapped upgrade error") - }, - true, - }, - { - "true with Errorf wrapped upgrade error", - func() { - err = fmt.Errorf("%w", types.NewUpgradeError(1, types.ErrInvalidChannel)) - }, - true, - }, - { - "true with nested Errorf wrapped upgrade error", - func() { - err = fmt.Errorf("%w", fmt.Errorf("%w", fmt.Errorf("%w", types.NewUpgradeError(1, types.ErrInvalidChannel)))) - }, - true, - }, - { - "false with non upgrade error", - func() { - err = errors.New("error") - }, - false, - }, - { - "false with wrapped non upgrade error", - func() { - randomErr := errors.New("error") - err = errorsmod.Wrap(randomErr, "wrapped random error") - }, - false, - }, - { - "false with nil error", - func() { - err = nil - }, - false, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { - err = types.NewUpgradeError(1, types.ErrInvalidChannel) - - tc.malleate() - - res := types.IsUpgradeError(err) - suite.Require().Equal(tc.expPass, res) - }) - } -} diff --git a/modules/core/05-port/types/module.go b/modules/core/05-port/types/module.go index 4baa22fe12b..c0a67981982 100644 --- a/modules/core/05-port/types/module.go +++ b/modules/core/05-port/types/module.go @@ -106,57 +106,6 @@ type IBCModule interface { ) error } -// UpgradableModule defines the callbacks required to perform a channel upgrade. -// Note: applications must ensure that state related to packet processing remains unmodified until the OnChanUpgradeOpen callback is executed. -// This guarantees that in-flight packets are correctly flushed using the existing channel parameters. -type UpgradableModule interface { - // OnChanUpgradeInit enables additional custom logic to be executed when the channel upgrade is initialized. - // It must validate the proposed version, order, and connection hops. - // NOTE: in the case of crossing hellos, this callback may be executed on both chains. - // NOTE: Any IBC application state changes made in this callback handler are not committed. - OnChanUpgradeInit( - ctx sdk.Context, - portID, channelID string, - proposedOrder channeltypes.Order, - proposedConnectionHops []string, - proposedVersion string, - ) (string, error) - - // OnChanUpgradeTry enables additional custom logic to be executed in the ChannelUpgradeTry step of the - // channel upgrade handshake. It must validate the proposed version (provided by the counterparty), order, - // and connection hops. - // NOTE: Any IBC application state changes made in this callback handler are not committed. - OnChanUpgradeTry( - ctx sdk.Context, - portID, channelID string, - proposedOrder channeltypes.Order, - proposedConnectionHops []string, - counterpartyVersion string, - ) (string, error) - - // OnChanUpgradeAck enables additional custom logic to be executed in the ChannelUpgradeAck step of the - // channel upgrade handshake. It must validate the version proposed by the counterparty. - // NOTE: Any IBC application state changes made in this callback handler are not committed. - OnChanUpgradeAck( - ctx sdk.Context, - portID, - channelID, - counterpartyVersion string, - ) error - - // OnChanUpgradeOpen enables additional custom logic to be executed when the channel upgrade has successfully completed, and the channel - // has returned to the OPEN state. Any logic associated with changing of the channel fields should be performed - // in this callback. - OnChanUpgradeOpen( - ctx sdk.Context, - portID, - channelID string, - proposedOrder channeltypes.Order, - proposedConnectionHops []string, - proposedVersion string, - ) -} - // ICS4Wrapper implements the ICS4 interfaces that IBC applications use to send packets and acknowledgements. type ICS4Wrapper interface { SendPacket( diff --git a/modules/core/24-host/channel_keys.go b/modules/core/24-host/channel_keys.go index b988601a870..40894ac776b 100644 --- a/modules/core/24-host/channel_keys.go +++ b/modules/core/24-host/channel_keys.go @@ -3,12 +3,8 @@ package host import "fmt" const ( - KeyChannelEndPrefix = "channelEnds" - KeyChannelPrefix = "channels" - KeyChannelUpgradePrefix = "channelUpgrades" - KeyUpgradePrefix = "upgrades" - KeyUpgradeErrorPrefix = "upgradeError" - KeyCounterpartyUpgrade = "counterpartyUpgrade" + KeyChannelEndPrefix = "channelEnds" + KeyChannelPrefix = "channels" ) // ICS04 @@ -19,21 +15,6 @@ func ChannelKey(portID, channelID string) []byte { return []byte(fmt.Sprintf("%s/%s", KeyChannelEndPrefix, channelPath(portID, channelID))) } -// ChannelUpgradeErrorKey returns the store key for a particular channelEnd used to stor the ErrorReceipt in the case that a chain does not accept the proposed upgrade -func ChannelUpgradeErrorKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", KeyChannelUpgradePrefix, KeyUpgradeErrorPrefix, channelPath(portID, channelID))) -} - -// ChannelUpgradeKey returns the store key for a particular channel upgrade attempt -func ChannelUpgradeKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", KeyChannelUpgradePrefix, KeyUpgradePrefix, channelPath(portID, channelID))) -} - -// ChannelCounterpartyUpgradeKey returns the store key for the upgrade used on the counterparty channel. -func ChannelCounterpartyUpgradeKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", KeyChannelUpgradePrefix, KeyCounterpartyUpgrade, channelPath(portID, channelID))) -} - func channelPath(portID, channelID string) string { return fmt.Sprintf("%s/%s/%s/%s", KeyPortPrefix, portID, KeyChannelPrefix, channelID) } diff --git a/modules/core/24-host/packet_keys.go b/modules/core/24-host/packet_keys.go index 55e7f024e41..1c9e513345d 100644 --- a/modules/core/24-host/packet_keys.go +++ b/modules/core/24-host/packet_keys.go @@ -10,7 +10,6 @@ const ( KeyPacketCommitmentPrefix = "commitments" KeyPacketAckPrefix = "acks" KeyPacketReceiptPrefix = "receipts" - KeyPruningSequenceStart = "pruningSequenceStart" KeyRecvStartSequence = "recvStartSequence" ) @@ -63,11 +62,6 @@ func PacketReceiptKey(portID, channelID string, sequence uint64) []byte { return []byte(fmt.Sprintf("%s/%s/%s", KeyPacketReceiptPrefix, channelPath(portID, channelID), sequencePath(sequence))) } -// PruningSequenceStartKey returns the store key for the pruning sequence start of a particular channel -func PruningSequenceStartKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s", KeyPruningSequenceStart, channelPath(portID, channelID))) -} - // RecvStartSequenceKey returns the store key for the recv start sequence of a particular channel func RecvStartSequenceKey(portID, channelID string) []byte { return []byte(fmt.Sprintf("%s/%s", KeyRecvStartSequence, channelPath(portID, channelID))) diff --git a/modules/core/ante/ante_test.go b/modules/core/ante/ante_test.go index a9668b155d6..b374847d182 100644 --- a/modules/core/ante/ante_test.go +++ b/modules/core/ante/ante_test.go @@ -214,7 +214,7 @@ func (suite *AnteTestSuite) createTimeoutOnCloseMessage(isRedundant bool) sdk.Ms channelKey := host.ChannelKey(packet.GetDestPort(), packet.GetDestChannel()) closedProof, _ := suite.chainA.QueryProof(channelKey) - return channeltypes.NewMsgTimeoutOnClose(packet, 1, proof, closedProof, proofHeight, suite.path.EndpointA.Chain.SenderAccount.GetAddress().String(), 0) + return channeltypes.NewMsgTimeoutOnClose(packet, 1, proof, closedProof, proofHeight, suite.path.EndpointA.Chain.SenderAccount.GetAddress().String()) } func (suite *AnteTestSuite) createUpdateClientMessage() sdk.Msg { diff --git a/modules/core/client/cli/cli.go b/modules/core/client/cli/cli.go index 3285fd6bcbe..6bcba61d7ed 100644 --- a/modules/core/client/cli/cli.go +++ b/modules/core/client/cli/cli.go @@ -24,7 +24,6 @@ func GetTxCmd() *cobra.Command { ibcTxCmd.AddCommand( ibcclient.GetTxCmd(), - channel.GetTxCmd(), channelv2.GetTxCmd(), ) diff --git a/modules/core/genesis_test.go b/modules/core/genesis_test.go index e715f3ef653..9aa65bab87c 100644 --- a/modules/core/genesis_test.go +++ b/modules/core/genesis_test.go @@ -159,7 +159,6 @@ func (suite *IBCTestSuite) TestValidateGenesis() { channeltypes.NewPacketSequence(port2, channel2, 1), }, 0, - channeltypes.Params{UpgradeTimeout: channeltypes.DefaultTimeout}, ), ChannelV2Genesis: channelv2types.NewGenesisState( []channelv2types.PacketState{ @@ -396,7 +395,6 @@ func (suite *IBCTestSuite) TestInitGenesis() { channeltypes.NewPacketSequence(port2, channel2, 1), }, 0, - channeltypes.Params{UpgradeTimeout: channeltypes.DefaultTimeout}, ), ChannelV2Genesis: channelv2types.NewGenesisState( []channelv2types.PacketState{ diff --git a/modules/core/integration_test.go b/modules/core/integration_test.go deleted file mode 100644 index b9395bc33e6..00000000000 --- a/modules/core/integration_test.go +++ /dev/null @@ -1,98 +0,0 @@ -package ibc_test - -import ( - clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/v10/modules/core/24-host" - ibctesting "github.com/cosmos/ibc-go/v10/testing" - ibcmock "github.com/cosmos/ibc-go/v10/testing/mock" -) - -// If packet receipts are pruned, it may be possible to double spend via a -// replay attack by resubmitting the same proof used to process the original receive. -// Core IBC performs an additional check to ensure that any packet being received -// MUST NOT be in the range of packet receipts which are allowed to be pruned thus -// adding replay protection for upgraded channels. -// This test has been added to ensure we have replay protection after -// pruning stale state upon the successful completion of a channel upgrade. -func (suite *IBCTestSuite) TestReplayProtectionAfterReceivePruning() { - var path *ibctesting.Path - - testCases := []struct { - name string - malleate func() - }{ - { - "unordered channel upgrades version", - func() { - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - }, - }, - { - "ordered channel upgrades to unordered channel", - func() { - path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED - path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Ordering = channeltypes.UNORDERED - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Ordering = channeltypes.UNORDERED - }, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - path = ibctesting.NewPath(suite.chainA, suite.chainB) - - tc.malleate() - - path.Setup() - - // Setup replay attack by sending a packet. We will save the receive - // proof to replay relaying after the channel upgrade completes. - disabledTimeoutTimestamp := uint64(0) - timeoutHeight := clienttypes.NewHeight(1, 110) - sequence, err := path.EndpointA.SendPacket(timeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData) - suite.Require().NoError(err) - packet := channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) - - // save receive proof for replay submission - packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - proof, proofHeight := path.EndpointA.Chain.QueryProof(packetKey) - recvMsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, path.EndpointB.Chain.SenderAccount.GetAddress().String()) - - err = path.RelayPacket(packet) - suite.Require().NoError(err) - - // perform upgrade - err = path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeAck() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeConfirm() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeOpen() - suite.Require().NoError(err) - - // prune stale receive state - msgPrune := channeltypes.NewMsgPruneAcknowledgements(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, 1, path.EndpointB.Chain.SenderAccount.GetAddress().String()) - res, err := path.EndpointB.Chain.SendMsgs(msgPrune) - suite.Require().NotNil(res) - suite.Require().NoError(err) - - // replay initial packet send - res, err = path.EndpointB.Chain.SendMsgs(recvMsg) - suite.Require().NotNil(res) - suite.Require().ErrorContains(err, channeltypes.ErrPacketReceived.Error(), "replay protection missing") - }) - } -} diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index e76d788bd77..de6fa16bfa8 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "errors" errorsmod "cosmossdk.io/errors" @@ -11,7 +10,6 @@ import ( clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" clientv2types "github.com/cosmos/ibc-go/v10/modules/core/02-client/v2/types" connectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types" - "github.com/cosmos/ibc-go/v10/modules/core/04-channel/keeper" channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v10/modules/core/05-port/types" ibcerrors "github.com/cosmos/ibc-go/v10/modules/core/errors" @@ -404,7 +402,7 @@ func (k *Keeper) ChannelCloseConfirm(goCtx context.Context, msg *channeltypes.Ms return nil, errorsmod.Wrapf(err, "channel close confirm callback failed for port ID: %s, channel ID: %s", msg.PortId, msg.ChannelId) } - err := k.ChannelKeeper.ChanCloseConfirm(ctx, msg.PortId, msg.ChannelId, msg.ProofInit, msg.ProofHeight, msg.CounterpartyUpgradeSequence) + err := k.ChannelKeeper.ChanCloseConfirm(ctx, msg.PortId, msg.ChannelId, msg.ProofInit, msg.ProofHeight) if err != nil { ctx.Logger().Error("channel close confirm failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) return nil, errorsmod.Wrap(err, "channel handshake close confirm failed") @@ -551,7 +549,7 @@ func (k *Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTime // If the timeout was already received, perform a no-op // Use a cached context to prevent accidental state changes cacheCtx, writeFn := ctx.CacheContext() - channelVersion, err := k.ChannelKeeper.TimeoutOnClose(cacheCtx, msg.Packet, msg.ProofUnreceived, msg.ProofClose, msg.ProofHeight, msg.NextSequenceRecv, msg.CounterpartyUpgradeSequence) + channelVersion, err := k.ChannelKeeper.TimeoutOnClose(cacheCtx, msg.Packet, msg.ProofUnreceived, msg.ProofClose, msg.ProofHeight, msg.NextSequenceRecv) switch err { case nil: @@ -632,342 +630,6 @@ func (k *Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAck return &channeltypes.MsgAcknowledgementResponse{Result: channeltypes.SUCCESS}, nil } -// ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit. -func (k *Keeper) ChannelUpgradeInit(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeInit) (*channeltypes.MsgChannelUpgradeInitResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - if k.GetAuthority() != msg.Signer { - return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer) - } - - app, ok := k.PortKeeper.Route(msg.PortId) - if !ok { - ctx.Logger().Error("channel upgrade init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) - return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) - } - - cbs, ok := app.(porttypes.UpgradableModule) - if !ok { - ctx.Logger().Error("channel upgrade init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId)) - return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId) - } - - upgrade, err := k.ChannelKeeper.ChanUpgradeInit(ctx, msg.PortId, msg.ChannelId, msg.Fields) - if err != nil { - ctx.Logger().Error("channel upgrade init failed", "error", errorsmod.Wrap(err, "channel upgrade init failed")) - return nil, errorsmod.Wrap(err, "channel upgrade init failed") - } - - // NOTE: a cached context is used to discard ibc application state changes and events. - // IBC applications must flush in-flight packets using the pre-upgrade channel parameters. - cacheCtx, _ := ctx.CacheContext() - upgradeVersion, err := cbs.OnChanUpgradeInit(cacheCtx, msg.PortId, msg.ChannelId, upgrade.Fields.Ordering, upgrade.Fields.ConnectionHops, upgrade.Fields.Version) - if err != nil { - ctx.Logger().Error("channel upgrade init callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) - return nil, errorsmod.Wrapf(err, "channel upgrade init callback failed for port ID: %s, channel ID: %s", msg.PortId, msg.ChannelId) - } - - channel, upgrade := k.ChannelKeeper.WriteUpgradeInitChannel(ctx, msg.PortId, msg.ChannelId, upgrade, upgradeVersion) - - ctx.Logger().Info("channel upgrade init succeeded", "channel-id", msg.ChannelId, "version", upgradeVersion) - keeper.EmitChannelUpgradeInitEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade) - - return &channeltypes.MsgChannelUpgradeInitResponse{ - Upgrade: upgrade, - UpgradeSequence: channel.UpgradeSequence, - }, nil -} - -// ChannelUpgradeTry defines a rpc handler method for MsgChannelUpgradeTry. -func (k *Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeTry) (*channeltypes.MsgChannelUpgradeTryResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - app, ok := k.PortKeeper.Route(msg.PortId) - if !ok { - ctx.Logger().Error("channel upgrade try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) - return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) - } - - cbs, ok := app.(porttypes.UpgradableModule) - if !ok { - ctx.Logger().Error("channel upgrade try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId)) - return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId) - } - - channel, upgrade, err := k.ChannelKeeper.ChanUpgradeTry(ctx, msg.PortId, msg.ChannelId, msg.ProposedUpgradeConnectionHops, msg.CounterpartyUpgradeFields, msg.CounterpartyUpgradeSequence, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight) - if err != nil { - ctx.Logger().Error("channel upgrade try failed", "error", errorsmod.Wrap(err, "channel upgrade try failed")) - if channeltypes.IsUpgradeError(err) { - // In case the error is a wrapped upgrade error, we need to extract the inner error else process as normal - var upgradeErr *channeltypes.UpgradeError - if errors.As(err, &upgradeErr) { - k.ChannelKeeper.WriteErrorReceipt(ctx, msg.PortId, msg.ChannelId, upgradeErr) - // NOTE: a FAILURE result is returned to the client and an error receipt is written to state. - // This signals to the relayer to begin the cancel upgrade handshake subprotocol. - return &channeltypes.MsgChannelUpgradeTryResponse{Result: channeltypes.FAILURE}, nil - } - } - - // NOTE: an error is returned to baseapp and transaction state is not committed. - return nil, errorsmod.Wrap(err, "channel upgrade try failed") - } - - // NOTE: a cached context is used to discard ibc application state changes and events. - // IBC applications must flush in-flight packets using the pre-upgrade channel parameters. - cacheCtx, _ := ctx.CacheContext() - upgradeVersion, err := cbs.OnChanUpgradeTry(cacheCtx, msg.PortId, msg.ChannelId, upgrade.Fields.Ordering, upgrade.Fields.ConnectionHops, upgrade.Fields.Version) - if err != nil { - ctx.Logger().Error("channel upgrade try callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) - return nil, errorsmod.Wrapf(err, "channel upgrade try callback failed for port ID: %s, channel ID: %s", msg.PortId, msg.ChannelId) - } - - channel, upgrade = k.ChannelKeeper.WriteUpgradeTryChannel(ctx, msg.PortId, msg.ChannelId, upgrade, upgradeVersion) - - ctx.Logger().Info("channel upgrade try succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) - keeper.EmitChannelUpgradeTryEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade) - - return &channeltypes.MsgChannelUpgradeTryResponse{ - Result: channeltypes.SUCCESS, - Upgrade: upgrade, - UpgradeSequence: channel.UpgradeSequence, - }, nil -} - -// ChannelUpgradeAck defines a rpc handler method for MsgChannelUpgradeAck. -func (k *Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeAck) (*channeltypes.MsgChannelUpgradeAckResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - app, ok := k.PortKeeper.Route(msg.PortId) - if !ok { - err := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) - ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", err) - return nil, err - } - - cbs, ok := app.(porttypes.UpgradableModule) - if !ok { - err := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId) - ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", err) - return nil, err - } - - err := k.ChannelKeeper.ChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight) - if err != nil { - ctx.Logger().Error("channel upgrade ack failed", "error", errorsmod.Wrap(err, "channel upgrade ack failed")) - if channeltypes.IsUpgradeError(err) { - k.ChannelKeeper.MustAbortUpgrade(ctx, msg.PortId, msg.ChannelId, err) - - // NOTE: a FAILURE result is returned to the client and an error receipt is written to state. - // This signals to the relayer to begin the cancel upgrade handshake subprotocol. - return &channeltypes.MsgChannelUpgradeAckResponse{Result: channeltypes.FAILURE}, nil - } - - // NOTE: an error is returned to baseapp and transaction state is not committed. - return nil, errorsmod.Wrap(err, "channel upgrade ack failed") - } - - // NOTE: a cached context is used to discard ibc application state changes and events. - // IBC applications must flush in-flight packets using the pre-upgrade channel parameters. - cacheCtx, _ := ctx.CacheContext() - err = cbs.OnChanUpgradeAck(cacheCtx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade.Fields.Version) - if err != nil { - channel, found := k.ChannelKeeper.GetChannel(ctx, msg.PortId, msg.ChannelId) - if !found { - return nil, errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "channel not found for port ID (%s) channel ID (%s)", msg.PortId, msg.ChannelId) - } - - ctx.Logger().Error("channel upgrade ack callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) - - // explicitly wrap the application callback in an upgrade error with the correct upgrade sequence. - // this prevents any errors caused from the application returning an UpgradeError with an incorrect sequence. - k.ChannelKeeper.MustAbortUpgrade(ctx, msg.PortId, msg.ChannelId, channeltypes.NewUpgradeError(channel.UpgradeSequence, err)) - - return &channeltypes.MsgChannelUpgradeAckResponse{Result: channeltypes.FAILURE}, nil - } - - channel, upgrade := k.ChannelKeeper.WriteUpgradeAckChannel(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade) - - ctx.Logger().Info("channel upgrade ack succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) - keeper.EmitChannelUpgradeAckEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade) - - return &channeltypes.MsgChannelUpgradeAckResponse{Result: channeltypes.SUCCESS}, nil -} - -// ChannelUpgradeConfirm defines a rpc handler method for MsgChannelUpgradeConfirm. -func (k *Keeper) ChannelUpgradeConfirm(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeConfirm) (*channeltypes.MsgChannelUpgradeConfirmResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - app, ok := k.PortKeeper.Route(msg.PortId) - if !ok { - err := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) - ctx.Logger().Error("channel upgrade confirm failed", "port-id", msg.PortId, "error", err) - return nil, err - } - - cbs, ok := app.(porttypes.UpgradableModule) - if !ok { - err := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId) - ctx.Logger().Error("channel upgrade confirm failed", "port-id", msg.PortId, "error", err) - return nil, err - } - - err := k.ChannelKeeper.ChanUpgradeConfirm(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyChannelState, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight) - if err != nil { - ctx.Logger().Error("channel upgrade confirm failed", "error", errorsmod.Wrap(err, "channel upgrade confirm failed")) - if channeltypes.IsUpgradeError(err) { - k.ChannelKeeper.MustAbortUpgrade(ctx, msg.PortId, msg.ChannelId, err) - - // NOTE: a FAILURE result is returned to the client and an error receipt is written to state. - // This signals to the relayer to begin the cancel upgrade handshake subprotocol. - return &channeltypes.MsgChannelUpgradeConfirmResponse{Result: channeltypes.FAILURE}, nil - } - - // NOTE: an error is returned to baseapp and transaction state is not committed. - return nil, errorsmod.Wrap(err, "channel upgrade confirm failed") - } - - channel := k.ChannelKeeper.WriteUpgradeConfirmChannel(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade) - ctx.Logger().Info("channel upgrade confirm succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) - keeper.EmitChannelUpgradeConfirmEvent(ctx, msg.PortId, msg.ChannelId, channel) - - // Move channel to OPEN state if both chains have finished flushing in-flight packets. - // Counterparty channel state has been verified in ChanUpgradeConfirm. - if channel.State == channeltypes.FLUSHCOMPLETE && msg.CounterpartyChannelState == channeltypes.FLUSHCOMPLETE { - upgrade, found := k.ChannelKeeper.GetUpgrade(ctx, msg.PortId, msg.ChannelId) - if !found { - return nil, errorsmod.Wrapf(channeltypes.ErrUpgradeNotFound, "failed to retrieve channel upgrade: port ID (%s) channel ID (%s)", msg.PortId, msg.ChannelId) - } - - cbs.OnChanUpgradeOpen(ctx, msg.PortId, msg.ChannelId, upgrade.Fields.Ordering, upgrade.Fields.ConnectionHops, upgrade.Fields.Version) - channel := k.ChannelKeeper.WriteUpgradeOpenChannel(ctx, msg.PortId, msg.ChannelId) - - ctx.Logger().Info("channel upgrade open succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) - keeper.EmitChannelUpgradeOpenEvent(ctx, msg.PortId, msg.ChannelId, channel) - } - - return &channeltypes.MsgChannelUpgradeConfirmResponse{Result: channeltypes.SUCCESS}, nil -} - -// ChannelUpgradeOpen defines a rpc handler method for MsgChannelUpgradeOpen. -func (k *Keeper) ChannelUpgradeOpen(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeOpen) (*channeltypes.MsgChannelUpgradeOpenResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - app, ok := k.PortKeeper.Route(msg.PortId) - if !ok { - err := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) - ctx.Logger().Error("channel upgrade open failed", "port-id", msg.PortId, "error", err) - return nil, err - } - - cbs, ok := app.(porttypes.UpgradableModule) - if !ok { - err := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId) - ctx.Logger().Error("channel upgrade open failed", "port-id", msg.PortId, "error", err) - return nil, err - } - - if err := k.ChannelKeeper.ChanUpgradeOpen(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyChannelState, msg.CounterpartyUpgradeSequence, msg.ProofChannel, msg.ProofHeight); err != nil { - ctx.Logger().Error("channel upgrade open failed", "error", errorsmod.Wrap(err, "channel upgrade open failed")) - return nil, errorsmod.Wrap(err, "channel upgrade open failed") - } - - upgrade, found := k.ChannelKeeper.GetUpgrade(ctx, msg.PortId, msg.ChannelId) - if !found { - return nil, errorsmod.Wrapf(channeltypes.ErrUpgradeNotFound, "failed to retrieve channel upgrade: port ID (%s) channel ID (%s)", msg.PortId, msg.ChannelId) - } - - cbs.OnChanUpgradeOpen(ctx, msg.PortId, msg.ChannelId, upgrade.Fields.Ordering, upgrade.Fields.ConnectionHops, upgrade.Fields.Version) - channel := k.ChannelKeeper.WriteUpgradeOpenChannel(ctx, msg.PortId, msg.ChannelId) - - ctx.Logger().Info("channel upgrade open succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) - keeper.EmitChannelUpgradeOpenEvent(ctx, msg.PortId, msg.ChannelId, channel) - - return &channeltypes.MsgChannelUpgradeOpenResponse{}, nil -} - -// ChannelUpgradeTimeout defines a rpc handler method for MsgChannelUpgradeTimeout. -func (k *Keeper) ChannelUpgradeTimeout(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeTimeout) (*channeltypes.MsgChannelUpgradeTimeoutResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - if err := k.ChannelKeeper.ChanUpgradeTimeout(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyChannel, msg.ProofChannel, msg.ProofHeight); err != nil { - return nil, errorsmod.Wrapf(err, "could not timeout upgrade for channel: %s", msg.ChannelId) - } - - channel, upgrade := k.ChannelKeeper.WriteUpgradeTimeoutChannel(ctx, msg.PortId, msg.ChannelId) - - ctx.Logger().Info("channel upgrade timeout callback succeeded: portID %s, channelID %s", msg.PortId, msg.ChannelId) - keeper.EmitChannelUpgradeTimeoutEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade) - - return &channeltypes.MsgChannelUpgradeTimeoutResponse{}, nil -} - -// ChannelUpgradeCancel defines a rpc handler method for MsgChannelUpgradeCancel. -func (k *Keeper) ChannelUpgradeCancel(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeCancel) (*channeltypes.MsgChannelUpgradeCancelResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - channel, found := k.ChannelKeeper.GetChannel(ctx, msg.PortId, msg.ChannelId) - if !found { - return nil, errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", msg.PortId, msg.ChannelId) - } - - // if the msgSender is authorized to make and cancel upgrades AND the current channel has not already reached FLUSHCOMPLETE - // then we can restore immediately without any additional checks - isAuthority := k.GetAuthority() == msg.Signer - if isAuthority && channel.State != channeltypes.FLUSHCOMPLETE { - upgrade, found := k.ChannelKeeper.GetUpgrade(ctx, msg.PortId, msg.ChannelId) - if !found { - return nil, errorsmod.Wrapf(channeltypes.ErrUpgradeNotFound, "failed to retrieve channel upgrade: port ID (%s) channel ID (%s)", msg.PortId, msg.ChannelId) - } - - k.ChannelKeeper.WriteUpgradeCancelChannel(ctx, msg.PortId, msg.ChannelId, channel.UpgradeSequence) - - ctx.Logger().Info("channel upgrade cancel succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) - - keeper.EmitChannelUpgradeCancelEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade) - - return &channeltypes.MsgChannelUpgradeCancelResponse{}, nil - } - - if err := k.ChannelKeeper.ChanUpgradeCancel(ctx, msg.PortId, msg.ChannelId, msg.ErrorReceipt, msg.ProofErrorReceipt, msg.ProofHeight); err != nil { - ctx.Logger().Error("channel upgrade cancel failed", "port-id", msg.PortId, "error", err.Error()) - return nil, errorsmod.Wrap(err, "channel upgrade cancel failed") - } - - // get upgrade here since it will be deleted in WriteUpgradeCancelChannel - upgrade, found := k.ChannelKeeper.GetUpgrade(ctx, msg.PortId, msg.ChannelId) - if !found { - return nil, errorsmod.Wrapf(channeltypes.ErrUpgradeNotFound, "failed to retrieve channel upgrade: port ID (%s) channel ID (%s)", msg.PortId, msg.ChannelId) - } - - k.ChannelKeeper.WriteUpgradeCancelChannel(ctx, msg.PortId, msg.ChannelId, msg.ErrorReceipt.Sequence) - - ctx.Logger().Info("channel upgrade cancel succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) - - // get channel here again to get latest state after write - channel, found = k.ChannelKeeper.GetChannel(ctx, msg.PortId, msg.ChannelId) - if !found { - return nil, errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", msg.PortId, msg.ChannelId) - } - keeper.EmitChannelUpgradeCancelEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade) - - return &channeltypes.MsgChannelUpgradeCancelResponse{}, nil -} - -// PruneAcknowledgements defines a rpc handler method for MsgPruneAcknowledgements. -func (k *Keeper) PruneAcknowledgements(goCtx context.Context, msg *channeltypes.MsgPruneAcknowledgements) (*channeltypes.MsgPruneAcknowledgementsResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - pruned, remaining, err := k.ChannelKeeper.PruneAcknowledgements(ctx, msg.PortId, msg.ChannelId, msg.Limit) - if err != nil { - return nil, err - } - - return &channeltypes.MsgPruneAcknowledgementsResponse{ - TotalPrunedSequences: pruned, - TotalRemainingSequences: remaining, - }, nil -} - // UpdateClientParams defines a rpc handler method for MsgUpdateParams. func (k *Keeper) UpdateClientParams(goCtx context.Context, msg *clienttypes.MsgUpdateParams) (*clienttypes.MsgUpdateParamsResponse, error) { if k.GetAuthority() != msg.Signer { @@ -991,15 +653,3 @@ func (k *Keeper) UpdateConnectionParams(goCtx context.Context, msg *connectionty return &connectiontypes.MsgUpdateParamsResponse{}, nil } - -// UpdateChannelParams defines a rpc handler method for MsgUpdateParams. -func (k *Keeper) UpdateChannelParams(goCtx context.Context, msg *channeltypes.MsgUpdateParams) (*channeltypes.MsgUpdateParamsResponse, error) { - if k.GetAuthority() != msg.Authority { - return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) - } - - ctx := sdk.UnwrapSDKContext(goCtx) - k.ChannelKeeper.SetParams(ctx, msg.Params) - - return &channeltypes.MsgUpdateParamsResponse{}, nil -} diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index d60d724dd07..414c35ab7d0 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -2,20 +2,16 @@ package keeper_test import ( "errors" - "fmt" upgradetypes "cosmossdk.io/x/upgrade/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - abci "github.com/cometbft/cometbft/abci/types" - clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" clientv2types "github.com/cosmos/ibc-go/v10/modules/core/02-client/v2/types" connectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" - porttypes "github.com/cosmos/ibc-go/v10/modules/core/05-port/types" commitmenttypes "github.com/cosmos/ibc-go/v10/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v10/modules/core/24-host" ibcerrors "github.com/cosmos/ibc-go/v10/modules/core/errors" @@ -676,10 +672,9 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { // 'TimeoutExecuted' can be found in the 04-channel/keeper/timeout_test.go. func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { var ( - packet channeltypes.Packet - packetKey []byte - path *ibctesting.Path - counterpartyUpgradeSequence uint64 + packet channeltypes.Packet + packetKey []byte + path *ibctesting.Path ) testCases := []struct { @@ -811,7 +806,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { channelKey := host.ChannelKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) closedProof, _ := suite.chainB.QueryProof(channelKey) - msg := channeltypes.NewMsgTimeoutOnClose(packet, 1, proof, closedProof, proofHeight, suite.chainA.SenderAccount.GetAddress().String(), counterpartyUpgradeSequence) + msg := channeltypes.NewMsgTimeoutOnClose(packet, 1, proof, closedProof, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) _, err := suite.chainA.App.GetIBCKeeper().TimeoutOnClose(suite.chainA.GetContext(), msg) @@ -967,1712 +962,178 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { } } -func (suite *KeeperTestSuite) TestChannelUpgradeInit() { - var ( - path *ibctesting.Path - msg *channeltypes.MsgChannelUpgradeInit - ) - - cases := []struct { - name string - malleate func() - expResult func(res *channeltypes.MsgChannelUpgradeInitResponse, events []abci.Event, err error) +// TestIBCSoftwareUpgrade tests the IBCSoftwareUpgrade rpc handler +func (suite *KeeperTestSuite) TestIBCSoftwareUpgrade() { + var msg *clienttypes.MsgIBCSoftwareUpgrade + testCases := []struct { + name string + malleate func() + expError error }{ { - "success", - func() { - msg = channeltypes.NewMsgChannelUpgradeInit( - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - path.EndpointA.GetProposedUpgrade().Fields, - path.EndpointA.Chain.GetSimApp().IBCKeeper.GetAuthority(), - ) - }, - func(res *channeltypes.MsgChannelUpgradeInitResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(uint64(1), res.UpgradeSequence) - channel := path.EndpointA.GetChannel() - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeInit, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, + "success: valid authority and client upgrade", + func() {}, + nil, }, { - "authority is not signer of the upgrade init msg", + "failure: invalid authority address", func() { - msg = channeltypes.NewMsgChannelUpgradeInit( - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - path.EndpointA.GetProposedUpgrade().Fields, - path.EndpointA.Chain.SenderAccount.String(), - ) - }, - func(res *channeltypes.MsgChannelUpgradeInitResponse, events []abci.Event, err error) { - suite.Require().Error(err) - suite.Require().ErrorContains(err, ibcerrors.ErrUnauthorized.Error()) - suite.Require().Nil(res) - - suite.Require().Empty(events) + msg.Signer = suite.chainA.SenderAccount.GetAddress().String() }, + ibcerrors.ErrUnauthorized, }, { - "ibc application does not implement the UpgradeableModule interface", + "failure: invalid clientState", func() { - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.EndpointA.ChannelConfig.PortID = ibcmock.MockBlockUpgrade - path.EndpointB.ChannelConfig.PortID = ibcmock.MockBlockUpgrade - - path.Setup() - - msg = channeltypes.NewMsgChannelUpgradeInit( - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - path.EndpointA.GetProposedUpgrade().Fields, - path.EndpointA.Chain.GetSimApp().IBCKeeper.GetAuthority(), - ) - }, - func(res *channeltypes.MsgChannelUpgradeInitResponse, events []abci.Event, err error) { - suite.Require().ErrorIs(err, porttypes.ErrInvalidRoute) - suite.Require().Nil(res) - - suite.Require().Empty(events) + msg.UpgradedClientState = nil }, + clienttypes.ErrInvalidClientType, }, { - "ibc application does not commit state changes in callback", + "failure: failed to schedule client upgrade", func() { - msg = channeltypes.NewMsgChannelUpgradeInit( - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - path.EndpointA.GetProposedUpgrade().Fields, - path.EndpointA.Chain.GetSimApp().IBCKeeper.GetAuthority(), - ) - - suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnChanUpgradeInit = func(ctx sdk.Context, portID, channelID string, order channeltypes.Order, connectionHops []string, version string) (string, error) { - storeKey := suite.chainA.GetSimApp().GetKey(exported.ModuleName) - store := ctx.KVStore(storeKey) - store.Set(ibcmock.TestKey, ibcmock.TestValue) - - ctx.EventManager().EmitEvent(sdk.NewEvent(ibcmock.MockEventType)) - return ibcmock.UpgradeVersion, nil - } - }, - func(res *channeltypes.MsgChannelUpgradeInitResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(uint64(1), res.UpgradeSequence) - - storeKey := suite.chainA.GetSimApp().GetKey(exported.ModuleName) - store := suite.chainA.GetContext().KVStore(storeKey) - suite.Require().Nil(store.Get(ibcmock.TestKey)) - - for _, event := range events { - if event.GetType() == ibcmock.MockEventType { - suite.Fail("expected application callback events to be discarded") - } - } + msg.Plan.Height = 0 }, + sdkerrors.ErrInvalidRequest, }, } - for _, tc := range cases { + for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupClients() + validAuthority := suite.chainA.App.GetIBCKeeper().GetAuthority() + plan := upgradetypes.Plan{ + Name: "upgrade IBC clients", + Height: 1000, + } + // update trusting period + clientState, ok := path.EndpointB.GetClientState().(*ibctm.ClientState) + suite.Require().True(ok) + clientState.TrustingPeriod += 100 - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() + var err error + msg, err = clienttypes.NewMsgIBCSoftwareUpgrade( + validAuthority, + plan, + clientState, + ) - // configure the channel upgrade version on testing endpoints - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion + suite.Require().NoError(err) tc.malleate() - ctx := suite.chainA.GetContext() - res, err := suite.chainA.GetSimApp().GetIBCKeeper().ChannelUpgradeInit(ctx, msg) - events := ctx.EventManager().Events().ToABCIEvents() + _, err = suite.chainA.App.GetIBCKeeper().IBCSoftwareUpgrade(suite.chainA.GetContext(), msg) + + if tc.expError == nil { + suite.Require().NoError(err) + // upgrade plan is stored + storedPlan, err := suite.chainA.GetSimApp().UpgradeKeeper.GetUpgradePlan(suite.chainA.GetContext()) + suite.Require().NoError(err) + suite.Require().Equal(plan, storedPlan) - tc.expResult(res, events, err) + // upgraded client state is stored + bz, err := suite.chainA.GetSimApp().UpgradeKeeper.GetUpgradedClient(suite.chainA.GetContext(), plan.Height) + suite.Require().NoError(err) + upgradedClientState, err := clienttypes.UnmarshalClientState(suite.chainA.App.AppCodec(), bz) + suite.Require().NoError(err) + suite.Require().Equal(clientState.ZeroCustomFields(), upgradedClientState) + } else { + suite.Require().True(errors.Is(err, tc.expError)) + } }) } } -func (suite *KeeperTestSuite) TestChannelUpgradeTry() { - var ( - path *ibctesting.Path - msg *channeltypes.MsgChannelUpgradeTry - ) - - cases := []struct { - name string - malleate func() - expResult func(res *channeltypes.MsgChannelUpgradeTryResponse, events []abci.Event, err error) +// TestUpdateClientParams tests the UpdateClientParams rpc handler +func (suite *KeeperTestSuite) TestUpdateClientParams() { + signer := suite.chainA.App.GetIBCKeeper().GetAuthority() + testCases := []struct { + name string + msg *clienttypes.MsgUpdateParams + expError error }{ { - "success", - func() {}, - func(res *channeltypes.MsgChannelUpgradeTryResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(channeltypes.SUCCESS, res.Result) - - channel := path.EndpointB.GetChannel() - suite.Require().Equal(channeltypes.FLUSHING, channel.State) - suite.Require().Equal(uint64(1), channel.UpgradeSequence) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeTry, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, + "success: valid signer and default params", + clienttypes.NewMsgUpdateParams(signer, clienttypes.DefaultParams()), + nil, }, { - "unsynchronized upgrade sequence writes upgrade error receipt", - func() { - path.EndpointB.UpdateChannel(func(channel *channeltypes.Channel) { channel.UpgradeSequence = 99 }) - }, - func(res *channeltypes.MsgChannelUpgradeTryResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - - suite.Require().NotNil(res) - suite.Require().Equal(channeltypes.FAILURE, res.Result) - - errorReceipt, found := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(99), errorReceipt.Sequence) - - channel := path.EndpointB.GetChannel() - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeError, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - // need to manually insert this because the errorReceipt is a string constant as it is written into state - sdk.NewAttribute(channeltypes.AttributeKeyErrorReceipt, "counterparty upgrade sequence < current upgrade sequence (1 < 99): invalid upgrade sequence"), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, + "failure: malformed signer address", + clienttypes.NewMsgUpdateParams(ibctesting.InvalidID, clienttypes.DefaultParams()), + errors.New("unauthorized"), }, { - "ibc application does not implement the UpgradeableModule interface", - func() { - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.EndpointA.ChannelConfig.PortID = ibcmock.MockBlockUpgrade - path.EndpointB.ChannelConfig.PortID = ibcmock.MockBlockUpgrade - - path.Setup() - - msg.PortId = path.EndpointB.ChannelConfig.PortID - msg.ChannelId = path.EndpointB.ChannelID - }, - func(res *channeltypes.MsgChannelUpgradeTryResponse, events []abci.Event, err error) { - suite.Require().ErrorIs(err, porttypes.ErrInvalidRoute) - suite.Require().Nil(res) - - suite.Require().Empty(events) - }, + "failure: empty signer address", + clienttypes.NewMsgUpdateParams("", clienttypes.DefaultParams()), + errors.New("unauthorized"), }, { - "ibc application does not commit state changes in callback", - func() { - suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnChanUpgradeTry = func(ctx sdk.Context, portID, channelID string, order channeltypes.Order, connectionHops []string, counterpartyVersion string) (string, error) { - storeKey := suite.chainA.GetSimApp().GetKey(exported.ModuleName) - store := ctx.KVStore(storeKey) - store.Set(ibcmock.TestKey, ibcmock.TestValue) - - ctx.EventManager().EmitEvent(sdk.NewEvent(ibcmock.MockEventType)) - return ibcmock.UpgradeVersion, nil - } - }, - func(res *channeltypes.MsgChannelUpgradeTryResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(uint64(1), res.UpgradeSequence) - - storeKey := suite.chainA.GetSimApp().GetKey(exported.ModuleName) - store := suite.chainA.GetContext().KVStore(storeKey) - suite.Require().Nil(store.Get(ibcmock.TestKey)) - - for _, event := range events { - if event.GetType() == ibcmock.MockEventType { - suite.Fail("expected application callback events to be discarded") - } - } - }, + "failure: whitespace signer address", + clienttypes.NewMsgUpdateParams(" ", clienttypes.DefaultParams()), + errors.New("unauthorized"), + }, + { + "failure: unauthorized signer address", + clienttypes.NewMsgUpdateParams(ibctesting.TestAccAddress, clienttypes.DefaultParams()), + errors.New("unauthorized"), }, } - for _, tc := range cases { + for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - // configure the channel upgrade version on testing endpoints - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.UpdateClient() - suite.Require().NoError(err) - - counterpartySequence := path.EndpointA.GetChannel().UpgradeSequence - counterpartyUpgrade, found := suite.chainA.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - - channelProof, upgradeProof, proofHeight := path.EndpointA.QueryChannelUpgradeProof() - - msg = &channeltypes.MsgChannelUpgradeTry{ - PortId: path.EndpointB.ChannelConfig.PortID, - ChannelId: path.EndpointB.ChannelID, - ProposedUpgradeConnectionHops: []string{ibctesting.FirstConnectionID}, - CounterpartyUpgradeSequence: counterpartySequence, - CounterpartyUpgradeFields: counterpartyUpgrade.Fields, - ProofChannel: channelProof, - ProofUpgrade: upgradeProof, - ProofHeight: proofHeight, - Signer: suite.chainB.SenderAccount.GetAddress().String(), + _, err := suite.chainA.App.GetIBCKeeper().UpdateClientParams(suite.chainA.GetContext(), tc.msg) + if tc.expError == nil { + suite.Require().NoError(err) + p := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetParams(suite.chainA.GetContext()) + suite.Require().Equal(tc.msg.Params, p) + } else { + suite.Require().Error(err) + suite.Require().Contains(err.Error(), tc.expError.Error()) } - - tc.malleate() - - ctx := suite.chainB.GetContext() - res, err := suite.chainB.GetSimApp().GetIBCKeeper().ChannelUpgradeTry(ctx, msg) - events := ctx.EventManager().Events().ToABCIEvents() - - tc.expResult(res, events, err) }) } } -func (suite *KeeperTestSuite) TestChannelUpgradeAck() { - var ( - path *ibctesting.Path - msg *channeltypes.MsgChannelUpgradeAck - ) - - cases := []struct { - name string - malleate func() - expResult func(res *channeltypes.MsgChannelUpgradeAckResponse, events []abci.Event, err error) +// TestUpdateConnectionParams tests the UpdateConnectionParams rpc handler +func (suite *KeeperTestSuite) TestUpdateConnectionParams() { + signer := suite.chainA.App.GetIBCKeeper().GetAuthority() + testCases := []struct { + name string + msg *connectiontypes.MsgUpdateParams + expErr error }{ { - "success, no pending in-flight packets", - func() {}, - func(res *channeltypes.MsgChannelUpgradeAckResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(channeltypes.SUCCESS, res.Result) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(channeltypes.FLUSHCOMPLETE, channel.State) - suite.Require().Equal(uint64(1), channel.UpgradeSequence) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeAck, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "success, pending in-flight packets", - func() { - portID := path.EndpointA.ChannelConfig.PortID - channelID := path.EndpointA.ChannelID - // Set a dummy packet commitment to simulate in-flight packets - suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), portID, channelID, 1, []byte("hash")) - }, - func(res *channeltypes.MsgChannelUpgradeAckResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(channeltypes.SUCCESS, res.Result) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(channeltypes.FLUSHING, channel.State) - suite.Require().Equal(uint64(1), channel.UpgradeSequence) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeAck, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "core handler returns error and no upgrade error receipt is written", - func() { - // force an error by overriding the channel state to an invalid value - path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { channel.State = channeltypes.CLOSED }) - }, - func(res *channeltypes.MsgChannelUpgradeAckResponse, events []abci.Event, err error) { - suite.Require().Error(err) - suite.Require().Nil(res) - suite.Require().ErrorIs(err, channeltypes.ErrInvalidChannelState) - - errorReceipt, found := suite.chainA.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().Empty(errorReceipt) - suite.Require().False(found) - - suite.Require().Empty(events) - }, - }, - { - "core handler returns error and writes upgrade error receipt", - func() { - // force an upgrade error by modifying the channel upgrade ordering to an incompatible value - upgrade := path.EndpointA.GetChannelUpgrade() - upgrade.Fields.Ordering = channeltypes.NONE - - path.EndpointA.SetChannelUpgrade(upgrade) - }, - func(res *channeltypes.MsgChannelUpgradeAckResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - - suite.Require().NotNil(res) - suite.Require().Equal(channeltypes.FAILURE, res.Result) - - errorReceipt, found := suite.chainA.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(1), errorReceipt.Sequence) - - channel := path.EndpointB.GetChannel() - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeError, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - // need to manually insert this because the errorReceipt is a string constant as it is written into state - sdk.NewAttribute(channeltypes.AttributeKeyErrorReceipt, "expected upgrade ordering (ORDER_NONE_UNSPECIFIED) to match counterparty upgrade ordering (ORDER_UNORDERED): incompatible counterparty upgrade"), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, + "success: valid signer and default params", + connectiontypes.NewMsgUpdateParams(signer, connectiontypes.DefaultParams()), + nil, }, { - "application callback returns error and error receipt is written", - func() { - suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnChanUpgradeAck = func( - ctx sdk.Context, portID, channelID, counterpartyVersion string, - ) error { - // set arbitrary value in store to mock application state changes - store := ctx.KVStore(suite.chainA.GetSimApp().GetKey(exported.ModuleName)) - store.Set([]byte("foo"), []byte("bar")) - return fmt.Errorf("mock app callback failed") - } - }, - func(res *channeltypes.MsgChannelUpgradeAckResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - - suite.Require().NotNil(res) - suite.Require().Equal(channeltypes.FAILURE, res.Result) - - errorReceipt, found := suite.chainA.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(1), errorReceipt.Sequence) - - // assert application state changes are not committed - store := suite.chainA.GetContext().KVStore(suite.chainA.GetSimApp().GetKey(exported.ModuleName)) - suite.Require().False(store.Has([]byte("foo"))) - - channel := path.EndpointB.GetChannel() - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeError, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - // need to manually insert this because the errorReceipt is a string constant as it is written into state - sdk.NewAttribute(channeltypes.AttributeKeyErrorReceipt, "mock app callback failed"), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, + "failure: malformed signer address", + connectiontypes.NewMsgUpdateParams(ibctesting.InvalidID, connectiontypes.DefaultParams()), + errors.New("unauthorized"), }, { - "ibc application does not implement the UpgradeableModule interface", - func() { - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.EndpointA.ChannelConfig.PortID = ibcmock.MockBlockUpgrade - path.EndpointB.ChannelConfig.PortID = ibcmock.MockBlockUpgrade - - path.Setup() - - msg.PortId = path.EndpointA.ChannelConfig.PortID - msg.ChannelId = path.EndpointA.ChannelID - }, - func(res *channeltypes.MsgChannelUpgradeAckResponse, events []abci.Event, err error) { - suite.Require().ErrorIs(err, porttypes.ErrInvalidRoute) - suite.Require().Nil(res) - suite.Require().Empty(events) - }, + "failure: empty signer address", + connectiontypes.NewMsgUpdateParams("", connectiontypes.DefaultParams()), + errors.New("unauthorized"), }, { - "application callback returns an upgrade error", - func() { - suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnChanUpgradeAck = func(ctx sdk.Context, portID, channelID, counterpartyVersion string) error { - return channeltypes.NewUpgradeError(10000000, ibcmock.MockApplicationCallbackError) - } - }, - func(res *channeltypes.MsgChannelUpgradeAckResponse, events []abci.Event, err error) { - suite.Require().Equal(channeltypes.FAILURE, res.Result) - suite.Require().Equal(uint64(1), path.EndpointA.GetChannel().UpgradeSequence, "application callback upgrade sequence should not be used") - }, + "failure: whitespace signer address", + connectiontypes.NewMsgUpdateParams(" ", connectiontypes.DefaultParams()), + errors.New("unauthorized"), }, { - "ibc application does not commit state changes in callback", - func() { - suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnChanUpgradeAck = func(ctx sdk.Context, portID, channelID, counterpartyVersion string) error { - storeKey := suite.chainA.GetSimApp().GetKey(exported.ModuleName) - store := ctx.KVStore(storeKey) - store.Set(ibcmock.TestKey, ibcmock.TestValue) - - ctx.EventManager().EmitEvent(sdk.NewEvent(ibcmock.MockEventType)) - return nil - } - }, - func(res *channeltypes.MsgChannelUpgradeAckResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - storeKey := suite.chainA.GetSimApp().GetKey(exported.ModuleName) - store := suite.chainA.GetContext().KVStore(storeKey) - suite.Require().Nil(store.Get(ibcmock.TestKey)) - - for _, event := range events { - if event.GetType() == ibcmock.MockEventType { - suite.Fail("expected application callback events to be discarded") - } - } - }, + "failure: unauthorized signer address", + connectiontypes.NewMsgUpdateParams(ibctesting.TestAccAddress, connectiontypes.DefaultParams()), + errors.New("unauthorized"), }, } - for _, tc := range cases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - // configure the channel upgrade version on testing endpoints - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - err = path.EndpointA.UpdateClient() - suite.Require().NoError(err) - - counterpartyUpgrade := path.EndpointB.GetChannelUpgrade() - - channelProof, upgradeProof, proofHeight := path.EndpointB.QueryChannelUpgradeProof() - - msg = &channeltypes.MsgChannelUpgradeAck{ - PortId: path.EndpointA.ChannelConfig.PortID, - ChannelId: path.EndpointA.ChannelID, - CounterpartyUpgrade: counterpartyUpgrade, - ProofChannel: channelProof, - ProofUpgrade: upgradeProof, - ProofHeight: proofHeight, - Signer: suite.chainA.SenderAccount.GetAddress().String(), - } - - tc.malleate() - - ctx := suite.chainA.GetContext() - res, err := suite.chainA.GetSimApp().GetIBCKeeper().ChannelUpgradeAck(ctx, msg) - events := ctx.EventManager().Events().ToABCIEvents() - - tc.expResult(res, events, err) - }) - } -} - -func (suite *KeeperTestSuite) TestChannelUpgradeConfirm() { - var ( - path *ibctesting.Path - msg *channeltypes.MsgChannelUpgradeConfirm - ) - - cases := []struct { - name string - malleate func() - expResult func(res *channeltypes.MsgChannelUpgradeConfirmResponse, events []abci.Event, err error) - }{ - { - "success, no pending in-flight packets", - func() {}, - func(res *channeltypes.MsgChannelUpgradeConfirmResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(channeltypes.SUCCESS, res.Result) - - channel := path.EndpointB.GetChannel() - suite.Require().Equal(channeltypes.OPEN, channel.State) - suite.Require().Equal(uint64(1), channel.UpgradeSequence) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeConfirm, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelState, channeltypes.FLUSHCOMPLETE.String()), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeOpen, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelState, channeltypes.OPEN.String()), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "success, pending in-flight packets on init chain", - func() { - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - seq, err := path.EndpointA.SendPacket(path.EndpointB.Chain.GetTimeoutHeight(), 0, ibctesting.MockPacketData) - suite.Require().Equal(uint64(1), seq) - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeAck() - suite.Require().NoError(err) - - err = path.EndpointB.UpdateClient() - suite.Require().NoError(err) - - counterpartyChannelState := path.EndpointA.GetChannel().State - counterpartyUpgrade := path.EndpointA.GetChannelUpgrade() - - channelProof, upgradeProof, proofHeight := path.EndpointA.QueryChannelUpgradeProof() - - msg = &channeltypes.MsgChannelUpgradeConfirm{ - PortId: path.EndpointB.ChannelConfig.PortID, - ChannelId: path.EndpointB.ChannelID, - CounterpartyChannelState: counterpartyChannelState, - CounterpartyUpgrade: counterpartyUpgrade, - ProofChannel: channelProof, - ProofUpgrade: upgradeProof, - ProofHeight: proofHeight, - Signer: suite.chainA.SenderAccount.GetAddress().String(), - } - }, - func(res *channeltypes.MsgChannelUpgradeConfirmResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(channeltypes.SUCCESS, res.Result) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(channeltypes.FLUSHING, channel.State) - suite.Require().Equal(uint64(1), channel.UpgradeSequence) - - channel = path.EndpointB.GetChannel() - suite.Require().Equal(channeltypes.FLUSHCOMPLETE, channel.State) - suite.Require().Equal(uint64(1), channel.UpgradeSequence) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeConfirm, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelState, channeltypes.FLUSHCOMPLETE.String()), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "success, pending in-flight packets on try chain", - func() { - portID, channelID := path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID - suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), portID, channelID, 1, []byte("hash")) - }, - func(res *channeltypes.MsgChannelUpgradeConfirmResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(channeltypes.SUCCESS, res.Result) - - channel := path.EndpointB.GetChannel() - suite.Require().Equal(channeltypes.FLUSHING, channel.State) - suite.Require().Equal(uint64(1), channel.UpgradeSequence) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeConfirm, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelState, channeltypes.FLUSHING.String()), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "core handler returns error and no upgrade error receipt is written", - func() { - // force an error by overriding the channel state to an invalid value - path.EndpointB.UpdateChannel(func(channel *channeltypes.Channel) { channel.State = channeltypes.CLOSED }) - }, - func(res *channeltypes.MsgChannelUpgradeConfirmResponse, events []abci.Event, err error) { - suite.Require().Error(err) - suite.Require().Nil(res) - suite.Require().ErrorIs(err, channeltypes.ErrInvalidChannelState) - - errorReceipt, found := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().Empty(errorReceipt) - suite.Require().False(found) - - suite.Require().Empty(events) - }, - }, - { - "core handler returns error and writes upgrade error receipt", - func() { - // force an upgrade error by modifying the counterparty channel upgrade timeout to be elapsed - upgrade := path.EndpointA.GetChannelUpgrade() - upgrade.Timeout = channeltypes.NewTimeout(clienttypes.ZeroHeight(), uint64(path.EndpointB.Chain.ProposedHeader.Time.UnixNano())) - - path.EndpointA.SetChannelUpgrade(upgrade) - - suite.coordinator.CommitBlock(suite.chainA) - - err := path.EndpointB.UpdateClient() - suite.Require().NoError(err) - - channelProof, upgradeProof, proofHeight := path.EndpointA.QueryChannelUpgradeProof() - - msg.CounterpartyUpgrade = upgrade - msg.ProofChannel = channelProof - msg.ProofUpgrade = upgradeProof - msg.ProofHeight = proofHeight - }, - func(res *channeltypes.MsgChannelUpgradeConfirmResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - - suite.Require().NotNil(res) - suite.Require().Equal(channeltypes.FAILURE, res.Result) - - errorReceipt, found := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(1), errorReceipt.Sequence) - - channel := path.EndpointB.GetChannel() - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeError, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - // need to manually insert this because the errorReceipt is a string constant as it is written into state - sdk.NewAttribute(channeltypes.AttributeKeyErrorReceipt, "counterparty upgrade timeout elapsed: current timestamp: 1578269010000000000, timeout timestamp 1578268995000000000: timeout elapsed"), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "ibc application does not implement the UpgradeableModule interface", - func() { - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.EndpointA.ChannelConfig.PortID = ibcmock.MockBlockUpgrade - path.EndpointB.ChannelConfig.PortID = ibcmock.MockBlockUpgrade - - path.Setup() - - msg.PortId = path.EndpointB.ChannelConfig.PortID - msg.ChannelId = path.EndpointB.ChannelID - }, - func(res *channeltypes.MsgChannelUpgradeConfirmResponse, events []abci.Event, err error) { - suite.Require().ErrorIs(err, porttypes.ErrInvalidRoute) - suite.Require().Nil(res) - - suite.Require().Empty(events) - }, - }, - } - - for _, tc := range cases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - // configure the channel upgrade version on testing endpoints - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeAck() - suite.Require().NoError(err) - - err = path.EndpointB.UpdateClient() - suite.Require().NoError(err) - - counterpartyChannelState := path.EndpointA.GetChannel().State - counterpartyUpgrade := path.EndpointA.GetChannelUpgrade() - - channelProof, upgradeProof, proofHeight := path.EndpointA.QueryChannelUpgradeProof() - - msg = &channeltypes.MsgChannelUpgradeConfirm{ - PortId: path.EndpointB.ChannelConfig.PortID, - ChannelId: path.EndpointB.ChannelID, - CounterpartyChannelState: counterpartyChannelState, - CounterpartyUpgrade: counterpartyUpgrade, - ProofChannel: channelProof, - ProofUpgrade: upgradeProof, - ProofHeight: proofHeight, - Signer: suite.chainA.SenderAccount.GetAddress().String(), - } - - tc.malleate() - - ctx := suite.chainB.GetContext() - res, err := suite.chainB.GetSimApp().GetIBCKeeper().ChannelUpgradeConfirm(ctx, msg) - events := ctx.EventManager().Events().ToABCIEvents() - - tc.expResult(res, events, err) - }) - } -} - -func (suite *KeeperTestSuite) TestChannelUpgradeOpen() { - var ( - path *ibctesting.Path - msg *channeltypes.MsgChannelUpgradeOpen - ) - - cases := []struct { - name string - malleate func() - expResult func(res *channeltypes.MsgChannelUpgradeOpenResponse, events []abci.Event, err error) - }{ - { - "success", - func() {}, - func(res *channeltypes.MsgChannelUpgradeOpenResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(channeltypes.OPEN, channel.State) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeOpen, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelState, channeltypes.OPEN.String()), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "success with counterparty at greater upgrade sequence", - func() { - // create reason to upgrade - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion + "additional upgrade" - - err := path.EndpointB.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointA.UpdateClient() - suite.Require().NoError(err) - - counterpartyChannel := path.EndpointB.GetChannel() - channelKey := host.ChannelKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - channelProof, proofHeight := path.EndpointB.QueryProof(channelKey) - - msg.ProofChannel = channelProof - msg.ProofHeight = proofHeight - msg.CounterpartyUpgradeSequence = counterpartyChannel.UpgradeSequence - }, - func(res *channeltypes.MsgChannelUpgradeOpenResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - channel := path.EndpointA.GetChannel() - suite.Require().Equal(channeltypes.OPEN, channel.State) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeOpen, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelState, channeltypes.OPEN.String()), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "core handler fails", - func() { - path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { channel.State = channeltypes.FLUSHING }) - }, - func(res *channeltypes.MsgChannelUpgradeOpenResponse, events []abci.Event, err error) { - suite.Require().Error(err) - suite.Require().Nil(res) - - suite.Require().ErrorIs(err, channeltypes.ErrInvalidChannelState) - suite.Require().Empty(events) - }, - }, - { - "ibc application does not implement the UpgradeableModule interface", - func() { - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.EndpointA.ChannelConfig.PortID = ibcmock.MockBlockUpgrade - path.EndpointB.ChannelConfig.PortID = ibcmock.MockBlockUpgrade - - path.Setup() - - msg.PortId = path.EndpointA.ChannelConfig.PortID - msg.ChannelId = path.EndpointA.ChannelID - }, - func(res *channeltypes.MsgChannelUpgradeOpenResponse, events []abci.Event, err error) { - suite.Require().ErrorIs(err, porttypes.ErrInvalidRoute) - suite.Require().Nil(res) - - suite.Require().Empty(events) - }, - }, - } - - for _, tc := range cases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - // configure the channel upgrade version on testing endpoints - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeAck() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeConfirm() - suite.Require().NoError(err) - - err = path.EndpointA.UpdateClient() - suite.Require().NoError(err) - - counterpartyChannel := path.EndpointB.GetChannel() - channelKey := host.ChannelKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - channelProof, proofHeight := path.EndpointB.QueryProof(channelKey) - - msg = &channeltypes.MsgChannelUpgradeOpen{ - PortId: path.EndpointA.ChannelConfig.PortID, - ChannelId: path.EndpointA.ChannelID, - CounterpartyChannelState: counterpartyChannel.State, - CounterpartyUpgradeSequence: counterpartyChannel.UpgradeSequence, - ProofChannel: channelProof, - ProofHeight: proofHeight, - Signer: suite.chainA.SenderAccount.GetAddress().String(), - } - - tc.malleate() - - ctx := suite.chainA.GetContext() - res, err := suite.chainA.GetSimApp().GetIBCKeeper().ChannelUpgradeOpen(ctx, msg) - events := ctx.EventManager().Events().ToABCIEvents() - - tc.expResult(res, events, err) - }) - } -} - -func (suite *KeeperTestSuite) TestChannelUpgradeCancel() { - var ( - path *ibctesting.Path - msg *channeltypes.MsgChannelUpgradeCancel - ) - - cases := []struct { - name string - malleate func() - expResult func(res *channeltypes.MsgChannelUpgradeCancelResponse, events []abci.Event, err error) - }{ - { - "success: keeper is not authority, valid error receipt so channel changed to match error receipt seq", - func() {}, - func(res *channeltypes.MsgChannelUpgradeCancelResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - channel := path.EndpointA.GetChannel() - // Channel state should be reverted back to open. - suite.Require().Equal(channeltypes.OPEN, channel.State) - // Upgrade sequence should be changed to match sequence on error receipt. - suite.Require().Equal(uint64(2), channel.UpgradeSequence) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeCancel, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeError, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - sdk.NewAttribute(channeltypes.AttributeKeyErrorReceipt, "invalid upgrade"), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "success: keeper is authority & channel state in FLUSHING, so error receipt is ignored and channel is restored to initial upgrade sequence", - func() { - msg.Signer = suite.chainA.App.GetIBCKeeper().GetAuthority() - - path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { - channel.State = channeltypes.FLUSHING - channel.UpgradeSequence = uint64(3) - }) - }, - func(res *channeltypes.MsgChannelUpgradeCancelResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - channel := path.EndpointA.GetChannel() - // Channel state should be reverted back to open. - suite.Require().Equal(channeltypes.OPEN, channel.State) - // Upgrade sequence should be changed to match initial upgrade sequence. - suite.Require().Equal(uint64(3), channel.UpgradeSequence) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeCancel, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeError, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - // need to manually insert this because the errorReceipt is a string constant as it is written into state - sdk.NewAttribute(channeltypes.AttributeKeyErrorReceipt, "invalid upgrade"), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "success: keeper is authority & channel state in FLUSHING, can be cancelled even with invalid error receipt", - func() { - msg.Signer = suite.chainA.App.GetIBCKeeper().GetAuthority() - msg.ProofErrorReceipt = []byte("invalid proof") - - path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { - channel.State = channeltypes.FLUSHING - channel.UpgradeSequence = uint64(1) - }) - }, - func(res *channeltypes.MsgChannelUpgradeCancelResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - channel := path.EndpointA.GetChannel() - // Channel state should be reverted back to open. - suite.Require().Equal(channeltypes.OPEN, channel.State) - // Upgrade sequence should be changed to match initial upgrade sequence. - suite.Require().Equal(uint64(1), channel.UpgradeSequence) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeCancel, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeError, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - // need to manually insert this because the errorReceipt is a string constant as it is written into state - sdk.NewAttribute(channeltypes.AttributeKeyErrorReceipt, "invalid upgrade"), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "success: keeper is authority & channel state in FLUSHING, can be cancelled even with empty error receipt", - func() { - msg.Signer = suite.chainA.App.GetIBCKeeper().GetAuthority() - msg.ProofErrorReceipt = nil - - path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { - channel.State = channeltypes.FLUSHING - channel.UpgradeSequence = uint64(1) - }) - }, - func(res *channeltypes.MsgChannelUpgradeCancelResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - channel := path.EndpointA.GetChannel() - // Channel state should be reverted back to open. - suite.Require().Equal(channeltypes.OPEN, channel.State) - // Upgrade sequence should be changed to match initial upgrade sequence. - suite.Require().Equal(uint64(1), channel.UpgradeSequence) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeCancel, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeError, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - // need to manually insert this because the errorReceipt is a string constant as it is written into state - sdk.NewAttribute(channeltypes.AttributeKeyErrorReceipt, "invalid upgrade"), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "success: keeper is authority but channel state in FLUSHCOMPLETE, requires valid error receipt", - func() { - msg.Signer = suite.chainA.App.GetIBCKeeper().GetAuthority() - - path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { - channel.State = channeltypes.FLUSHCOMPLETE - channel.UpgradeSequence = uint64(2) // When in FLUSHCOMPLETE the sequence of the error receipt and the channel must match - }) - }, - func(res *channeltypes.MsgChannelUpgradeCancelResponse, events []abci.Event, err error) { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - channel := path.EndpointA.GetChannel() - // Channel state should be reverted back to open. - suite.Require().Equal(channeltypes.OPEN, channel.State) - // Upgrade sequence should not be changed. - suite.Require().Equal(uint64(2), channel.UpgradeSequence) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeCancel, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeError, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - // need to manually insert this because the errorReceipt is a string constant as it is written into state - sdk.NewAttribute(channeltypes.AttributeKeyErrorReceipt, "invalid upgrade"), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute( - sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "failure: keeper is authority and channel state in FLUSHCOMPLETE, but error receipt and channel upgrade sequences do not match", - func() { - msg.Signer = suite.chainA.App.GetIBCKeeper().GetAuthority() - - path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { channel.State = channeltypes.FLUSHCOMPLETE }) - }, - func(res *channeltypes.MsgChannelUpgradeCancelResponse, events []abci.Event, err error) { - suite.Require().Error(err) - suite.Require().Nil(res) - suite.Require().ErrorIs(err, channeltypes.ErrInvalidUpgradeSequence) - - channel := path.EndpointA.GetChannel() - // Channel state should not be reverted back to open. - suite.Require().Equal(channeltypes.FLUSHCOMPLETE, channel.State) - // Upgrade sequence should not be changed. - suite.Require().Equal(uint64(1), channel.UpgradeSequence) - }, - }, - { - "core handler fails: invalid proof", - func() { - msg.ProofErrorReceipt = []byte("invalid proof") - - // Force set to STATE_FLUSHCOMPLETE to check that state is not changed. - path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { - channel.State = channeltypes.FLUSHCOMPLETE - channel.UpgradeSequence = uint64(2) // When in FLUSHCOMPLETE the sequence of the error receipt and the channel must match - }) - }, - func(res *channeltypes.MsgChannelUpgradeCancelResponse, events []abci.Event, err error) { - suite.Require().Error(err) - suite.Require().Nil(res) - - channel := path.EndpointA.GetChannel() - suite.Require().ErrorIs(err, commitmenttypes.ErrInvalidProof) - // Channel state should not be changed. - suite.Require().Equal(channeltypes.FLUSHCOMPLETE, channel.State) - // Upgrade sequence should not be changed. - suite.Require().Equal(uint64(2), channel.UpgradeSequence) - - suite.Require().Empty(events) - }, - }, - } - - for _, tc := range cases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - // configure the channel upgrade version on testing endpoints - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - // cause the upgrade to fail on chain b so an error receipt is written. - // if the counterparty (chain A) upgrade sequence is less than the current sequence, (chain B) - // an upgrade error will be returned by chain B during ChanUpgradeTry. - path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) { channel.UpgradeSequence = uint64(1) }) - path.EndpointB.UpdateChannel(func(channel *channeltypes.Channel) { channel.UpgradeSequence = uint64(2) }) - - suite.Require().NoError(path.EndpointA.UpdateClient()) - suite.Require().NoError(path.EndpointB.UpdateClient()) - - suite.Require().NoError(path.EndpointB.ChanUpgradeTry()) - - suite.Require().NoError(path.EndpointA.UpdateClient()) - - upgradeErrorReceiptKey := host.ChannelUpgradeErrorKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - errorReceiptProof, proofHeight := path.EndpointB.QueryProof(upgradeErrorReceiptKey) - - errorReceipt, ok := suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(ok) - - msg = &channeltypes.MsgChannelUpgradeCancel{ - PortId: path.EndpointA.ChannelConfig.PortID, - ChannelId: path.EndpointA.ChannelID, - ErrorReceipt: errorReceipt, - ProofErrorReceipt: errorReceiptProof, - ProofHeight: proofHeight, - Signer: suite.chainA.SenderAccount.GetAddress().String(), - } - - tc.malleate() - - ctx := suite.chainA.GetContext() - res, err := suite.chainA.GetSimApp().GetIBCKeeper().ChannelUpgradeCancel(ctx, msg) - events := ctx.EventManager().Events().ToABCIEvents() - - tc.expResult(res, events, err) - }) - } -} - -func (suite *KeeperTestSuite) TestChannelUpgradeTimeout() { - var ( - path *ibctesting.Path - msg *channeltypes.MsgChannelUpgradeTimeout - ) - - timeoutUpgrade := func() { - upgrade := path.EndpointA.GetProposedUpgrade() - upgrade.Timeout = channeltypes.NewTimeout(clienttypes.ZeroHeight(), 1) - path.EndpointA.SetChannelUpgrade(upgrade) - suite.Require().NoError(path.EndpointB.UpdateClient()) - } - - cases := []struct { - name string - malleate func() - expResult func(res *channeltypes.MsgChannelUpgradeTimeoutResponse, events []abci.Event, err error) - }{ - { - "success", - func() { - timeoutUpgrade() - - suite.Require().NoError(path.EndpointA.UpdateClient()) - - channelKey := host.ChannelKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - channelProof, proofHeight := path.EndpointB.QueryProof(channelKey) - - msg.ProofChannel = channelProof - msg.ProofHeight = proofHeight - }, - func(res *channeltypes.MsgChannelUpgradeTimeoutResponse, events []abci.Event, err error) { - channel := path.EndpointA.GetChannel() - - suite.Require().Equalf(channeltypes.OPEN, channel.State, "channel state should be %s", channeltypes.OPEN.String()) - - _, found := path.EndpointA.Chain.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().False(found, "channel upgrade should be nil") - - suite.Require().NotNil(res) - suite.Require().NoError(err) - - errorReceipt, found := suite.chainA.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - suite.Require().Equal(uint64(1), errorReceipt.Sequence) - - // use the timeout we set in the malleate function - timeout := channeltypes.NewTimeout(clienttypes.ZeroHeight(), 1) - - expEvents := sdk.Events{ - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeTimeout, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeTimeoutHeight, timeout.Height.String()), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeTimeoutTimestamp, fmt.Sprintf("%d", timeout.Timestamp)), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - channeltypes.EventTypeChannelUpgradeError, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, path.EndpointA.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, path.EndpointA.ChannelID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, path.EndpointB.ChannelConfig.PortID), - sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, path.EndpointB.ChannelID), - sdk.NewAttribute(channeltypes.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - // need to manually insert this because the errorReceipt is a string constant as it is written into state - sdk.NewAttribute(channeltypes.AttributeKeyErrorReceipt, "upgrade timed-out"), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory), - ), - }.ToABCIEvents() - ibctesting.AssertEvents(&suite.Suite, expEvents, events) - }, - }, - { - "core handler fails: invalid proof", - func() { - timeoutUpgrade() - - suite.Require().NoError(path.EndpointA.UpdateClient()) - - _, _, proofHeight := path.EndpointB.QueryChannelUpgradeProof() - - msg.ProofHeight = proofHeight - msg.ProofChannel = []byte("invalid proof") - }, - func(res *channeltypes.MsgChannelUpgradeTimeoutResponse, events []abci.Event, err error) { - suite.Require().Error(err) - suite.Require().ErrorIs(err, commitmenttypes.ErrInvalidProof) - - channel := path.EndpointA.GetChannel() - suite.Require().Equalf(channeltypes.FLUSHCOMPLETE, channel.State, "channel state should be %s", channeltypes.OPEN) - suite.Require().Equal(uint64(1), channel.UpgradeSequence, "channel upgrade sequence should not incremented") - - _, found := path.EndpointA.Chain.GetSimApp().IBCKeeper.ChannelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found, "channel upgrade should not be nil") - - suite.Require().Empty(events) - }, - }, - } - - for _, tc := range cases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path = ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - - suite.Require().NoError(path.EndpointA.ChanUpgradeInit()) - suite.Require().NoError(path.EndpointB.ChanUpgradeTry()) - suite.Require().NoError(path.EndpointA.ChanUpgradeAck()) - - channelKey := host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - channelProof, proofHeight := path.EndpointB.QueryProof(channelKey) - - msg = &channeltypes.MsgChannelUpgradeTimeout{ - PortId: path.EndpointA.ChannelConfig.PortID, - ChannelId: path.EndpointA.ChannelID, - CounterpartyChannel: path.EndpointB.GetChannel(), - ProofChannel: channelProof, - ProofHeight: proofHeight, - Signer: suite.chainA.SenderAccount.GetAddress().String(), - } - - tc.malleate() - - ctx := suite.chainA.GetContext() - res, err := suite.chainA.GetSimApp().GetIBCKeeper().ChannelUpgradeTimeout(ctx, msg) - events := ctx.EventManager().Events().ToABCIEvents() - - tc.expResult(res, events, err) - }) - } -} - -// TestIBCSoftwareUpgrade tests the IBCSoftwareUpgrade rpc handler -func (suite *KeeperTestSuite) TestIBCSoftwareUpgrade() { - var msg *clienttypes.MsgIBCSoftwareUpgrade - testCases := []struct { - name string - malleate func() - expError error - }{ - { - "success: valid authority and client upgrade", - func() {}, - nil, - }, - { - "failure: invalid authority address", - func() { - msg.Signer = suite.chainA.SenderAccount.GetAddress().String() - }, - ibcerrors.ErrUnauthorized, - }, - { - "failure: invalid clientState", - func() { - msg.UpgradedClientState = nil - }, - clienttypes.ErrInvalidClientType, - }, - { - "failure: failed to schedule client upgrade", - func() { - msg.Plan.Height = 0 - }, - sdkerrors.ErrInvalidRequest, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.SetupClients() - validAuthority := suite.chainA.App.GetIBCKeeper().GetAuthority() - plan := upgradetypes.Plan{ - Name: "upgrade IBC clients", - Height: 1000, - } - // update trusting period - clientState, ok := path.EndpointB.GetClientState().(*ibctm.ClientState) - suite.Require().True(ok) - clientState.TrustingPeriod += 100 - - var err error - msg, err = clienttypes.NewMsgIBCSoftwareUpgrade( - validAuthority, - plan, - clientState, - ) - - suite.Require().NoError(err) - - tc.malleate() - - _, err = suite.chainA.App.GetIBCKeeper().IBCSoftwareUpgrade(suite.chainA.GetContext(), msg) - - if tc.expError == nil { - suite.Require().NoError(err) - // upgrade plan is stored - storedPlan, err := suite.chainA.GetSimApp().UpgradeKeeper.GetUpgradePlan(suite.chainA.GetContext()) - suite.Require().NoError(err) - suite.Require().Equal(plan, storedPlan) - - // upgraded client state is stored - bz, err := suite.chainA.GetSimApp().UpgradeKeeper.GetUpgradedClient(suite.chainA.GetContext(), plan.Height) - suite.Require().NoError(err) - upgradedClientState, err := clienttypes.UnmarshalClientState(suite.chainA.App.AppCodec(), bz) - suite.Require().NoError(err) - suite.Require().Equal(clientState.ZeroCustomFields(), upgradedClientState) - } else { - suite.Require().True(errors.Is(err, tc.expError)) - } - }) - } -} - -// TestUpdateClientParams tests the UpdateClientParams rpc handler -func (suite *KeeperTestSuite) TestUpdateClientParams() { - signer := suite.chainA.App.GetIBCKeeper().GetAuthority() - testCases := []struct { - name string - msg *clienttypes.MsgUpdateParams - expError error - }{ - { - "success: valid signer and default params", - clienttypes.NewMsgUpdateParams(signer, clienttypes.DefaultParams()), - nil, - }, - { - "failure: malformed signer address", - clienttypes.NewMsgUpdateParams(ibctesting.InvalidID, clienttypes.DefaultParams()), - errors.New("unauthorized"), - }, - { - "failure: empty signer address", - clienttypes.NewMsgUpdateParams("", clienttypes.DefaultParams()), - errors.New("unauthorized"), - }, - { - "failure: whitespace signer address", - clienttypes.NewMsgUpdateParams(" ", clienttypes.DefaultParams()), - errors.New("unauthorized"), - }, - { - "failure: unauthorized signer address", - clienttypes.NewMsgUpdateParams(ibctesting.TestAccAddress, clienttypes.DefaultParams()), - errors.New("unauthorized"), - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - _, err := suite.chainA.App.GetIBCKeeper().UpdateClientParams(suite.chainA.GetContext(), tc.msg) - if tc.expError == nil { - suite.Require().NoError(err) - p := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetParams(suite.chainA.GetContext()) - suite.Require().Equal(tc.msg.Params, p) - } else { - suite.Require().Error(err) - suite.Require().Contains(err.Error(), tc.expError.Error()) - } - }) - } -} - -// TestUpdateConnectionParams tests the UpdateConnectionParams rpc handler -func (suite *KeeperTestSuite) TestUpdateConnectionParams() { - signer := suite.chainA.App.GetIBCKeeper().GetAuthority() - testCases := []struct { - name string - msg *connectiontypes.MsgUpdateParams - expErr error - }{ - { - "success: valid signer and default params", - connectiontypes.NewMsgUpdateParams(signer, connectiontypes.DefaultParams()), - nil, - }, - { - "failure: malformed signer address", - connectiontypes.NewMsgUpdateParams(ibctesting.InvalidID, connectiontypes.DefaultParams()), - errors.New("unauthorized"), - }, - { - "failure: empty signer address", - connectiontypes.NewMsgUpdateParams("", connectiontypes.DefaultParams()), - errors.New("unauthorized"), - }, - { - "failure: whitespace signer address", - connectiontypes.NewMsgUpdateParams(" ", connectiontypes.DefaultParams()), - errors.New("unauthorized"), - }, - { - "failure: unauthorized signer address", - connectiontypes.NewMsgUpdateParams(ibctesting.TestAccAddress, connectiontypes.DefaultParams()), - errors.New("unauthorized"), - }, - } - - for _, tc := range testCases { + for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { suite.SetupTest() @@ -2688,132 +1149,3 @@ func (suite *KeeperTestSuite) TestUpdateConnectionParams() { }) } } - -// TestUpdateChannelParams tests the UpdateChannelParams rpc handler -func (suite *KeeperTestSuite) TestUpdateChannelParams() { - authority := suite.chainA.App.GetIBCKeeper().GetAuthority() - testCases := []struct { - name string - msg *channeltypes.MsgUpdateParams - expError error - }{ - { - "success: valid authority and default params", - channeltypes.NewMsgUpdateChannelParams(authority, channeltypes.DefaultParams()), - nil, - }, - { - "failure: malformed authority address", - channeltypes.NewMsgUpdateChannelParams(ibctesting.InvalidID, channeltypes.DefaultParams()), - ibcerrors.ErrUnauthorized, - }, - { - "failure: empty authority address", - channeltypes.NewMsgUpdateChannelParams("", channeltypes.DefaultParams()), - ibcerrors.ErrUnauthorized, - }, - { - "failure: empty signer", - channeltypes.NewMsgUpdateChannelParams("", channeltypes.DefaultParams()), - ibcerrors.ErrUnauthorized, - }, - { - "failure: unauthorized authority address", - channeltypes.NewMsgUpdateChannelParams(ibctesting.TestAccAddress, channeltypes.DefaultParams()), - ibcerrors.ErrUnauthorized, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - resp, err := suite.chainA.App.GetIBCKeeper().UpdateChannelParams(suite.chainA.GetContext(), tc.msg) - if tc.expError == nil { - suite.Require().NoError(err) - suite.Require().NotNil(resp) - p := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetParams(suite.chainA.GetContext()) - suite.Require().Equal(tc.msg.Params, p) - } else { - suite.Require().Nil(resp) - suite.Require().ErrorIs(err, tc.expError) - } - }) - } -} - -func (suite *KeeperTestSuite) TestPruneAcknowledgements() { - var msg *channeltypes.MsgPruneAcknowledgements - - testCases := []struct { - name string - malleate func() - expErr error - }{ - { - "success", - func() {}, - nil, - }, - { - "failure: core keeper function fails, pruning sequence end not found", - func() { - msg.PortId = "portidone" - }, - channeltypes.ErrRecvStartSequenceNotFound, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - suite.SetupTest() - - path := ibctesting.NewPath(suite.chainA, suite.chainB) - path.Setup() - - // configure the channel upgrade version on testing endpoints - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion - - err := path.EndpointA.ChanUpgradeInit() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeTry() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeAck() - suite.Require().NoError(err) - - err = path.EndpointB.ChanUpgradeConfirm() - suite.Require().NoError(err) - - err = path.EndpointA.ChanUpgradeOpen() - suite.Require().NoError(err) - - err = path.EndpointA.UpdateClient() - suite.Require().NoError(err) - - msg = channeltypes.NewMsgPruneAcknowledgements( - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - 10, - suite.chainA.SenderAccount.GetAddress().String(), - ) - - tc.malleate() - - resp, err := suite.chainA.App.GetIBCKeeper().PruneAcknowledgements(suite.chainA.GetContext(), msg) - - if tc.expErr == nil { - suite.Require().NoError(err) - suite.Require().NotNil(resp) - suite.Require().Equal(uint64(0), resp.TotalPrunedSequences) - suite.Require().Equal(uint64(0), resp.TotalRemainingSequences) - } else { - suite.Require().Error(err) - suite.Require().Nil(resp) - } - }) - } -} diff --git a/modules/core/module.go b/modules/core/module.go index 6acb58ce59f..a76a6d70d1c 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -168,14 +168,22 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { panic(err) } - channelMigrator := channelkeeper.NewMigrator(am.keeper.ChannelKeeper) - if err := cfg.RegisterMigration(exported.ModuleName, 5, channelMigrator.MigrateParams); err != nil { + // This upgrade used to just add default params, since we have deleted it (in consensus version 8 - ibc-go v10), + // we just return directly to increment the ConsensusVersion as expected + if err := cfg.RegisterMigration(exported.ModuleName, 5, func(_ sdk.Context) error { + return nil + }); err != nil { panic(err) } if err := cfg.RegisterMigration(exported.ModuleName, 6, clientMigrator.MigrateToStatelessLocalhost); err != nil { panic(err) } + + channelMigrator := channelkeeper.NewMigrator(am.keeper.ChannelKeeper) + if err := cfg.RegisterMigration(exported.ModuleName, 7, channelMigrator.Migrate7To8); err != nil { + panic(err) + } } // InitGenesis performs genesis initialization for the ibc module. It returns @@ -196,7 +204,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 7 } +func (AppModule) ConsensusVersion() uint64 { return 8 } // BeginBlock returns the begin blocker for the ibc module. func (am AppModule) BeginBlock(goCtx context.Context) error { diff --git a/proto/ibc/core/channel/v1/channel.proto b/proto/ibc/core/channel/v1/channel.proto index aba71984864..b37cf972f04 100644 --- a/proto/ibc/core/channel/v1/channel.proto +++ b/proto/ibc/core/channel/v1/channel.proto @@ -24,9 +24,6 @@ message Channel { repeated string connection_hops = 4; // opaque channel version, which is agreed upon during the handshake string version = 5; - // upgrade sequence indicates the latest upgrade attempt performed by this channel - // the value of 0 indicates the channel has never been upgraded - uint64 upgrade_sequence = 6; } // IdentifiedChannel defines a channel with additional port and channel @@ -49,13 +46,10 @@ message IdentifiedChannel { string port_id = 6; // channel identifier string channel_id = 7; - // upgrade sequence indicates the latest upgrade attempt performed by this channel - // the value of 0 indicates the channel has never been upgraded - uint64 upgrade_sequence = 8; } // State defines if a channel is in one of the following states: -// CLOSED, INIT, TRYOPEN, OPEN, FLUSHING, FLUSHCOMPLETE or UNINITIALIZED. +// CLOSED, INIT, TRYOPEN, OPEN, or UNINITIALIZED. enum State { option (gogoproto.goproto_enum_prefix) = false; @@ -71,10 +65,6 @@ enum State { // A channel has been closed and can no longer be used to send or receive // packets. STATE_CLOSED = 4 [(gogoproto.enumvalue_customname) = "CLOSED"]; - // A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - STATE_FLUSHING = 5 [(gogoproto.enumvalue_customname) = "FLUSHING"]; - // A channel has just completed flushing any in-flight packets. - STATE_FLUSHCOMPLETE = 6 [(gogoproto.enumvalue_customname) = "FLUSHCOMPLETE"]; } // Order defines if a channel is ORDERED or UNORDERED @@ -171,17 +161,11 @@ message Acknowledgement { } // Timeout defines an execution deadline structure for 04-channel handlers. -// This includes packet lifecycle handlers as well as the upgrade handshake handlers. +// This includes packet lifecycle handlers. // A valid Timeout contains either one or both of a timestamp and block height (sequence). message Timeout { - // block height after which the packet or upgrade times out + // block height after which the packet times out ibc.core.client.v1.Height height = 1 [(gogoproto.nullable) = false]; - // block timestamp (in nanoseconds) after which the packet or upgrade times out + // block timestamp (in nanoseconds) after which the packet times out uint64 timestamp = 2; } - -// Params defines the set of IBC channel parameters. -message Params { - // the relative timeout after which channel upgrades will time out. - Timeout upgrade_timeout = 1 [(gogoproto.nullable) = false]; -} diff --git a/proto/ibc/core/channel/v1/genesis.proto b/proto/ibc/core/channel/v1/genesis.proto index eec59444140..f03e4db4dc2 100644 --- a/proto/ibc/core/channel/v1/genesis.proto +++ b/proto/ibc/core/channel/v1/genesis.proto @@ -18,7 +18,6 @@ message GenesisState { repeated PacketSequence ack_sequences = 7 [(gogoproto.nullable) = false]; // the sequence for the next generated channel identifier uint64 next_channel_sequence = 8; - Params params = 9 [(gogoproto.nullable) = false]; } // PacketSequence defines the genesis type necessary to retrieve and store diff --git a/proto/ibc/core/channel/v1/query.proto b/proto/ibc/core/channel/v1/query.proto index 26f0c251dd0..ca4041b47f3 100644 --- a/proto/ibc/core/channel/v1/query.proto +++ b/proto/ibc/core/channel/v1/query.proto @@ -10,7 +10,6 @@ import "ibc/core/channel/v1/channel.proto"; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "gogoproto/gogo.proto"; -import "ibc/core/channel/v1/upgrade.proto"; // Query provides defines the gRPC querier service service Query { @@ -105,23 +104,6 @@ service Query { option (google.api.http).get = "/ibc/core/channel/v1/channels/{channel_id}/" "ports/{port_id}/next_sequence_send"; } - - // UpgradeError returns the error receipt if the upgrade handshake failed. - rpc UpgradeError(QueryUpgradeErrorRequest) returns (QueryUpgradeErrorResponse) { - option (google.api.http).get = "/ibc/core/channel/v1/channels/{channel_id}/" - "ports/{port_id}/upgrade_error"; - } - - // Upgrade returns the upgrade for a given port and channel id. - rpc Upgrade(QueryUpgradeRequest) returns (QueryUpgradeResponse) { - option (google.api.http).get = "/ibc/core/channel/v1/channels/{channel_id}/" - "ports/{port_id}/upgrade"; - } - - // ChannelParams queries all parameters of the ibc channel submodule. - rpc ChannelParams(QueryChannelParamsRequest) returns (QueryChannelParamsResponse) { - option (google.api.http).get = "/ibc/core/channel/v1/params"; - } } // QueryChannelRequest is the request type for the Query/Channel RPC method @@ -418,42 +400,3 @@ message QueryNextSequenceSendResponse { // height at which the proof was retrieved ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; } - -// QueryUpgradeErrorRequest is the request type for the Query/QueryUpgradeError RPC method -message QueryUpgradeErrorRequest { - string port_id = 1; - string channel_id = 2; -} - -// QueryUpgradeErrorResponse is the response type for the Query/QueryUpgradeError RPC method -message QueryUpgradeErrorResponse { - ErrorReceipt error_receipt = 1 [(gogoproto.nullable) = false]; - // merkle proof of existence - bytes proof = 2; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} - -// QueryUpgradeRequest is the request type for the QueryUpgradeRequest RPC method -message QueryUpgradeRequest { - string port_id = 1; - string channel_id = 2; -} - -// QueryUpgradeResponse is the response type for the QueryUpgradeResponse RPC method -message QueryUpgradeResponse { - Upgrade upgrade = 1 [(gogoproto.nullable) = false]; - // merkle proof of existence - bytes proof = 2; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} - -// QueryChannelParamsRequest is the request type for the Query/ChannelParams RPC method. -message QueryChannelParamsRequest {} - -// QueryChannelParamsResponse is the response type for the Query/ChannelParams RPC method. -message QueryChannelParamsResponse { - // params defines the parameters of the module. - Params params = 1; -} diff --git a/proto/ibc/core/channel/v1/tx.proto b/proto/ibc/core/channel/v1/tx.proto index 75baa1f42a5..85c8ac44853 100644 --- a/proto/ibc/core/channel/v1/tx.proto +++ b/proto/ibc/core/channel/v1/tx.proto @@ -8,7 +8,6 @@ import "gogoproto/gogo.proto"; import "cosmos/msg/v1/msg.proto"; import "ibc/core/client/v1/client.proto"; import "ibc/core/channel/v1/channel.proto"; -import "ibc/core/channel/v1/upgrade.proto"; // Msg defines the ibc/channel Msg service. service Msg { @@ -44,33 +43,6 @@ service Msg { // Acknowledgement defines a rpc handler method for MsgAcknowledgement. rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse); - - // ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit. - rpc ChannelUpgradeInit(MsgChannelUpgradeInit) returns (MsgChannelUpgradeInitResponse); - - // ChannelUpgradeTry defines a rpc handler method for MsgChannelUpgradeTry. - rpc ChannelUpgradeTry(MsgChannelUpgradeTry) returns (MsgChannelUpgradeTryResponse); - - // ChannelUpgradeAck defines a rpc handler method for MsgChannelUpgradeAck. - rpc ChannelUpgradeAck(MsgChannelUpgradeAck) returns (MsgChannelUpgradeAckResponse); - - // ChannelUpgradeConfirm defines a rpc handler method for MsgChannelUpgradeConfirm. - rpc ChannelUpgradeConfirm(MsgChannelUpgradeConfirm) returns (MsgChannelUpgradeConfirmResponse); - - // ChannelUpgradeOpen defines a rpc handler method for MsgChannelUpgradeOpen. - rpc ChannelUpgradeOpen(MsgChannelUpgradeOpen) returns (MsgChannelUpgradeOpenResponse); - - // ChannelUpgradeTimeout defines a rpc handler method for MsgChannelUpgradeTimeout. - rpc ChannelUpgradeTimeout(MsgChannelUpgradeTimeout) returns (MsgChannelUpgradeTimeoutResponse); - - // ChannelUpgradeCancel defines a rpc handler method for MsgChannelUpgradeCancel. - rpc ChannelUpgradeCancel(MsgChannelUpgradeCancel) returns (MsgChannelUpgradeCancelResponse); - - // UpdateChannelParams defines a rpc handler method for MsgUpdateParams. - rpc UpdateChannelParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); - - // PruneAcknowledgements defines a rpc handler method for MsgPruneAcknowledgements. - rpc PruneAcknowledgements(MsgPruneAcknowledgements) returns (MsgPruneAcknowledgementsResponse); } // ResponseResultType defines the possible outcomes of the execution of a message @@ -136,9 +108,6 @@ message MsgChannelOpenTryResponse { // MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge // the change of channel state to TRYOPEN on Chain B. -// WARNING: a channel upgrade MUST NOT initialize an upgrade for this channel -// in the same block as executing this message otherwise the counterparty will -// be incapable of opening. message MsgChannelOpenAck { option (cosmos.msg.v1.signer) = "signer"; @@ -201,7 +170,6 @@ message MsgChannelCloseConfirm { bytes proof_init = 3; ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; string signer = 5; - uint64 counterparty_upgrade_sequence = 6; } // MsgChannelCloseConfirmResponse defines the Msg/ChannelCloseConfirm response @@ -259,7 +227,6 @@ message MsgTimeoutOnClose { ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; uint64 next_sequence_recv = 5; string signer = 6; - uint64 counterparty_upgrade_sequence = 7; } // MsgTimeoutOnCloseResponse defines the Msg/TimeoutOnClose response type. @@ -288,182 +255,3 @@ message MsgAcknowledgementResponse { ResponseResultType result = 1; } - -// MsgChannelUpgradeInit defines the request type for the ChannelUpgradeInit rpc -// WARNING: Initializing a channel upgrade in the same block as opening the channel -// may result in the counterparty being incapable of opening. -message MsgChannelUpgradeInit { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - - string port_id = 1; - string channel_id = 2; - UpgradeFields fields = 3 [(gogoproto.nullable) = false]; - string signer = 4; -} - -// MsgChannelUpgradeInitResponse defines the MsgChannelUpgradeInit response type -message MsgChannelUpgradeInitResponse { - option (gogoproto.goproto_getters) = false; - - Upgrade upgrade = 1 [(gogoproto.nullable) = false]; - uint64 upgrade_sequence = 2; -} - -// MsgChannelUpgradeTry defines the request type for the ChannelUpgradeTry rpc -message MsgChannelUpgradeTry { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - - string port_id = 1; - string channel_id = 2; - repeated string proposed_upgrade_connection_hops = 3; - UpgradeFields counterparty_upgrade_fields = 4 [(gogoproto.nullable) = false]; - uint64 counterparty_upgrade_sequence = 5; - bytes proof_channel = 6; - bytes proof_upgrade = 7; - ibc.core.client.v1.Height proof_height = 8 [(gogoproto.nullable) = false]; - string signer = 9; -} - -// MsgChannelUpgradeTryResponse defines the MsgChannelUpgradeTry response type -message MsgChannelUpgradeTryResponse { - option (gogoproto.goproto_getters) = false; - - Upgrade upgrade = 1 [(gogoproto.nullable) = false]; - uint64 upgrade_sequence = 2; - ResponseResultType result = 3; -} - -// MsgChannelUpgradeAck defines the request type for the ChannelUpgradeAck rpc -message MsgChannelUpgradeAck { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - string port_id = 1; - string channel_id = 2; - Upgrade counterparty_upgrade = 3 [(gogoproto.nullable) = false]; - bytes proof_channel = 4; - bytes proof_upgrade = 5; - ibc.core.client.v1.Height proof_height = 6 [(gogoproto.nullable) = false]; - string signer = 7; -} - -// MsgChannelUpgradeAckResponse defines MsgChannelUpgradeAck response type -message MsgChannelUpgradeAckResponse { - option (gogoproto.goproto_getters) = false; - - ResponseResultType result = 1; -} - -// MsgChannelUpgradeConfirm defines the request type for the ChannelUpgradeConfirm rpc -message MsgChannelUpgradeConfirm { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - string port_id = 1; - string channel_id = 2; - State counterparty_channel_state = 3; - Upgrade counterparty_upgrade = 4 [(gogoproto.nullable) = false]; - bytes proof_channel = 5; - bytes proof_upgrade = 6; - ibc.core.client.v1.Height proof_height = 7 [(gogoproto.nullable) = false]; - string signer = 8; -} - -// MsgChannelUpgradeConfirmResponse defines MsgChannelUpgradeConfirm response type -message MsgChannelUpgradeConfirmResponse { - option (gogoproto.goproto_getters) = false; - - ResponseResultType result = 1; -} - -// MsgChannelUpgradeOpen defines the request type for the ChannelUpgradeOpen rpc -message MsgChannelUpgradeOpen { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - string port_id = 1; - string channel_id = 2; - State counterparty_channel_state = 3; - uint64 counterparty_upgrade_sequence = 4; - bytes proof_channel = 5; - ibc.core.client.v1.Height proof_height = 6 [(gogoproto.nullable) = false]; - string signer = 7; -} - -// MsgChannelUpgradeOpenResponse defines the MsgChannelUpgradeOpen response type -message MsgChannelUpgradeOpenResponse {} - -// MsgChannelUpgradeTimeout defines the request type for the ChannelUpgradeTimeout rpc -message MsgChannelUpgradeTimeout { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - - string port_id = 1; - string channel_id = 2; - Channel counterparty_channel = 3 [(gogoproto.nullable) = false]; - bytes proof_channel = 4; - ibc.core.client.v1.Height proof_height = 5 [(gogoproto.nullable) = false]; - string signer = 6; -} - -// MsgChannelUpgradeTimeoutResponse defines the MsgChannelUpgradeTimeout response type -message MsgChannelUpgradeTimeoutResponse {} - -// MsgChannelUpgradeCancel defines the request type for the ChannelUpgradeCancel rpc -message MsgChannelUpgradeCancel { - option (cosmos.msg.v1.signer) = "signer"; - - option (gogoproto.goproto_getters) = false; - - string port_id = 1; - string channel_id = 2; - ErrorReceipt error_receipt = 3 [(gogoproto.nullable) = false]; - bytes proof_error_receipt = 4; - ibc.core.client.v1.Height proof_height = 5 [(gogoproto.nullable) = false]; - string signer = 6; -} - -// MsgChannelUpgradeCancelResponse defines the MsgChannelUpgradeCancel response type -message MsgChannelUpgradeCancelResponse {} - -// MsgUpdateParams is the MsgUpdateParams request type. -message MsgUpdateParams { - option (cosmos.msg.v1.signer) = "authority"; - - option (gogoproto.goproto_getters) = false; - - // authority is the address that controls the module (defaults to x/gov unless overwritten). - string authority = 1; - - // params defines the channel parameters to update. - // - // NOTE: All parameters must be supplied. - Params params = 2 [(gogoproto.nullable) = false]; -} - -// MsgUpdateParamsResponse defines the MsgUpdateParams response type. -message MsgUpdateParamsResponse {} - -// MsgPruneAcknowledgements defines the request type for the PruneAcknowledgements rpc. -message MsgPruneAcknowledgements { - option (cosmos.msg.v1.signer) = "signer"; - option (gogoproto.goproto_getters) = false; - - string port_id = 1; - string channel_id = 2; - uint64 limit = 3; - string signer = 4; -} - -// MsgPruneAcknowledgementsResponse defines the response type for the PruneAcknowledgements rpc. -message MsgPruneAcknowledgementsResponse { - // Number of sequences pruned (includes both packet acknowledgements and packet receipts where appropriate). - uint64 total_pruned_sequences = 1; - // Number of sequences left after pruning. - uint64 total_remaining_sequences = 2; -} diff --git a/proto/ibc/core/channel/v1/upgrade.proto b/proto/ibc/core/channel/v1/upgrade.proto deleted file mode 100644 index 319954d9aed..00000000000 --- a/proto/ibc/core/channel/v1/upgrade.proto +++ /dev/null @@ -1,43 +0,0 @@ -syntax = "proto3"; - -package ibc.core.channel.v1; - -option go_package = "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types"; - -import "gogoproto/gogo.proto"; -import "ibc/core/channel/v1/channel.proto"; - -// Upgrade is a verifiable type which contains the relevant information -// for an attempted upgrade. It provides the proposed changes to the channel -// end, the timeout for this upgrade attempt and the next packet sequence -// which allows the counterparty to efficiently know the highest sequence it has received. -// The next sequence send is used for pruning and upgrading from unordered to ordered channels. -message Upgrade { - option (gogoproto.goproto_getters) = false; - - UpgradeFields fields = 1 [(gogoproto.nullable) = false]; - Timeout timeout = 2 [(gogoproto.nullable) = false]; - uint64 next_sequence_send = 3; -} - -// UpgradeFields are the fields in a channel end which may be changed -// during a channel upgrade. -message UpgradeFields { - option (gogoproto.goproto_getters) = false; - - Order ordering = 1; - repeated string connection_hops = 2; - string version = 3; -} - -// ErrorReceipt defines a type which encapsulates the upgrade sequence and error associated with the -// upgrade handshake failure. When a channel upgrade handshake is aborted both chains are expected to increment to the -// next sequence. -message ErrorReceipt { - option (gogoproto.goproto_getters) = false; - - // the channel upgrade sequence - uint64 sequence = 1; - // the error message detailing the cause of failure - string message = 2; -} diff --git a/testing/config.go b/testing/config.go index c2fc455970e..879d61d079a 100644 --- a/testing/config.go +++ b/testing/config.go @@ -47,10 +47,9 @@ func NewConnectionConfig() *ConnectionConfig { } type ChannelConfig struct { - PortID string - Version string - Order channeltypes.Order - ProposedUpgrade channeltypes.Upgrade + PortID string + Version string + Order channeltypes.Order } func NewChannelConfig() *ChannelConfig { diff --git a/testing/endpoint.go b/testing/endpoint.go index 42a9afb0b00..bf1f909b842 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -8,8 +8,6 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/baseapp" - sdk "github.com/cosmos/cosmos-sdk/types" - govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" abci "github.com/cometbft/cometbft/abci/types" @@ -599,203 +597,11 @@ func (endpoint *Endpoint) TimeoutOnClose(packet channeltypes.Packet) error { timeoutOnCloseMsg := channeltypes.NewMsgTimeoutOnClose( packet, nextSeqRecv, proof, closedProof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String(), - endpoint.Counterparty.GetChannel().UpgradeSequence, ) return endpoint.Chain.sendMsgs(timeoutOnCloseMsg) } -// QueryChannelUpgradeProof returns all the proofs necessary to execute UpgradeTry/UpgradeAck/UpgradeOpen. -// It returns the proof for the channel on the endpoint's chain, the proof for the upgrade attempt on the -// endpoint's chain, and the height at which the proof was queried. -func (endpoint *Endpoint) QueryChannelUpgradeProof() ([]byte, []byte, clienttypes.Height) { - channelKey := host.ChannelKey(endpoint.ChannelConfig.PortID, endpoint.ChannelID) - channelProof, height := endpoint.QueryProof(channelKey) - - upgradeKey := host.ChannelUpgradeKey(endpoint.ChannelConfig.PortID, endpoint.ChannelID) - upgradeProof, _ := endpoint.QueryProof(upgradeKey) - - return channelProof, upgradeProof, height -} - -// ChanUpgradeInit sends a MsgChannelUpgradeInit on the associated endpoint. -// A default upgrade proposal is used with overrides from the ProposedUpgrade -// in the channel config, and submitted via governance proposal -func (endpoint *Endpoint) ChanUpgradeInit() error { - upgrade := endpoint.GetProposedUpgrade() - - // create upgrade init message via gov proposal and submit the proposal - msg := channeltypes.NewMsgChannelUpgradeInit( - endpoint.ChannelConfig.PortID, - endpoint.ChannelID, - upgrade.Fields, - endpoint.Chain.GetSimApp().IBCKeeper.GetAuthority(), - ) - - proposal, err := govtypesv1.NewMsgSubmitProposal( - []sdk.Msg{msg}, - sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, govtypesv1.DefaultMinDepositTokens)), - endpoint.Chain.SenderAccount.GetAddress().String(), - endpoint.ChannelID, - "upgrade-init", - fmt.Sprintf("gov proposal for initialising channel upgrade: %s", endpoint.ChannelID), - false, - ) - require.NoError(endpoint.Chain.TB, err) - - var proposalID uint64 - res, err := endpoint.Chain.SendMsgs(proposal) - if err != nil { - return err - } - - proposalID, err = ParseProposalIDFromEvents(res.Events) - require.NoError(endpoint.Chain.TB, err) - - return VoteAndCheckProposalStatus(endpoint, proposalID) -} - -// ChanUpgradeTry sends a MsgChannelUpgradeTry on the associated endpoint. -func (endpoint *Endpoint) ChanUpgradeTry() error { - err := endpoint.UpdateClient() - require.NoError(endpoint.Chain.TB, err) - - upgrade := endpoint.GetProposedUpgrade() - channelProof, upgradeProof, height := endpoint.Counterparty.QueryChannelUpgradeProof() - - counterpartyUpgrade, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(endpoint.Counterparty.Chain.GetContext(), endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) - require.True(endpoint.Chain.TB, found) - - if !found { - return fmt.Errorf("could not find upgrade for channel %s", endpoint.ChannelID) - } - - msg := channeltypes.NewMsgChannelUpgradeTry( - endpoint.ChannelConfig.PortID, - endpoint.ChannelID, - upgrade.Fields.ConnectionHops, - counterpartyUpgrade.Fields, - endpoint.Counterparty.GetChannel().UpgradeSequence, - channelProof, - upgradeProof, - height, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - - return endpoint.Chain.sendMsgs(msg) -} - -// ChanUpgradeAck sends a MsgChannelUpgradeAck to the associated endpoint. -func (endpoint *Endpoint) ChanUpgradeAck() error { - err := endpoint.UpdateClient() - require.NoError(endpoint.Chain.TB, err) - - channelProof, upgradeProof, height := endpoint.Counterparty.QueryChannelUpgradeProof() - - counterpartyUpgrade, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(endpoint.Counterparty.Chain.GetContext(), endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) - require.True(endpoint.Chain.TB, found) - - msg := channeltypes.NewMsgChannelUpgradeAck( - endpoint.ChannelConfig.PortID, - endpoint.ChannelID, - counterpartyUpgrade, - channelProof, - upgradeProof, - height, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - - return endpoint.Chain.sendMsgs(msg) -} - -// ChanUpgradeConfirm sends a MsgChannelUpgradeConfirm to the associated endpoint. -func (endpoint *Endpoint) ChanUpgradeConfirm() error { - err := endpoint.UpdateClient() - require.NoError(endpoint.Chain.TB, err) - - channelProof, upgradeProof, height := endpoint.Counterparty.QueryChannelUpgradeProof() - - counterpartyUpgrade, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(endpoint.Counterparty.Chain.GetContext(), endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) - require.True(endpoint.Chain.TB, found) - - msg := channeltypes.NewMsgChannelUpgradeConfirm( - endpoint.ChannelConfig.PortID, - endpoint.ChannelID, - endpoint.Counterparty.GetChannel().State, - counterpartyUpgrade, - channelProof, - upgradeProof, - height, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - - return endpoint.Chain.sendMsgs(msg) -} - -// ChanUpgradeOpen sends a MsgChannelUpgradeOpen to the associated endpoint. -func (endpoint *Endpoint) ChanUpgradeOpen() error { - err := endpoint.UpdateClient() - require.NoError(endpoint.Chain.TB, err) - - channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) - channelProof, height := endpoint.Counterparty.QueryProof(channelKey) - - msg := channeltypes.NewMsgChannelUpgradeOpen( - endpoint.ChannelConfig.PortID, - endpoint.ChannelID, - endpoint.Counterparty.GetChannel().State, - endpoint.Counterparty.GetChannel().UpgradeSequence, - channelProof, - height, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - - return endpoint.Chain.sendMsgs(msg) -} - -// ChanUpgradeTimeout sends a MsgChannelUpgradeTimeout to the associated endpoint. -func (endpoint *Endpoint) ChanUpgradeTimeout() error { - err := endpoint.UpdateClient() - require.NoError(endpoint.Chain.TB, err) - - channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) - channelProof, height := endpoint.Counterparty.Chain.QueryProof(channelKey) - - msg := channeltypes.NewMsgChannelUpgradeTimeout( - endpoint.ChannelConfig.PortID, - endpoint.ChannelID, - endpoint.Counterparty.GetChannel(), - channelProof, - height, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - - return endpoint.Chain.sendMsgs(msg) -} - -// ChanUpgradeCancel sends a MsgChannelUpgradeCancel to the associated endpoint. -func (endpoint *Endpoint) ChanUpgradeCancel() error { - err := endpoint.UpdateClient() - require.NoError(endpoint.Chain.TB, err) - - errorReceiptKey := host.ChannelUpgradeErrorKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) - proofErrorReceipt, height := endpoint.Counterparty.Chain.QueryProof(errorReceiptKey) - - errorReceipt, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(endpoint.Counterparty.Chain.GetContext(), endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) - require.True(endpoint.Chain.TB, found) - - msg := channeltypes.NewMsgChannelUpgradeCancel( - endpoint.ChannelConfig.PortID, - endpoint.ChannelID, - errorReceipt, - proofErrorReceipt, - height, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - - return endpoint.Chain.sendMsgs(msg) -} - // Deprecated: usage of this function should be replaced by `UpdateChannel` // SetChannelState sets a channel state func (endpoint *Endpoint) SetChannelState(state channeltypes.State) error { @@ -881,25 +687,6 @@ func (endpoint *Endpoint) SetChannel(channel channeltypes.Channel) { endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel) } -// GetChannelUpgrade retrieves an IBC Channel Upgrade for the endpoint. The upgrade -// is expected to exist otherwise testing will fail. -func (endpoint *Endpoint) GetChannelUpgrade() channeltypes.Upgrade { - upgrade, found := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID) - require.True(endpoint.Chain.TB, found) - - return upgrade -} - -// SetChannelUpgrade sets the channel upgrade for this endpoint. -func (endpoint *Endpoint) SetChannelUpgrade(upgrade channeltypes.Upgrade) { - endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SetUpgrade(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, upgrade) -} - -// SetChannelCounterpartyUpgrade sets the channel counterparty upgrade for this endpoint. -func (endpoint *Endpoint) SetChannelCounterpartyUpgrade(upgrade channeltypes.Upgrade) { - endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SetCounterpartyUpgrade(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, upgrade) -} - // QueryClientStateProof performs and abci query for a client stat associated // with this endpoint and returns the ClientState along with the proof. func (endpoint *Endpoint) QueryClientStateProof() (exported.ClientState, []byte) { @@ -912,43 +699,6 @@ func (endpoint *Endpoint) QueryClientStateProof() (exported.ClientState, []byte) return clientState, clientProof } -// GetProposedUpgrade returns a valid upgrade which can be used for UpgradeInit and UpgradeTry. -// By default, the endpoint's existing channel fields will be used for the upgrade fields and -// a sane default timeout will be used by querying the counterparty's latest height. -// If any non-empty values are specified in the ChannelConfig's ProposedUpgrade, -// those values will be used in the returned upgrade. -func (endpoint *Endpoint) GetProposedUpgrade() channeltypes.Upgrade { - // create a default upgrade - upgrade := channeltypes.Upgrade{ - Fields: channeltypes.UpgradeFields{ - Ordering: endpoint.ChannelConfig.Order, - ConnectionHops: []string{endpoint.ConnectionID}, - Version: endpoint.ChannelConfig.Version, - }, - Timeout: channeltypes.NewTimeout(endpoint.Counterparty.Chain.GetTimeoutHeight(), 0), - NextSequenceSend: 0, - } - - override := endpoint.ChannelConfig.ProposedUpgrade - if override.Timeout.IsValid() { - upgrade.Timeout = override.Timeout - } - - if override.Fields.Ordering != channeltypes.NONE { - upgrade.Fields.Ordering = override.Fields.Ordering - } - - if override.Fields.Version != "" { - upgrade.Fields.Version = override.Fields.Version - } - - if len(override.Fields.ConnectionHops) != 0 { - upgrade.Fields.ConnectionHops = override.Fields.ConnectionHops - } - - return upgrade -} - // UpdateConnection updates the connection associated with the given endpoint. It accepts a // closure which takes a connection allowing the caller to modify the connection fields. func (endpoint *Endpoint) UpdateConnection(updater func(connection *connectiontypes.ConnectionEnd)) { diff --git a/testing/mock/ibc_module.go b/testing/mock/ibc_module.go index 8ef011b93ed..25417ec130c 100644 --- a/testing/mock/ibc_module.go +++ b/testing/mock/ibc_module.go @@ -15,7 +15,6 @@ import ( var ( _ porttypes.IBCModule = (*IBCModule)(nil) _ porttypes.PacketDataUnmarshaler = (*IBCModule)(nil) - _ porttypes.UpgradableModule = (*IBCModule)(nil) ) // applicationCallbackError is a custom error type that will be unique for testing purposes. @@ -143,40 +142,6 @@ func (im IBCModule) OnTimeoutPacket(ctx sdk.Context, channelVersion string, pack return nil } -// OnChanUpgradeInit implements the IBCModule interface -func (im IBCModule) OnChanUpgradeInit(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, proposedVersion string) (string, error) { - if im.IBCApp.OnChanUpgradeInit != nil { - return im.IBCApp.OnChanUpgradeInit(ctx, portID, channelID, proposedOrder, proposedConnectionHops, proposedVersion) - } - - return proposedVersion, nil -} - -// OnChanUpgradeTry implements the IBCModule interface -func (im IBCModule) OnChanUpgradeTry(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, counterpartyVersion string) (string, error) { - if im.IBCApp.OnChanUpgradeTry != nil { - return im.IBCApp.OnChanUpgradeTry(ctx, portID, channelID, proposedOrder, proposedConnectionHops, counterpartyVersion) - } - - return counterpartyVersion, nil -} - -// OnChanUpgradeAck implements the IBCModule interface -func (im IBCModule) OnChanUpgradeAck(ctx sdk.Context, portID, channelID, counterpartyVersion string) error { - if im.IBCApp.OnChanUpgradeAck != nil { - return im.IBCApp.OnChanUpgradeAck(ctx, portID, channelID, counterpartyVersion) - } - - return nil -} - -// OnChanUpgradeOpen implements the IBCModule interface -func (im IBCModule) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, proposedVersion string) { - if im.IBCApp.OnChanUpgradeOpen != nil { - im.IBCApp.OnChanUpgradeOpen(ctx, portID, channelID, proposedOrder, proposedConnectionHops, proposedVersion) - } -} - // UnmarshalPacketData returns the MockPacketData. This function implements the optional // PacketDataUnmarshaler interface required for ADR 008 support. func (IBCModule) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) { diff --git a/testing/solomachine.go b/testing/solomachine.go index 12dfe820a5d..46900f6c36e 100644 --- a/testing/solomachine.go +++ b/testing/solomachine.go @@ -346,7 +346,6 @@ func (solo *Solomachine) ChanCloseConfirm(chain *TestChain, portID, channelID st initProof, clienttypes.ZeroHeight(), chain.SenderAccount.GetAddress().String(), - 0, // use default value for channel that hasn't undergone an upgrade ) res, err := chain.SendMsgs(msgChanCloseConfirm) @@ -439,7 +438,6 @@ func (solo *Solomachine) TimeoutPacketOnClose(chain *TestChain, packet channelty closedProof, clienttypes.ZeroHeight(), chain.SenderAccount.GetAddress().String(), - 0, // use default value for channel that hasn't undergone an upgrade ) res, err := chain.SendMsgs(msgTimeout)