diff --git a/.github/compatibility-test-matrices/main/client-chain-a.json b/.github/compatibility-test-matrices/main/client-chain-a.json index 013909a76b0..841e3b20b58 100644 --- a/.github/compatibility-test-matrices/main/client-chain-a.json +++ b/.github/compatibility-test-matrices/main/client-chain-a.json @@ -20,6 +20,7 @@ ], "test": [ "TestClientUpdateProposal_Succeeds", + "TestClient_Update_Misbehaviour", "TestAllowedClientsParam" ], "relayer-type": [ diff --git a/.github/compatibility-test-matrices/main/client-chain-b.json b/.github/compatibility-test-matrices/main/client-chain-b.json index 1042bec4085..a3ba8b166b9 100644 --- a/.github/compatibility-test-matrices/main/client-chain-b.json +++ b/.github/compatibility-test-matrices/main/client-chain-b.json @@ -20,6 +20,7 @@ ], "test": [ "TestClientUpdateProposal_Succeeds", + "TestClient_Update_Misbehaviour", "TestAllowedClientsParam" ], "relayer-type": [ diff --git a/.github/compatibility-test-matrices/main/ica-chain-a.json b/.github/compatibility-test-matrices/main/ica-chain-a.json index 22aafb9324b..78c47df79bc 100644 --- a/.github/compatibility-test-matrices/main/ica-chain-a.json +++ b/.github/compatibility-test-matrices/main/ica-chain-a.json @@ -14,7 +14,9 @@ "test": [ "TestMsgSendTx_SuccessfulTransfer", "TestMsgSendTx_FailedTransfer_InsufficientFunds", - "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA" + "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA", + "TestControllerEnabledParam", + "TestHostEnabledParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/main/ica-chain-b.json b/.github/compatibility-test-matrices/main/ica-chain-b.json index da650ca6a6d..16b4b62481c 100644 --- a/.github/compatibility-test-matrices/main/ica-chain-b.json +++ b/.github/compatibility-test-matrices/main/ica-chain-b.json @@ -14,7 +14,9 @@ "test": [ "TestMsgSendTx_SuccessfulTransfer", "TestMsgSendTx_FailedTransfer_InsufficientFunds", - "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA" + "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA", + "TestControllerEnabledParam", + "TestHostEnabledParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v6.1.x/client-chain-a.json b/.github/compatibility-test-matrices/release-v6.1.x/client-chain-a.json index 2f5ce2f51da..08a81f3c93d 100644 --- a/.github/compatibility-test-matrices/release-v6.1.x/client-chain-a.json +++ b/.github/compatibility-test-matrices/release-v6.1.x/client-chain-a.json @@ -19,7 +19,8 @@ ], "test": [ "TestClientUpdateProposal_Succeeds", - "TestClient_Update_Misbehaviour" + "TestClient_Update_Misbehaviour", + "TestAllowedClientsParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v6.1.x/client-chain-b.json b/.github/compatibility-test-matrices/release-v6.1.x/client-chain-b.json index 659212b3cf8..7bbdab6b77c 100644 --- a/.github/compatibility-test-matrices/release-v6.1.x/client-chain-b.json +++ b/.github/compatibility-test-matrices/release-v6.1.x/client-chain-b.json @@ -19,7 +19,8 @@ ], "test": [ "TestClientUpdateProposal_Succeeds", - "TestClient_Update_Misbehaviour" + "TestClient_Update_Misbehaviour", + "TestAllowedClientsParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v6.1.x/ica-chain-a.json b/.github/compatibility-test-matrices/release-v6.1.x/ica-chain-a.json index 799883e45d4..e147730f594 100644 --- a/.github/compatibility-test-matrices/release-v6.1.x/ica-chain-a.json +++ b/.github/compatibility-test-matrices/release-v6.1.x/ica-chain-a.json @@ -14,7 +14,9 @@ "test": [ "TestMsgSendTx_SuccessfulTransfer", "TestMsgSendTx_FailedTransfer_InsufficientFunds", - "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA" + "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA", + "TestControllerEnabledParam", + "TestHostEnabledParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v6.1.x/ica-chain-b.json b/.github/compatibility-test-matrices/release-v6.1.x/ica-chain-b.json index f1f18f7ae71..c6c006f3fda 100644 --- a/.github/compatibility-test-matrices/release-v6.1.x/ica-chain-b.json +++ b/.github/compatibility-test-matrices/release-v6.1.x/ica-chain-b.json @@ -14,7 +14,9 @@ "test": [ "TestMsgSendTx_SuccessfulTransfer", "TestMsgSendTx_FailedTransfer_InsufficientFunds", - "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA" + "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA", + "TestControllerEnabledParam", + "TestHostEnabledParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v6.2.x/client-chain-a.json b/.github/compatibility-test-matrices/release-v6.2.x/client-chain-a.json index 0e6b2e7e087..5b89787290b 100644 --- a/.github/compatibility-test-matrices/release-v6.2.x/client-chain-a.json +++ b/.github/compatibility-test-matrices/release-v6.2.x/client-chain-a.json @@ -19,7 +19,8 @@ ], "test": [ "TestClientUpdateProposal_Succeeds", - "TestClient_Update_Misbehaviour" + "TestClient_Update_Misbehaviour", + "TestAllowedClientsParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v6.2.x/client-chain-b.json b/.github/compatibility-test-matrices/release-v6.2.x/client-chain-b.json index 014e2152fa0..4ab1dc6cd3a 100644 --- a/.github/compatibility-test-matrices/release-v6.2.x/client-chain-b.json +++ b/.github/compatibility-test-matrices/release-v6.2.x/client-chain-b.json @@ -19,7 +19,8 @@ ], "test": [ "TestClientUpdateProposal_Succeeds", - "TestClient_Update_Misbehaviour" + "TestClient_Update_Misbehaviour", + "TestAllowedClientsParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v6.2.x/ica-chain-a.json b/.github/compatibility-test-matrices/release-v6.2.x/ica-chain-a.json index 7ed9089e323..ed1fbd2c647 100644 --- a/.github/compatibility-test-matrices/release-v6.2.x/ica-chain-a.json +++ b/.github/compatibility-test-matrices/release-v6.2.x/ica-chain-a.json @@ -14,7 +14,9 @@ "test": [ "TestMsgSendTx_SuccessfulTransfer", "TestMsgSendTx_FailedTransfer_InsufficientFunds", - "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA" + "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA", + "TestControllerEnabledParam", + "TestHostEnabledParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v6.2.x/ica-chain-b.json b/.github/compatibility-test-matrices/release-v6.2.x/ica-chain-b.json index 21b17c19f1b..b410beaef75 100644 --- a/.github/compatibility-test-matrices/release-v6.2.x/ica-chain-b.json +++ b/.github/compatibility-test-matrices/release-v6.2.x/ica-chain-b.json @@ -14,7 +14,9 @@ "test": [ "TestMsgSendTx_SuccessfulTransfer", "TestMsgSendTx_FailedTransfer_InsufficientFunds", - "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA" + "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA", + "TestControllerEnabledParam", + "TestHostEnabledParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v7.2.x/client-chain-a.json b/.github/compatibility-test-matrices/release-v7.2.x/client-chain-a.json index 69e13955205..21c7b3db767 100644 --- a/.github/compatibility-test-matrices/release-v7.2.x/client-chain-a.json +++ b/.github/compatibility-test-matrices/release-v7.2.x/client-chain-a.json @@ -19,7 +19,8 @@ ], "test": [ "TestClientUpdateProposal_Succeeds", - "TestClient_Update_Misbehaviour" + "TestClient_Update_Misbehaviour", + "TestAllowedClientsParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v7.2.x/client-chain-b.json b/.github/compatibility-test-matrices/release-v7.2.x/client-chain-b.json index 8f1288b1fb8..18242bea61a 100644 --- a/.github/compatibility-test-matrices/release-v7.2.x/client-chain-b.json +++ b/.github/compatibility-test-matrices/release-v7.2.x/client-chain-b.json @@ -19,7 +19,8 @@ ], "test": [ "TestClientUpdateProposal_Succeeds", - "TestClient_Update_Misbehaviour" + "TestClient_Update_Misbehaviour", + "TestAllowedClientsParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v7.2.x/ica-chain-a.json b/.github/compatibility-test-matrices/release-v7.2.x/ica-chain-a.json index bd0159aeffb..ea2fd7e3604 100644 --- a/.github/compatibility-test-matrices/release-v7.2.x/ica-chain-a.json +++ b/.github/compatibility-test-matrices/release-v7.2.x/ica-chain-a.json @@ -14,7 +14,9 @@ "test": [ "TestMsgSendTx_SuccessfulTransfer", "TestMsgSendTx_FailedTransfer_InsufficientFunds", - "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA" + "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA", + "TestControllerEnabledParam", + "TestHostEnabledParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v7.2.x/ica-chain-b.json b/.github/compatibility-test-matrices/release-v7.2.x/ica-chain-b.json index 045b12ee4f1..0a3d595596c 100644 --- a/.github/compatibility-test-matrices/release-v7.2.x/ica-chain-b.json +++ b/.github/compatibility-test-matrices/release-v7.2.x/ica-chain-b.json @@ -14,7 +14,9 @@ "test": [ "TestMsgSendTx_SuccessfulTransfer", "TestMsgSendTx_FailedTransfer_InsufficientFunds", - "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA" + "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA", + "TestControllerEnabledParam", + "TestHostEnabledParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v7.3.x/client-chain-a.json b/.github/compatibility-test-matrices/release-v7.3.x/client-chain-a.json index 49801524a7f..927c7a942e5 100644 --- a/.github/compatibility-test-matrices/release-v7.3.x/client-chain-a.json +++ b/.github/compatibility-test-matrices/release-v7.3.x/client-chain-a.json @@ -19,7 +19,8 @@ ], "test": [ "TestClientUpdateProposal_Succeeds", - "TestClient_Update_Misbehaviour" + "TestClient_Update_Misbehaviour", + "TestAllowedClientsParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v7.3.x/client-chain-b.json b/.github/compatibility-test-matrices/release-v7.3.x/client-chain-b.json index af5c0fe51ea..f35ceab65b0 100644 --- a/.github/compatibility-test-matrices/release-v7.3.x/client-chain-b.json +++ b/.github/compatibility-test-matrices/release-v7.3.x/client-chain-b.json @@ -19,7 +19,8 @@ ], "test": [ "TestClientUpdateProposal_Succeeds", - "TestClient_Update_Misbehaviour" + "TestClient_Update_Misbehaviour", + "TestAllowedClientsParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v7.3.x/ica-chain-a.json b/.github/compatibility-test-matrices/release-v7.3.x/ica-chain-a.json index 42f48cb64ce..980dca4f7e2 100644 --- a/.github/compatibility-test-matrices/release-v7.3.x/ica-chain-a.json +++ b/.github/compatibility-test-matrices/release-v7.3.x/ica-chain-a.json @@ -14,7 +14,9 @@ "test": [ "TestMsgSendTx_SuccessfulTransfer", "TestMsgSendTx_FailedTransfer_InsufficientFunds", - "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA" + "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA", + "TestControllerEnabledParam", + "TestHostEnabledParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/release-v7.3.x/ica-chain-b.json b/.github/compatibility-test-matrices/release-v7.3.x/ica-chain-b.json index 13d53354187..6325c1bbc43 100644 --- a/.github/compatibility-test-matrices/release-v7.3.x/ica-chain-b.json +++ b/.github/compatibility-test-matrices/release-v7.3.x/ica-chain-b.json @@ -14,7 +14,9 @@ "test": [ "TestMsgSendTx_SuccessfulTransfer", "TestMsgSendTx_FailedTransfer_InsufficientFunds", - "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA" + "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA", + "TestControllerEnabledParam", + "TestHostEnabledParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/unreleased/client.json b/.github/compatibility-test-matrices/unreleased/client.json index cd01aa0b133..692e422a115 100644 --- a/.github/compatibility-test-matrices/unreleased/client.json +++ b/.github/compatibility-test-matrices/unreleased/client.json @@ -27,7 +27,9 @@ "TestClientTestSuite" ], "test": [ - "TestClientUpdateProposal_Succeeds" + "TestClientUpdateProposal_Succeeds", + "TestClient_Update_Misbehaviour", + "TestAllowedClientsParam" ], "relayer-type": [ "rly" diff --git a/.github/compatibility-test-matrices/unreleased/ica.json b/.github/compatibility-test-matrices/unreleased/ica.json index 96861e0f7bc..0c59df65a89 100644 --- a/.github/compatibility-test-matrices/unreleased/ica.json +++ b/.github/compatibility-test-matrices/unreleased/ica.json @@ -17,7 +17,9 @@ "test": [ "TestMsgSendTx_SuccessfulTransfer", "TestMsgSendTx_FailedTransfer_InsufficientFunds", - "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA" + "TestMsgSendTx_SuccessfulTransfer_AfterReopeningICA", + "TestControllerEnabledParam", + "TestHostEnabledParam" ], "relayer-type": [ "rly" diff --git a/.github/workflows/golangci.yml b/.github/workflows/golangci.yml index df8f5e1d14a..01be2fa5492 100644 --- a/.github/workflows/golangci.yml +++ b/.github/workflows/golangci.yml @@ -22,5 +22,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3.6.0 with: - version: v1.53.1 + version: v1.53.3 args: --timeout 5m diff --git a/.golangci.yml b/.golangci.yml index bf5ec00714b..b0d9d884a88 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,7 +5,6 @@ run: linters: disable-all: true enable: - - dogsled - exportloopref - errcheck - gci @@ -20,32 +19,24 @@ linters: - nakedret - staticcheck - thelper + - typecheck - stylecheck - revive - typecheck + - tenv - unconvert - unused - misspell issues: exclude-rules: - - text: 'unused-parameter' + - text: 'differs only by capitalization to method' linters: - revive - - text: 'SA1019:' - linters: - - staticcheck - text: 'Use of weak random number generator' linters: - gosec - - text: 'ST1003:' - linters: - - stylecheck - # FIXME: Disabled until golangci-lint updates stylecheck with this fix: - # https://github.com/dominikh/go-tools/issues/389 - - text: 'ST1016:' - linters: - - stylecheck + max-issues-per-linter: 10000 max-same-issues: 10000 @@ -61,17 +52,57 @@ linters-settings: - prefix(github.com/cometbft/cometbft) - prefix(github.com/cosmos/ibc-go) custom-order: true - dogsled: - max-blank-identifiers: 3 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true - nolintlint: - allow-unused: false - allow-leading-space: true - require-explanation: false - require-specific: false revive: + enable-all-rules: true + # Do NOT whine about the following, full explanation found in: + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#description-of-available-rules rules: + - name: use-any + disabled: true - name: if-return disabled: true + - name: max-public-structs + disabled: true + - name: cognitive-complexity + disabled: true + - name: argument-limit + disabled: true + - name: cyclomatic + disabled: true + - name: file-header + disabled: true + - name: function-length + disabled: true + - name: function-result-limit + disabled: true + - name: line-length-limit + disabled: true + - name: flag-parameter + disabled: true + - name: add-constant + disabled: true + - name: empty-lines + disabled: true + - name: banned-characters + disabled: true + - name: deep-exit + disabled: true + - name: confusing-results + disabled: true + - name: unused-parameter + disabled: true + - name: modifies-value-receiver + disabled: true + - name: early-return + disabled: true + - name: confusing-naming + disabled: true + - name: defer + disabled: true + - name: unhandled-error + disabled: false + arguments: + - 'fmt.Printf' + - 'fmt.Print' + - 'fmt.Println' + - 'myFunction' diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index e0848f0c069..e44b62b4592 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -284,6 +284,11 @@ module.exports = { directory: false, path: "/apps/interchain-accounts/parameters.html", }, + { + title: "Tx Encoding", + directory: false, + path: "/apps/interchain-accounts/tx-encoding.html", + }, { title: "Client", directory: false, @@ -314,7 +319,7 @@ module.exports = { directory: false, path: "/apps/interchain-accounts/legacy/keeper-api.html", }, - ] + ], }, ], }, @@ -425,7 +430,7 @@ module.exports = { directory: false, path: "/ibc/light-clients/setup.html", }, - ] + ], }, { title: "Localhost", diff --git a/docs/apps/interchain-accounts/active-channels.md b/docs/apps/interchain-accounts/active-channels.md index f9d457f1a85..4864f70c6f4 100644 --- a/docs/apps/interchain-accounts/active-channels.md +++ b/docs/apps/interchain-accounts/active-channels.md @@ -1,5 +1,5 @@ # Understanding Active Channels diff --git a/docs/apps/interchain-accounts/client.md b/docs/apps/interchain-accounts/client.md index c35d28f0df0..868aeaeb4e4 100644 --- a/docs/apps/interchain-accounts/client.md +++ b/docs/apps/interchain-accounts/client.md @@ -1,5 +1,5 @@ # Client @@ -58,7 +58,7 @@ See below for example contents of `packet-data.json`. The CLI handler will unmar } ``` -Note the `data` field is a base64 encoded byte string as per the [proto3 JSON encoding specification](https://developers.google.com/protocol-buffers/docs/proto3#json). +Note the `data` field is a base64 encoded byte string as per the tx encoding agreed upon during the channel handshake. A helper CLI is provided in the host submodule which can be used to generate the packet data JSON using the counterparty chain's binary. See the [`generate-packet-data` command](#generate-packet-data) for an example. @@ -84,7 +84,7 @@ simd tx interchain-accounts host --help ##### `generate-packet-data` -The `generate-packet-data` command allows users to generate interchain accounts packet data for input message(s). The packet data can then be used with the controller submodule's [`send-tx` command](#send-tx). +The `generate-packet-data` command allows users to generate protobuf encoded interchain accounts packet data for input message(s). The packet data can then be used with the controller submodule's [`send-tx` command](#send-tx). ```shell simd tx interchain-accounts host generate-packet-data [message] diff --git a/docs/apps/interchain-accounts/tx-encoding.md b/docs/apps/interchain-accounts/tx-encoding.md new file mode 100644 index 00000000000..ec9e7fd25ac --- /dev/null +++ b/docs/apps/interchain-accounts/tx-encoding.md @@ -0,0 +1,55 @@ + + +# Transaction Encoding + +When orchestrating an interchain account transaction, which comprises multiple `sdk.Msg` objects represented as `Any` types, the transactions must be encoded as bytes within [`InterchainAccountPacketData`](https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/interchain_accounts/v1/packet.proto#L21-L26). + +```protobuf +// InterchainAccountPacketData is comprised of a raw transaction, type of transaction and optional memo field. +message InterchainAccountPacketData { + Type type = 1; + bytes data = 2; + string memo = 3; +} +``` + +The `data` field must be encoded as a [`CosmosTx`](https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/interchain_accounts/v1/packet.proto#L28-L31). + +```protobuf +// CosmosTx contains a list of sdk.Msg's. It should be used when sending transactions to an SDK host chain. +message CosmosTx { + repeated google.protobuf.Any messages = 1; +} +``` + +The encoding method for `CosmosTx` is determined during the channel handshake process. If the channel version [metadata's `encoding` field](https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/interchain_accounts/v1/metadata.proto#L22) is marked as `proto3`, then `CosmosTx` undergoes protobuf encoding. Conversely, if the field is set to `proto3json`, then [proto3 json](https://protobuf.dev/programming-guides/proto3/#json) encoding takes place, which generates a JSON representation of the protobuf message. + +## Protobuf Encoding + +Protobuf encoding serves as the standard encoding process for `CosmosTx`. This occurs if the channel handshake initiates with an empty channel version metadata or if the `encoding` field explicitly denotes `proto3`. In Golang, the protobuf encoding procedure utilizes the `proto.Marshal` function. Every protobuf autogenerated Golang type comes equipped with a `Marshal` method that can be employed to encode the message. + +## (Protobuf) JSON Encoding + +The proto3 JSON encoding presents an alternative encoding technique for `CosmosTx`. It is selected if the channel handshake begins with the channel version metadata `encoding` field labeled as `proto3json`. In Golang, the Proto3 canonical encoding in JSON is implemented by the `"github.com/cosmos/gogoproto/jsonpb"` package. Within Cosmos SDK, the `ProtoCodec` structure implements the `JSONCodec` interface, leveraging the `jsonpb` package. This method generates a JSON format as follows: + +```json +{ + "messages": [ + { + "@type": "/cosmos.bank.v1beta1.MsgSend", + "from_address": "cosmos1...", + "to_address": "cosmos1...", + "amount": [ + { + "denom": "uatom", + "amount": "1000000" + } + ] + } + ] +} +``` + +Here, the `"messages"` array is populated with transactions. Each transaction is represented as a JSON object with the `@type` field denoting the transaction type and the remaining fields representing the transaction's attributes. diff --git a/docs/ibc/light-clients/localhost/connection.md b/docs/ibc/light-clients/localhost/connection.md index 33251bde432..301d93455b5 100644 --- a/docs/ibc/light-clients/localhost/connection.md +++ b/docs/ibc/light-clients/localhost/connection.md @@ -16,7 +16,7 @@ The `ConnectionEnd` and its `Counterparty` both reference the `09-localhost` cli // CreateSentinelLocalhostConnection creates and sets the sentinel localhost connection end in the IBC store. func (k Keeper) CreateSentinelLocalhostConnection(ctx sdk.Context) { counterparty := types.NewCounterparty(exported.LocalhostClientID, exported.LocalhostConnectionID, commitmenttypes.NewMerklePrefix(k.GetCommitmentPrefix().Bytes())) - connectionEnd := types.NewConnectionEnd(types.OPEN, exported.LocalhostClientID, counterparty, types.ExportedVersionsToProto(types.GetCompatibleVersions()), 0) + connectionEnd := types.NewConnectionEnd(types.OPEN, exported.LocalhostClientID, counterparty, types.GetCompatibleVersions(), 0) k.SetConnection(ctx, exported.LocalhostConnectionID, connectionEnd) } diff --git a/docs/requirements/localhost-requirements.md b/docs/requirements/localhost-requirements.md index 2508d87fece..656f60f11ae 100644 --- a/docs/requirements/localhost-requirements.md +++ b/docs/requirements/localhost-requirements.md @@ -46,19 +46,19 @@ Polymer plans to leverage the localhost client with multiple connections as part | ID | Description | Verification | Status | Release | | -- | ----------- | ------------ | ------ | ------- | -| 1.01 | The localhost client shall have a client ID of the string `09-localhost`. | [Localhost client is created with client ID `09-localhost`](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/02-client/keeper/keeper.go#L60). | `Implemented` | | -| 1.02 | The localhost client shall have a sentinel connection ID of the string `connection-localhost`. | [Creation of sentinel connection with ID `connection-localhost`](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/03-connection/keeper/keeper.go#L200). | `Implemented` | | -| 1.03 | Only 1 localhost connection is required | Localhost connection handshakes are forbidden in [Init](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/03-connection/types/msgs.go#L47) and [Try](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/03-connection/types/msgs.go#L110). | `Implemented` | | -| 1.04 | When the localhost client is initialised the consensus state must be `nil`. | [Error is returned if consensus state is not `nil`](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/light-clients/09-localhost/client_state.go#L57). | `Implemented` | | -| 1.05 | The localhost client can be added to a chain through an upgrade. | [Automatic migration handler configured in core IBC module to set the localhost `ClientState` and sentinel `ConnectionEnd` in state.](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/module.go#L132-L145). | `Implemented` | | -| 1.06 | A chain can enable the localhost client by initialising the client in the genesis state. | [`InitGenesis` handler in 02-client](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/02-client/genesis.go#L52) and [`InitGenesis` handler in 03-connection](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/03-connection/genesis.go#L23). | `Implemented` | | +| 1.01 | The localhost client shall have a client ID of the string `09-localhost`. | [Localhost client is created with client ID `09-localhost`](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/02-client/keeper/keeper.go#L60). | `Verified` | v7.1.0 | +| 1.02 | The localhost client shall have a sentinel connection ID of the string `connection-localhost`. | [Creation of sentinel connection with ID `connection-localhost`](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/03-connection/keeper/keeper.go#L200). | `Verified` | v7.1.0 | +| 1.03 | Only 1 localhost connection is required | Localhost connection handshakes are forbidden in [Init](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/03-connection/types/msgs.go#L47) and [Try](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/03-connection/types/msgs.go#L110). | `Verified` | v7.1.0 | +| 1.04 | When the localhost client is initialised the consensus state must be `nil`. | [Error is returned if consensus state is not `nil`](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/light-clients/09-localhost/client_state.go#L57). | `Verified` | v7.1.0 | +| 1.05 | The localhost client can be added to a chain through an upgrade. | [Automatic migration handler configured in core IBC module to set the localhost `ClientState` and sentinel `ConnectionEnd` in state.](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/module.go#L132-L145). | `Verified` | v7.1.0 | +| 1.06 | A chain can enable the localhost client by initialising the client in the genesis state. | [`InitGenesis` handler in 02-client](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/02-client/genesis.go#L52) and [`InitGenesis` handler in 03-connection](https://github.com/cosmos/ibc-go/blob/release/v7.1.x/modules/core/03-connection/genesis.go#L23). | `Verified` | v7.1.0 | ### 2 - Operation | ID | Description | Verification | Status | Release | | -- | ----------- | ------------ | ------ | ------- | -| 2.01 | A user of the localhost client can send IBC messages to an application on the same chain. | [e2e test with transfer](https://github.com/cosmos/ibc-go/blob/main/e2e/tests/transfer/localhost_test.go#L32). | `Implemented`| | -| 2.02 | A user can use the localhost client through the existing IBC application module interfaces. | [e2e test with transfer](https://github.com/cosmos/ibc-go/blob/main/e2e/tests/transfer/localhost_test.go#L32). | `Implemented` | | +| 2.01 | A user of the localhost client can send IBC messages to an application on the same chain. | [e2e test with transfer](https://github.com/cosmos/ibc-go/blob/main/e2e/tests/transfer/localhost_test.go#L32). | `Verified`| v7.1.0 | +| 2.02 | A user can use the localhost client through the existing IBC application module interfaces. | [e2e test with transfer](https://github.com/cosmos/ibc-go/blob/main/e2e/tests/transfer/localhost_test.go#L32). | `Verified` | v7.1.0 | # External interface requirements @@ -66,4 +66,4 @@ Polymer plans to leverage the localhost client with multiple connections as part | ID | Description | Verification | Status | Release | | -- | ----------- | ------------ | ------ | ------- | -| 3.01 | Existing CLI interfaces used with IBC application modules shall be useable with the localhost client. | Manual test | `Implemented` | | +| 3.01 | Existing CLI interfaces used with IBC application modules shall be useable with the localhost client. | Manual test | `Verified` | v7.1.0 | diff --git a/e2e/go.mod b/e2e/go.mod index 2f707103bf4..02be5e29db9 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -13,9 +13,9 @@ require ( github.com/docker/docker v24.0.1+incompatible github.com/strangelove-ventures/interchaintest/v7 v7.0.0-20230622193330-220ce33823c0 github.com/stretchr/testify v1.8.4 - go.uber.org/zap v1.24.0 + go.uber.org/zap v1.25.0 golang.org/x/mod v0.12.0 - google.golang.org/grpc v1.56.2 + google.golang.org/grpc v1.57.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -193,7 +193,6 @@ require ( github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect - go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.11.0 // indirect golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect diff --git a/e2e/go.sum b/e2e/go.sum index 0a727b15fbc..b9acdc88ec9 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -1062,9 +1062,7 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= +go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -1072,8 +1070,8 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8 go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= +go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= golang.org/x/crypto v0.0.0-20170613210332-850760c427c5/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1650,8 +1648,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI= -google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index e6e5727871c..0ef2b80e1d4 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -18,7 +18,7 @@ import ( "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v7/ibc" test "github.com/strangelove-ventures/interchaintest/v7/testutil" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/client/grpc/ccmtservice" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -40,7 +40,7 @@ const ( ) func TestClientTestSuite(t *testing.T) { - suite.Run(t, new(ClientTestSuite)) + testifysuite.Run(t, new(ClientTestSuite)) } type ClientTestSuite struct { diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index 991b44d6d1d..a309ec2e7a9 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -10,19 +10,18 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - "github.com/strangelove-ventures/interchaintest/v7/ibc" - test "github.com/strangelove-ventures/interchaintest/v7/testutil" - "github.com/stretchr/testify/suite" - "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v7/testing" + "github.com/strangelove-ventures/interchaintest/v7/ibc" + test "github.com/strangelove-ventures/interchaintest/v7/testutil" + testifysuite "github.com/stretchr/testify/suite" ) func TestConnectionTestSuite(t *testing.T) { - suite.Run(t, new(ConnectionTestSuite)) + testifysuite.Run(t, new(ConnectionTestSuite)) } type ConnectionTestSuite struct { diff --git a/e2e/tests/interchain_accounts/base_test.go b/e2e/tests/interchain_accounts/base_test.go index c31e1b63880..ce0aecf521a 100644 --- a/e2e/tests/interchain_accounts/base_test.go +++ b/e2e/tests/interchain_accounts/base_test.go @@ -5,15 +5,14 @@ import ( "testing" "time" + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/gogoproto/proto" "github.com/strangelove-ventures/interchaintest/v7" "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v7/ibc" test "github.com/strangelove-ventures/interchaintest/v7/testutil" - "github.com/stretchr/testify/suite" - - sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/gogoproto/proto" + testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" @@ -24,7 +23,7 @@ import ( ) func TestInterchainAccountsTestSuite(t *testing.T) { - suite.Run(t, new(InterchainAccountsTestSuite)) + testifysuite.Run(t, new(InterchainAccountsTestSuite)) } type InterchainAccountsTestSuite struct { diff --git a/e2e/tests/interchain_accounts/gov_test.go b/e2e/tests/interchain_accounts/gov_test.go index 2daa2be095d..43efeef9bcf 100644 --- a/e2e/tests/interchain_accounts/gov_test.go +++ b/e2e/tests/interchain_accounts/gov_test.go @@ -10,20 +10,19 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/gogoproto/proto" - "github.com/strangelove-ventures/interchaintest/v7" - "github.com/strangelove-ventures/interchaintest/v7/ibc" - test "github.com/strangelove-ventures/interchaintest/v7/testutil" - "github.com/stretchr/testify/suite" - "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v7/testing" + "github.com/strangelove-ventures/interchaintest/v7" + "github.com/strangelove-ventures/interchaintest/v7/ibc" + test "github.com/strangelove-ventures/interchaintest/v7/testutil" + testifysuite "github.com/stretchr/testify/suite" ) func TestInterchainAccountsGovTestSuite(t *testing.T) { - suite.Run(t, new(InterchainAccountsGovTestSuite)) + testifysuite.Run(t, new(InterchainAccountsGovTestSuite)) } type InterchainAccountsGovTestSuite struct { diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index de24999cddb..7123de937c2 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -9,16 +9,15 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" grouptypes "github.com/cosmos/cosmos-sdk/x/group" "github.com/cosmos/gogoproto/proto" - interchaintest "github.com/strangelove-ventures/interchaintest/v7" - "github.com/strangelove-ventures/interchaintest/v7/ibc" - test "github.com/strangelove-ventures/interchaintest/v7/testutil" - "github.com/stretchr/testify/suite" - "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v7/testing" + interchaintest "github.com/strangelove-ventures/interchaintest/v7" + "github.com/strangelove-ventures/interchaintest/v7/ibc" + test "github.com/strangelove-ventures/interchaintest/v7/testutil" + testifysuite "github.com/stretchr/testify/suite" ) const ( @@ -53,7 +52,7 @@ const ( ) func TestInterchainAccountsGroupsTestSuite(t *testing.T) { - suite.Run(t, new(InterchainAccountsGroupsTestSuite)) + testifysuite.Run(t, new(InterchainAccountsGroupsTestSuite)) } type InterchainAccountsGroupsTestSuite struct { diff --git a/e2e/tests/interchain_accounts/incentivized_test.go b/e2e/tests/interchain_accounts/incentivized_test.go index 2d3dc532e0a..dae0daf4a7b 100644 --- a/e2e/tests/interchain_accounts/incentivized_test.go +++ b/e2e/tests/interchain_accounts/incentivized_test.go @@ -8,21 +8,20 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/gogoproto/proto" - interchaintest "github.com/strangelove-ventures/interchaintest/v7" - "github.com/strangelove-ventures/interchaintest/v7/ibc" - test "github.com/strangelove-ventures/interchaintest/v7/testutil" - "github.com/stretchr/testify/suite" - "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" feetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" ibctesting "github.com/cosmos/ibc-go/v7/testing" + interchaintest "github.com/strangelove-ventures/interchaintest/v7" + "github.com/strangelove-ventures/interchaintest/v7/ibc" + test "github.com/strangelove-ventures/interchaintest/v7/testutil" + testifysuite "github.com/stretchr/testify/suite" ) func TestIncentivizedInterchainAccountsTestSuite(t *testing.T) { - suite.Run(t, new(IncentivizedInterchainAccountsTestSuite)) + testifysuite.Run(t, new(IncentivizedInterchainAccountsTestSuite)) } type IncentivizedInterchainAccountsTestSuite struct { diff --git a/e2e/tests/interchain_accounts/intertx_incentivized_test.go b/e2e/tests/interchain_accounts/intertx_incentivized_test.go index 08cd59ca9d8..406e58e9b2f 100644 --- a/e2e/tests/interchain_accounts/intertx_incentivized_test.go +++ b/e2e/tests/interchain_accounts/intertx_incentivized_test.go @@ -6,19 +6,18 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/ibc-go/e2e/testvalues" + feetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" + ibctesting "github.com/cosmos/ibc-go/v7/testing" intertxtypes "github.com/cosmos/interchain-accounts/x/inter-tx/types" "github.com/strangelove-ventures/interchaintest/v7" "github.com/strangelove-ventures/interchaintest/v7/ibc" test "github.com/strangelove-ventures/interchaintest/v7/testutil" - "github.com/stretchr/testify/suite" - - "github.com/cosmos/ibc-go/e2e/testvalues" - feetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + testifysuite "github.com/stretchr/testify/suite" ) func TestIncentivizedInterTxTestSuite(t *testing.T) { - suite.Run(t, new(IncentivizedInterTxTestSuite)) + testifysuite.Run(t, new(IncentivizedInterTxTestSuite)) } type IncentivizedInterTxTestSuite struct { diff --git a/e2e/tests/interchain_accounts/intertx_test.go b/e2e/tests/interchain_accounts/intertx_test.go index 13c03083e59..c460e468100 100644 --- a/e2e/tests/interchain_accounts/intertx_test.go +++ b/e2e/tests/interchain_accounts/intertx_test.go @@ -4,15 +4,14 @@ import ( "context" "testing" + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + intertxtypes "github.com/cosmos/interchain-accounts/x/inter-tx/types" "github.com/strangelove-ventures/interchaintest/v7" "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v7/ibc" test "github.com/strangelove-ventures/interchaintest/v7/testutil" - "github.com/stretchr/testify/suite" - - sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - intertxtypes "github.com/cosmos/interchain-accounts/x/inter-tx/types" + testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" @@ -23,7 +22,7 @@ import ( ) func TestInterTxTestSuite(t *testing.T) { - suite.Run(t, new(InterTxTestSuite)) + testifysuite.Run(t, new(InterTxTestSuite)) } type InterTxTestSuite struct { diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index 7a0b1181893..a05fe20abba 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -8,6 +8,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/gogoproto/proto" + "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" @@ -15,17 +17,14 @@ import ( "github.com/cosmos/ibc-go/v7/modules/core/exported" localhost "github.com/cosmos/ibc-go/v7/modules/light-clients/09-localhost" ibctesting "github.com/cosmos/ibc-go/v7/testing" - "github.com/stretchr/testify/suite" - - "github.com/cosmos/ibc-go/e2e/testsuite" - "github.com/cosmos/ibc-go/e2e/testvalues" "github.com/strangelove-ventures/interchaintest/v7" "github.com/strangelove-ventures/interchaintest/v7/ibc" test "github.com/strangelove-ventures/interchaintest/v7/testutil" + testifysuite "github.com/stretchr/testify/suite" ) func TestInterchainAccountsLocalhostTestSuite(t *testing.T) { - suite.Run(t, new(LocalhostInterchainAccountsTestSuite)) + testifysuite.Run(t, new(LocalhostInterchainAccountsTestSuite)) } type LocalhostInterchainAccountsTestSuite struct { diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index efc9283a6c2..79708655b5b 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -6,19 +6,18 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - "github.com/strangelove-ventures/interchaintest/v7/ibc" - "github.com/stretchr/testify/suite" - "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" hosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v7/testing" + "github.com/strangelove-ventures/interchaintest/v7/ibc" + testifysuite "github.com/stretchr/testify/suite" ) func TestInterchainAccountsParamsTestSuite(t *testing.T) { - suite.Run(t, new(InterchainAccountsParamsTestSuite)) + testifysuite.Run(t, new(InterchainAccountsParamsTestSuite)) } type InterchainAccountsParamsTestSuite struct { diff --git a/e2e/tests/transfer/authz_test.go b/e2e/tests/transfer/authz_test.go index 3e8fe322bc0..a87f9fb90a4 100644 --- a/e2e/tests/transfer/authz_test.go +++ b/e2e/tests/transfer/authz_test.go @@ -9,17 +9,16 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/authz" - test "github.com/strangelove-ventures/interchaintest/v7/testutil" - "github.com/stretchr/testify/suite" - "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ibcerrors "github.com/cosmos/ibc-go/v7/modules/core/errors" + test "github.com/strangelove-ventures/interchaintest/v7/testutil" + testifysuite "github.com/stretchr/testify/suite" ) func TestAuthzTransferTestSuite(t *testing.T) { - suite.Run(t, new(AuthzTransferTestSuite)) + testifysuite.Run(t, new(AuthzTransferTestSuite)) } type AuthzTransferTestSuite struct { diff --git a/e2e/tests/transfer/base_test.go b/e2e/tests/transfer/base_test.go index a94867084ea..3b0b6d5afc3 100644 --- a/e2e/tests/transfer/base_test.go +++ b/e2e/tests/transfer/base_test.go @@ -11,17 +11,16 @@ import ( paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - "github.com/strangelove-ventures/interchaintest/v7/ibc" - test "github.com/strangelove-ventures/interchaintest/v7/testutil" - "github.com/stretchr/testify/suite" - "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" ibctesting "github.com/cosmos/ibc-go/v7/testing" + "github.com/strangelove-ventures/interchaintest/v7/ibc" + test "github.com/strangelove-ventures/interchaintest/v7/testutil" + testifysuite "github.com/stretchr/testify/suite" ) func TestTransferTestSuite(t *testing.T) { - suite.Run(t, new(TransferTestSuite)) + testifysuite.Run(t, new(TransferTestSuite)) } type TransferTestSuite struct { diff --git a/e2e/tests/transfer/incentivized_test.go b/e2e/tests/transfer/incentivized_test.go index 108bca5d3e7..86b5ae57676 100644 --- a/e2e/tests/transfer/incentivized_test.go +++ b/e2e/tests/transfer/incentivized_test.go @@ -6,14 +6,13 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/strangelove-ventures/interchaintest/v7/ibc" - test "github.com/strangelove-ventures/interchaintest/v7/testutil" - "github.com/stretchr/testify/suite" - "github.com/cosmos/ibc-go/e2e/testvalues" feetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + "github.com/strangelove-ventures/interchaintest/v7/ibc" + test "github.com/strangelove-ventures/interchaintest/v7/testutil" + testifysuite "github.com/stretchr/testify/suite" ) type IncentivizedTransferTestSuite struct { @@ -21,7 +20,7 @@ type IncentivizedTransferTestSuite struct { } func TestIncentivizedTransferTestSuite(t *testing.T) { - suite.Run(t, new(IncentivizedTransferTestSuite)) + testifysuite.Run(t, new(IncentivizedTransferTestSuite)) } func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncSingleSender_Succeeds() { diff --git a/e2e/tests/transfer/localhost_test.go b/e2e/tests/transfer/localhost_test.go index efca34f1fd4..efe2257e47e 100644 --- a/e2e/tests/transfer/localhost_test.go +++ b/e2e/tests/transfer/localhost_test.go @@ -4,8 +4,6 @@ import ( "context" "testing" - "github.com/stretchr/testify/suite" - transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" @@ -13,13 +11,14 @@ import ( localhost "github.com/cosmos/ibc-go/v7/modules/light-clients/09-localhost" ibctesting "github.com/cosmos/ibc-go/v7/testing" test "github.com/strangelove-ventures/interchaintest/v7/testutil" + testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" ) func TestTransferLocalhostTestSuite(t *testing.T) { - suite.Run(t, new(LocalhostTransferTestSuite)) + testifysuite.Run(t, new(LocalhostTransferTestSuite)) } type LocalhostTransferTestSuite struct { diff --git a/e2e/tests/upgrades/upgrade_test.go b/e2e/tests/upgrades/upgrade_test.go index ccc7ab6feb7..0ed76e10ae6 100644 --- a/e2e/tests/upgrades/upgrade_test.go +++ b/e2e/tests/upgrades/upgrade_test.go @@ -11,13 +11,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/gogoproto/proto" - intertxtypes "github.com/cosmos/interchain-accounts/x/inter-tx/types" - interchaintest "github.com/strangelove-ventures/interchaintest/v7" - "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" - "github.com/strangelove-ventures/interchaintest/v7/ibc" - test "github.com/strangelove-ventures/interchaintest/v7/testutil" - "github.com/stretchr/testify/suite" - "github.com/cosmos/ibc-go/e2e/semverutil" "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" @@ -29,6 +22,12 @@ import ( "github.com/cosmos/ibc-go/v7/modules/core/exported" solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine" ibctesting "github.com/cosmos/ibc-go/v7/testing" + intertxtypes "github.com/cosmos/interchain-accounts/x/inter-tx/types" + interchaintest "github.com/strangelove-ventures/interchaintest/v7" + "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" + "github.com/strangelove-ventures/interchaintest/v7/ibc" + test "github.com/strangelove-ventures/interchaintest/v7/testutil" + testifysuite "github.com/stretchr/testify/suite" ) const ( @@ -42,7 +41,7 @@ func TestUpgradeTestSuite(t *testing.T) { t.Fatalf("%s and %s must be set when running an upgrade test", testsuite.ChainUpgradeTagEnv, testsuite.ChainUpgradePlanEnv) } - suite.Run(t, new(UpgradeTestSuite)) + testifysuite.Run(t, new(UpgradeTestSuite)) } type UpgradeTestSuite struct { diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index 9bddf7908ed..e045a4ab70d 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -11,7 +11,7 @@ import ( "github.com/strangelove-ventures/interchaintest/v7/ibc" "github.com/strangelove-ventures/interchaintest/v7/testreporter" test "github.com/strangelove-ventures/interchaintest/v7/testutil" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" "go.uber.org/zap" "go.uber.org/zap/zaptest" @@ -32,7 +32,7 @@ const ( // E2ETestSuite has methods and functionality which can be shared among all test suites. type E2ETestSuite struct { - suite.Suite + testifysuite.Suite grpcClients map[string]GRPCClients paths map[string]pathPair diff --git a/go.mod b/go.mod index e95ab6e7efe..f45895409fa 100644 --- a/go.mod +++ b/go.mod @@ -7,9 +7,9 @@ require ( cosmossdk.io/client/v2 v2.0.0-20230722073756-0fa85b7a424d cosmossdk.io/core v0.9.0 cosmossdk.io/errors v1.0.0 - cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca + cosmossdk.io/log v1.2.0 cosmossdk.io/math v1.0.1 - cosmossdk.io/store v1.0.0-alpha.1 + cosmossdk.io/store v1.0.0-alpha.1.0.20230728080422-54ed7dab3982 cosmossdk.io/tools/confix v0.0.0-20230722073756-0fa85b7a424d cosmossdk.io/x/circuit v0.0.0-20230722073756-0fa85b7a424d cosmossdk.io/x/evidence v0.0.0-20230722073756-0fa85b7a424d @@ -19,7 +19,7 @@ require ( github.com/cometbft/cometbft v0.38.0-rc3 github.com/cosmos/cosmos-db v1.0.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/cosmos-sdk v0.50.0-beta.0.0.20230723220119-d68a1231a44b + github.com/cosmos/cosmos-sdk v0.50.0-beta.0.0.20230802171422-ee5b2e3afc4f github.com/cosmos/gogoproto v1.4.10 github.com/cosmos/ibc-go/modules/capability v1.0.0-rc3 github.com/cosmos/ics23/go v0.10.0 @@ -31,7 +31,7 @@ require ( github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.8.4 google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 - google.golang.org/grpc v1.56.2 + google.golang.org/grpc v1.57.0 google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -157,7 +157,7 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/cors v1.8.3 // indirect - github.com/rs/zerolog v1.29.1 // indirect + github.com/rs/zerolog v1.30.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect @@ -184,7 +184,7 @@ require ( google.golang.org/api v0.126.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.0 // indirect diff --git a/go.sum b/go.sum index 4880439986c..1cbb89dce2d 100644 --- a/go.sum +++ b/go.sum @@ -199,12 +199,12 @@ cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= -cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca h1:msenprh2BLLRwNT7zN56TbBHOGk/7ARQckXHxXyvjoQ= -cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca/go.mod h1:PkIAKXZvaxrTRc++z53XMRvFk8AcGGWYHcMIPzVYX9c= +cosmossdk.io/log v1.2.0 h1:BbykkDsutXPSy8RojFB3KZEWyvMsToLy0ykb/ZhsLqQ= +cosmossdk.io/log v1.2.0/go.mod h1:GNSCc/6+DhFIj1aLn/j7Id7PaO8DzNylUZoOYBL9+I4= cosmossdk.io/math v1.0.1 h1:Qx3ifyOPaMLNH/89WeZFH268yCvU4xEcnPLu3sJqPPg= cosmossdk.io/math v1.0.1/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k= -cosmossdk.io/store v1.0.0-alpha.1 h1:/151XxAgm0tiKuYrtJzMG61lf6enpPuP+D/hIN8cRjQ= -cosmossdk.io/store v1.0.0-alpha.1/go.mod h1:ejgU9GhRGMNBduVnDwC3RyhOmu4uKlNQlTiJgPmbDkI= +cosmossdk.io/store v1.0.0-alpha.1.0.20230728080422-54ed7dab3982 h1:61YFeW2AhwwPfoJWzNJWvVubCj32sm5jZkJfraS9pDQ= +cosmossdk.io/store v1.0.0-alpha.1.0.20230728080422-54ed7dab3982/go.mod h1:QAF9zeRa/9ghuv7E8NS9SzWqRbgVNwH/dZwGhYDHUjI= cosmossdk.io/tools/confix v0.0.0-20230722073756-0fa85b7a424d h1:MeOV6ByDuc5KNOsPmXP77HHmDUmtFCmtesmTgFA+U50= cosmossdk.io/tools/confix v0.0.0-20230722073756-0fa85b7a424d/go.mod h1:0hR2RA/sxP6yO6nffc6JW9/8S5AHzRvdkivxpvrkWuw= cosmossdk.io/x/circuit v0.0.0-20230722073756-0fa85b7a424d h1:pKQ4w2Ftqi41z0DZBy7zJD5jFJBoWryD2spG1iuGQvA= @@ -350,8 +350,8 @@ github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0 github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.50.0-beta.0.0.20230723220119-d68a1231a44b h1:gj5xt5WtP8akQjo7DWcR20W+vfYfV5yB9QA6asI3xQQ= -github.com/cosmos/cosmos-sdk v0.50.0-beta.0.0.20230723220119-d68a1231a44b/go.mod h1:MF/wnXyreoL0g8YdRZhUD4apPdgebMc29LgMJB+dh6M= +github.com/cosmos/cosmos-sdk v0.50.0-beta.0.0.20230802171422-ee5b2e3afc4f h1:KVypgBpP7iFjmTTTopZeNukTDwexCM3CAr1Jcj5u11Q= +github.com/cosmos/cosmos-sdk v0.50.0-beta.0.0.20230802171422-ee5b2e3afc4f/go.mod h1:pJU8sjvSa3I7lH2whf4QO1V2DTU79G8WwPTdqmDEh+Q= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= @@ -920,9 +920,9 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo= github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= -github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= +github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -1600,8 +1600,8 @@ google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 h1:Au6te5hbKUV8pIY google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:O9kGHb51iE/nOGvQaDUuadVYqovW56s5emA88lQnj6Y= google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 h1:s5YSX+ZH5b5vS9rnpGymvIyMpLRJizowqDlOuyjXnTk= google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e h1:S83+ibolgyZ0bqz7KEsUOPErxcv4VzlszxY+31OfB/E= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1643,8 +1643,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI= -google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/modules/apps/27-interchain-accounts/controller/client/cli/tx.go b/modules/apps/27-interchain-accounts/controller/client/cli/tx.go index 232d22b07c9..fe287dee6ec 100644 --- a/modules/apps/27-interchain-accounts/controller/client/cli/tx.go +++ b/modules/apps/27-interchain-accounts/controller/client/cli/tx.go @@ -80,7 +80,6 @@ appropriate relative timeoutTimestamp must be provided with flag {relative-packe var icaMsgData icatypes.InterchainAccountPacketData msgContentOrFileName := args[1] if err := cdc.UnmarshalJSON([]byte(msgContentOrFileName), &icaMsgData); err != nil { - // check for file path if JSON input is not provided contents, err := os.ReadFile(msgContentOrFileName) if err != nil { diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware.go index 1338b3f252f..1ccd5206604 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware.go @@ -17,7 +17,10 @@ import ( ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ) -var _ porttypes.Middleware = (*IBCMiddleware)(nil) +var ( + _ porttypes.Middleware = (*IBCMiddleware)(nil) + _ porttypes.PacketDataUnmarshaler = (*IBCMiddleware)(nil) +) // IBCMiddleware implements the ICS26 callbacks for the fee middleware given the // ICA controller keeper and the underlying application. @@ -76,7 +79,7 @@ func (im IBCMiddleware) OnChanOpenInit( } // OnChanOpenTry implements the IBCMiddleware interface -func (im IBCMiddleware) OnChanOpenTry( +func (IBCMiddleware) OnChanOpenTry( ctx sdk.Context, order channeltypes.Order, connectionHops []string, @@ -124,7 +127,7 @@ func (im IBCMiddleware) OnChanOpenAck( } // OnChanOpenConfirm implements the IBCMiddleware interface -func (im IBCMiddleware) OnChanOpenConfirm( +func (IBCMiddleware) OnChanOpenConfirm( ctx sdk.Context, portID, channelID string, @@ -133,7 +136,7 @@ func (im IBCMiddleware) OnChanOpenConfirm( } // OnChanCloseInit implements the IBCMiddleware interface -func (im IBCMiddleware) OnChanCloseInit( +func (IBCMiddleware) OnChanCloseInit( ctx sdk.Context, portID, channelID string, @@ -165,7 +168,7 @@ func (im IBCMiddleware) OnChanCloseConfirm( } // OnRecvPacket implements the IBCMiddleware interface -func (im IBCMiddleware) OnRecvPacket( +func (IBCMiddleware) OnRecvPacket( ctx sdk.Context, packet channeltypes.Packet, _ sdk.AccAddress, @@ -227,7 +230,7 @@ func (im IBCMiddleware) OnTimeoutPacket( } // SendPacket implements the ICS4 Wrapper interface -func (im IBCMiddleware) SendPacket( +func (IBCMiddleware) SendPacket( ctx sdk.Context, chanCap *capabilitytypes.Capability, sourcePort string, @@ -240,7 +243,7 @@ func (im IBCMiddleware) SendPacket( } // WriteAcknowledgement implements the ICS4 Wrapper interface -func (im IBCMiddleware) WriteAcknowledgement( +func (IBCMiddleware) WriteAcknowledgement( ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, @@ -253,3 +256,15 @@ func (im IBCMiddleware) WriteAcknowledgement( func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) { return im.keeper.GetAppVersion(ctx, portID, channelID) } + +// UnmarshalPacketData attempts to unmarshal the provided packet data bytes +// into an InterchainAccountPacketData. This function implements the optional +// PacketDataUnmarshaler interface required for ADR 008 support. +func (IBCMiddleware) UnmarshalPacketData(bz []byte) (interface{}, error) { + var packetData icatypes.InterchainAccountPacketData + if err := icatypes.ModuleCdc.UnmarshalJSON(bz, &packetData); err != nil { + return nil, err + } + + return packetData, nil +} 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 cf049e3ae50..0bf4af8496a 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" sdk "github.com/cosmos/cosmos-sdk/types" @@ -38,7 +38,7 @@ var ( ) type InterchainAccountsTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -49,7 +49,7 @@ type InterchainAccountsTestSuite struct { } func TestICATestSuite(t *testing.T) { - suite.Run(t, new(InterchainAccountsTestSuite)) + testifysuite.Run(t, new(InterchainAccountsTestSuite)) } func (suite *InterchainAccountsTestSuite) SetupTest() { @@ -918,3 +918,26 @@ func (suite *InterchainAccountsTestSuite) TestClosedChannelReopensWithMsgServer( err = path.EndpointB.ChanOpenConfirm() suite.Require().NoError(err) } + +func (suite *InterchainAccountsTestSuite) TestPacketDataUnmarshalerInterface() { + path := NewICAPath(suite.chainA, suite.chainB) + suite.coordinator.SetupConnections(path) + err := SetupICAPath(path, TestOwnerAddress) + suite.Require().NoError(err) + + expPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, + Data: []byte("data"), + Memo: "", + } + + packetData, err := controller.IBCMiddleware{}.UnmarshalPacketData(expPacketData.GetBytes()) + suite.Require().NoError(err) + suite.Require().Equal(expPacketData, packetData) + + // test invalid packet data + invalidPacketData := []byte("invalid packet data") + packetData, err = controller.IBCMiddleware{}.UnmarshalPacketData(invalidPacketData) + suite.Require().Error(err) + suite.Require().Nil(packetData) +} diff --git a/modules/apps/27-interchain-accounts/controller/keeper/export_test.go b/modules/apps/27-interchain-accounts/controller/keeper/export_test.go new file mode 100644 index 00000000000..3600380f0a8 --- /dev/null +++ b/modules/apps/27-interchain-accounts/controller/keeper/export_test.go @@ -0,0 +1,12 @@ +package keeper + +/* + This file is to allow for unexported functions and fields to be accessible to the testing package. +*/ + +import porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + +// GetICS4Wrapper is a getter for the keeper's ICS4Wrapper. +func (k *Keeper) GetICS4Wrapper() porttypes.ICS4Wrapper { + return k.ics4Wrapper +} diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index 8084c8e5d66..3fff058df99 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -129,7 +129,7 @@ func (k Keeper) OnChanOpenAck( } // OnChanCloseConfirm removes the active channel stored in state -func (k Keeper) OnChanCloseConfirm( +func (Keeper) OnChanCloseConfirm( ctx sdk.Context, portID, channelID string, diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go index 6bdbcaa8ebb..d329ccf50db 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go @@ -65,8 +65,15 @@ func NewKeeper( } } +// WithICS4Wrapper sets the ICS4Wrapper. This function may be used after +// the keepers creation to set the middleware which is above this module +// in the IBC application stack. +func (k *Keeper) WithICS4Wrapper(wrapper porttypes.ICS4Wrapper) { + k.ics4Wrapper = wrapper +} + // Logger returns the application logger, scoped to the associated module -func (k Keeper) Logger(ctx sdk.Context) log.Logger { +func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s-%s", exported.ModuleName, icatypes.ModuleName)) } diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go index c89122d1d39..3fc9b5c2e84 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -11,6 +11,8 @@ import ( "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" genesistypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/genesis/types" icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" + ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper" + channelkeeper "github.com/cosmos/ibc-go/v7/modules/core/04-channel/keeper" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v7/testing" ) @@ -33,7 +35,7 @@ var ( ) type KeeperTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -103,7 +105,7 @@ func RegisterInterchainAccount(endpoint *ibctesting.Endpoint, owner string) erro } func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) + testifysuite.Run(t, new(KeeperTestSuite)) } func (suite *KeeperTestSuite) TestGetAllPorts() { @@ -292,3 +294,24 @@ func (suite *KeeperTestSuite) TestGetAuthority() { expectedAuth := authtypes.NewModuleAddress(govtypes.ModuleName).String() suite.Require().Equal(expectedAuth, authority) } + +func (suite *KeeperTestSuite) TestWithICS4Wrapper() { + suite.SetupTest() + + // test if the ics4 wrapper is the fee keeper initially + ics4Wrapper := suite.chainA.GetSimApp().ICAControllerKeeper.GetICS4Wrapper() + + _, isFeeKeeper := ics4Wrapper.(ibcfeekeeper.Keeper) + suite.Require().True(isFeeKeeper) + _, isChannelKeeper := ics4Wrapper.(channelkeeper.Keeper) + suite.Require().False(isChannelKeeper) + + // set the ics4 wrapper to the channel keeper + suite.chainA.GetSimApp().ICAControllerKeeper.WithICS4Wrapper(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper) + ics4Wrapper = suite.chainA.GetSimApp().ICAControllerKeeper.GetICS4Wrapper() + + _, isChannelKeeper = ics4Wrapper.(channelkeeper.Keeper) + suite.Require().True(isChannelKeeper) + _, isFeeKeeper = ics4Wrapper.(ibcfeekeeper.Keeper) + suite.Require().False(isFeeKeeper) +} diff --git a/modules/apps/27-interchain-accounts/controller/keeper/relay.go b/modules/apps/27-interchain-accounts/controller/keeper/relay.go index 412d2cb2f0c..651af21966d 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay.go @@ -55,6 +55,6 @@ func (k Keeper) sendTx(ctx sdk.Context, connectionID, portID string, icaPacketDa // OnTimeoutPacket removes the active channel associated with the provided packet, the underlying channel end is closed // due to the semantics of ORDERED channels -func (k Keeper) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet) error { +func (Keeper) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet) error { return nil } diff --git a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go index c079459c0aa..5c6ce64e154 100644 --- a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go +++ b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go @@ -3,7 +3,7 @@ package v6_test import ( "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" sdk "github.com/cosmos/cosmos-sdk/types" @@ -18,7 +18,7 @@ import ( ) type MigrationsTestSuite struct { - suite.Suite + testifysuite.Suite chainA *ibctesting.TestChain chainB *ibctesting.TestChain @@ -58,7 +58,7 @@ func (suite *MigrationsTestSuite) SetupPath() error { return suite.path.EndpointB.ChanOpenConfirm() } -func (suite *MigrationsTestSuite) RegisterInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error { +func (*MigrationsTestSuite) RegisterInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error { portID, err := icatypes.NewControllerPortID(owner) if err != nil { return err @@ -81,7 +81,7 @@ func (suite *MigrationsTestSuite) RegisterInterchainAccount(endpoint *ibctesting } func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(MigrationsTestSuite)) + testifysuite.Run(t, new(MigrationsTestSuite)) } func (suite *MigrationsTestSuite) TestMigrateICS27ChannelCapability() { diff --git a/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go b/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go index d26ebff53a9..0f258eb6216 100644 --- a/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go +++ b/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go @@ -1,7 +1,9 @@ package types_test import ( - "github.com/stretchr/testify/suite" + "testing" + + testifysuite "github.com/stretchr/testify/suite" controllertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" genesistypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/genesis/types" @@ -19,7 +21,11 @@ var ( ) type GenesisTypesTestSuite struct { - suite.Suite + testifysuite.Suite +} + +func TestGenesisTypesTestSuite(t *testing.T) { + testifysuite.Run(t, new(GenesisTypesTestSuite)) } func (suite *GenesisTypesTestSuite) TestValidateGenesisState() { diff --git a/modules/apps/27-interchain-accounts/host/client/cli/tx.go b/modules/apps/27-interchain-accounts/host/client/cli/tx.go index c536fbde43f..d3902d35f9a 100644 --- a/modules/apps/27-interchain-accounts/host/client/cli/tx.go +++ b/modules/apps/27-interchain-accounts/host/client/cli/tx.go @@ -22,8 +22,8 @@ const ( func generatePacketDataCmd() *cobra.Command { cmd := &cobra.Command{ Use: "generate-packet-data [message]", - Short: "Generates ICA packet data.", - Long: `generate-packet-data accepts a message string and serializes it + Short: "Generates protobuf encoded ICA packet data.", + Long: `generate-packet-data accepts a message string and serializes it using protobuf into packet data which is outputted to stdout. It can be used in conjunction with send-tx" which submits pre-built packet data containing messages to be executed on the host chain. `, diff --git a/modules/apps/27-interchain-accounts/host/ibc_module.go b/modules/apps/27-interchain-accounts/host/ibc_module.go index 012130c2efc..6efd8c47cb8 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module.go @@ -29,7 +29,7 @@ func NewIBCModule(k keeper.Keeper) IBCModule { } // OnChanOpenInit implements the IBCModule interface -func (im IBCModule) OnChanOpenInit( +func (IBCModule) OnChanOpenInit( ctx sdk.Context, order channeltypes.Order, connectionHops []string, @@ -61,7 +61,7 @@ func (im IBCModule) OnChanOpenTry( } // OnChanOpenAck implements the IBCModule interface -func (im IBCModule) OnChanOpenAck( +func (IBCModule) OnChanOpenAck( ctx sdk.Context, portID, channelID string, @@ -85,7 +85,7 @@ func (im IBCModule) OnChanOpenConfirm( } // OnChanCloseInit implements the IBCModule interface -func (im IBCModule) OnChanCloseInit( +func (IBCModule) OnChanCloseInit( ctx sdk.Context, portID, channelID string, @@ -132,7 +132,7 @@ func (im IBCModule) OnRecvPacket( } // OnAcknowledgementPacket implements the IBCModule interface -func (im IBCModule) OnAcknowledgementPacket( +func (IBCModule) OnAcknowledgementPacket( ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, @@ -142,7 +142,7 @@ func (im IBCModule) OnAcknowledgementPacket( } // OnTimeoutPacket implements the IBCModule interface -func (im IBCModule) OnTimeoutPacket( +func (IBCModule) OnTimeoutPacket( ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, 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 35687bbdc1b..05f9c7d520f 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/cosmos/gogoproto/proto" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" sdkmath "cosmossdk.io/math" @@ -42,7 +42,7 @@ var ( ) type InterchainAccountsTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -52,7 +52,7 @@ type InterchainAccountsTestSuite struct { } func TestICATestSuite(t *testing.T) { - suite.Run(t, new(InterchainAccountsTestSuite)) + testifysuite.Run(t, new(InterchainAccountsTestSuite)) } func (suite *InterchainAccountsTestSuite) SetupTest() { diff --git a/modules/apps/27-interchain-accounts/host/keeper/export_test.go b/modules/apps/27-interchain-accounts/host/keeper/export_test.go index 03c13e894d5..100e5203076 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/export_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/export_test.go @@ -1,15 +1,21 @@ package keeper /* - This file is to allow for unexported functions to be accessible to the testing package. + This file is to allow for unexported functions and fields to be accessible to the testing package. */ import ( sdk "github.com/cosmos/cosmos-sdk/types" icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" + porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" ) +// GetICS4Wrapper is a getter for the keeper's ICS4Wrapper. +func (k *Keeper) GetICS4Wrapper() porttypes.ICS4Wrapper { + return k.ics4Wrapper +} + // GetAppMetadata is a wrapper around getAppMetadata to allow the function to be directly called in tests. func (k Keeper) GetAppMetadata(ctx sdk.Context, portID, channelID string) (icatypes.Metadata, error) { return k.getAppMetadata(ctx, portID, channelID) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake.go b/modules/apps/27-interchain-accounts/host/keeper/handshake.go index f565ad65a7d..7b4f2254235 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake.go @@ -123,7 +123,7 @@ func (k Keeper) OnChanOpenConfirm( } // OnChanCloseConfirm removes the active channel stored in state -func (k Keeper) OnChanCloseConfirm( +func (Keeper) OnChanCloseConfirm( ctx sdk.Context, portID, channelID string, diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index 9dce448e1da..94b1c9daed4 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -73,8 +73,15 @@ func NewKeeper( } } +// WithICS4Wrapper sets the ICS4Wrapper. This function may be used after +// the keepers creation to set the middleware which is above this module +// in the IBC application stack. +func (k *Keeper) WithICS4Wrapper(wrapper porttypes.ICS4Wrapper) { + k.ics4Wrapper = wrapper +} + // Logger returns the application logger, scoped to the associated module -func (k Keeper) Logger(ctx sdk.Context) log.Logger { +func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s-%s", exported.ModuleName, icatypes.ModuleName)) } diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go index b8b91e83df8..cb03e1371e3 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go @@ -4,11 +4,13 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" genesistypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/genesis/types" "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" + ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper" + channelkeeper "github.com/cosmos/ibc-go/v7/modules/core/04-channel/keeper" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ibcerrors "github.com/cosmos/ibc-go/v7/modules/core/errors" ibctesting "github.com/cosmos/ibc-go/v7/testing" @@ -41,7 +43,7 @@ var ( ) type KeeperTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -122,7 +124,7 @@ func RegisterInterchainAccount(endpoint *ibctesting.Endpoint, owner string) erro } func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) + testifysuite.Run(t, new(KeeperTestSuite)) } func (suite *KeeperTestSuite) TestGetInterchainAccountAddress() { @@ -301,3 +303,24 @@ func (suite *KeeperTestSuite) TestUnsetParams() { suite.chainA.GetSimApp().ICAHostKeeper.GetParams(ctx) }) } + +func (suite *KeeperTestSuite) TestWithICS4Wrapper() { + suite.SetupTest() + + // test if the ics4 wrapper is the fee keeper initially + ics4Wrapper := suite.chainA.GetSimApp().ICAHostKeeper.GetICS4Wrapper() + + _, isFeeKeeper := ics4Wrapper.(ibcfeekeeper.Keeper) + suite.Require().True(isFeeKeeper) + _, isChannelKeeper := ics4Wrapper.(channelkeeper.Keeper) + suite.Require().False(isChannelKeeper) + + // set the ics4 wrapper to the channel keeper + suite.chainA.GetSimApp().ICAHostKeeper.WithICS4Wrapper(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper) + ics4Wrapper = suite.chainA.GetSimApp().ICAHostKeeper.GetICS4Wrapper() + + _, isChannelKeeper = ics4Wrapper.(channelkeeper.Keeper) + suite.Require().True(isChannelKeeper) + _, isFeeKeeper = ics4Wrapper.(ibcfeekeeper.Keeper) + suite.Require().False(isFeeKeeper) +} diff --git a/modules/apps/27-interchain-accounts/module.go b/modules/apps/27-interchain-accounts/module.go index 2d63052943b..9303de77fbc 100644 --- a/modules/apps/27-interchain-accounts/module.go +++ b/modules/apps/27-interchain-accounts/module.go @@ -210,11 +210,11 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } // WeightedOperations is unimplemented. -func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { +func (AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return nil } // RegisterStoreDecoder registers a decoder for interchain accounts module's types -func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { +func (AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { sdr[types.StoreKey] = simulation.NewDecodeStore() } diff --git a/modules/apps/27-interchain-accounts/module_test.go b/modules/apps/27-interchain-accounts/module_test.go index 760dfeac79d..5719e70e5c5 100644 --- a/modules/apps/27-interchain-accounts/module_test.go +++ b/modules/apps/27-interchain-accounts/module_test.go @@ -4,7 +4,7 @@ import ( "testing" dbm "github.com/cosmos/cosmos-db" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" "cosmossdk.io/log" @@ -20,13 +20,13 @@ import ( ) type InterchainAccountsTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator } func TestICATestSuite(t *testing.T) { - suite.Run(t, new(InterchainAccountsTestSuite)) + testifysuite.Run(t, new(InterchainAccountsTestSuite)) } func (suite *InterchainAccountsTestSuite) SetupTest() { diff --git a/modules/apps/27-interchain-accounts/types/account.go b/modules/apps/27-interchain-accounts/types/account.go index 9a01f559055..60c05ad448c 100644 --- a/modules/apps/27-interchain-accounts/types/account.go +++ b/modules/apps/27-interchain-accounts/types/account.go @@ -76,13 +76,13 @@ func NewInterchainAccount(ba *authtypes.BaseAccount, accountOwner string) *Inter } } -// SetPubKey implements the sdk.AccountI interface -func (ia InterchainAccount) SetPubKey(pubKey crypto.PubKey) error { +// SetPubKey implements the authtypes.AccountI interface +func (InterchainAccount) SetPubKey(pubkey crypto.PubKey) error { return errorsmod.Wrap(ErrUnsupported, "cannot set public key for interchain account") } -// SetSequence implements the sdk.AccountI interface -func (ia InterchainAccount) SetSequence(seq uint64) error { +// SetSequence implements the authtypes.AccountI interface +func (InterchainAccount) SetSequence(seq uint64) error { return errorsmod.Wrap(ErrUnsupported, "cannot set sequence number for interchain account") } diff --git a/modules/apps/27-interchain-accounts/types/account_test.go b/modules/apps/27-interchain-accounts/types/account_test.go index 50eadc8aad3..69ba9dfcdfe 100644 --- a/modules/apps/27-interchain-accounts/types/account_test.go +++ b/modules/apps/27-interchain-accounts/types/account_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" @@ -24,7 +24,7 @@ var ( ) type TypesTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -40,7 +40,7 @@ func (suite *TypesTestSuite) SetupTest() { } func TestTypesTestSuite(t *testing.T) { - suite.Run(t, new(TypesTestSuite)) + testifysuite.Run(t, new(TypesTestSuite)) } func (suite *TypesTestSuite) TestGenerateAddress() { diff --git a/modules/apps/27-interchain-accounts/types/metadata.go b/modules/apps/27-interchain-accounts/types/metadata.go index 3df2028d9b1..d8167e0ab59 100644 --- a/modules/apps/27-interchain-accounts/types/metadata.go +++ b/modules/apps/27-interchain-accounts/types/metadata.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ibc-go/v7/internal/collections" connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" ) @@ -133,13 +134,7 @@ func ValidateHostMetadata(ctx sdk.Context, channelKeeper ChannelKeeper, connecti // isSupportedEncoding returns true if the provided encoding is supported, otherwise false func isSupportedEncoding(encoding string) bool { - for _, enc := range getSupportedEncoding() { - if enc == encoding { - return true - } - } - - return false + return collections.Contains(encoding, getSupportedEncoding()) } // getSupportedEncoding returns a string slice of supported encoding formats @@ -149,13 +144,7 @@ func getSupportedEncoding() []string { // isSupportedTxType returns true if the provided transaction type is supported, otherwise false func isSupportedTxType(txType string) bool { - for _, t := range getSupportedTxTypes() { - if t == txType { - return true - } - } - - return false + return collections.Contains(txType, getSupportedTxTypes()) } // getSupportedTxTypes returns a string slice of supported transaction types diff --git a/modules/apps/27-interchain-accounts/types/packet.go b/modules/apps/27-interchain-accounts/types/packet.go index 213497f6ac6..3091e6ba33c 100644 --- a/modules/apps/27-interchain-accounts/types/packet.go +++ b/modules/apps/27-interchain-accounts/types/packet.go @@ -1,12 +1,21 @@ package types import ( + "encoding/json" + "strings" "time" errorsmod "cosmossdk.io/errors" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" +) + +var ( + _ ibcexported.PacketData = (*InterchainAccountPacketData)(nil) + _ ibcexported.PacketDataProvider = (*InterchainAccountPacketData)(nil) ) // MaxMemoCharLength defines the maximum length for the InterchainAccountPacketData memo field @@ -64,3 +73,41 @@ func (ct CosmosTx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { return nil } + +// GetPacketSender returns the sender address of the interchain accounts packet data. +// It is obtained from the source port ID by cutting off the ControllerPortPrefix. +// If the source port ID does not have the ControllerPortPrefix, then an empty string is returned. +// +// NOTE: +// - The sender address is set by the packet sender and may not have been validated a signature +// check if the packet sender isn't the interchain accounts module. +// - The sender address must only be used by modules on the sending chain. +func (InterchainAccountPacketData) GetPacketSender(sourcePortID string) string { + icaOwner, found := strings.CutPrefix(sourcePortID, ControllerPortPrefix) + if !found { + return "" + } + return icaOwner +} + +// GetCustomPacketData interprets the memo field of the packet data as a JSON object +// and returns the value associated with the given key. +// If the key is missing or the memo is not properly formatted, then nil is returned. +func (iapd InterchainAccountPacketData) GetCustomPacketData(key string) interface{} { + if len(iapd.Memo) == 0 { + return nil + } + + jsonObject := make(map[string]interface{}) + err := json.Unmarshal([]byte(iapd.Memo), &jsonObject) + if err != nil { + return nil + } + + memoData, found := jsonObject[key] + if !found { + return nil + } + + return memoData +} diff --git a/modules/apps/27-interchain-accounts/types/packet_test.go b/modules/apps/27-interchain-accounts/types/packet_test.go index 329e5a837f4..c1ff4753652 100644 --- a/modules/apps/27-interchain-accounts/types/packet_test.go +++ b/modules/apps/27-interchain-accounts/types/packet_test.go @@ -1,7 +1,10 @@ package types_test import ( + "fmt" + "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" + ibctesting "github.com/cosmos/ibc-go/v7/testing" ) var largeMemo = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum" @@ -82,3 +85,98 @@ func (suite *TypesTestSuite) TestValidateBasic() { }) } } + +func (suite *TypesTestSuite) TestGetPacketSender() { + testCases := []struct { + name string + srcPortID string + expSender string + }{ + { + "success: port id has prefix", + types.ControllerPortPrefix + ibctesting.TestAccAddress, + ibctesting.TestAccAddress, + }, + { + "failure: missing prefix", + ibctesting.TestAccAddress, + "", + }, + { + "failure: empty port id", + "", + "", + }, + } + + for _, tc := range testCases { + packetData := types.InterchainAccountPacketData{} + suite.Require().Equal(tc.expSender, packetData.GetPacketSender(tc.srcPortID)) + } +} + +func (suite *TypesTestSuite) TestPacketDataProvider() { + expCallbackAddr := ibctesting.TestAccAddress + + testCases := []struct { + name string + packetData types.InterchainAccountPacketData + expCustomData interface{} + }{ + { + "success: src_callback key in memo", + types.InterchainAccountPacketData{ + Type: types.EXECUTE_TX, + Data: []byte("data"), + Memo: fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, expCallbackAddr), + }, + map[string]interface{}{ + "address": expCallbackAddr, + }, + }, + { + "success: src_callback key in memo with additional fields", + types.InterchainAccountPacketData{ + Type: types.EXECUTE_TX, + Data: []byte("data"), + Memo: fmt.Sprintf(`{"src_callback": {"address": "%s", "gas_limit": "200000"}}`, expCallbackAddr), + }, + map[string]interface{}{ + "address": expCallbackAddr, + "gas_limit": "200000", + }, + }, + { + "success: src_callback has string valu", + types.InterchainAccountPacketData{ + Type: types.EXECUTE_TX, + Data: []byte("data"), + Memo: `{"src_callback": "string"}`, + }, + "string", + }, + { + "failure: empty memo", + types.InterchainAccountPacketData{ + Type: types.EXECUTE_TX, + Data: []byte("data"), + Memo: "", + }, + nil, + }, + { + "failure: non-json memo", + types.InterchainAccountPacketData{ + Type: types.EXECUTE_TX, + Data: []byte("data"), + Memo: "invalid", + }, + nil, + }, + } + + for _, tc := range testCases { + customData := tc.packetData.GetCustomPacketData("src_callback") + suite.Require().Equal(tc.expCustomData, customData) + } +} diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go index 0505a186132..390bfd4e571 100644 --- a/modules/apps/29-fee/fee_test.go +++ b/modules/apps/29-fee/fee_test.go @@ -3,7 +3,7 @@ package fee_test import ( "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" @@ -13,7 +13,7 @@ import ( ) type FeeTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -48,7 +48,7 @@ func (suite *FeeTestSuite) SetupTest() { } func TestIBCFeeTestSuite(t *testing.T) { - suite.Run(t, new(FeeTestSuite)) + testifysuite.Run(t, new(FeeTestSuite)) } func (suite *FeeTestSuite) CreateMockPacket() channeltypes.Packet { diff --git a/modules/apps/29-fee/ibc_middleware.go b/modules/apps/29-fee/ibc_middleware.go index 5b260ad7be9..1390d816386 100644 --- a/modules/apps/29-fee/ibc_middleware.go +++ b/modules/apps/29-fee/ibc_middleware.go @@ -16,7 +16,10 @@ import ( "github.com/cosmos/ibc-go/v7/modules/core/exported" ) -var _ porttypes.Middleware = (*IBCMiddleware)(nil) +var ( + _ porttypes.Middleware = (*IBCMiddleware)(nil) + _ porttypes.PacketDataUnmarshaler = (*IBCMiddleware)(nil) +) // IBCMiddleware implements the ICS26 callbacks for the fee middleware given the // fee keeper and the underlying application. @@ -348,3 +351,15 @@ func (im IBCMiddleware) WriteAcknowledgement( func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) { return im.keeper.GetAppVersion(ctx, portID, channelID) } + +// UnmarshalPacketData attempts to use the underlying app to unmarshal the packet data. +// If the underlying app does not support the PacketDataUnmarshaler interface, an error is returned. +// This function implements the optional PacketDataUnmarshaler interface required for ADR 008 support. +func (im IBCMiddleware) UnmarshalPacketData(bz []byte) (interface{}, error) { + unmarshaler, ok := im.app.(porttypes.PacketDataUnmarshaler) + if !ok { + return nil, errorsmod.Wrapf(types.ErrUnsupportedAction, "underlying app does not implement %T", (*porttypes.PacketDataUnmarshaler)(nil)) + } + + return unmarshaler.UnmarshalPacketData(bz) +} diff --git a/modules/apps/29-fee/ibc_middleware_test.go b/modules/apps/29-fee/ibc_middleware_test.go index ee1d0ed228a..b2a740a06e5 100644 --- a/modules/apps/29-fee/ibc_middleware_test.go +++ b/modules/apps/29-fee/ibc_middleware_test.go @@ -3,15 +3,18 @@ package fee_test import ( "fmt" + errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - fee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee" + ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee" + feekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper" "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" host "github.com/cosmos/ibc-go/v7/modules/core/24-host" "github.com/cosmos/ibc-go/v7/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v7/testing" @@ -1066,7 +1069,7 @@ func (suite *FeeTestSuite) TestGetAppVersion() { cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) suite.Require().True(ok) - feeModule := cbs.(fee.IBCMiddleware) + feeModule := cbs.(ibcfee.IBCMiddleware) appVersion, found := feeModule.GetAppVersion(suite.chainA.GetContext(), portID, channelID) @@ -1080,3 +1083,27 @@ func (suite *FeeTestSuite) TestGetAppVersion() { }) } } + +func (suite *FeeTestSuite) TestPacketDataUnmarshalerInterface() { + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) + suite.Require().NoError(err) + + cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + suite.Require().True(ok) + + feeModule, ok := cbs.(porttypes.PacketDataUnmarshaler) + suite.Require().True(ok) + + packetData, err := feeModule.UnmarshalPacketData(ibcmock.MockPacketData) + suite.Require().NoError(err) + suite.Require().Equal(ibcmock.MockPacketData, packetData) +} + +func (suite *FeeTestSuite) TestPacketDataUnmarshalerInterfaceError() { + // test the case when the underlying application cannot be casted to a PacketDataUnmarshaler + mockFeeMiddleware := ibcfee.NewIBCMiddleware(nil, feekeeper.Keeper{}) + + _, err := mockFeeMiddleware.UnmarshalPacketData(ibcmock.MockPacketData) + expError := errorsmod.Wrapf(types.ErrUnsupportedAction, "underlying app does not implement %T", (*porttypes.PacketDataUnmarshaler)(nil)) + suite.Require().ErrorIs(err, expError) +} diff --git a/modules/apps/29-fee/keeper/export_test.go b/modules/apps/29-fee/keeper/export_test.go new file mode 100644 index 00000000000..3600380f0a8 --- /dev/null +++ b/modules/apps/29-fee/keeper/export_test.go @@ -0,0 +1,12 @@ +package keeper + +/* + This file is to allow for unexported functions and fields to be accessible to the testing package. +*/ + +import porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + +// GetICS4Wrapper is a getter for the keeper's ICS4Wrapper. +func (k *Keeper) GetICS4Wrapper() porttypes.ICS4Wrapper { + return k.ics4Wrapper +} diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index e9c5455bfe7..328a3839be1 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -50,8 +50,15 @@ func NewKeeper( } } +// WithICS4Wrapper sets the ICS4Wrapper. This function may be used after +// the keepers creation to set the middleware which is above this module +// in the IBC application stack. +func (k *Keeper) WithICS4Wrapper(wrapper porttypes.ICS4Wrapper) { + k.ics4Wrapper = wrapper +} + // Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { +func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+ibcexported.ModuleName+"-"+types.ModuleName) } diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index f2265afe695..9cf73d3ffba 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -4,13 +4,15 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper" "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" + channelkeeper "github.com/cosmos/ibc-go/v7/modules/core/04-channel/keeper" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v7/testing" ibcmock "github.com/cosmos/ibc-go/v7/testing/mock" @@ -24,7 +26,7 @@ var ( ) type KeeperTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -60,7 +62,7 @@ func (suite *KeeperTestSuite) SetupTest() { } func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) + testifysuite.Run(t, new(KeeperTestSuite)) } // helper function @@ -297,3 +299,24 @@ func (suite *KeeperTestSuite) TestGetAllCounterpartyPayees() { suite.Require().Len(counterpartyPayeeAddr, len(expectedCounterpartyPayee)) suite.Require().Equal(counterpartyPayeeAddr, expectedCounterpartyPayee) } + +func (suite *KeeperTestSuite) TestWithICS4Wrapper() { + suite.SetupTest() + + // test if the ics4 wrapper is the channel keeper initially + ics4Wrapper := suite.chainA.GetSimApp().IBCFeeKeeper.GetICS4Wrapper() + + _, isChannelKeeper := ics4Wrapper.(channelkeeper.Keeper) + suite.Require().True(isChannelKeeper) + _, isFeeKeeper := ics4Wrapper.(keeper.Keeper) + suite.Require().False(isFeeKeeper) + + // set the ics4 wrapper to itself (don't do this in production) + suite.chainA.GetSimApp().IBCFeeKeeper.WithICS4Wrapper(suite.chainA.GetSimApp().IBCFeeKeeper) + ics4Wrapper = suite.chainA.GetSimApp().IBCFeeKeeper.GetICS4Wrapper() + + _, isFeeKeeper = ics4Wrapper.(keeper.Keeper) + suite.Require().True(isFeeKeeper) + _, isChannelKeeper = ics4Wrapper.(channelkeeper.Keeper) + suite.Require().False(isChannelKeeper) +} diff --git a/modules/apps/29-fee/module.go b/modules/apps/29-fee/module.go index e56889771ae..fdc7c5fe977 100644 --- a/modules/apps/29-fee/module.go +++ b/modules/apps/29-fee/module.go @@ -126,10 +126,10 @@ func (AppModule) GenerateGenesisState(_ *module.SimulationState) { } // RegisterStoreDecoder registers a decoder for 29-fee module's types -func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) { +func (AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) { } // WeightedOperations returns the all the 29-fee module operations with their respective weights. -func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { +func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { return nil } diff --git a/modules/apps/29-fee/types/errors.go b/modules/apps/29-fee/types/errors.go index 26167c71016..22dd35000a2 100644 --- a/modules/apps/29-fee/types/errors.go +++ b/modules/apps/29-fee/types/errors.go @@ -16,4 +16,5 @@ var ( ErrFeeNotEnabled = errorsmod.Register(ModuleName, 9, "fee module is not enabled for this channel. If this error occurs after channel setup, fee module may not be enabled") ErrRelayerNotFoundForAsyncAck = errorsmod.Register(ModuleName, 10, "relayer address must be stored for async WriteAcknowledgement") ErrFeeModuleLocked = errorsmod.Register(ModuleName, 11, "the fee module is currently locked, a severe bug has been detected") + ErrUnsupportedAction = errorsmod.Register(ModuleName, 12, "unsupported action") ) diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 0464ee934f4..c60c1e5ff9e 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -163,12 +163,12 @@ func (msg MsgPayPacketFee) GetSigners() []sdk.AccAddress { } // Type implements legacytx.LegacyMsg -func (msg MsgPayPacketFee) Type() string { +func (MsgPayPacketFee) Type() string { return TypeMsgPayPacketFee } // Route implements legacytx.LegacyMsg -func (msg MsgPayPacketFee) Route() string { +func (MsgPayPacketFee) Route() string { return RouterKey } @@ -205,12 +205,12 @@ func (msg MsgPayPacketFeeAsync) GetSigners() []sdk.AccAddress { } // Type implements legacytx.LegacyMsg -func (msg MsgPayPacketFeeAsync) Type() string { +func (MsgPayPacketFeeAsync) Type() string { return TypeMsgPayPacketFeeAsync } // Route implements legacytx.LegacyMsg -func (msg MsgPayPacketFeeAsync) Route() string { +func (MsgPayPacketFeeAsync) Route() string { return RouterKey } diff --git a/modules/apps/transfer/ibc_module.go b/modules/apps/transfer/ibc_module.go index 613315bacc3..da807cef434 100644 --- a/modules/apps/transfer/ibc_module.go +++ b/modules/apps/transfer/ibc_module.go @@ -19,6 +19,11 @@ import ( ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ) +var ( + _ porttypes.IBCModule = (*IBCModule)(nil) + _ porttypes.PacketDataUnmarshaler = (*IBCModule)(nil) +) + // IBCModule implements the ICS26 interface for transfer given the transfer keeper. type IBCModule struct { keeper keeper.Keeper @@ -36,7 +41,7 @@ func NewIBCModule(k keeper.Keeper) IBCModule { // supported version. Only 2^32 channels are allowed to be created. func ValidateTransferChannelParams( ctx sdk.Context, - keeper keeper.Keeper, + transferkeeper keeper.Keeper, order channeltypes.Order, portID string, channelID string, @@ -55,7 +60,7 @@ func ValidateTransferChannelParams( } // Require portID is the portID transfer module is bound to - boundPort := keeper.GetPort(ctx) + boundPort := transferkeeper.GetPort(ctx) if boundPort != portID { return errorsmod.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) } @@ -122,7 +127,7 @@ func (im IBCModule) OnChanOpenTry( } // OnChanOpenAck implements the IBCModule interface -func (im IBCModule) OnChanOpenAck( +func (IBCModule) OnChanOpenAck( ctx sdk.Context, portID, channelID string, @@ -136,7 +141,7 @@ func (im IBCModule) OnChanOpenAck( } // OnChanOpenConfirm implements the IBCModule interface -func (im IBCModule) OnChanOpenConfirm( +func (IBCModule) OnChanOpenConfirm( ctx sdk.Context, portID, channelID string, @@ -145,7 +150,7 @@ func (im IBCModule) OnChanOpenConfirm( } // OnChanCloseInit implements the IBCModule interface -func (im IBCModule) OnChanCloseInit( +func (IBCModule) OnChanCloseInit( ctx sdk.Context, portID, channelID string, @@ -155,7 +160,7 @@ func (im IBCModule) OnChanCloseInit( } // OnChanCloseConfirm implements the IBCModule interface -func (im IBCModule) OnChanCloseConfirm( +func (IBCModule) OnChanCloseConfirm( ctx sdk.Context, portID, channelID string, @@ -301,3 +306,15 @@ func (im IBCModule) OnTimeoutPacket( return nil } + +// UnmarshalPacketData attempts to unmarshal the provided packet data bytes +// into a FungibleTokenPacketData. This function implements the optional +// PacketDataUnmarshaler interface required for ADR 008 support. +func (IBCModule) UnmarshalPacketData(bz []byte) (interface{}, error) { + var packetData types.FungibleTokenPacketData + if err := types.ModuleCdc.UnmarshalJSON(bz, &packetData); err != nil { + return nil, err + } + + return packetData, nil +} diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index deed17c37c6..d8e532632a4 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -3,6 +3,9 @@ package transfer_test import ( "math" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" "github.com/cosmos/ibc-go/v7/modules/apps/transfer" "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" @@ -238,3 +241,69 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() { }) } } + +func (suite *TransferTestSuite) TestPacketDataUnmarshalerInterface() { + var ( + sender = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() + receiver = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() + + data []byte + expPacketData types.FungibleTokenPacketData + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success: valid packet data with memo", + func() { + expPacketData = types.FungibleTokenPacketData{ + Denom: ibctesting.TestCoin.Denom, + Amount: ibctesting.TestCoin.Amount.String(), + Sender: sender, + Receiver: receiver, + Memo: "some memo", + } + data = expPacketData.GetBytes() + }, + true, + }, + { + "success: valid packet data without memo", + func() { + expPacketData = types.FungibleTokenPacketData{ + Denom: ibctesting.TestCoin.Denom, + Amount: ibctesting.TestCoin.Amount.String(), + Sender: sender, + Receiver: receiver, + Memo: "", + } + data = expPacketData.GetBytes() + }, + true, + }, + { + "failure: invalid packet data", + func() { + data = []byte("invalid packet data") + }, + false, + }, + } + + for _, tc := range testCases { + tc.malleate() + + packetData, err := transfer.IBCModule{}.UnmarshalPacketData(data) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().Equal(expPacketData, packetData) + } else { + suite.Require().Error(err) + suite.Require().Nil(packetData) + } + } +} diff --git a/modules/apps/transfer/keeper/export_test.go b/modules/apps/transfer/keeper/export_test.go new file mode 100644 index 00000000000..3600380f0a8 --- /dev/null +++ b/modules/apps/transfer/keeper/export_test.go @@ -0,0 +1,12 @@ +package keeper + +/* + This file is to allow for unexported functions and fields to be accessible to the testing package. +*/ + +import porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + +// GetICS4Wrapper is a getter for the keeper's ICS4Wrapper. +func (k *Keeper) GetICS4Wrapper() porttypes.ICS4Wrapper { + return k.ics4Wrapper +} diff --git a/modules/apps/transfer/keeper/grpc_query.go b/modules/apps/transfer/keeper/grpc_query.go index f910e38d615..bd40c9da6da 100644 --- a/modules/apps/transfer/keeper/grpc_query.go +++ b/modules/apps/transfer/keeper/grpc_query.go @@ -112,7 +112,7 @@ func (k Keeper) DenomHash(c context.Context, req *types.QueryDenomHashRequest) ( } // EscrowAddress implements the EscrowAddress gRPC method -func (k Keeper) EscrowAddress(c context.Context, req *types.QueryEscrowAddressRequest) (*types.QueryEscrowAddressResponse, error) { +func (Keeper) EscrowAddress(c context.Context, req *types.QueryEscrowAddressRequest) (*types.QueryEscrowAddressResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } diff --git a/modules/apps/transfer/keeper/keeper.go b/modules/apps/transfer/keeper/keeper.go index 7a8bdeadc02..5fe27ac9e28 100644 --- a/modules/apps/transfer/keeper/keeper.go +++ b/modules/apps/transfer/keeper/keeper.go @@ -77,13 +77,20 @@ func NewKeeper( } } +// WithICS4Wrapper sets the ICS4Wrapper. This function may be used after +// the keepers creation to set the middleware which is above this module +// in the IBC application stack. +func (k *Keeper) WithICS4Wrapper(wrapper porttypes.ICS4Wrapper) { + k.ics4Wrapper = wrapper +} + // GetAuthority returns the transfer module's authority. func (k Keeper) GetAuthority() string { return k.authority } // Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { +func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+exported.ModuleName+"-"+types.ModuleName) } @@ -235,9 +242,9 @@ func (k Keeper) GetAllTotalEscrowed(ctx sdk.Context) sdk.Coins { // IterateTokensInEscrow iterates over the denomination escrows in the store // and performs a callback function. Denominations for which an invalid value // (i.e. not integer) is stored, will be skipped. -func (k Keeper) IterateTokensInEscrow(ctx sdk.Context, prefix []byte, cb func(denomEscrow sdk.Coin) bool) { +func (k Keeper) IterateTokensInEscrow(ctx sdk.Context, storeprefix []byte, cb func(denomEscrow sdk.Coin) bool) { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, prefix) + iterator := storetypes.KVStorePrefixIterator(store, storeprefix) defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() }) for ; iterator.Valid(); iterator.Next() { diff --git a/modules/apps/transfer/keeper/keeper_test.go b/modules/apps/transfer/keeper/keeper_test.go index ddcf7836670..834d01fd35c 100644 --- a/modules/apps/transfer/keeper/keeper_test.go +++ b/modules/apps/transfer/keeper/keeper_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" sdkmath "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" @@ -13,12 +13,14 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper" "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + channelkeeper "github.com/cosmos/ibc-go/v7/modules/core/04-channel/keeper" ibctesting "github.com/cosmos/ibc-go/v7/testing" ) type KeeperTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -39,7 +41,7 @@ func (suite *KeeperTestSuite) SetupTest() { } func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) + testifysuite.Run(t, new(KeeperTestSuite)) } func (suite *KeeperTestSuite) TestSetGetTotalEscrowForDenom() { @@ -263,3 +265,24 @@ func (suite *KeeperTestSuite) TestUnsetParams() { suite.chainA.GetSimApp().TransferKeeper.GetParams(ctx) }) } + +func (suite *KeeperTestSuite) TestWithICS4Wrapper() { + suite.SetupTest() + + // test if the ics4 wrapper is the fee keeper initially + ics4Wrapper := suite.chainA.GetSimApp().TransferKeeper.GetICS4Wrapper() + _, isFeeKeeper := ics4Wrapper.(ibcfeekeeper.Keeper) + + suite.Require().True(isFeeKeeper) + _, isChannelKeeper := ics4Wrapper.(channelkeeper.Keeper) + suite.Require().False(isChannelKeeper) + + // set the ics4 wrapper to the channel keeper + suite.chainA.GetSimApp().TransferKeeper.WithICS4Wrapper(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper) + ics4Wrapper = suite.chainA.GetSimApp().TransferKeeper.GetICS4Wrapper() + + _, isChannelKeeper = ics4Wrapper.(channelkeeper.Keeper) + suite.Require().True(isChannelKeeper) + _, isFeeKeeper = ics4Wrapper.(ibcfeekeeper.Keeper) + suite.Require().False(isFeeKeeper) +} diff --git a/modules/apps/transfer/keeper/mbt_relay_test.go b/modules/apps/transfer/keeper/mbt_relay_test.go index 6c5f7a406fe..1b091350a86 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -1,8 +1,8 @@ package keeper_test -/// This file is a test driver for model-based tests generated from the TLA+ model of token transfer -/// Written by Andrey Kuprianov within the scope of IBC Audit performed by Informal Systems. -/// In case of any questions please don't hesitate to contact andrey@informal.systems. +// This file is a test driver for model-based tests generated from the TLA+ model of token transfer +// Written by Andrey Kuprianov within the scope of IBC Audit performed by Informal Systems. +// In case of any questions please don't hesitate to contact andrey@informal.systems. import ( "encoding/json" @@ -269,13 +269,13 @@ func BankOfChain(chain *ibctesting.TestChain) Bank { } // Check that the state of the bank is the bankBefore + expectedBankChange -func (suite *KeeperTestSuite) CheckBankBalances(chain *ibctesting.TestChain, bankBefore *Bank, expectedBankChange *Bank) error { +func (*KeeperTestSuite) CheckBankBalances(chain *ibctesting.TestChain, bankBefore *Bank, expectedBankChange *Bank) error { bankAfter := BankOfChain(chain) bankChange := bankAfter.Sub(bankBefore) diff := bankChange.Sub(expectedBankChange) - NonZeroString := diff.NonZeroString() - if len(NonZeroString) != 0 { - return errorsmod.Wrap(ibcerrors.ErrInvalidCoins, "Unexpected changes in the bank: \n"+NonZeroString) + nonZeroString := diff.NonZeroString() + if len(nonZeroString) != 0 { + return errorsmod.Wrap(ibcerrors.ErrInvalidCoins, "Unexpected changes in the bank: \n"+nonZeroString) } return nil } diff --git a/modules/apps/transfer/module.go b/modules/apps/transfer/module.go index bc06d8f1641..17721a818bb 100644 --- a/modules/apps/transfer/module.go +++ b/modules/apps/transfer/module.go @@ -151,6 +151,6 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { } // WeightedOperations returns the all the transfer module operations with their respective weights. -func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { +func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { return nil } diff --git a/modules/apps/transfer/transfer_test.go b/modules/apps/transfer/transfer_test.go index 8b68e6570a2..a5232b9e702 100644 --- a/modules/apps/transfer/transfer_test.go +++ b/modules/apps/transfer/transfer_test.go @@ -3,7 +3,7 @@ package transfer_test import ( "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" sdkmath "cosmossdk.io/math" @@ -15,7 +15,7 @@ import ( ) type TransferTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -134,5 +134,5 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { } func TestTransferTestSuite(t *testing.T) { - suite.Run(t, new(TransferTestSuite)) + testifysuite.Run(t, new(TransferTestSuite)) } diff --git a/modules/apps/transfer/types/packet.go b/modules/apps/transfer/types/packet.go index 66f3e5730e1..ec543dd75f9 100644 --- a/modules/apps/transfer/types/packet.go +++ b/modules/apps/transfer/types/packet.go @@ -1,6 +1,7 @@ package types import ( + "encoding/json" "strings" "time" @@ -10,6 +11,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ibcerrors "github.com/cosmos/ibc-go/v7/modules/core/errors" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" +) + +var ( + _ ibcexported.PacketData = (*FungibleTokenPacketData)(nil) + _ ibcexported.PacketDataProvider = (*FungibleTokenPacketData)(nil) ) var ( @@ -64,3 +71,36 @@ func (ftpd FungibleTokenPacketData) ValidateBasic() error { func (ftpd FungibleTokenPacketData) GetBytes() []byte { return sdk.MustSortJSON(mustProtoMarshalJSON(&ftpd)) } + +// GetPacketSender returns the sender address embedded in the packet data. +// +// NOTE: +// - The sender address is set by the module which requested the packet to be sent, +// and this module may not have validated the sender address by a signature check. +// - The sender address must only be used by modules on the sending chain. +// - sourcePortID is not used in this implementation. +func (ftpd FungibleTokenPacketData) GetPacketSender(sourcePortID string) string { + return ftpd.Sender +} + +// GetCustomPacketData interprets the memo field of the packet data as a JSON object +// and returns the value associated with the given key. +// If the key is missing or the memo is not properly formatted, then nil is returned. +func (ftpd FungibleTokenPacketData) GetCustomPacketData(key string) interface{} { + if len(ftpd.Memo) == 0 { + return nil + } + + jsonObject := make(map[string]interface{}) + err := json.Unmarshal([]byte(ftpd.Memo), &jsonObject) + if err != nil { + return nil + } + + memoData, found := jsonObject[key] + if !found { + return nil + } + + return memoData +} diff --git a/modules/apps/transfer/types/packet_test.go b/modules/apps/transfer/types/packet_test.go index 6c877d4fcb0..fa10f64e5ba 100644 --- a/modules/apps/transfer/types/packet_test.go +++ b/modules/apps/transfer/types/packet_test.go @@ -1,6 +1,7 @@ package types_test import ( + "fmt" "testing" "github.com/stretchr/testify/require" @@ -43,3 +44,89 @@ func TestFungibleTokenPacketDataValidateBasic(t *testing.T) { } } } + +func (suite *TypesTestSuite) TestGetPacketSender() { + packetData := types.FungibleTokenPacketData{ + Denom: denom, + Amount: amount, + Sender: sender, + Receiver: receiver, + Memo: "", + } + + suite.Require().Equal(sender, packetData.GetPacketSender(types.PortID)) +} + +func (suite *TypesTestSuite) TestPacketDataProvider() { + testCases := []struct { + name string + packetData types.FungibleTokenPacketData + expCustomData interface{} + }{ + { + "success: src_callback key in memo", + types.FungibleTokenPacketData{ + Denom: denom, + Amount: amount, + Sender: sender, + Receiver: receiver, + Memo: fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, receiver), + }, + map[string]interface{}{ + "address": receiver, + }, + }, + { + "success: src_callback key in memo with additional fields", + types.FungibleTokenPacketData{ + Denom: denom, + Amount: amount, + Sender: sender, + Receiver: receiver, + Memo: fmt.Sprintf(`{"src_callback": {"address": "%s", "gas_limit": "200000"}}`, receiver), + }, + map[string]interface{}{ + "address": receiver, + "gas_limit": "200000", + }, + }, + { + "success: src_callback has string value", + types.FungibleTokenPacketData{ + Denom: denom, + Amount: amount, + Sender: sender, + Receiver: receiver, + Memo: `{"src_callback": "string"}`, + }, + "string", + }, + { + "failure: empty memo", + types.FungibleTokenPacketData{ + Denom: denom, + Amount: amount, + Sender: sender, + Receiver: receiver, + Memo: "", + }, + nil, + }, + { + "failure: non-json memo", + types.FungibleTokenPacketData{ + Denom: denom, + Amount: amount, + Sender: sender, + Receiver: receiver, + Memo: "invalid", + }, + nil, + }, + } + + for _, tc := range testCases { + customData := tc.packetData.GetCustomPacketData("src_callback") + suite.Require().Equal(tc.expCustomData, customData) + } +} diff --git a/modules/apps/transfer/types/trace.go b/modules/apps/transfer/types/trace.go index f539ba65cf4..d9151f93faa 100644 --- a/modules/apps/transfer/types/trace.go +++ b/modules/apps/transfer/types/trace.go @@ -86,8 +86,8 @@ func (dt DenomTrace) IsNativeDenom() bool { // the elements that constitute the complete denom. func extractPathAndBaseFromFullDenom(fullDenomItems []string) (string, string) { var ( - path []string - baseDenom []string + pathSlice []string + baseDenomSlice []string ) length := len(fullDenomItems) @@ -102,14 +102,17 @@ func extractPathAndBaseFromFullDenom(fullDenomItems []string) (string, string) { // as an IBC denomination. The hash used to store the token internally on our chain // will be the same value as the base denomination being correctly parsed. if i < length-1 && length > 2 && channeltypes.IsValidChannelID(fullDenomItems[i+1]) { - path = append(path, fullDenomItems[i], fullDenomItems[i+1]) + pathSlice = append(pathSlice, fullDenomItems[i], fullDenomItems[i+1]) } else { - baseDenom = fullDenomItems[i:] + baseDenomSlice = fullDenomItems[i:] break } } - return strings.Join(path, "/"), strings.Join(baseDenom, "/") + path := strings.Join(pathSlice, "/") + baseDenom := strings.Join(baseDenomSlice, "/") + + return path, baseDenom } func validateTraceIdentifiers(identifiers []string) error { diff --git a/modules/apps/transfer/types/transfer_authorization.go b/modules/apps/transfer/types/transfer_authorization.go index 998a7544495..992ef70e9cd 100644 --- a/modules/apps/transfer/types/transfer_authorization.go +++ b/modules/apps/transfer/types/transfer_authorization.go @@ -30,7 +30,7 @@ func NewTransferAuthorization(allocations ...Allocation) *TransferAuthorization } // MsgTypeURL implements Authorization.MsgTypeURL. -func (a TransferAuthorization) MsgTypeURL() string { +func (TransferAuthorization) MsgTypeURL() string { return sdk.MsgTypeURL(&MsgTransfer{}) } diff --git a/modules/apps/transfer/types/types_test.go b/modules/apps/transfer/types/types_test.go index 86069b1a887..d17bf91bf49 100644 --- a/modules/apps/transfer/types/types_test.go +++ b/modules/apps/transfer/types/types_test.go @@ -3,14 +3,14 @@ package types_test import ( "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ibctesting "github.com/cosmos/ibc-go/v7/testing" ) type TypesTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -36,5 +36,5 @@ func NewTransferPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path { } func TestTypesTestSuite(t *testing.T) { - suite.Run(t, new(TypesTestSuite)) + testifysuite.Run(t, new(TypesTestSuite)) } diff --git a/modules/capability/capability_test.go b/modules/capability/capability_test.go index 1ed4cb1457e..70e27d8123b 100644 --- a/modules/capability/capability_test.go +++ b/modules/capability/capability_test.go @@ -3,12 +3,11 @@ package capability_test import ( "testing" - "github.com/stretchr/testify/suite" - "cosmossdk.io/log" "cosmossdk.io/store" "cosmossdk.io/store/metrics" storetypes "cosmossdk.io/store/types" + testifysuite "github.com/stretchr/testify/suite" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/codec" @@ -26,7 +25,7 @@ import ( const mockMemStoreKey = "memory:mock" type CapabilityTestSuite struct { - suite.Suite + testifysuite.Suite cdc codec.Codec ctx sdk.Context @@ -125,5 +124,5 @@ func (suite *CapabilityTestSuite) TestInitializeMemStore() { } func TestCapabilityTestSuite(t *testing.T) { - suite.Run(t, new(CapabilityTestSuite)) + testifysuite.Run(t, new(CapabilityTestSuite)) } diff --git a/modules/capability/go.mod b/modules/capability/go.mod index 5e0f6ce70fb..9434e87e650 100644 --- a/modules/capability/go.mod +++ b/modules/capability/go.mod @@ -7,12 +7,12 @@ replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.2021 require ( cosmossdk.io/core v0.9.0 cosmossdk.io/errors v1.0.0 - cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca + cosmossdk.io/log v1.2.0 cosmossdk.io/math v1.0.1 - cosmossdk.io/store v1.0.0-alpha.1 + cosmossdk.io/store v1.0.0-alpha.1.0.20230728080422-54ed7dab3982 github.com/cometbft/cometbft v0.38.0-rc3 github.com/cosmos/cosmos-db v1.0.0 - github.com/cosmos/cosmos-sdk v0.50.0-beta.0 + github.com/cosmos/cosmos-sdk v0.50.0-beta.0.0.20230802171422-ee5b2e3afc4f github.com/cosmos/gogoproto v1.4.10 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/spf13/cobra v1.7.0 @@ -121,7 +121,7 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/cors v1.8.3 // indirect - github.com/rs/zerolog v1.29.1 // indirect + github.com/rs/zerolog v1.30.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cast v1.5.1 // indirect @@ -144,8 +144,8 @@ require ( golang.org/x/text v0.11.0 // indirect google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect - google.golang.org/grpc v1.56.2 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e // indirect + google.golang.org/grpc v1.57.0 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/modules/capability/go.sum b/modules/capability/go.sum index d9cf3566eb3..10c3274d609 100644 --- a/modules/capability/go.sum +++ b/modules/capability/go.sum @@ -45,12 +45,12 @@ cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= -cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca h1:msenprh2BLLRwNT7zN56TbBHOGk/7ARQckXHxXyvjoQ= -cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca/go.mod h1:PkIAKXZvaxrTRc++z53XMRvFk8AcGGWYHcMIPzVYX9c= +cosmossdk.io/log v1.2.0 h1:BbykkDsutXPSy8RojFB3KZEWyvMsToLy0ykb/ZhsLqQ= +cosmossdk.io/log v1.2.0/go.mod h1:GNSCc/6+DhFIj1aLn/j7Id7PaO8DzNylUZoOYBL9+I4= cosmossdk.io/math v1.0.1 h1:Qx3ifyOPaMLNH/89WeZFH268yCvU4xEcnPLu3sJqPPg= cosmossdk.io/math v1.0.1/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k= -cosmossdk.io/store v1.0.0-alpha.1 h1:/151XxAgm0tiKuYrtJzMG61lf6enpPuP+D/hIN8cRjQ= -cosmossdk.io/store v1.0.0-alpha.1/go.mod h1:ejgU9GhRGMNBduVnDwC3RyhOmu4uKlNQlTiJgPmbDkI= +cosmossdk.io/store v1.0.0-alpha.1.0.20230728080422-54ed7dab3982 h1:61YFeW2AhwwPfoJWzNJWvVubCj32sm5jZkJfraS9pDQ= +cosmossdk.io/store v1.0.0-alpha.1.0.20230728080422-54ed7dab3982/go.mod h1:QAF9zeRa/9ghuv7E8NS9SzWqRbgVNwH/dZwGhYDHUjI= cosmossdk.io/x/tx v0.9.1 h1:9pmmXA9Vs4qdouOFnzhsdsff2mif0f0kylMq5xTGhRI= cosmossdk.io/x/tx v0.9.1/go.mod h1:/YFGTXG6+kyihd8YbfuJiXHV4R/mIMm2uvVzo80CIhA= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= @@ -161,8 +161,8 @@ github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0 github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.50.0-beta.0 h1:cPblupyMlA4qvnvuuQEjYQPq1uqSXBgQmsiGREQ5hd0= -github.com/cosmos/cosmos-sdk v0.50.0-beta.0/go.mod h1:MF/wnXyreoL0g8YdRZhUD4apPdgebMc29LgMJB+dh6M= +github.com/cosmos/cosmos-sdk v0.50.0-beta.0.0.20230802171422-ee5b2e3afc4f h1:KVypgBpP7iFjmTTTopZeNukTDwexCM3CAr1Jcj5u11Q= +github.com/cosmos/cosmos-sdk v0.50.0-beta.0.0.20230802171422-ee5b2e3afc4f/go.mod h1:pJU8sjvSa3I7lH2whf4QO1V2DTU79G8WwPTdqmDEh+Q= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= @@ -655,9 +655,9 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo= github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= -github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= +github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -1119,8 +1119,8 @@ google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 h1:Au6te5hbKUV8pIY google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:O9kGHb51iE/nOGvQaDUuadVYqovW56s5emA88lQnj6Y= google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 h1:s5YSX+ZH5b5vS9rnpGymvIyMpLRJizowqDlOuyjXnTk= google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e h1:S83+ibolgyZ0bqz7KEsUOPErxcv4VzlszxY+31OfB/E= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1147,8 +1147,8 @@ google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI= -google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/modules/capability/keeper/keeper_test.go b/modules/capability/keeper/keeper_test.go index e606219edd1..357c2e72314 100644 --- a/modules/capability/keeper/keeper_test.go +++ b/modules/capability/keeper/keeper_test.go @@ -4,9 +4,8 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/suite" - storetypes "cosmossdk.io/store/types" + testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -23,7 +22,7 @@ var ( ) type KeeperTestSuite struct { - suite.Suite + testifysuite.Suite ctx sdk.Context keeper *keeper.Keeper @@ -308,5 +307,5 @@ func (suite *KeeperTestSuite) TestRevertCapability() { } func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) + testifysuite.Run(t, new(KeeperTestSuite)) } diff --git a/modules/core/02-client/abci_test.go b/modules/core/02-client/abci_test.go index a8c451113eb..788856683c4 100644 --- a/modules/core/02-client/abci_test.go +++ b/modules/core/02-client/abci_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" upgradetypes "cosmossdk.io/x/upgrade/types" @@ -19,7 +19,7 @@ import ( ) type ClientTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -35,7 +35,7 @@ func (suite *ClientTestSuite) SetupTest() { } func TestClientTestSuite(t *testing.T) { - suite.Run(t, new(ClientTestSuite)) + testifysuite.Run(t, new(ClientTestSuite)) } func (suite *ClientTestSuite) TestBeginBlocker() { diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index 5ffc745897b..9258c773e0f 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -247,10 +247,10 @@ func (k Keeper) ClientStatus(c context.Context, req *types.QueryClientStatusRequ ) } - status := k.GetClientStatus(ctx, clientState, req.ClientId) + clientStatus := k.GetClientStatus(ctx, clientState, req.ClientId) return &types.QueryClientStatusResponse{ - Status: status.String(), + Status: clientStatus.String(), }, nil } diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index 5220d7869de..83ac95a1015 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -53,7 +53,7 @@ func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace pa } // Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { +func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) } @@ -372,9 +372,9 @@ func (k Keeper) SetUpgradedConsensusState(ctx sdk.Context, planHeight int64, bz // IterateClientStates provides an iterator over all stored light client State // objects. For each State object, cb will be called. If the cb returns true, // the iterator will close and stop. -func (k Keeper) IterateClientStates(ctx sdk.Context, prefix []byte, cb func(clientID string, cs exported.ClientState) bool) { +func (k Keeper) IterateClientStates(ctx sdk.Context, storeprefix []byte, cb func(clientID string, cs exported.ClientState) bool) { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, host.PrefixedClientStoreKey(prefix)) + iterator := storetypes.KVStorePrefixIterator(store, host.PrefixedClientStoreKey(storeprefix)) defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() }) for ; iterator.Valid(); iterator.Next() { diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index de688f74d4f..c8b72082062 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" sdkmath "cosmossdk.io/math" @@ -48,7 +48,7 @@ var ( ) type KeeperTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -103,7 +103,7 @@ func (suite *KeeperTestSuite) SetupTest() { suite.Require().NoError(err) pk, err := cryptocodec.FromCmtPubKeyInterface(tmPk) suite.Require().NoError(err) - val, err := stakingtypes.NewValidator(sdk.ValAddress(pk.Address()), pk, stakingtypes.Description{}) + val, err := stakingtypes.NewValidator(pk.Address().String(), pk, stakingtypes.Description{}) suite.Require().NoError(err) val.Status = stakingtypes.Bonded @@ -119,7 +119,7 @@ func (suite *KeeperTestSuite) SetupTest() { } func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) + testifysuite.Run(t, new(KeeperTestSuite)) } func (suite *KeeperTestSuite) TestSetClientState() { diff --git a/modules/core/02-client/migrations/v7/solomachine.go b/modules/core/02-client/migrations/v7/solomachine.go index 70b2e6026a8..6c8315fda2f 100644 --- a/modules/core/02-client/migrations/v7/solomachine.go +++ b/modules/core/02-client/migrations/v7/solomachine.go @@ -51,80 +51,80 @@ func (cs ConsensusState) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error } // ClientType panics! -func (cs ClientState) ClientType() string { +func (ClientState) ClientType() string { panic("legacy solo machine is deprecated!") } // GetLatestHeight panics! -func (cs ClientState) GetLatestHeight() exported.Height { +func (ClientState) GetLatestHeight() exported.Height { panic("legacy solo machine is deprecated!") } // Status panics! -func (cs ClientState) Status(_ sdk.Context, _ storetypes.KVStore, _ codec.BinaryCodec) exported.Status { +func (ClientState) Status(_ sdk.Context, _ storetypes.KVStore, _ codec.BinaryCodec) exported.Status { panic("legacy solo machine is deprecated!") } // Validate panics! -func (cs ClientState) Validate() error { +func (ClientState) Validate() error { panic("legacy solo machine is deprecated!") } // ZeroCustomFields panics! -func (cs ClientState) ZeroCustomFields() exported.ClientState { +func (ClientState) ZeroCustomFields() exported.ClientState { panic("legacy solo machine is deprecated!") } // Initialize panics! -func (cs ClientState) Initialize(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, consState exported.ConsensusState) error { +func (ClientState) Initialize(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ConsensusState) error { panic("legacy solo machine is deprecated!") } // ExportMetadata panics! -func (cs ClientState) ExportMetadata(_ storetypes.KVStore) []exported.GenesisMetadata { +func (ClientState) ExportMetadata(_ storetypes.KVStore) []exported.GenesisMetadata { panic("legacy solo machine is deprecated!") } // CheckForMisbehaviour panics! -func (cs ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, msg exported.ClientMessage) bool { +func (ClientState) CheckForMisbehaviour(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage) bool { panic("legacy solo machine is deprecated!") } // UpdateStateOnMisbehaviour panics! -func (cs *ClientState) UpdateStateOnMisbehaviour( +func (*ClientState) UpdateStateOnMisbehaviour( _ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage, ) { panic("legacy solo machine is deprecated!") } // VerifyClientMessage panics! -func (cs *ClientState) VerifyClientMessage( +func (*ClientState) VerifyClientMessage( _ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage, ) error { panic("legacy solo machine is deprecated!") } // UpdateState panis! -func (cs *ClientState) UpdateState(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage) []exported.Height { +func (*ClientState) UpdateState(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage) []exported.Height { panic("legacy solo machine is deprecated!") } // CheckHeaderAndUpdateState panics! -func (cs *ClientState) CheckHeaderAndUpdateState( +func (*ClientState) CheckHeaderAndUpdateState( _ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage, ) (exported.ClientState, exported.ConsensusState, error) { panic("legacy solo machine is deprecated!") } // CheckMisbehaviourAndUpdateState panics! -func (cs ClientState) CheckMisbehaviourAndUpdateState( +func (ClientState) CheckMisbehaviourAndUpdateState( _ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage, ) (exported.ClientState, error) { panic("legacy solo machine is deprecated!") } // CheckSubstituteAndUpdateState panics! -func (cs ClientState) CheckSubstituteAndUpdateState( +func (ClientState) CheckSubstituteAndUpdateState( ctx sdk.Context, _ codec.BinaryCodec, _, _ storetypes.KVStore, _ exported.ClientState, ) error { @@ -132,7 +132,7 @@ func (cs ClientState) CheckSubstituteAndUpdateState( } // VerifyUpgradeAndUpdateState panics! -func (cs ClientState) VerifyUpgradeAndUpdateState( +func (ClientState) VerifyUpgradeAndUpdateState( _ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientState, _ exported.ConsensusState, _, _ []byte, ) error { @@ -140,7 +140,7 @@ func (cs ClientState) VerifyUpgradeAndUpdateState( } // VerifyClientState panics! -func (cs ClientState) VerifyClientState( +func (ClientState) VerifyClientState( store storetypes.KVStore, cdc codec.BinaryCodec, _ exported.Height, _ exported.Prefix, _ string, _ []byte, clientState exported.ClientState, ) error { @@ -148,7 +148,7 @@ func (cs ClientState) VerifyClientState( } // VerifyClientConsensusState panics! -func (cs ClientState) VerifyClientConsensusState( +func (ClientState) VerifyClientConsensusState( storetypes.KVStore, codec.BinaryCodec, exported.Height, string, exported.Height, exported.Prefix, []byte, exported.ConsensusState, @@ -157,7 +157,7 @@ func (cs ClientState) VerifyClientConsensusState( } // VerifyConnectionState panics! -func (cs ClientState) VerifyConnectionState( +func (ClientState) VerifyConnectionState( storetypes.KVStore, codec.BinaryCodec, exported.Height, exported.Prefix, []byte, string, exported.ConnectionI, ) error { @@ -165,7 +165,7 @@ func (cs ClientState) VerifyConnectionState( } // VerifyChannelState panics! -func (cs ClientState) VerifyChannelState( +func (ClientState) VerifyChannelState( storetypes.KVStore, codec.BinaryCodec, exported.Height, exported.Prefix, []byte, string, string, exported.ChannelI, ) error { @@ -173,7 +173,7 @@ func (cs ClientState) VerifyChannelState( } // VerifyPacketCommitment panics! -func (cs ClientState) VerifyPacketCommitment( +func (ClientState) VerifyPacketCommitment( sdk.Context, storetypes.KVStore, codec.BinaryCodec, exported.Height, uint64, uint64, exported.Prefix, []byte, string, string, uint64, []byte, @@ -182,7 +182,7 @@ func (cs ClientState) VerifyPacketCommitment( } // VerifyPacketAcknowledgement panics! -func (cs ClientState) VerifyPacketAcknowledgement( +func (ClientState) VerifyPacketAcknowledgement( sdk.Context, storetypes.KVStore, codec.BinaryCodec, exported.Height, uint64, uint64, exported.Prefix, []byte, string, string, uint64, []byte, @@ -191,7 +191,7 @@ func (cs ClientState) VerifyPacketAcknowledgement( } // VerifyPacketReceiptAbsence panics! -func (cs ClientState) VerifyPacketReceiptAbsence( +func (ClientState) VerifyPacketReceiptAbsence( sdk.Context, storetypes.KVStore, codec.BinaryCodec, exported.Height, uint64, uint64, exported.Prefix, []byte, string, string, uint64, @@ -200,7 +200,7 @@ func (cs ClientState) VerifyPacketReceiptAbsence( } // VerifyNextSequenceRecv panics! -func (cs ClientState) VerifyNextSequenceRecv( +func (ClientState) VerifyNextSequenceRecv( sdk.Context, storetypes.KVStore, codec.BinaryCodec, exported.Height, uint64, uint64, exported.Prefix, []byte, string, string, uint64, @@ -209,14 +209,14 @@ func (cs ClientState) VerifyNextSequenceRecv( } // GetTimestampAtHeight panics! -func (cs ClientState) GetTimestampAtHeight( +func (ClientState) GetTimestampAtHeight( sdk.Context, storetypes.KVStore, codec.BinaryCodec, exported.Height, ) (uint64, error) { panic("legacy solo machine is deprecated!") } // VerifyMembership panics! -func (cs *ClientState) VerifyMembership( +func (*ClientState) VerifyMembership( ctx sdk.Context, clientStore storetypes.KVStore, cdc codec.BinaryCodec, @@ -231,7 +231,7 @@ func (cs *ClientState) VerifyMembership( } // VerifyNonMembership panics! -func (cs *ClientState) VerifyNonMembership( +func (*ClientState) VerifyNonMembership( ctx sdk.Context, clientStore storetypes.KVStore, cdc codec.BinaryCodec, @@ -250,11 +250,11 @@ func (ConsensusState) ClientType() string { } // GetTimestamp panics! -func (cs ConsensusState) GetTimestamp() uint64 { +func (ConsensusState) GetTimestamp() uint64 { panic("legacy solo machine is deprecated!") } // ValidateBasic panics! -func (cs ConsensusState) ValidateBasic() error { +func (ConsensusState) ValidateBasic() error { panic("legacy solo machine is deprecated!") } diff --git a/modules/core/02-client/migrations/v7/store_test.go b/modules/core/02-client/migrations/v7/store_test.go index 524e439a4f6..981888ac01d 100644 --- a/modules/core/02-client/migrations/v7/store_test.go +++ b/modules/core/02-client/migrations/v7/store_test.go @@ -4,7 +4,7 @@ import ( "strconv" "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/codec" @@ -20,7 +20,7 @@ import ( const numCreations = 10 type MigrationsV7TestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -36,7 +36,7 @@ func (suite *MigrationsV7TestSuite) SetupTest() { } func TestIBCTestSuite(t *testing.T) { - suite.Run(t, new(MigrationsV7TestSuite)) + testifysuite.Run(t, new(MigrationsV7TestSuite)) } // create multiple solo machine clients, tendermint and localhost clients diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index 2d265dcbc6c..b200524221f 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -6,7 +6,7 @@ import ( "github.com/golang/protobuf/proto" //nolint:staticcheck "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" sdk "github.com/cosmos/cosmos-sdk/types" @@ -18,7 +18,7 @@ import ( ) type TypesTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -35,7 +35,7 @@ func (suite *TypesTestSuite) SetupTest() { } func TestTypesTestSuite(t *testing.T) { - suite.Run(t, new(TypesTestSuite)) + testifysuite.Run(t, new(TypesTestSuite)) } // tests that different clients within MsgCreateClient can be marshaled diff --git a/modules/core/02-client/types/params.go b/modules/core/02-client/types/params.go index 0f2f6b93229..e413586601b 100644 --- a/modules/core/02-client/types/params.go +++ b/modules/core/02-client/types/params.go @@ -4,6 +4,7 @@ import ( "fmt" "strings" + "github.com/cosmos/ibc-go/v7/internal/collections" "github.com/cosmos/ibc-go/v7/modules/core/exported" ) @@ -29,12 +30,7 @@ func (p Params) Validate() error { // IsAllowedClient checks if the given client type is registered on the allowlist. func (p Params) IsAllowedClient(clientType string) bool { - for _, allowedClient := range p.AllowedClients { - if allowedClient == clientType { - return true - } - } - return false + return collections.Contains(clientType, p.AllowedClients) } // validateClients checks that the given clients are not blank. diff --git a/modules/core/02-client/types/proposal.go b/modules/core/02-client/types/proposal.go index 5542bee36d8..2392a01d7a5 100644 --- a/modules/core/02-client/types/proposal.go +++ b/modules/core/02-client/types/proposal.go @@ -47,10 +47,10 @@ func (cup *ClientUpdateProposal) GetTitle() string { return cup.Title } func (cup *ClientUpdateProposal) GetDescription() string { return cup.Description } // ProposalRoute returns the routing key of a client update proposal. -func (cup *ClientUpdateProposal) ProposalRoute() string { return RouterKey } +func (*ClientUpdateProposal) ProposalRoute() string { return RouterKey } // ProposalType returns the type of a client update proposal. -func (cup *ClientUpdateProposal) ProposalType() string { return ProposalTypeClientUpdate } +func (*ClientUpdateProposal) ProposalType() string { return ProposalTypeClientUpdate } // ValidateBasic runs basic stateless validity checks func (cup *ClientUpdateProposal) ValidateBasic() error { @@ -94,10 +94,10 @@ func (up *UpgradeProposal) GetTitle() string { return up.Title } func (up *UpgradeProposal) GetDescription() string { return up.Description } // ProposalRoute returns the routing key of a upgrade proposal. -func (up *UpgradeProposal) ProposalRoute() string { return RouterKey } +func (*UpgradeProposal) ProposalRoute() string { return RouterKey } // ProposalType returns the upgrade proposal type. -func (up *UpgradeProposal) ProposalType() string { return ProposalTypeUpgrade } +func (*UpgradeProposal) ProposalType() string { return ProposalTypeUpgrade } // ValidateBasic runs basic stateless validity checks func (up *UpgradeProposal) ValidateBasic() error { diff --git a/modules/core/03-connection/keeper/grpc_query_test.go b/modules/core/03-connection/keeper/grpc_query_test.go index 59200a0d415..1245b511be8 100644 --- a/modules/core/03-connection/keeper/grpc_query_test.go +++ b/modules/core/03-connection/keeper/grpc_query_test.go @@ -54,7 +54,7 @@ func (suite *KeeperTestSuite) TestQueryConnection() { suite.Require().NoError(err) counterparty := types.NewCounterparty(path.EndpointB.ClientID, "", suite.chainB.GetPrefix()) - expConnection = types.NewConnectionEnd(types.INIT, path.EndpointA.ClientID, counterparty, types.ExportedVersionsToProto(types.GetCompatibleVersions()), 500) + expConnection = types.NewConnectionEnd(types.INIT, path.EndpointA.ClientID, counterparty, types.GetCompatibleVersions(), 500) suite.chainA.App.GetIBCKeeper().ConnectionKeeper.SetConnection(suite.chainA.GetContext(), path.EndpointA.ConnectionID, expConnection) req = &types.QueryConnectionRequest{ @@ -134,9 +134,9 @@ func (suite *KeeperTestSuite) TestQueryConnections() { // counterparty connection id is blank after open init counterparty3 := types.NewCounterparty(path3.EndpointB.ClientID, "", suite.chainB.GetPrefix()) - conn1 := types.NewConnectionEnd(types.OPEN, path1.EndpointA.ClientID, counterparty1, types.ExportedVersionsToProto(types.GetCompatibleVersions()), 0) - conn2 := types.NewConnectionEnd(types.OPEN, path2.EndpointA.ClientID, counterparty2, types.ExportedVersionsToProto(types.GetCompatibleVersions()), 0) - conn3 := types.NewConnectionEnd(types.INIT, path3.EndpointA.ClientID, counterparty3, types.ExportedVersionsToProto(types.GetCompatibleVersions()), 0) + conn1 := types.NewConnectionEnd(types.OPEN, path1.EndpointA.ClientID, counterparty1, types.GetCompatibleVersions(), 0) + conn2 := types.NewConnectionEnd(types.OPEN, path2.EndpointA.ClientID, counterparty2, types.GetCompatibleVersions(), 0) + conn3 := types.NewConnectionEnd(types.INIT, path3.EndpointA.ClientID, counterparty3, types.GetCompatibleVersions(), 0) iconn1 := types.NewIdentifiedConnection(path1.EndpointA.ConnectionID, conn1) iconn2 := types.NewIdentifiedConnection(path2.EndpointA.ConnectionID, conn2) diff --git a/modules/core/03-connection/keeper/handshake.go b/modules/core/03-connection/keeper/handshake.go index 61e50b7a55d..60267beff36 100644 --- a/modules/core/03-connection/keeper/handshake.go +++ b/modules/core/03-connection/keeper/handshake.go @@ -31,7 +31,7 @@ func (k Keeper) ConnOpenInit( return "", errorsmod.Wrap(types.ErrInvalidVersion, "version is not supported") } - versions = []exported.Version{version} + versions = []*types.Version{version} } clientState, found := k.clientKeeper.GetClientState(ctx, clientID) @@ -49,7 +49,7 @@ func (k Keeper) ConnOpenInit( } // connection defines chain A's ConnectionEnd - connection := types.NewConnectionEnd(types.INIT, clientID, counterparty, types.ExportedVersionsToProto(versions), delayPeriod) + connection := types.NewConnectionEnd(types.INIT, clientID, counterparty, versions, delayPeriod) k.SetConnection(ctx, connectionID, connection) k.Logger(ctx).Info("connection state updated", "connection-id", connectionID, "previous-state", types.UNINITIALIZED.String(), "new-state", types.INIT.String()) @@ -73,7 +73,7 @@ func (k Keeper) ConnOpenTry( delayPeriod uint64, clientID string, // clientID of chainA clientState exported.ClientState, // clientState that chainA has for chainB - counterpartyVersions []exported.Version, // supported versions of chain A + counterpartyVersions []*types.Version, // supported versions of chain A proofInit []byte, // proof that chainA stored connectionEnd in state (on ConnOpenInit) proofClient []byte, // proof that chainA stored a light client of chainB proofConsensus []byte, // proof that chainA stored chainB's consensus state at consensus height @@ -108,7 +108,7 @@ func (k Keeper) ConnOpenTry( // NOTE: chainA and chainB must have the same delay period prefix := k.GetCommitmentPrefix() expectedCounterparty := types.NewCounterparty(clientID, "", commitmenttypes.NewMerklePrefix(prefix.Bytes())) - expectedConnection := types.NewConnectionEnd(types.INIT, counterparty.ClientId, expectedCounterparty, types.ExportedVersionsToProto(counterpartyVersions), delayPeriod) + expectedConnection := types.NewConnectionEnd(types.INIT, counterparty.ClientId, expectedCounterparty, counterpartyVersions, delayPeriod) // chain B picks a version from Chain A's available versions that is compatible // with Chain B's supported IBC versions. PickVersion will select the intersection @@ -197,7 +197,7 @@ func (k Keeper) ConnOpenAck( } // ensure selected version is supported - if !types.IsSupportedVersion(types.ProtoVersionsToExported(connection.Versions), version) { + if !types.IsSupportedVersion(connection.Versions, version) { return errorsmod.Wrapf( types.ErrInvalidConnectionState, "the counterparty selected version %s is not supported by versions selected on INIT", version, diff --git a/modules/core/03-connection/keeper/handshake_test.go b/modules/core/03-connection/keeper/handshake_test.go index 5751c9e531a..c67d5c9bf31 100644 --- a/modules/core/03-connection/keeper/handshake_test.go +++ b/modules/core/03-connection/keeper/handshake_test.go @@ -33,7 +33,7 @@ func (suite *KeeperTestSuite) TestConnOpenInit() { emptyConnBID = true }, true}, {"success with non empty version", func() { - version = types.ExportedVersionsToProto(types.GetCompatibleVersions())[0] + version = types.GetCompatibleVersions()[0] }, true}, {"success with non zero delayPeriod", func() { delayPeriod = uint64(time.Hour.Nanoseconds()) @@ -96,7 +96,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { var ( path *ibctesting.Path delayPeriod uint64 - versions []exported.Version + versions []*types.Version consensusHeight exported.Height counterpartyClient exported.ClientState ) @@ -181,7 +181,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { counterpartyClient = suite.chainA.GetClientState(path.EndpointA.ClientID) version := types.NewVersion("0.0", nil) - versions = []exported.Version{version} + versions = []*types.Version{version} }, false}, {"connection state verification failed", func() { // chainA connection not created @@ -478,9 +478,9 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { for _, tc := range testCases { tc := tc suite.Run(tc.msg, func() { - suite.SetupTest() // reset - version = types.ExportedVersionsToProto(types.GetCompatibleVersions())[0] // must be explicitly changed in malleate - consensusHeight = clienttypes.ZeroHeight() // must be explicitly changed in malleate + suite.SetupTest() // reset + version = types.GetCompatibleVersions()[0] // must be explicitly changed in malleate + consensusHeight = clienttypes.ZeroHeight() // must be explicitly changed in malleate path = ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(path) diff --git a/modules/core/03-connection/keeper/keeper.go b/modules/core/03-connection/keeper/keeper.go index 9735f36ec9e..f892455cf60 100644 --- a/modules/core/03-connection/keeper/keeper.go +++ b/modules/core/03-connection/keeper/keeper.go @@ -43,7 +43,7 @@ func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace pa } // Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { +func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) } @@ -200,7 +200,7 @@ func (k Keeper) GetAllConnections(ctx sdk.Context) (connections []types.Identifi // CreateSentinelLocalhostConnection creates and sets the sentinel localhost connection end in the IBC store. func (k Keeper) CreateSentinelLocalhostConnection(ctx sdk.Context) { counterparty := types.NewCounterparty(exported.LocalhostClientID, exported.LocalhostConnectionID, commitmenttypes.NewMerklePrefix(k.GetCommitmentPrefix().Bytes())) - connectionEnd := types.NewConnectionEnd(types.OPEN, exported.LocalhostClientID, counterparty, types.ExportedVersionsToProto(types.GetCompatibleVersions()), 0) + connectionEnd := types.NewConnectionEnd(types.OPEN, exported.LocalhostClientID, counterparty, types.GetCompatibleVersions(), 0) k.SetConnection(ctx, exported.LocalhostConnectionID, connectionEnd) } diff --git a/modules/core/03-connection/keeper/keeper_test.go b/modules/core/03-connection/keeper/keeper_test.go index 5f4e5b3f244..375ba0eb658 100644 --- a/modules/core/03-connection/keeper/keeper_test.go +++ b/modules/core/03-connection/keeper/keeper_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" @@ -13,7 +13,7 @@ import ( ) type KeeperTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -29,7 +29,7 @@ func (suite *KeeperTestSuite) SetupTest() { } func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) + testifysuite.Run(t, new(KeeperTestSuite)) } func (suite *KeeperTestSuite) TestSetAndGetConnection() { @@ -74,8 +74,8 @@ func (suite KeeperTestSuite) TestGetAllConnections() { //nolint:govet // this is counterpartyB0 := types.NewCounterparty(path1.EndpointB.ClientID, path1.EndpointB.ConnectionID, suite.chainB.GetPrefix()) // connection B0 counterpartyB1 := types.NewCounterparty(path2.EndpointB.ClientID, path2.EndpointB.ConnectionID, suite.chainB.GetPrefix()) // connection B1 - conn1 := types.NewConnectionEnd(types.OPEN, path1.EndpointA.ClientID, counterpartyB0, types.ExportedVersionsToProto(types.GetCompatibleVersions()), 0) // A0 - B0 - conn2 := types.NewConnectionEnd(types.OPEN, path2.EndpointA.ClientID, counterpartyB1, types.ExportedVersionsToProto(types.GetCompatibleVersions()), 0) // A1 - B1 + conn1 := types.NewConnectionEnd(types.OPEN, path1.EndpointA.ClientID, counterpartyB0, types.GetCompatibleVersions(), 0) // A0 - B0 + conn2 := types.NewConnectionEnd(types.OPEN, path2.EndpointA.ClientID, counterpartyB1, types.GetCompatibleVersions(), 0) // A1 - B1 iconn1 := types.NewIdentifiedConnection(path1.EndpointA.ConnectionID, conn1) iconn2 := types.NewIdentifiedConnection(path2.EndpointA.ConnectionID, conn2) @@ -172,7 +172,7 @@ func (suite *KeeperTestSuite) TestLocalhostConnectionEndCreation() { suite.Require().True(found) suite.Require().Equal(types.OPEN, connectionEnd.State) suite.Require().Equal(exported.LocalhostClientID, connectionEnd.ClientId) - suite.Require().Equal(types.ExportedVersionsToProto(types.GetCompatibleVersions()), connectionEnd.Versions) + suite.Require().Equal(types.GetCompatibleVersions(), connectionEnd.Versions) expectedCounterParty := types.NewCounterparty(exported.LocalhostClientID, exported.LocalhostConnectionID, commitmenttypes.NewMerklePrefix(connectionKeeper.GetCommitmentPrefix().Bytes())) suite.Require().Equal(expectedCounterParty, connectionEnd.Counterparty) } diff --git a/modules/core/03-connection/simulation/decoder_test.go b/modules/core/03-connection/simulation/decoder_test.go index 8cb2ae5f3ef..0a80a8edf34 100644 --- a/modules/core/03-connection/simulation/decoder_test.go +++ b/modules/core/03-connection/simulation/decoder_test.go @@ -22,7 +22,7 @@ func TestDecodeStore(t *testing.T) { connection := types.ConnectionEnd{ ClientId: "clientidone", - Versions: types.ExportedVersionsToProto(types.GetCompatibleVersions()), + Versions: types.GetCompatibleVersions(), } paths := types.ClientPaths{ diff --git a/modules/core/03-connection/types/codec.go b/modules/core/03-connection/types/codec.go index d6c1c1b2693..4deebb33401 100644 --- a/modules/core/03-connection/types/codec.go +++ b/modules/core/03-connection/types/codec.go @@ -22,11 +22,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { (*exported.CounterpartyConnectionI)(nil), &Counterparty{}, ) - registry.RegisterInterface( - "ibc.core.connection.v1.Version", - (*exported.Version)(nil), - &Version{}, - ) registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgConnectionOpenInit{}, diff --git a/modules/core/03-connection/types/connection.go b/modules/core/03-connection/types/connection.go index 03735cccced..e202d5b2c45 100644 --- a/modules/core/03-connection/types/connection.go +++ b/modules/core/03-connection/types/connection.go @@ -38,8 +38,8 @@ func (c ConnectionEnd) GetCounterparty() exported.CounterpartyConnectionI { } // GetVersions implements the Connection interface -func (c ConnectionEnd) GetVersions() []exported.Version { - return ProtoVersionsToExported(c.Versions) +func (c ConnectionEnd) GetVersions() []*Version { + return c.Versions } // GetDelayPeriod implements the Connection interface diff --git a/modules/core/03-connection/types/msgs_test.go b/modules/core/03-connection/types/msgs_test.go index a4c35830135..23f3ce22a1f 100644 --- a/modules/core/03-connection/types/msgs_test.go +++ b/modules/core/03-connection/types/msgs_test.go @@ -7,7 +7,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" log "cosmossdk.io/log" "cosmossdk.io/store/iavl" @@ -34,7 +34,7 @@ var ( ) type MsgTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -79,7 +79,7 @@ func (suite *MsgTestSuite) SetupTest() { } func TestMsgTestSuite(t *testing.T) { - suite.Run(t, new(MsgTestSuite)) + testifysuite.Run(t, new(MsgTestSuite)) } func (suite *MsgTestSuite) TestNewMsgConnectionOpenInit() { diff --git a/modules/core/03-connection/types/version.go b/modules/core/03-connection/types/version.go index c4310c4dfa9..393a36bbc30 100644 --- a/modules/core/03-connection/types/version.go +++ b/modules/core/03-connection/types/version.go @@ -5,8 +5,7 @@ import ( errorsmod "cosmossdk.io/errors" - collections "github.com/cosmos/ibc-go/v7/internal/collections" - "github.com/cosmos/ibc-go/v7/modules/core/exported" + "github.com/cosmos/ibc-go/v7/internal/collections" ) var ( @@ -31,8 +30,6 @@ var ( } ) -var _ exported.Version = (*Version)(nil) - // NewVersion returns a new instance of Version. func NewVersion(identifier string, features []string) *Version { return &Version{ @@ -73,7 +70,7 @@ func ValidateVersion(version *Version) error { // proposed version is supported by this chain. If the feature set is // empty it verifies that this is allowed for the specified version // identifier. -func (version Version) VerifyProposedVersion(proposedVersion exported.Version) error { +func (version Version) VerifyProposedVersion(proposedVersion *Version) error { if proposedVersion.GetIdentifier() != version.GetIdentifier() { return errorsmod.Wrapf( ErrVersionNegotiationFailed, @@ -102,27 +99,22 @@ func (version Version) VerifyProposedVersion(proposedVersion exported.Version) e // VerifySupportedFeature takes in a version and feature string and returns // true if the feature is supported by the version and false otherwise. -func VerifySupportedFeature(version exported.Version, feature string) bool { - for _, f := range version.GetFeatures() { - if f == feature { - return true - } - } - return false +func VerifySupportedFeature(version *Version, feature string) bool { + return collections.Contains(feature, version.GetFeatures()) } // GetCompatibleVersions returns a descending ordered set of compatible IBC // versions for the caller chain's connection end. The latest supported // version should be first element and the set should descend to the oldest // supported version. -func GetCompatibleVersions() []exported.Version { - return []exported.Version{DefaultIBCVersion} +func GetCompatibleVersions() []*Version { + return []*Version{DefaultIBCVersion} } // IsSupportedVersion returns true if the proposed version has a matching version // identifier and its entire feature set is supported or the version identifier // supports an empty feature set. -func IsSupportedVersion(supportedVersions []exported.Version, proposedVersion *Version) bool { +func IsSupportedVersion(supportedVersions []*Version, proposedVersion *Version) bool { supportedVersion, found := FindSupportedVersion(proposedVersion, supportedVersions) if !found { return false @@ -138,12 +130,13 @@ func IsSupportedVersion(supportedVersions []exported.Version, proposedVersion *V // FindSupportedVersion returns the version with a matching version identifier // if it exists. The returned boolean is true if the version is found and // false otherwise. -func FindSupportedVersion(version exported.Version, supportedVersions []exported.Version) (exported.Version, bool) { +func FindSupportedVersion(version *Version, supportedVersions []*Version) (*Version, bool) { for _, supportedVersion := range supportedVersions { if version.GetIdentifier() == supportedVersion.GetIdentifier() { return supportedVersion, true } } + return nil, false } @@ -158,7 +151,7 @@ func FindSupportedVersion(version exported.Version, supportedVersions []exported // // CONTRACT: PickVersion must only provide a version that is in the // intersection of the supported versions and the counterparty versions. -func PickVersion(supportedVersions, counterpartyVersions []exported.Version) (*Version, error) { +func PickVersion(supportedVersions, counterpartyVersions []*Version) (*Version, error) { for _, supportedVersion := range supportedVersions { // check if the source version is supported by the counterparty if counterpartyVersion, found := FindSupportedVersion(supportedVersion, counterpartyVersions); found { @@ -190,25 +183,3 @@ func GetFeatureSetIntersection(sourceFeatureSet, counterpartyFeatureSet []string return featureSet } - -// ExportedVersionsToProto casts a slice of the Version interface to a slice -// of the Version proto definition. -func ExportedVersionsToProto(exportedVersions []exported.Version) []*Version { - versions := make([]*Version, len(exportedVersions)) - for i := range exportedVersions { - versions[i] = exportedVersions[i].(*Version) - } - - return versions -} - -// ProtoVersionsToExported converts a slice of the Version proto definition to -// the Version interface. -func ProtoVersionsToExported(versions []*Version) []exported.Version { - exportedVersions := make([]exported.Version, len(versions)) - for i := range versions { - exportedVersions[i] = versions[i] - } - - return exportedVersions -} diff --git a/modules/core/03-connection/types/version_test.go b/modules/core/03-connection/types/version_test.go index 9aa4abf9259..9830781ddaf 100644 --- a/modules/core/03-connection/types/version_test.go +++ b/modules/core/03-connection/types/version_test.go @@ -6,7 +6,6 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - "github.com/cosmos/ibc-go/v7/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v7/testing" ) @@ -41,7 +40,7 @@ func TestIsSupportedVersion(t *testing.T) { }{ { "version is supported", - types.ExportedVersionsToProto(types.GetCompatibleVersions())[0], + types.GetCompatibleVersions()[0], true, }, { @@ -65,14 +64,14 @@ func TestFindSupportedVersion(t *testing.T) { testCases := []struct { name string version *types.Version - supportedVersions []exported.Version + supportedVersions []*types.Version expVersion *types.Version expFound bool }{ {"valid supported version", types.DefaultIBCVersion, types.GetCompatibleVersions(), types.DefaultIBCVersion, true}, {"empty (invalid) version", &types.Version{}, types.GetCompatibleVersions(), &types.Version{}, false}, - {"empty supported versions", types.DefaultIBCVersion, []exported.Version{}, &types.Version{}, false}, - {"desired version is last", types.DefaultIBCVersion, []exported.Version{types.NewVersion("1.1", nil), types.NewVersion("2", []string{"ORDER_UNORDERED"}), types.NewVersion("3", nil), types.DefaultIBCVersion}, types.DefaultIBCVersion, true}, + {"empty supported versions", types.DefaultIBCVersion, []*types.Version{}, &types.Version{}, false}, + {"desired version is last", types.DefaultIBCVersion, []*types.Version{types.NewVersion("1.1", nil), types.NewVersion("2", []string{"ORDER_UNORDERED"}), types.NewVersion("3", nil), types.DefaultIBCVersion}, types.DefaultIBCVersion, true}, {"desired version identifier with different feature set", types.NewVersion(types.DefaultIBCVersionIdentifier, []string{"ORDER_DAG"}), types.GetCompatibleVersions(), types.DefaultIBCVersion, true}, {"version not supported", types.NewVersion("2", []string{"ORDER_DAG"}), types.GetCompatibleVersions(), &types.Version{}, false}, } @@ -92,17 +91,17 @@ func TestFindSupportedVersion(t *testing.T) { func TestPickVersion(t *testing.T) { testCases := []struct { name string - supportedVersions []exported.Version - counterpartyVersions []exported.Version + supportedVersions []*types.Version + counterpartyVersions []*types.Version expVer *types.Version expPass bool }{ {"valid default ibc version", types.GetCompatibleVersions(), types.GetCompatibleVersions(), types.DefaultIBCVersion, true}, - {"valid version in counterparty versions", types.GetCompatibleVersions(), []exported.Version{types.NewVersion("version1", nil), types.NewVersion("2.0.0", []string{"ORDER_UNORDERED-ZK"}), types.DefaultIBCVersion}, types.DefaultIBCVersion, true}, - {"valid identifier match but empty feature set not allowed", types.GetCompatibleVersions(), []exported.Version{types.NewVersion(types.DefaultIBCVersionIdentifier, []string{"DAG", "ORDERED-ZK", "UNORDERED-zk]"})}, types.NewVersion(types.DefaultIBCVersionIdentifier, nil), false}, - {"empty counterparty versions", types.GetCompatibleVersions(), []exported.Version{}, &types.Version{}, false}, - {"non-matching counterparty versions", types.GetCompatibleVersions(), []exported.Version{types.NewVersion("2.0.0", nil)}, &types.Version{}, false}, - {"non-matching counterparty versions (uses ordered channels only) contained in supported versions (uses unordered channels only)", []exported.Version{types.NewVersion(types.DefaultIBCVersionIdentifier, []string{"ORDER_UNORDERED"})}, []exported.Version{types.NewVersion(types.DefaultIBCVersionIdentifier, []string{"ORDER_ORDERED"})}, &types.Version{}, false}, + {"valid version in counterparty versions", types.GetCompatibleVersions(), []*types.Version{types.NewVersion("version1", nil), types.NewVersion("2.0.0", []string{"ORDER_UNORDERED-ZK"}), types.DefaultIBCVersion}, types.DefaultIBCVersion, true}, + {"valid identifier match but empty feature set not allowed", types.GetCompatibleVersions(), []*types.Version{types.NewVersion(types.DefaultIBCVersionIdentifier, []string{"DAG", "ORDERED-ZK", "UNORDERED-zk]"})}, types.NewVersion(types.DefaultIBCVersionIdentifier, nil), false}, + {"empty counterparty versions", types.GetCompatibleVersions(), []*types.Version{}, &types.Version{}, false}, + {"non-matching counterparty versions", types.GetCompatibleVersions(), []*types.Version{types.NewVersion("2.0.0", nil)}, &types.Version{}, false}, + {"non-matching counterparty versions (uses ordered channels only) contained in supported versions (uses unordered channels only)", []*types.Version{types.NewVersion(types.DefaultIBCVersionIdentifier, []string{"ORDER_UNORDERED"})}, []*types.Version{types.NewVersion(types.DefaultIBCVersionIdentifier, []string{"ORDER_ORDERED"})}, &types.Version{}, false}, } for i, tc := range testCases { diff --git a/modules/core/04-channel/keeper/events.go b/modules/core/04-channel/keeper/events.go index a7afcb35a8b..5cb39ab6dab 100644 --- a/modules/core/04-channel/keeper/events.go +++ b/modules/core/04-channel/keeper/events.go @@ -137,7 +137,7 @@ func emitSendPacketEvent(ctx sdk.Context, packet exported.PacketI, channel types sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), // we only support 1-hop packets now, and that is the most important hop for a relayer // (is it going to a chain I am connected to) - sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), //nolint:staticcheck // DEPRECATED + sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), ), sdk.NewEvent( @@ -165,7 +165,7 @@ func emitRecvPacketEvent(ctx sdk.Context, packet exported.PacketI, channel types sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), // we only support 1-hop packets now, and that is the most important hop for a relayer // (is it going to a chain I am connected to) - sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), //nolint:staticcheck // DEPRECATED + sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), ), sdk.NewEvent( @@ -193,7 +193,7 @@ func emitWriteAcknowledgementEvent(ctx sdk.Context, packet exported.PacketI, cha sdk.NewAttribute(types.AttributeKeyAckHex, hex.EncodeToString(acknowledgement)), // we only support 1-hop packets now, and that is the most important hop for a relayer // (is it going to a chain I am connected to) - sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), //nolint:staticcheck // DEPRECATED + sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), ), sdk.NewEvent( @@ -219,7 +219,7 @@ func emitAcknowledgePacketEvent(ctx sdk.Context, packet exported.PacketI, channe sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), // we only support 1-hop packets now, and that is the most important hop for a relayer // (is it going to a chain I am connected to) - sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), //nolint:staticcheck // DEPRECATED + sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), ), sdk.NewEvent( diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index fa7c1549c93..6622ab43bb2 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -54,7 +54,7 @@ func NewKeeper( } // Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { +func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) } @@ -242,7 +242,7 @@ func (k Keeper) HasPacketAcknowledgement(ctx sdk.Context, portID, channelID stri // 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. -func (k Keeper) IteratePacketSequence(ctx sdk.Context, iterator db.Iterator, cb func(portID, channelID string, sequence uint64) bool) { +func (Keeper) IteratePacketSequence(ctx sdk.Context, iterator db.Iterator, cb func(portID, channelID string, sequence uint64) bool) { defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() }) for ; iterator.Valid(); iterator.Next() { portID, channelID, err := host.ParseChannelPath(string(iterator.Key())) @@ -481,7 +481,7 @@ func (k Keeper) LookupModuleByChannel(ctx sdk.Context, portID, channelID string) } // 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) { +func (Keeper) iterateHashes(ctx sdk.Context, iterator db.Iterator, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() }) for ; iterator.Valid(); iterator.Next() { diff --git a/modules/core/04-channel/keeper/keeper_test.go b/modules/core/04-channel/keeper/keeper_test.go index 92afaba9135..835e9da87c0 100644 --- a/modules/core/04-channel/keeper/keeper_test.go +++ b/modules/core/04-channel/keeper/keeper_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" @@ -14,7 +14,7 @@ import ( // KeeperTestSuite is a testing suite to test keeper functions. type KeeperTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -25,7 +25,7 @@ type KeeperTestSuite struct { // TestKeeperTestSuite runs all the tests within this package. func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) + testifysuite.Run(t, new(KeeperTestSuite)) } // SetupTest creates a coordinator with 2 test chains. diff --git a/modules/core/04-channel/types/msgs_test.go b/modules/core/04-channel/types/msgs_test.go index af8fedfda53..b63ed20b3f4 100644 --- a/modules/core/04-channel/types/msgs_test.go +++ b/modules/core/04-channel/types/msgs_test.go @@ -5,7 +5,7 @@ import ( "testing" dbm "github.com/cosmos/cosmos-db" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" log "cosmossdk.io/log" "cosmossdk.io/store/iavl" @@ -69,7 +69,7 @@ var ( ) type TypesTestSuite struct { - suite.Suite + testifysuite.Suite proof []byte } @@ -104,7 +104,7 @@ func (suite *TypesTestSuite) SetupTest() { } func TestTypesTestSuite(t *testing.T) { - suite.Run(t, new(TypesTestSuite)) + testifysuite.Run(t, new(TypesTestSuite)) } func (suite *TypesTestSuite) TestMsgChannelOpenInitValidateBasic() { diff --git a/modules/core/05-port/keeper/keeper.go b/modules/core/05-port/keeper/keeper.go index 54699307333..f290f99fed9 100644 --- a/modules/core/05-port/keeper/keeper.go +++ b/modules/core/05-port/keeper/keeper.go @@ -28,7 +28,7 @@ func NewKeeper(sck exported.ScopedKeeper) Keeper { } // Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { +func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) } diff --git a/modules/core/05-port/keeper/keeper_test.go b/modules/core/05-port/keeper/keeper_test.go index a546623490a..578348efa84 100644 --- a/modules/core/05-port/keeper/keeper_test.go +++ b/modules/core/05-port/keeper/keeper_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" sdk "github.com/cosmos/cosmos-sdk/types" @@ -18,7 +18,7 @@ var ( ) type KeeperTestSuite struct { - suite.Suite + testifysuite.Suite ctx sdk.Context keeper *keeper.Keeper @@ -33,7 +33,7 @@ func (suite *KeeperTestSuite) SetupTest() { } func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) + testifysuite.Run(t, new(KeeperTestSuite)) } func (suite *KeeperTestSuite) TestBind() { diff --git a/modules/core/05-port/types/module.go b/modules/core/05-port/types/module.go index 33465bf6f98..a8306f73064 100644 --- a/modules/core/05-port/types/module.go +++ b/modules/core/05-port/types/module.go @@ -138,3 +138,10 @@ type Middleware interface { IBCModule ICS4Wrapper } + +// PacketDataUnmarshaler defines an optional interface which allows a middleware to +// request the packet data to be unmarshaled by the base application. +type PacketDataUnmarshaler interface { + // UnmarshalPacketData unmarshals the packet data into a concrete type + UnmarshalPacketData([]byte) (interface{}, error) +} diff --git a/modules/core/23-commitment/types/commitment_test.go b/modules/core/23-commitment/types/commitment_test.go index 3aaf55df74c..6d8a2d227af 100644 --- a/modules/core/23-commitment/types/commitment_test.go +++ b/modules/core/23-commitment/types/commitment_test.go @@ -4,7 +4,7 @@ import ( "testing" dbm "github.com/cosmos/cosmos-db" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" "cosmossdk.io/log" "cosmossdk.io/store/iavl" @@ -14,7 +14,7 @@ import ( ) type MerkleTestSuite struct { - suite.Suite + testifysuite.Suite store *rootmulti.Store storeKey *storetypes.KVStoreKey @@ -35,5 +35,5 @@ func (suite *MerkleTestSuite) SetupTest() { } func TestMerkleTestSuite(t *testing.T) { - suite.Run(t, new(MerkleTestSuite)) + testifysuite.Run(t, new(MerkleTestSuite)) } diff --git a/modules/core/23-commitment/types/merkle.go b/modules/core/23-commitment/types/merkle.go index 79a2c113fc6..6cf5d973bc2 100644 --- a/modules/core/23-commitment/types/merkle.go +++ b/modules/core/23-commitment/types/merkle.go @@ -205,13 +205,13 @@ func (proof MerkleProof) VerifyNonMembership(specs []*ics23.ProofSpec, root expo // BatchVerifyMembership verifies a group of key value pairs against the given root // NOTE: Currently left unimplemented as it is unused -func (proof MerkleProof) BatchVerifyMembership(specs []*ics23.ProofSpec, root exported.Root, path exported.Path, items map[string][]byte) error { +func (MerkleProof) BatchVerifyMembership(specs []*ics23.ProofSpec, root exported.Root, path exported.Path, items map[string][]byte) error { return errorsmod.Wrap(ErrInvalidProof, "batch proofs are currently unsupported") } // BatchVerifyNonMembership verifies absence of a group of keys against the given root // NOTE: Currently left unimplemented as it is unused -func (proof MerkleProof) BatchVerifyNonMembership(specs []*ics23.ProofSpec, root exported.Root, path exported.Path, items [][]byte) error { +func (MerkleProof) BatchVerifyNonMembership(specs []*ics23.ProofSpec, root exported.Root, path exported.Path, items [][]byte) error { return errorsmod.Wrap(ErrInvalidProof, "batch proofs are currently unsupported") } diff --git a/modules/core/24-host/parse.go b/modules/core/24-host/parse.go index 81074bbfcca..f838cc07b9d 100644 --- a/modules/core/24-host/parse.go +++ b/modules/core/24-host/parse.go @@ -63,7 +63,9 @@ func parseClientStatePath(path string) (string, error) { return "", errorsmod.Wrap(ErrInvalidPath, "clientID is empty") } - return split[1], nil + clientID := split[1] + + return clientID, nil } // ParseConnectionPath returns the connection ID from a full path. It returns @@ -74,7 +76,9 @@ func ParseConnectionPath(path string) (string, error) { return "", errorsmod.Wrapf(ErrInvalidPath, "cannot parse connection path %s", path) } - return split[1], nil + connectionID := split[1] + + return connectionID, nil } // ParseChannelPath returns the port and channel ID from a full path. It returns @@ -89,7 +93,10 @@ func ParseChannelPath(path string) (string, string, error) { return "", "", errorsmod.Wrapf(ErrInvalidPath, "cannot parse channel path %s", path) } - return split[2], split[4], nil + portID := split[2] + channelID := split[4] + + return portID, channelID, nil } // MustParseConnectionPath returns the connection ID from a full path. Panics diff --git a/modules/core/ante/ante_test.go b/modules/core/ante/ante_test.go index 1ec224abe58..649390d30f5 100644 --- a/modules/core/ante/ante_test.go +++ b/modules/core/ante/ante_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" sdk "github.com/cosmos/cosmos-sdk/types" @@ -17,7 +17,7 @@ import ( ) type AnteTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -42,7 +42,7 @@ func (suite *AnteTestSuite) SetupTest() { // TestAnteTestSuite runs all the tests within this package. func TestAnteTestSuite(t *testing.T) { - suite.Run(t, new(AnteTestSuite)) + testifysuite.Run(t, new(AnteTestSuite)) } // createRecvPacketMessage creates a RecvPacket message for a packet sent from chain A to chain B. @@ -337,7 +337,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { } // append non packet and update message to msgs to ensure multimsg tx should pass - msgs = append(msgs, &clienttypes.MsgSubmitMisbehaviour{}) + msgs = append(msgs, &clienttypes.MsgSubmitMisbehaviour{}) //nolint:staticcheck // we're using the deprecated message for testing return msgs }, true, diff --git a/modules/core/exported/channel.go b/modules/core/exported/channel.go index ac52a3f34ba..a6ec511880b 100644 --- a/modules/core/exported/channel.go +++ b/modules/core/exported/channel.go @@ -17,36 +17,3 @@ type CounterpartyChannelI interface { GetChannelID() string ValidateBasic() error } - -// PacketI defines the standard interface for IBC packets -type PacketI interface { - GetSequence() uint64 - GetTimeoutHeight() Height - GetTimeoutTimestamp() uint64 - GetSourcePort() string - GetSourceChannel() string - GetDestPort() string - GetDestChannel() string - GetData() []byte - ValidateBasic() error -} - -// Acknowledgement defines the interface used to return acknowledgements in the OnRecvPacket callback. -// The Acknowledgement interface is used by core IBC to ensure partial state changes are not committed -// when packet receives have not properly succeeded (typically resulting in an error acknowledgement being returned). -// The interface also allows core IBC to obtain the acknowledgement bytes whose encoding is determined by each IBC application or middleware. -// Each custom acknowledgement type must implement this interface. -type Acknowledgement interface { - // Success determines if the IBC application state should be persisted when handling `RecvPacket`. - // During `OnRecvPacket` IBC application callback execution, all state changes are held in a cache store and committed if: - // - the acknowledgement.Success() returns true - // - a nil acknowledgement is returned (asynchronous acknowledgements) - // - // Note 1: IBC application callback events are always persisted so long as `RecvPacket` succeeds without error. - // - // Note 2: The return value should account for the success of the underlying IBC application or middleware. Thus the `acknowledgement.Success` is representative of the entire IBC stack's success when receiving a packet. The individual success of each acknowledgement associated with an IBC application or middleware must be determined by obtaining the actual acknowledgement type after decoding the acknowledgement bytes. - // - // See https://github.com/cosmos/ibc-go/blob/v7.0.0/docs/ibc/apps.md for further explanations. - Success() bool - Acknowledgement() []byte -} diff --git a/modules/core/exported/connection.go b/modules/core/exported/connection.go index c418e8497a7..a8341a255a9 100644 --- a/modules/core/exported/connection.go +++ b/modules/core/exported/connection.go @@ -19,10 +19,3 @@ type CounterpartyConnectionI interface { GetPrefix() Prefix ValidateBasic() error } - -// Version defines an IBC version used in connection handshake negotiation. -type Version interface { - GetIdentifier() string - GetFeatures() []string - VerifyProposedVersion(Version) error -} diff --git a/modules/core/exported/packet.go b/modules/core/exported/packet.go new file mode 100644 index 00000000000..f8e6a09ebd6 --- /dev/null +++ b/modules/core/exported/packet.go @@ -0,0 +1,52 @@ +package exported + +// PacketI defines the standard interface for IBC packets +type PacketI interface { + GetSequence() uint64 + GetTimeoutHeight() Height + GetTimeoutTimestamp() uint64 + GetSourcePort() string + GetSourceChannel() string + GetDestPort() string + GetDestChannel() string + GetData() []byte + ValidateBasic() error +} + +// Acknowledgement defines the interface used to return acknowledgements in the OnRecvPacket callback. +// The Acknowledgement interface is used by core IBC to ensure partial state changes are not committed +// when packet receives have not properly succeeded (typically resulting in an error acknowledgement being returned). +// The interface also allows core IBC to obtain the acknowledgement bytes whose encoding is determined by each IBC application or middleware. +// Each custom acknowledgement type must implement this interface. +type Acknowledgement interface { + // Success determines if the IBC application state should be persisted when handling `RecvPacket`. + // During `OnRecvPacket` IBC application callback execution, all state changes are held in a cache store and committed if: + // - the acknowledgement.Success() returns true + // - a nil acknowledgement is returned (asynchronous acknowledgements) + // + // Note 1: IBC application callback events are always persisted so long as `RecvPacket` succeeds without error. + // + // Note 2: The return value should account for the success of the underlying IBC application or middleware. Thus the `acknowledgement.Success` is representative of the entire IBC stack's success when receiving a packet. The individual success of each acknowledgement associated with an IBC application or middleware must be determined by obtaining the actual acknowledgement type after decoding the acknowledgement bytes. + // + // See https://github.com/cosmos/ibc-go/blob/v7.0.0/docs/ibc/apps.md for further explanations. + Success() bool + Acknowledgement() []byte +} + +// PacketData defines an optional interface which an application's packet data structure may implement. +type PacketData interface { + // GetPacketSender returns the sender address of the packet data. + // If the packet sender is unknown or undefined, an empty string should be returned. + GetPacketSender(sourcePortID string) string +} + +// PacketDataProvider defines an optional interfaces for retrieving custom packet data stored on behalf of another application. +// An existing problem in the IBC middleware design is the inability for a middleware to define its own packet data type and insert packet sender provided information. +// A short term solution was introduced into several application's packet data to utilize a memo field to carry this information on behalf of another application. +// This interfaces standardizes that behaviour. Upon realization of the ability for middleware's to define their own packet data types, this interface will be deprecated and removed with time. +type PacketDataProvider interface { + // GetCustomPacketData returns the packet data held on behalf of another application. + // The name the information is stored under should be provided as the key. + // If no custom packet data exists for the key, nil should be returned. + GetCustomPacketData(key string) interface{} +} diff --git a/modules/core/genesis_test.go b/modules/core/genesis_test.go index 96f864fb688..e18b49fb013 100644 --- a/modules/core/genesis_test.go +++ b/modules/core/genesis_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/codec" @@ -36,7 +36,7 @@ const ( var clientHeight = clienttypes.NewHeight(1, 10) type IBCTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -53,7 +53,7 @@ func (suite *IBCTestSuite) SetupTest() { } func TestIBCTestSuite(t *testing.T) { - suite.Run(t, new(IBCTestSuite)) + testifysuite.Run(t, new(IBCTestSuite)) } func (suite *IBCTestSuite) TestValidateGenesis() { diff --git a/modules/core/keeper/keeper_test.go b/modules/core/keeper/keeper_test.go index b8305a3d2be..4a8564a906d 100644 --- a/modules/core/keeper/keeper_test.go +++ b/modules/core/keeper/keeper_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" upgradekeeper "cosmossdk.io/x/upgrade/keeper" @@ -20,7 +20,7 @@ import ( ) type KeeperTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -41,7 +41,7 @@ func (suite *KeeperTestSuite) SetupTest() { } func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) + testifysuite.Run(t, new(KeeperTestSuite)) } // MockStakingKeeper implements clienttypes.StakingKeeper used in ibckeeper.NewKeeper @@ -49,11 +49,11 @@ type MockStakingKeeper struct { mockField string } -func (d MockStakingKeeper) GetHistoricalInfo(ctx context.Context, height int64) (stakingtypes.HistoricalInfo, error) { +func (MockStakingKeeper) GetHistoricalInfo(_ context.Context, height int64) (stakingtypes.HistoricalInfo, error) { return stakingtypes.HistoricalInfo{}, nil } -func (d MockStakingKeeper) UnbondingTime(ctx context.Context) (time.Duration, error) { +func (MockStakingKeeper) UnbondingTime(_ context.Context) (time.Duration, error) { return 0, nil } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index b135172ed43..3ee15b1eaff 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -85,7 +85,7 @@ func (k Keeper) UpgradeClient(goCtx context.Context, msg *clienttypes.MsgUpgrade // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. // Warning: DEPRECATED // This handler is redudant as `MsgUpdateClient` is now capable of handling both a Header and a Misbehaviour -func (k Keeper) SubmitMisbehaviour(goCtx context.Context, msg *clienttypes.MsgSubmitMisbehaviour) (*clienttypes.MsgSubmitMisbehaviourResponse, error) { +func (k Keeper) SubmitMisbehaviour(goCtx context.Context, msg *clienttypes.MsgSubmitMisbehaviour) (*clienttypes.MsgSubmitMisbehaviourResponse, error) { //nolint:staticcheck // for now, we're using msgsubmitmisbehaviour. ctx := sdk.UnwrapSDKContext(goCtx) misbehaviour, err := clienttypes.UnpackClientMessage(msg.Misbehaviour) @@ -122,7 +122,7 @@ func (k Keeper) ConnectionOpenTry(goCtx context.Context, msg *connectiontypes.Ms if _, err := k.ConnectionKeeper.ConnOpenTry( ctx, msg.Counterparty, msg.DelayPeriod, msg.ClientId, targetClient, - connectiontypes.ProtoVersionsToExported(msg.CounterpartyVersions), msg.ProofInit, msg.ProofClient, msg.ProofConsensus, + msg.CounterpartyVersions, msg.ProofInit, msg.ProofClient, msg.ProofConsensus, msg.ProofHeight, msg.ConsensusHeight, ); err != nil { return nil, errorsmod.Wrap(err, "connection handshake open try failed") diff --git a/modules/core/migrations/v7/genesis_test.go b/modules/core/migrations/v7/genesis_test.go index bdbacb066b8..77111b2b705 100644 --- a/modules/core/migrations/v7/genesis_test.go +++ b/modules/core/migrations/v7/genesis_test.go @@ -3,7 +3,7 @@ package v7_test import ( "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -20,7 +20,7 @@ import ( ) type MigrationsV7TestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -31,7 +31,7 @@ type MigrationsV7TestSuite struct { // TestMigrationsV7TestSuite runs all the tests within this package. func TestMigrationsV7TestSuite(t *testing.T) { - suite.Run(t, new(MigrationsV7TestSuite)) + testifysuite.Run(t, new(MigrationsV7TestSuite)) } // SetupTest creates a coordinator with 2 test chains. diff --git a/modules/core/module.go b/modules/core/module.go index 1e8e0d77a1d..dc9f59c011f 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -113,7 +113,7 @@ func (AppModule) Name() string { } // RegisterInvariants registers the ibc module invariants. -func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { +func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { // TODO: } @@ -190,6 +190,6 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { } // WeightedOperations returns the all the ibc module operations with their respective weights. -func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { +func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { return nil } diff --git a/modules/light-clients/06-solomachine/client_state.go b/modules/light-clients/06-solomachine/client_state.go index ca07ad5b85a..67a373ca3bb 100644 --- a/modules/light-clients/06-solomachine/client_state.go +++ b/modules/light-clients/06-solomachine/client_state.go @@ -30,7 +30,7 @@ func NewClientState(latestSequence uint64, consensusState *ConsensusState) *Clie } // ClientType is Solo Machine. -func (cs ClientState) ClientType() string { +func (ClientState) ClientType() string { return exported.Solomachine } @@ -75,7 +75,7 @@ func (cs ClientState) Validate() error { } // ZeroCustomFields is not implemented for solo machine -func (cs ClientState) ZeroCustomFields() exported.ClientState { +func (ClientState) ZeroCustomFields() exported.ClientState { panic("ZeroCustomFields is not implemented as the solo machine implementation does not support upgrades.") } @@ -93,12 +93,12 @@ func (cs ClientState) Initialize(_ sdk.Context, cdc codec.BinaryCodec, clientSto } // ExportMetadata is a no-op since solomachine does not store any metadata in client store -func (cs ClientState) ExportMetadata(_ storetypes.KVStore) []exported.GenesisMetadata { +func (ClientState) ExportMetadata(_ storetypes.KVStore) []exported.GenesisMetadata { return nil } // VerifyUpgradeAndUpdateState returns an error since solomachine client does not support upgrades -func (cs ClientState) VerifyUpgradeAndUpdateState( +func (ClientState) VerifyUpgradeAndUpdateState( _ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientState, _ exported.ConsensusState, _, _ []byte, ) error { diff --git a/modules/light-clients/06-solomachine/misbehaviour.go b/modules/light-clients/06-solomachine/misbehaviour.go index fcfb8fdb277..becc6ca1e2f 100644 --- a/modules/light-clients/06-solomachine/misbehaviour.go +++ b/modules/light-clients/06-solomachine/misbehaviour.go @@ -12,12 +12,12 @@ import ( var _ exported.ClientMessage = (*Misbehaviour)(nil) // ClientType is a Solo Machine light client. -func (misbehaviour Misbehaviour) ClientType() string { +func (Misbehaviour) ClientType() string { return exported.Solomachine } // Type implements Misbehaviour interface. -func (misbehaviour Misbehaviour) Type() string { +func (Misbehaviour) Type() string { return exported.TypeClientMisbehaviour } diff --git a/modules/light-clients/06-solomachine/misbehaviour_handle.go b/modules/light-clients/06-solomachine/misbehaviour_handle.go index 4e7fd346a6e..8214b971fe4 100644 --- a/modules/light-clients/06-solomachine/misbehaviour_handle.go +++ b/modules/light-clients/06-solomachine/misbehaviour_handle.go @@ -12,7 +12,7 @@ import ( ) // CheckForMisbehaviour returns true for type Misbehaviour (passed VerifyClientMessage check), otherwise returns false -func (cs ClientState) CheckForMisbehaviour(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, clientMsg exported.ClientMessage) bool { +func (ClientState) CheckForMisbehaviour(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, clientMsg exported.ClientMessage) bool { if _, ok := clientMsg.(*Misbehaviour); ok { return true } diff --git a/modules/light-clients/06-solomachine/solomachine_test.go b/modules/light-clients/06-solomachine/solomachine_test.go index e2fb50875e8..fe974f8f585 100644 --- a/modules/light-clients/06-solomachine/solomachine_test.go +++ b/modules/light-clients/06-solomachine/solomachine_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" storetypes "cosmossdk.io/store/types" @@ -27,7 +27,7 @@ import ( var channelIDSolomachine = "channel-on-solomachine" // channelID generated on solo machine side type SoloMachineTestSuite struct { - suite.Suite + testifysuite.Suite solomachine *ibctesting.Solomachine // singlesig public key solomachineMulti *ibctesting.Solomachine // multisig public key @@ -52,7 +52,7 @@ func (suite *SoloMachineTestSuite) SetupTest() { } func TestSoloMachineTestSuite(t *testing.T) { - suite.Run(t, new(SoloMachineTestSuite)) + testifysuite.Run(t, new(SoloMachineTestSuite)) } func (suite *SoloMachineTestSuite) SetupSolomachine() string { diff --git a/modules/light-clients/07-tendermint/client_state.go b/modules/light-clients/07-tendermint/client_state.go index 9cc9b6710f5..93c009b975f 100644 --- a/modules/light-clients/07-tendermint/client_state.go +++ b/modules/light-clients/07-tendermint/client_state.go @@ -49,7 +49,7 @@ func (cs ClientState) GetChainID() string { } // ClientType is tendermint. -func (cs ClientState) ClientType() string { +func (ClientState) ClientType() string { return exported.Tendermint } @@ -59,7 +59,7 @@ func (cs ClientState) GetLatestHeight() exported.Height { } // GetTimestampAtHeight returns the timestamp in nanoseconds of the consensus state at the given height. -func (cs ClientState) GetTimestampAtHeight( +func (ClientState) GetTimestampAtHeight( ctx sdk.Context, clientStore storetypes.KVStore, cdc codec.BinaryCodec, diff --git a/modules/light-clients/07-tendermint/genesis.go b/modules/light-clients/07-tendermint/genesis.go index bed681e03a9..45ddea672bd 100644 --- a/modules/light-clients/07-tendermint/genesis.go +++ b/modules/light-clients/07-tendermint/genesis.go @@ -9,7 +9,7 @@ import ( // ExportMetadata exports all the consensus metadata in the client store so they can be included in clients genesis // and imported by a ClientKeeper -func (cs ClientState) ExportMetadata(store storetypes.KVStore) []exported.GenesisMetadata { +func (ClientState) ExportMetadata(store storetypes.KVStore) []exported.GenesisMetadata { gm := make([]exported.GenesisMetadata, 0) IterateConsensusMetadata(store, func(key, val []byte) bool { gm = append(gm, clienttypes.NewGenesisMetadata(key, val)) diff --git a/modules/light-clients/07-tendermint/header.go b/modules/light-clients/07-tendermint/header.go index 1014c8a75ee..caa81e7493c 100644 --- a/modules/light-clients/07-tendermint/header.go +++ b/modules/light-clients/07-tendermint/header.go @@ -25,7 +25,7 @@ func (h Header) ConsensusState() *ConsensusState { } // ClientType defines that the Header is a Tendermint consensus algorithm -func (h Header) ClientType() string { +func (Header) ClientType() string { return exported.Tendermint } diff --git a/modules/light-clients/07-tendermint/migrations/migrations_test.go b/modules/light-clients/07-tendermint/migrations/migrations_test.go index 7a261caaf8c..906aa1f0932 100644 --- a/modules/light-clients/07-tendermint/migrations/migrations_test.go +++ b/modules/light-clients/07-tendermint/migrations/migrations_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v7/modules/core/24-host" @@ -15,7 +15,7 @@ import ( ) type MigrationsTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -31,7 +31,7 @@ func (suite *MigrationsTestSuite) SetupTest() { } func TestTendermintTestSuite(t *testing.T) { - suite.Run(t, new(MigrationsTestSuite)) + testifysuite.Run(t, new(MigrationsTestSuite)) } // test pruning of multiple expired tendermint consensus states diff --git a/modules/light-clients/07-tendermint/misbehaviour.go b/modules/light-clients/07-tendermint/misbehaviour.go index bce812e4537..de6c97d191a 100644 --- a/modules/light-clients/07-tendermint/misbehaviour.go +++ b/modules/light-clients/07-tendermint/misbehaviour.go @@ -28,7 +28,7 @@ func NewMisbehaviour(clientID string, header1, header2 *Header) *Misbehaviour { } // ClientType is Tendermint light client -func (misbehaviour Misbehaviour) ClientType() string { +func (Misbehaviour) ClientType() string { return exported.Tendermint } diff --git a/modules/light-clients/07-tendermint/misbehaviour_handle.go b/modules/light-clients/07-tendermint/misbehaviour_handle.go index c5ae3d5fcfb..542afc0ee82 100644 --- a/modules/light-clients/07-tendermint/misbehaviour_handle.go +++ b/modules/light-clients/07-tendermint/misbehaviour_handle.go @@ -19,7 +19,7 @@ import ( // CheckForMisbehaviour detects duplicate height misbehaviour and BFT time violation misbehaviour // in a submitted Header message and verifies the correctness of a submitted Misbehaviour ClientMessage -func (cs ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, msg exported.ClientMessage) bool { +func (ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, msg exported.ClientMessage) bool { switch msg := msg.(type) { case *Header: tmHeader := msg diff --git a/modules/light-clients/07-tendermint/tendermint_test.go b/modules/light-clients/07-tendermint/tendermint_test.go index be69b42a21a..6f424b3398a 100644 --- a/modules/light-clients/07-tendermint/tendermint_test.go +++ b/modules/light-clients/07-tendermint/tendermint_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -36,7 +36,7 @@ var ( ) type TendermintTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -111,5 +111,5 @@ func getBothSigners(suite *TendermintTestSuite, altVal *tmtypes.Validator, altPr } func TestTendermintTestSuite(t *testing.T) { - suite.Run(t, new(TendermintTestSuite)) + testifysuite.Run(t, new(TendermintTestSuite)) } diff --git a/modules/light-clients/09-localhost/client_state.go b/modules/light-clients/09-localhost/client_state.go index 8b21d8a9f93..5b7274aed13 100644 --- a/modules/light-clients/09-localhost/client_state.go +++ b/modules/light-clients/09-localhost/client_state.go @@ -26,7 +26,7 @@ func NewClientState(height clienttypes.Height) exported.ClientState { } // ClientType returns the 09-localhost client type. -func (cs ClientState) ClientType() string { +func (ClientState) ClientType() string { return exported.Localhost } @@ -36,7 +36,7 @@ func (cs ClientState) GetLatestHeight() exported.Height { } // Status always returns Active. The 09-localhost status cannot be changed. -func (cs ClientState) Status(_ sdk.Context, _ storetypes.KVStore, _ codec.BinaryCodec) exported.Status { +func (ClientState) Status(_ sdk.Context, _ storetypes.KVStore, _ codec.BinaryCodec) exported.Status { return exported.Active } @@ -55,7 +55,7 @@ func (cs ClientState) ZeroCustomFields() exported.ClientState { } // Initialize ensures that initial consensus state for localhost is nil. -func (cs ClientState) Initialize(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, consState exported.ConsensusState) error { +func (ClientState) Initialize(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, consState exported.ConsensusState) error { if consState != nil { return errorsmod.Wrap(clienttypes.ErrInvalidConsensus, "initial consensus state for localhost must be nil.") } @@ -71,14 +71,14 @@ func (cs ClientState) Initialize(ctx sdk.Context, cdc codec.BinaryCodec, clientS // GetTimestampAtHeight returns the current block time retrieved from the application context. The localhost client does not store consensus states and thus // cannot provide a timestamp for the provided height. -func (cs ClientState) GetTimestampAtHeight(ctx sdk.Context, _ storetypes.KVStore, _ codec.BinaryCodec, _ exported.Height) (uint64, error) { +func (ClientState) GetTimestampAtHeight(ctx sdk.Context, _ storetypes.KVStore, _ codec.BinaryCodec, _ exported.Height) (uint64, error) { return uint64(ctx.BlockTime().UnixNano()), nil } // VerifyMembership is a generic proof verification method which verifies the existence of a given key and value within the IBC store. // The caller is expected to construct the full CommitmentPath from a CommitmentPrefix and a standardized path (as defined in ICS 24). // The caller must provide the full IBC store. -func (cs ClientState) VerifyMembership( +func (ClientState) VerifyMembership( ctx sdk.Context, store storetypes.KVStore, _ codec.BinaryCodec, @@ -119,7 +119,7 @@ func (cs ClientState) VerifyMembership( // VerifyNonMembership is a generic proof verification method which verifies the absence of a given CommitmentPath within the IBC store. // The caller is expected to construct the full CommitmentPath from a CommitmentPrefix and a standardized path (as defined in ICS 24). // The caller must provide the full IBC store. -func (cs ClientState) VerifyNonMembership( +func (ClientState) VerifyNonMembership( ctx sdk.Context, store storetypes.KVStore, _ codec.BinaryCodec, @@ -152,17 +152,17 @@ func (cs ClientState) VerifyNonMembership( } // VerifyClientMessage is unsupported by the 09-localhost client type and returns an error. -func (cs ClientState) VerifyClientMessage(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage) error { +func (ClientState) VerifyClientMessage(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage) error { return errorsmod.Wrap(clienttypes.ErrUpdateClientFailed, "client message verification is unsupported by the localhost client") } // CheckForMisbehaviour is unsupported by the 09-localhost client type and performs a no-op, returning false. -func (cs ClientState) CheckForMisbehaviour(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage) bool { +func (ClientState) CheckForMisbehaviour(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage) bool { return false } // UpdateStateOnMisbehaviour is unsupported by the 09-localhost client type and performs a no-op. -func (cs ClientState) UpdateStateOnMisbehaviour(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage) { +func (ClientState) UpdateStateOnMisbehaviour(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage) { } // UpdateState updates and stores as necessary any associated information for an IBC client, such as the ClientState and corresponding ConsensusState. @@ -177,18 +177,18 @@ func (cs ClientState) UpdateState(ctx sdk.Context, cdc codec.BinaryCodec, client } // ExportMetadata is a no-op for the 09-localhost client. -func (cs ClientState) ExportMetadata(_ storetypes.KVStore) []exported.GenesisMetadata { +func (ClientState) ExportMetadata(_ storetypes.KVStore) []exported.GenesisMetadata { return nil } // CheckSubstituteAndUpdateState returns an error. The localhost cannot be modified by // proposals. -func (cs ClientState) CheckSubstituteAndUpdateState(_ sdk.Context, _ codec.BinaryCodec, _, _ storetypes.KVStore, _ exported.ClientState) error { +func (ClientState) CheckSubstituteAndUpdateState(_ sdk.Context, _ codec.BinaryCodec, _, _ storetypes.KVStore, _ exported.ClientState) error { return errorsmod.Wrap(clienttypes.ErrUpdateClientFailed, "cannot update localhost client with a proposal") } // VerifyUpgradeAndUpdateState returns an error since localhost cannot be upgraded -func (cs ClientState) VerifyUpgradeAndUpdateState( +func (ClientState) VerifyUpgradeAndUpdateState( _ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, diff --git a/modules/light-clients/09-localhost/client_state_test.go b/modules/light-clients/09-localhost/client_state_test.go index b11034a87e3..f241c400d85 100644 --- a/modules/light-clients/09-localhost/client_state_test.go +++ b/modules/light-clients/09-localhost/client_state_test.go @@ -139,7 +139,7 @@ func (suite *LocalhostTestSuite) TestVerifyMembership() { connectiontypes.OPEN, exported.LocalhostClientID, connectiontypes.NewCounterparty(exported.LocalhostClientID, exported.LocalhostConnectionID, suite.chain.GetPrefix()), - connectiontypes.ExportedVersionsToProto(connectiontypes.GetCompatibleVersions()), 0, + connectiontypes.GetCompatibleVersions(), 0, ) suite.chain.GetSimApp().GetIBCKeeper().ConnectionKeeper.SetConnection(suite.chain.GetContext(), exported.LocalhostConnectionID, connectionEnd) diff --git a/modules/light-clients/09-localhost/localhost_test.go b/modules/light-clients/09-localhost/localhost_test.go index c22ef1e35ae..555337f1cef 100644 --- a/modules/light-clients/09-localhost/localhost_test.go +++ b/modules/light-clients/09-localhost/localhost_test.go @@ -3,13 +3,13 @@ package localhost_test import ( "testing" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" ibctesting "github.com/cosmos/ibc-go/v7/testing" ) type LocalhostTestSuite struct { - suite.Suite + testifysuite.Suite coordinator ibctesting.Coordinator chain *ibctesting.TestChain @@ -21,5 +21,5 @@ func (suite *LocalhostTestSuite) SetupTest() { } func TestLocalhostTestSuite(t *testing.T) { - suite.Run(t, new(LocalhostTestSuite)) + testifysuite.Run(t, new(LocalhostTestSuite)) } diff --git a/testing/README.md b/testing/README.md index 9a9be197211..3961f7f378a 100644 --- a/testing/README.md +++ b/testing/README.md @@ -152,7 +152,7 @@ Here is an example of how to setup your testing environment in every package you ```go // KeeperTestSuite is a testing suite to test keeper functions. type KeeperTestSuite struct { - suite.Suite + testifysuite.Suite coordinator *ibctesting.Coordinator @@ -163,7 +163,7 @@ type KeeperTestSuite struct { // TestKeeperTestSuite runs all the tests within this package. func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) + testifysuite.Run(t, new(KeeperTestSuite)) } // SetupTest creates a coordinator with 2 test chains. diff --git a/testing/chain.go b/testing/chain.go index 63c5ca9586e..e26f7a27e25 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -130,7 +130,7 @@ func NewTestChainWithValSet(tb testing.TB, coord *Coordinator, chainID string, v app := SetupWithGenesisValSet(tb, valSet, genAccs, chainID, sdk.DefaultPowerReduction, genBals...) - // create genesis header + // create current header and call begin block header := cmtproto.Header{ ChainID: chainID, Height: 1, @@ -399,6 +399,9 @@ func (chain *TestChain) GetConsensusState(clientID string, height exported.Heigh // GetValsAtHeight will return the validator set of the chain at a given height. It will return // a success boolean depending on if the validator set exists or not at that height. func (chain *TestChain) GetValsAtHeight(height int64) (*cmttypes.ValidatorSet, bool) { + // if the current uncommitted header equals the requested height, then we can return + // the current validator set as this validator set will be stored in the historical info + // when the block height is executed if height == chain.CurrentHeader.Height { return chain.Vals, true } @@ -449,20 +452,13 @@ func (chain *TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight(counterpa tmTrustedVals *cmttypes.ValidatorSet ok bool ) - // Once we get TrustedHeight from client, we must query the validators from the counterparty chain - // If the LatestHeight == LastHeader.Height, then TrustedValidators are current validators - // If LatestHeight < LastHeader.Height, we can query the historical validator set from HistoricalInfo - if trustedHeight == counterparty.LastHeader.GetHeight() { - tmTrustedVals = counterparty.Vals - } else { - // NOTE: We need to get validators from counterparty at height: trustedHeight+1 - // since the last trusted validators for a header at height h - // is the NextValidators at h+1 committed to in header h by - // NextValidatorsHash - tmTrustedVals, ok = counterparty.GetValsAtHeight(int64(trustedHeight.RevisionHeight + 1)) - if !ok { - return nil, errorsmod.Wrapf(ibctm.ErrInvalidHeaderHeight, "could not retrieve trusted validators at trustedHeight: %d", trustedHeight) - } + + // NOTE: We need to get validators from counterparty at height: trustedHeight+1 + // since the last trusted validators for a header at height h + // is the NextValidators at h+1 committed to in header h via the NextValidatorsHash field + tmTrustedVals, ok = counterparty.GetValsAtHeight(int64(trustedHeight.RevisionHeight + 1)) + if !ok { + return nil, errorsmod.Wrapf(ibctm.ErrInvalidHeaderHeight, "could not retrieve trusted validators at trustedHeight: %d", trustedHeight) } // inject trusted fields into last header // for now assume revision number is 0 diff --git a/testing/config.go b/testing/config.go index 9a6ace904ba..584a8d1df36 100644 --- a/testing/config.go +++ b/testing/config.go @@ -30,7 +30,7 @@ func NewTendermintConfig() *TendermintConfig { } } -func (tmcfg *TendermintConfig) GetClientType() string { +func (*TendermintConfig) GetClientType() string { return exported.Tendermint } diff --git a/testing/endpoint.go b/testing/endpoint.go index 8a2c1712611..a480d052a82 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -312,7 +312,7 @@ func (endpoint *Endpoint) QueryConnectionHandshakeProof() ( connectionKey := host.ConnectionKey(endpoint.Counterparty.ConnectionID) proofConnection, _ = endpoint.Counterparty.QueryProofAtHeight(connectionKey, proofHeight.GetRevisionHeight()) - return + return clientState, proofClient, proofConsensus, consensusHeight, proofConnection, proofHeight } // ChanOpenInit will construct and execute a MsgChannelOpenInit on the associated endpoint. diff --git a/testing/events.go b/testing/events.go index 370bdfa9260..2962cd43435 100644 --- a/testing/events.go +++ b/testing/events.go @@ -4,7 +4,7 @@ import ( "fmt" "strconv" - "github.com/stretchr/testify/suite" + testifysuite "github.com/stretchr/testify/suite" abci "github.com/cometbft/cometbft/abci/types" @@ -138,7 +138,7 @@ func ParseAckFromEvents(events []abci.Event) ([]byte, error) { // AssertEventsLegacy asserts that expected events are present in the actual events. // Expected map needs to be a subset of actual events to pass. func AssertEventsLegacy( - suite *suite.Suite, + suite *testifysuite.Suite, expected EventsMap, actual []abci.Event, ) { @@ -167,7 +167,7 @@ func AssertEventsLegacy( // AssertEvents asserts that expected events are present in the actual events. func AssertEvents( - suite *suite.Suite, + suite *testifysuite.Suite, expected []abci.Event, actual []abci.Event, ) { diff --git a/testing/mock/ack.go b/testing/mock/ack.go index 280e848b3be..619ac098d44 100644 --- a/testing/mock/ack.go +++ b/testing/mock/ack.go @@ -13,11 +13,11 @@ func NewEmptyAcknowledgement() EmptyAcknowledgement { } // Success implements the Acknowledgement interface -func (ack EmptyAcknowledgement) Success() bool { +func (EmptyAcknowledgement) Success() bool { return true } // Acknowledgement implements the Acknowledgement interface -func (ack EmptyAcknowledgement) Acknowledgement() []byte { +func (EmptyAcknowledgement) Acknowledgement() []byte { return []byte{} } diff --git a/testing/mock/ibc_module.go b/testing/mock/ibc_module.go index ec03110e164..a53dce74122 100644 --- a/testing/mock/ibc_module.go +++ b/testing/mock/ibc_module.go @@ -3,6 +3,7 @@ package mock import ( "bytes" "fmt" + "reflect" "strconv" "strings" @@ -10,10 +11,23 @@ import ( capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" host "github.com/cosmos/ibc-go/v7/modules/core/24-host" "github.com/cosmos/ibc-go/v7/modules/core/exported" ) +var ( + _ porttypes.IBCModule = (*IBCModule)(nil) + _ porttypes.PacketDataUnmarshaler = (*IBCModule)(nil) +) + +// applicationCallbackError is a custom error type that will be unique for testing purposes. +type applicationCallbackError struct{} + +func (applicationCallbackError) Error() string { + return "mock application callback failed" +} + // IBCModule implements the ICS26 callbacks for testing/mock. type IBCModule struct { appModule *AppModule @@ -162,6 +176,15 @@ func (im IBCModule) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, return nil } +// UnmarshalPacketData returns the MockPacketData. This function implements the optional +// PacketDataUnmarshaler interface required for ADR 008 support. +func (IBCModule) UnmarshalPacketData(bz []byte) (interface{}, error) { + if reflect.DeepEqual(bz, MockPacketData) { + return MockPacketData, nil + } + return nil, MockApplicationCallbackError +} + // GetMockRecvCanaryCapabilityName generates a capability name for testing OnRecvPacket functionality. func GetMockRecvCanaryCapabilityName(packet channeltypes.Packet) string { return fmt.Sprintf("%s%s%s%s", MockRecvCanaryCapabilityName, packet.GetDestPort(), packet.GetDestChannel(), strconv.Itoa(int(packet.GetSequence()))) diff --git a/testing/mock/mock.go b/testing/mock/mock.go index 8613c4fc5d8..80833c2b094 100644 --- a/testing/mock/mock.go +++ b/testing/mock/mock.go @@ -41,6 +41,9 @@ var ( MockRecvCanaryCapabilityName = "mock receive canary capability name" MockAckCanaryCapabilityName = "mock acknowledgement canary capability name" MockTimeoutCanaryCapabilityName = "mock timeout canary capability name" + // MockApplicationCallbackError should be returned when an application callback should fail. It is possible to + // test that this error was returned using ErrorIs. + MockApplicationCallbackError error = &applicationCallbackError{} ) var _ porttypes.IBCModule = IBCModule{} @@ -77,7 +80,7 @@ func (AppModuleBasic) ValidateGenesis(codec.JSONCodec, client.TxEncodingConfig, } // RegisterGRPCGatewayRoutes implements AppModuleBasic interface. -func (a AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {} +func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {} // GetTxCmd implements AppModuleBasic interface. func (AppModuleBasic) GetTxCmd() *cobra.Command { @@ -107,7 +110,7 @@ func NewAppModule(pk PortKeeper) AppModule { func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} // RegisterServices implements the AppModule interface. -func (am AppModule) RegisterServices(module.Configurator) {} +func (AppModule) RegisterServices(module.Configurator) {} // InitGenesis implements the AppModule interface. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { @@ -126,7 +129,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. } // ExportGenesis implements the AppModule interface. -func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { +func (AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { return nil } diff --git a/testing/mock/privval.go b/testing/mock/privval.go index c8eff94d017..0fc09423507 100644 --- a/testing/mock/privval.go +++ b/testing/mock/privval.go @@ -26,7 +26,7 @@ func NewPV() PV { // GetPubKey implements PrivValidator interface func (pv PV) GetPubKey() (crypto.PubKey, error) { - return cryptocodec.ToTmPubKeyInterface(pv.PrivKey.PubKey()) + return cryptocodec.ToCmtPubKeyInterface(pv.PrivKey.PubKey()) } // SignVote implements PrivValidator interface diff --git a/testing/path.go b/testing/path.go index 4c614194e41..43aa504d4d4 100644 --- a/testing/path.go +++ b/testing/path.go @@ -66,7 +66,6 @@ func (path *Path) RelayPacket(packet channeltypes.Packet) error { func (path *Path) RelayPacketWithResults(packet channeltypes.Packet) (*abci.ExecTxResult, []byte, error) { pc := path.EndpointA.Chain.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(path.EndpointA.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if bytes.Equal(pc, channeltypes.CommitPacket(path.EndpointA.Chain.App.AppCodec(), packet)) { - // packet found, relay from A to B if err := path.EndpointB.UpdateClient(); err != nil { return nil, nil, err diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 79c864e369c..5c299846a4c 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -560,7 +560,7 @@ func NewSimApp( // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper - /**** Module Options ****/ + // **** Module Options **** // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. @@ -752,7 +752,10 @@ func NewSimApp( if err != nil { // Once we switch to using protoreflect-based antehandlers, we might // want to panic here instead of logging a warning. - fmt.Fprintln(os.Stderr, err.Error()) + _, err := fmt.Fprintln(os.Stderr, err.Error()) + if err != nil { + fmt.Println("could not write to stderr") + } } if loadLatest { @@ -822,8 +825,8 @@ func (app *SimApp) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { } // Configurator returns the configurator for the app -func (a *SimApp) Configurator() module.Configurator { - return a.configurator +func (app *SimApp) Configurator() module.Configurator { + return app.configurator } // InitChainer application update at chain initialization @@ -890,8 +893,8 @@ func (app *SimApp) AutoCliOpts() autocli.AppOptions { } // DefaultGenesis returns a default genesis from the registered AppModuleBasic's. -func (a *SimApp) DefaultGenesis() map[string]json.RawMessage { - return a.BasicModuleManager.DefaultGenesis(a.appCodec) +func (app *SimApp) DefaultGenesis() map[string]json.RawMessage { + return app.BasicModuleManager.DefaultGenesis(app.appCodec) } // GetKey returns the KVStoreKey for the provided store key. diff --git a/testing/simapp/config.go b/testing/simapp/config.go deleted file mode 100644 index 98df982bd30..00000000000 --- a/testing/simapp/config.go +++ /dev/null @@ -1,75 +0,0 @@ -package simapp - -import ( - "flag" - - "github.com/cosmos/cosmos-sdk/types/simulation" -) - -// List of available flags for the simulator -var ( - FlagGenesisFileValue string - FlagParamsFileValue string - FlagExportParamsPathValue string - FlagExportParamsHeightValue int - FlagExportStatePathValue string - FlagExportStatsPathValue string - FlagSeedValue int64 - FlagInitialBlockHeightValue int - FlagNumBlocksValue int - FlagBlockSizeValue int - FlagLeanValue bool - FlagCommitValue bool - FlagOnOperationValue bool // TODO: Remove in favor of binary search for invariant violation - FlagAllInvariantsValue bool - - FlagEnabledValue bool - FlagVerboseValue bool - FlagPeriodValue uint - FlagGenesisTimeValue int64 -) - -// GetSimulatorFlags gets the values of all the available simulation flags -func GetSimulatorFlags() { - // config fields - flag.StringVar(&FlagGenesisFileValue, "Genesis", "", "custom simulation genesis file; cannot be used with params file") - flag.StringVar(&FlagParamsFileValue, "Params", "", "custom simulation params file which overrides any random params; cannot be used with genesis") - flag.StringVar(&FlagExportParamsPathValue, "ExportParamsPath", "", "custom file path to save the exported params JSON") - flag.IntVar(&FlagExportParamsHeightValue, "ExportParamsHeight", 0, "height to which export the randomly generated params") - flag.StringVar(&FlagExportStatePathValue, "ExportStatePath", "", "custom file path to save the exported app state JSON") - flag.StringVar(&FlagExportStatsPathValue, "ExportStatsPath", "", "custom file path to save the exported simulation statistics JSON") - flag.Int64Var(&FlagSeedValue, "Seed", 42, "simulation random seed") - flag.IntVar(&FlagInitialBlockHeightValue, "InitialBlockHeight", 1, "initial block to start the simulation") - flag.IntVar(&FlagNumBlocksValue, "NumBlocks", 500, "number of new blocks to simulate from the initial block height") - flag.IntVar(&FlagBlockSizeValue, "BlockSize", 200, "operations per block") - flag.BoolVar(&FlagLeanValue, "Lean", false, "lean simulation log output") - flag.BoolVar(&FlagCommitValue, "Commit", false, "have the simulation commit") - flag.BoolVar(&FlagOnOperationValue, "SimulateEveryOperation", false, "run slow invariants every operation") - flag.BoolVar(&FlagAllInvariantsValue, "PrintAllInvariants", false, "print all invariants if a broken invariant is found") - - // simulation flags - flag.BoolVar(&FlagEnabledValue, "Enabled", false, "enable the simulation") - flag.BoolVar(&FlagVerboseValue, "Verbose", false, "verbose log output") - flag.UintVar(&FlagPeriodValue, "Period", 0, "run slow invariants only once every period assertions") - flag.Int64Var(&FlagGenesisTimeValue, "GenesisTime", 0, "override genesis UNIX time instead of using a random UNIX time") -} - -// NewConfigFromFlags creates a simulation from the retrieved values of the flags. -func NewConfigFromFlags() simulation.Config { - return simulation.Config{ - GenesisFile: FlagGenesisFileValue, - ParamsFile: FlagParamsFileValue, - ExportParamsPath: FlagExportParamsPathValue, - ExportParamsHeight: FlagExportParamsHeightValue, - ExportStatePath: FlagExportStatePathValue, - ExportStatsPath: FlagExportStatsPathValue, - Seed: FlagSeedValue, - InitialBlockHeight: FlagInitialBlockHeightValue, - NumBlocks: FlagNumBlocksValue, - BlockSize: FlagBlockSizeValue, - Lean: FlagLeanValue, - Commit: FlagCommitValue, - OnOperation: FlagOnOperationValue, - AllInvariants: FlagAllInvariantsValue, - } -} diff --git a/testing/simapp/params/proto.go b/testing/simapp/params/proto.go index 2a38fff0400..4270c2b0dbf 100644 --- a/testing/simapp/params/proto.go +++ b/testing/simapp/params/proto.go @@ -16,12 +16,12 @@ import ( func MakeTestEncodingConfig() EncodingConfig { cdc := codec.NewLegacyAmino() interfaceRegistry := types.NewInterfaceRegistry() - codec := codec.NewProtoCodec(interfaceRegistry) + protoCdc := codec.NewProtoCodec(interfaceRegistry) return EncodingConfig{ InterfaceRegistry: interfaceRegistry, - Codec: codec, - TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes), + Codec: protoCdc, + TxConfig: tx.NewTxConfig(protoCdc, tx.DefaultSignModes), Amino: cdc, } } diff --git a/testing/simapp/simd/cmd/root.go b/testing/simapp/simd/cmd/root.go index 70663e25a61..5ac6a9f1cb0 100644 --- a/testing/simapp/simd/cmd/root.go +++ b/testing/simapp/simd/cmd/root.go @@ -209,7 +209,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, b genesisCommand(encodingConfig, basicManager), txCommand(basicManager), queryCommand(basicManager), - keys.Commands(simapp.DefaultNodeHome), + keys.Commands(), ) } diff --git a/testing/simapp/test_helpers.go b/testing/simapp/test_helpers.go index 470d7954317..a3c4e8764be 100644 --- a/testing/simapp/test_helpers.go +++ b/testing/simapp/test_helpers.go @@ -36,7 +36,8 @@ type SetupOptions struct { AppOpts servertypes.AppOptions } -func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) { +// initSetup initializes a new SimApp. A Nop logger is set in SimApp. +func initSetup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) { db := dbm.NewMemDB() appOptions := make(simtestutil.AppOptionsMap, 0) @@ -82,7 +83,7 @@ func Setup(t *testing.T, isCheckTx bool) *SimApp { func SetupWithGenesisValSet(t *testing.T, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *SimApp { t.Helper() - app, genesisState := setup(true, 5) + app, genesisState := initSetup(true, 5) genesisState, err := simtestutil.GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, genAccs, balances...) require.NoError(t, err) diff --git a/testing/values.go b/testing/values.go index 3e933053c23..291cf9a44b4 100644 --- a/testing/values.go +++ b/testing/values.go @@ -57,7 +57,7 @@ var ( UpgradePath = []string{"upgrade", "upgradedIBCState"} - ConnectionVersion = connectiontypes.ExportedVersionsToProto(connectiontypes.GetCompatibleVersions())[0] + ConnectionVersion = connectiontypes.GetCompatibleVersions()[0] MockAcknowledgement = mock.MockAcknowledgement.Acknowledgement() MockPacketData = mock.MockPacketData