From f129891ac8768e9ae11134e42f31fb33ff54528a Mon Sep 17 00:00:00 2001 From: Reece Williams <31943163+Reecepbcups@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:50:18 -0500 Subject: [PATCH 1/2] ci: broken links & spelling (#1431) * base * typos fixed * lint links * relative links --- .codespellrc | 5 ++ .github/workflows/chores.yml | 35 +++++++++ CHANGELOG.md | 6 +- Makefile | 2 +- README.md | 77 ++++++++++--------- cmd/keys.go | 12 +-- docs/advanced_usage.md | 8 +- docs/node_pruning.md | 2 +- docs/troubleshooting.md | 8 +- examples/README.md | 6 +- interchaintest/interchain_accounts_test.go | 2 +- interchaintest/localhost_client_test.go | 6 +- interchaintest/misbehaviour_test.go | 2 +- interchaintest/multi_channel_test.go | 2 +- interchaintest/path_filter_test.go | 4 +- interchaintest/relay_many_test.go | 2 +- interchaintest/relayer_override_test.go | 2 +- .../chains/cosmos/cosmos_chain_processor.go | 2 +- relayer/chains/cosmos/keys.go | 2 +- relayer/chains/cosmos/query.go | 2 +- relayer/chains/cosmos/tx.go | 8 +- relayer/chains/mock/mock_chain_processor.go | 2 +- relayer/chains/penumbra/keys.go | 2 +- relayer/chains/penumbra/query.go | 2 +- relayer/chains/penumbra/tx.go | 2 +- relayer/client.go | 2 +- relayer/processor/chain_processor.go | 2 +- relayer/processor/message_processor.go | 2 +- relayer/processor/metrics.go | 2 +- relayer/processor/path_end_test.go | 6 +- relayer/processor/types_internal.go | 6 +- relayer/relayMsgs.go | 2 +- 32 files changed, 133 insertions(+), 92 deletions(-) create mode 100644 .codespellrc create mode 100644 .github/workflows/chores.yml diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 000000000..a6b4ca175 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,5 @@ +[codespell] +skip = *.pulsar.go,*.pb.go,*.pb.gw.go,*.json,*.git,*.bin,*.sum,*.mod,query_test.go +ignore-words-list = usera +count = +quiet-level = 3 \ No newline at end of file diff --git a/.github/workflows/chores.yml b/.github/workflows/chores.yml new file mode 100644 index 000000000..ef47e5f31 --- /dev/null +++ b/.github/workflows/chores.yml @@ -0,0 +1,35 @@ +name: chores + +on: + pull_request: + +jobs: + link-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 + + typos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run codespell + continue-on-error: true + run: | + # .codespellrc is used + sudo apt-get install codespell -y + codespell -w --config .codespellrc + exit $? + + pr-title-format: + name: Lint PR Title + permissions: + pull-requests: read + statuses: write + contents: read + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5.4.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fe923eecd..65a5dd6e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ * [\#1226](https://github.com/cosmos/relayer/pull/1226) Avoid invalid Bech32 prefix error in parallel tests when sdk Config get overwritten by each other in single process. * [\#1231](https://github.com/cosmos/relayer/pull/1231) Reduce get bech32 prefix when get signer. * [\#1302](https://github.com/cosmos/relayer/pull/1302) Avoid packet get relayed when estimated gas is higher than max gas. -* [\#1303](https://github.com/cosmos/relayer/pull/1303) Add missing max gas amount on txf to avoid estimate less gas when simualte runTx. +* [\#1303](https://github.com/cosmos/relayer/pull/1303) Add missing max gas amount on txf to avoid estimate less gas when simulate runTx. * [\#1324](https://github.com/cosmos/relayer/pull/1324) Add log-level in global config. * [\#1325](https://github.com/cosmos/relayer/pull/1325) Ignore only file not exist error when loadConfigFile. * [\#1326](https://github.com/cosmos/relayer/pull/1326) Avoid sending channel close confirm message after channel get closed successfully. @@ -137,7 +137,7 @@ ### CLI/scripts * [\#412](https://github.com/cosmos/relayer/pull/412) Auto update clients to prevent expiry. `rly start` command supports auto updating a client if it is about to expire. Use the `--time-threshold` flag. -* [\#323](https://github.com/cosmos/relayer/pull/323) Implmenet an API server. A rest server with API endpoints to support interacting with the relayer +* [\#323](https://github.com/cosmos/relayer/pull/323) Implement an API server. A rest server with API endpoints to support interacting with the relayer * [\#406](https://github.com/cosmos/relayer/pull/406) Split `add-dir` into `add-chains` and `add-paths`. You must add a chain, then the keys, and then the paths. This enables support of bottom up validation. * [\#428](https://github.com/cosmos/relayer/pull/428) Fix add-paths failure when called on exiting configuration * [\#427](https://github.com/cosmos/relayer/pull/427) Fix nil paths bug which occurred when validating paths @@ -154,5 +154,5 @@ * (deps) Bump SDK version to [v0.41.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.41.0). * Bug fixes and minor improvements -* (relayer)[\#329](https://github.com/cosmos/relayer/issues/329) client, conenction, and channel handshake refactor (identifiers generated auto generated on-chain) +* (relayer)[\#329](https://github.com/cosmos/relayer/issues/329) client, connection, and channel handshake refactor (identifiers generated auto generated on-chain) * (relayer)[\#386](https://github.com/cosmos/relayer/pull/386) client, connection and channel identifier reuse diff --git a/Makefile b/Makefile index d27c4c7ec..874515ffd 100644 --- a/Makefile +++ b/Makefile @@ -115,7 +115,7 @@ get-gaia: @git clone --branch $(GAIA_VERSION) --depth=1 https://github.com/cosmos/gaia.git $(GAIA_REPO) build-gaia: - @[ -d $(GAIA_REPO) ] || { echo "Repositry for gaia does not exist at $(GAIA_REPO). Try running 'make get-gaia'..." ; exit 1; } + @[ -d $(GAIA_REPO) ] || { echo "Repository for gaia does not exist at $(GAIA_REPO). Try running 'make get-gaia'..." ; exit 1; } @cd $(GAIA_REPO) && \ make install &> /dev/null @gaiad version --long diff --git a/README.md b/README.md index b67da9dfb..48af4767a 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,12 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/cosmos/relayer)](https://goreportcard.com/report/github.com/cosmos/relayer) [![License: Apache-2.0](https://img.shields.io/github/license/cosmos/relayer.svg?style=flat-square)](https://github.com/cosmos/relayer/blob/main/LICENSE) [![Lines Of Code](https://img.shields.io/tokei/lines/github/cosmos/relayer?style=flat-square)](https://github.com/cosmos/relayer) -[![Version](https://img.shields.io/github/tag/cosmos/relayer.svg?style=flat-square)](https://github.com/cosmos/relayer/latest) +[![Version](https://img.shields.io/github/tag/cosmos/relayer.svg?style=flat-square)](https://github.com/cosmos/relayer/releases/latest) -In IBC, blockchains do not directly pass messages to each other over the network. This is where `relayer` comes in. +In IBC, blockchains do not directly pass messages to each other over the network. This is where `relayer` comes in. A relayer process monitors for updates on opens paths between sets of [IBC](https://ibcprotocol.org/) enabled chains. -The relayer submits these updates in the form of specific message types to the counterparty chain. Clients are then used to +The relayer submits these updates in the form of specific message types to the counterparty chain. Clients are then used to track and verify the consensus state. In addition to relaying packets, this relayer can open paths across chains, thus creating clients, connections and channels. @@ -24,7 +24,7 @@ Additional information on how IBC works can be found [here](https://ibc.cosmos.n --- ## Table Of Contents -- [Basic Usage - Relaying Across Chains](#Basic-Usage---Relaying-Packets-Across-Chains) +- [Basic Usage - Relaying Across Chains](#basic-usage---relaying-packets-across-chains) - [Create Path Across Chains](./docs/create-path-across-chain.md) - [Advanced Usage](./docs/advanced_usage.md) - [Troubleshooting](./docs/troubleshooting.md) @@ -35,6 +35,7 @@ Additional information on how IBC works can be found [here](https://ibc.cosmos.n - [Demo/Dev-Environment](./examples/README.md) --- + ## Basic Usage - Relaying Packets Across Chains > The `-h` (help) flag tailing any `rly` command will be your best friend. USE THIS IN YOUR RELAYING JOURNEY. @@ -52,7 +53,7 @@ Additional information on how IBC works can be found [here](https://ibc.cosmos.n ``` 2. **Initialize the relayer's configuration directory/file.** - + ```shell $ rly config init ``` @@ -66,26 +67,26 @@ Additional information on how IBC works can be found [here](https://ibc.cosmos.n $ rly config init --memo "My custom memo" ``` - Custom memos will have `rly(VERSION)` appended. For example, a memo of `My custom memo` running on relayer version `v2.5.2` would result in a transaction memo of `My custom memo | rly(v2.5.2)`. - + Custom memos will have `rly(VERSION)` appended. For example, a memo of `My custom memo` running on relayer version `v2.5.2` would result in a transaction memo of `My custom memo | rly(v2.5.2)`. + The `--memo` flag is also available for other `rly` commands also that involve sending transactions such as `rly tx link` and `rly start`. It can be passed there to override the `config.yaml` value if desired. To omit the memo entirely, including the default value of `rly(VERSION)`, use `-` for the memo. 3. **Configure the chains you want to relay between.** - - In our example, we will configure the relayer to operate on the canonical path between the Cosmos Hub and Osmosis. + + In our example, we will configure the relayer to operate on the canonical path between the Cosmos Hub and Osmosis.
The `rly chains add` command fetches chain meta-data from the [chain-registry](https://github.com/cosmos/chain-registry) and adds it to your config file. - + ```shell $ rly chains add cosmoshub osmosis ``` - - Adding chains from the chain-registry randomly selects an RPC address from the registry entry. - If you are running your own node, manually go into the config and adjust the `rpc-addr` setting. - > NOTE: `rly chains add` will check the liveliness of the available RPC endpoints for that chain in the chain-registry. + Adding chains from the chain-registry randomly selects an RPC address from the registry entry. + If you are running your own node, manually go into the config and adjust the `rpc-addr` setting. + + > NOTE: `rly chains add` will check the liveliness of the available RPC endpoints for that chain in the chain-registry. > It is possible that the command will fail if none of these RPC endpoints are available. In this case, you will want to manually add the chain config. To add the chain config files manually, example config files have been included [here](https://github.com/cosmos/relayer/tree/main/docs/example-configs/) @@ -93,18 +94,18 @@ Additional information on how IBC works can be found [here](https://ibc.cosmos.n $ rly chains add --url https://raw.githubusercontent.com/cosmos/relayer/main/docs/example-configs/cosmoshub-4.json cosmoshub $ rly chains add --url https://raw.githubusercontent.com/cosmos/relayer/main/docs/example-configs/osmosis-1.json osmosis ``` - + 4. **Import OR create new keys for the relayer to use when signing and relaying transactions.** - >`key-name` is an identifier of your choosing. + >`key-name` is an identifier of your choosing. If you need to generate a new private key you can use the `add` subcommand. ```shell - $ rly keys add cosmoshub [key-name] - $ rly keys add osmosis [key-name] + $ rly keys add cosmoshub [key-name] + $ rly keys add osmosis [key-name] ``` - + If you already have a private key and want to restore it from your mnemonic you can use the `restore` subcommand. ```shell @@ -115,18 +116,18 @@ Additional information on how IBC works can be found [here](https://ibc.cosmos.n 5. **Use the `key-name` created above.** >This step is necessary if you chose a `key-name` other than "default" - + ```shell - $ rly keys use cosmoshub [key-name] - $ rly keys use osmosis [key-name] + $ rly keys use cosmoshub [key-name] + $ rly keys use osmosis [key-name] ``` 6. **Ensure the keys associated with the configured chains are funded.** - >Your configured addresses will need to contain some of the respective native tokens for paying relayer fees. - + >Your configured addresses will need to contain some of the respective native tokens for paying relayer fees. +
- You can query the balance of each configured key by running: + You can query the balance of each configured key by running: ```shell $ rly q balance cosmoshub @@ -135,7 +136,7 @@ Additional information on how IBC works can be found [here](https://ibc.cosmos.n 7. **Configure path meta-data in config file.**
- We have the chain meta-data configured, now we need path meta-data. For more info on `path` terminology visit [here](docs/troubleshooting.md). + We have the chain meta-data configured, now we need path meta-data. For more info on `path` terminology visit [here](docs/troubleshooting.md). >NOTE: Thinking of chains in the config as "source" and "destination" can be confusing. Be aware that most path are bi-directional.
@@ -145,22 +146,22 @@ Additional information on how IBC works can be found [here](https://ibc.cosmos.n ```shell $ rly paths fetch ``` - > **NOTE:** Don't see the path metadata for paths you want to relay on? + > **NOTE:** Don't see the path metadata for paths you want to relay on? > Please open a PR to add this metadata to the GitHub repo! 8. #### **Configure the channel filter.** - - By default, the relayer will relay packets over all channels on a given connection. + + By default, the relayer will relay packets over all channels on a given connection.
- Each path has a `src-channel-filter` which you can utilize to specify which channels you would like to relay on. + Each path has a `src-channel-filter` which you can utilize to specify which channels you would like to relay on.
- The `rule` can be one of three values: + The `rule` can be one of three values: - `allowlist` which tells the relayer to relay on _ONLY_ the channels in `channel-list` - `denylist` which tells the relayer to relay on all channels _BESIDES_ the channels in `channel-list` - - empty value, which is the default setting, and tells the relayer to relay on all channels + - empty value, which is the default setting, and tells the relayer to relay on all channels
- - Since we are only worried about the canonical channel between the Cosmos Hub and Osmosis our filter settings would look like the following. + + Since we are only worried about the canonical channel between the Cosmos Hub and Osmosis our filter settings would look like the following.
Example: ```yaml @@ -175,9 +176,9 @@ Additional information on how IBC works can be found [here](https://ibc.cosmos.n connection-id: connection-1 src-channel-filter: rule: allowlist - channel-list: [channel-141] + channel-list: [channel-141] ``` - + >Because two channels between chains are tightly coupled, there is no need to specify the dst channels. >If you only know the "dst" channel-ID you can query the "src" channel-ID by running: `rly q channel | jq '.channel.counterparty.channel_id'` @@ -189,9 +190,9 @@ Additional information on how IBC works can be found [here](https://ibc.cosmos.n $ rly paths list $ rly start [path] # Optionally you can omit the `path` argument to start all configured paths - $ rly start + $ rly start ``` - + >When running multiple instances of `rly start`, you will need to use the `--debug-addr` flag and provide an address:port. You can also pass an empty string `''` to turn off this feature or pass `localhost:0` to randomly select a port. --- diff --git a/cmd/keys.go b/cmd/keys.go index ec7013c35..a7a907b4e 100644 --- a/cmd/keys.go +++ b/cmd/keys.go @@ -73,7 +73,7 @@ $ %s keys use ibc-0 key_name`, appName)), return cmd } -// keysAddCmd respresents the `keys add` command +// keysAddCmd represents the `keys add` command func keysAddCmd(a *appState) *cobra.Command { cmd := &cobra.Command{ Use: "add chain_name key_name", @@ -143,7 +143,7 @@ $ %s k a cosmoshub testkey`, appName, appName, appName)), return cmd } -// keysRestoreCmd respresents the `keys add` command +// keysRestoreCmd represents the `keys add` command func keysRestoreCmd(a *appState) *cobra.Command { cmd := &cobra.Command{ Use: "restore chain_name key_name mnemonic", @@ -265,7 +265,7 @@ $ %s k r demo-key "[mnemonic-words]" --restore-all`, appName, appName, appName)) return cmd } -// keysDeleteCmd respresents the `keys delete` command +// keysDeleteCmd represents the `keys delete` command func keysDeleteCmd(a *appState) *cobra.Command { cmd := &cobra.Command{ Use: "delete chain_name key_name", @@ -326,7 +326,7 @@ func askForConfirmation(a *appState, stdin io.Reader, stderr io.Writer) bool { } } -// keysListCmd respresents the `keys list` command +// keysListCmd represents the `keys list` command func keysListCmd(a *appState) *cobra.Command { cmd := &cobra.Command{ Use: "list chain_name", @@ -364,7 +364,7 @@ $ %s k l ibc-1`, appName, appName)), return cmd } -// keysExportCmd respresents the `keys export` command +// keysExportCmd represents the `keys export` command func keysExportCmd(a *appState) *cobra.Command { cmd := &cobra.Command{ Use: "export chain_name key_name", @@ -425,7 +425,7 @@ func (a *appState) showAddressByChainAndKey(cmd *cobra.Command, args []string) e return nil } -// keysShowCmd respresents the `keys show` command +// keysShowCmd represents the `keys show` command func keysShowCmd(a *appState) *cobra.Command { cmd := &cobra.Command{ Use: "show chain_name [key_name]", diff --git a/docs/advanced_usage.md b/docs/advanced_usage.md index 83230db62..34624083a 100644 --- a/docs/advanced_usage.md +++ b/docs/advanced_usage.md @@ -22,7 +22,7 @@ Exported metrics: | cosmos_relayer_client_expiration_seconds | Seconds until the client expires | Gauge | | cosmos_relayer_client_trusting_period_seconds | The trusting period (in seconds) of the client | Gauge | | cosmos_relayer_unrelayed_packets | Current number of unrelayed packet sequences on a specific path and channel. This is updated after each flush (default is 5 min) | Gauge | -| cosmos_relayer_unrelayed_acks | Current number of unrelayed acknoledgment sequences on a specific path and channel. This is updated after each flush (default is 5 min) | Gauge | +| cosmos_relayer_unrelayed_acks | Current number of unrelayed acknowledgment sequences on a specific path and channel. This is updated after each flush (default is 5 min) | Gauge | @@ -31,7 +31,7 @@ Exported metrics: ## Auto Update Light Client -By default, the Relayer will automatically update clients (`MsgUpdateClient`) if the client has <= 1/3 of its trusting period left. +By default, the Relayer will automatically update clients (`MsgUpdateClient`) if the client has <= 1/3 of its trusting period left. > NOTE: The trusting period of the corresponding client is restored with each transaction a relayer relays. In other words, every time a relayer relays a message, it also sends a `MsgUpdateClient` message restarting the time to the clients expiration.* @@ -49,8 +49,8 @@ Example: Selecting a time-threshold that is greater than 2/3 of the client trusting period will deem itself useless. Use cases for configuring the `--time-threshold` flag: -- The underlying chain node that the relayer is using as an endpoint has restrictive pruning. Client updates are needed more frequently since states 2/3 trusting period ago would not be available due to pruning. -- Mitiage relayer operational errors allowing more frequent updates incase a relayer node goes down for > the client trusting period. +- The underlying chain node that the relayer is using as an endpoint has restrictive pruning. Client updates are needed more frequently since states 2/3 trusting period ago would not be available due to pruning. +- Mitiage relayer operational errors allowing more frequent updates in case a relayer node goes down for > the client trusting period. \* It is not mandatory for relayers to include the `MsgUpdateClient` when relaying packets, however most, if not all relayers currently do. diff --git a/docs/node_pruning.md b/docs/node_pruning.md index d50a30167..f62254075 100644 --- a/docs/node_pruning.md +++ b/docs/node_pruning.md @@ -17,4 +17,4 @@ Here are the settings used to configure SDK-based full nodes (assuming 3 week un Note, operators can tweak `--pruning-keep-every` and `--pruning-interval` to their liking. -[<-- Relayer Terminology](./terminology.md) - [Demo -->](./demo.md) \ No newline at end of file +[<-- Relayer Terminology](./terminology.md) - [Demo -->](../examples/README.md) \ No newline at end of file diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 10c35c739..1988a16fa 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -1,6 +1,6 @@ # Troubleshooting -- [Generic Troubleshooting](#generic-troubleshoot) +- [Generic Troubleshooting](#generic-troubleshooting) - [Inspect Go Runtime Debug Data](#inspect-go-runtime-debug-data) - [Specific Errors](#specific-errors) @@ -14,12 +14,12 @@ ### **Ensure `rly` package is properly installed** - Run: + Run: ```shell $ rly version ``` - If this returns an error, make sure you have Go installed and your Go environment is setup. Then redo [Step 1](#basic-usage---relaying-packets-across-chains). + If this returns an error, make sure you have Go installed and your Go environment is setup. Then redo [Step 1](../README.md#basic-usage---relaying-packets-across-chains). ### **Verify valid `keys`, `balance`, and `path`** @@ -131,7 +131,7 @@ A workaround is available in which the `min-gas-amount` may be set in the chain' invalid header: new header has a time from the future
-This is most likely an rpc issue. +This is most likely an rpc issue. The latest block time on the source and destination chain have likely drifted apart. You can confirm by this by checking the latest block time on each chain: diff --git a/examples/README.md b/examples/README.md index bbac9c71f..293e0992d 100644 --- a/examples/README.md +++ b/examples/README.md @@ -17,11 +17,11 @@ cd examples/demo/ ./dev-env ``` -This script creates a folder called "data": `examples/demo/data/`. +This script creates a folder called "data": `examples/demo/data/`. Logs and config info for each chain can be found here. -Note: After running, two `gaiad` instances will be running on your machine. +Note: After running, two `gaiad` instances will be running on your machine. To kill ALL `gaiad` instances run: ```bash killall gaiad @@ -40,4 +40,4 @@ This is an example of a config file with: --- -[<-- Pruning Settings](../node_pruning.md) \ No newline at end of file +[<-- Pruning Settings](../docs/node_pruning.md) \ No newline at end of file diff --git a/interchaintest/interchain_accounts_test.go b/interchaintest/interchain_accounts_test.go index dbdb71bdf..4b3653096 100644 --- a/interchaintest/interchain_accounts_test.go +++ b/interchaintest/interchain_accounts_test.go @@ -129,7 +129,7 @@ func TestScenarioInterchainAccounts(t *testing.T) { func() { err := r.StopRelayer(ctx, eRep) if err != nil { - t.Logf("an error occured while stopping the relayer: %s", err) + t.Logf("an error occurred while stopping the relayer: %s", err) } }, ) diff --git a/interchaintest/localhost_client_test.go b/interchaintest/localhost_client_test.go index 845a46763..da794e1e5 100644 --- a/interchaintest/localhost_client_test.go +++ b/interchaintest/localhost_client_test.go @@ -202,7 +202,7 @@ func TestLocalhost_TokenTransfers(t *testing.T) { func() { err := r.StopRelayer(ctx, eRep) if err != nil { - panic(fmt.Errorf("an error occured while stopping the relayer: %s", err)) + panic(fmt.Errorf("an error occurred while stopping the relayer: %s", err)) } }, ) @@ -399,7 +399,7 @@ func TestLocalhost_InterchainAccounts(t *testing.T) { func() { err := r.StopRelayer(ctx, eRep) if err != nil { - panic(fmt.Errorf("an error occured while stopping the relayer: %s", err)) + panic(fmt.Errorf("an error occurred while stopping the relayer: %s", err)) } }, ) @@ -449,7 +449,7 @@ func TestLocalhost_InterchainAccounts(t *testing.T) { icaAddr := parseInterchainAccountField(stdout) require.NotEmpty(t, icaAddr) - // asser the ICA balance, send some funds to the ICA, then re-assert balances + // assert the ICA balance, send some funds to the ICA, then re-assert balances icaBal, err := chainA.GetBalance(ctx, icaAddr, chainA.Config().Denom) require.NoError(t, err) require.True(t, sdkmath.ZeroInt().Equal(icaBal)) diff --git a/interchaintest/misbehaviour_test.go b/interchaintest/misbehaviour_test.go index 5714b5de4..9b02a8b5c 100644 --- a/interchaintest/misbehaviour_test.go +++ b/interchaintest/misbehaviour_test.go @@ -118,7 +118,7 @@ func TestRelayerMisbehaviourDetection(t *testing.T) { func() { err := r.StopRelayer(ctx, eRep) if err != nil { - panic(fmt.Errorf("an error occured while stopping the relayer: %s", err)) + panic(fmt.Errorf("an error occurred while stopping the relayer: %s", err)) } }, ) diff --git a/interchaintest/multi_channel_test.go b/interchaintest/multi_channel_test.go index e1fe87eca..1a1636104 100644 --- a/interchaintest/multi_channel_test.go +++ b/interchaintest/multi_channel_test.go @@ -108,7 +108,7 @@ func TestMultipleChannelsOneConnection(t *testing.T) { func() { err := r.StopRelayer(ctx, eRep) if err != nil { - t.Logf("an error occured while stopping the relayer: %s", err) + t.Logf("an error occurred while stopping the relayer: %s", err) } }, ) diff --git a/interchaintest/path_filter_test.go b/interchaintest/path_filter_test.go index 93506bd6a..0da923df7 100644 --- a/interchaintest/path_filter_test.go +++ b/interchaintest/path_filter_test.go @@ -95,7 +95,7 @@ func TestScenarioPathFilterAllow(t *testing.T) { func() { err := r.StopRelayer(ctx, eRep) if err != nil { - t.Logf("an error occured while stopping the relayer: %s", err) + t.Logf("an error occurred while stopping the relayer: %s", err) } }, ) @@ -241,7 +241,7 @@ func TestScenarioPathFilterDeny(t *testing.T) { func() { err := r.StopRelayer(ctx, eRep) if err != nil { - t.Logf("an error occured while stopping the relayer: %s", err) + t.Logf("an error occurred while stopping the relayer: %s", err) } }, ) diff --git a/interchaintest/relay_many_test.go b/interchaintest/relay_many_test.go index 384604ab8..a9c5d85eb 100644 --- a/interchaintest/relay_many_test.go +++ b/interchaintest/relay_many_test.go @@ -107,7 +107,7 @@ func TestRelayerMultiplePathsSingleProcess(t *testing.T) { func() { err := r.StopRelayer(ctx, eRep) if err != nil { - t.Logf("an error occured while stopping the relayer: %s", err) + t.Logf("an error occurred while stopping the relayer: %s", err) } }, ) diff --git a/interchaintest/relayer_override_test.go b/interchaintest/relayer_override_test.go index 9c1d42b58..f6d215d62 100644 --- a/interchaintest/relayer_override_test.go +++ b/interchaintest/relayer_override_test.go @@ -93,7 +93,7 @@ func TestClientOverrideFlag(t *testing.T) { func() { err := r.StopRelayer(ctx, eRep) if err != nil { - t.Logf("an error occured while stopping the relayer: %s", err) + t.Logf("an error occurred while stopping the relayer: %s", err) } }, ) diff --git a/relayer/chains/cosmos/cosmos_chain_processor.go b/relayer/chains/cosmos/cosmos_chain_processor.go index a88cf4f13..26004e64c 100644 --- a/relayer/chains/cosmos/cosmos_chain_processor.go +++ b/relayer/chains/cosmos/cosmos_chain_processor.go @@ -578,7 +578,7 @@ func (ccp *CosmosChainProcessor) CurrentRelayerBalance(ctx context.Context) { address, err := ccp.chainProvider.Address() if err != nil { ccp.log.Error( - "Failed to get relayer bech32 wallet addresss", + "Failed to get relayer bech32 wallet address", zap.Error(err), ) } diff --git a/relayer/chains/cosmos/keys.go b/relayer/chains/cosmos/keys.go index ff4ecdb05..3f2650b19 100644 --- a/relayer/chains/cosmos/keys.go +++ b/relayer/chains/cosmos/keys.go @@ -226,7 +226,7 @@ func CreateMnemonic() (string, error) { } // EncodeBech32AccAddr returns the string bech32 representation for the specified account address. -// It returns an empty sting if the byte slice is 0-length. +// It returns an empty string if the byte slice is 0-length. // It returns an error if the bech32 conversion fails or the prefix is empty. func (cc *CosmosProvider) EncodeBech32AccAddr(addr sdk.AccAddress) (string, error) { return sdk.Bech32ifyAddressBytes(cc.PCfg.AccountPrefix, addr) diff --git a/relayer/chains/cosmos/query.go b/relayer/chains/cosmos/query.go index 48886072f..272d15a97 100644 --- a/relayer/chains/cosmos/query.go +++ b/relayer/chains/cosmos/query.go @@ -379,7 +379,7 @@ func (cc *CosmosProvider) QueryTendermintProof(ctx context.Context, height int64 // ABCI queries at heights 1, 2 or less than or equal to 0 are not supported. // Base app does not support queries for height less than or equal to 1. // Therefore, a query at height 2 would be equivalent to a query at height 3. - // A height of 0 will query with the lastest state. + // A height of 0 will query with the latest state. if height != 0 && height <= 2 { return nil, nil, clienttypes.Height{}, fmt.Errorf("proof queries at height <= 2 are not supported") } diff --git a/relayer/chains/cosmos/tx.go b/relayer/chains/cosmos/tx.go index 89d76e033..eb8d03023 100644 --- a/relayer/chains/cosmos/tx.go +++ b/relayer/chains/cosmos/tx.go @@ -324,7 +324,7 @@ func (cc *CosmosProvider) SendMsgsWith(ctx context.Context, msgs []sdk.Msg, memo err = func() error { //done := cc.SetSDKContext() - // ensure that we allways call done, even in case of an error or panic + // ensure that we always call done, even in case of an error or panic //defer done() if err = tx.Sign(ctx, txf, signingKey, txb, false); err != nil { @@ -439,7 +439,7 @@ func (cc *CosmosProvider) waitForTx( cc.log.Error("Failed to wait for block inclusion", zap.Error(err)) if len(callbacks) > 0 { for _, cb := range callbacks { - //Call each callback in order since waitForTx is already invoked asyncronously + //Call each callback in order since waitForTx is already invoked asynchronously cb(nil, err) } } @@ -467,7 +467,7 @@ func (cc *CosmosProvider) waitForTx( } if len(callbacks) > 0 { for _, cb := range callbacks { - //Call each callback in order since waitForTx is already invoked asyncronously + //Call each callback in order since waitForTx is already invoked asynchronously cb(nil, err) } } @@ -477,7 +477,7 @@ func (cc *CosmosProvider) waitForTx( if len(callbacks) > 0 { for _, cb := range callbacks { - //Call each callback in order since waitForTx is already invoked asyncronously + //Call each callback in order since waitForTx is already invoked asynchronously cb(rlyResp, nil) } } diff --git a/relayer/chains/mock/mock_chain_processor.go b/relayer/chains/mock/mock_chain_processor.go index f0e4b8173..ead607cc4 100644 --- a/relayer/chains/mock/mock_chain_processor.go +++ b/relayer/chains/mock/mock_chain_processor.go @@ -153,7 +153,7 @@ func (mcp *MockChainProcessor) queryCycle(ctx context.Context, persistence *quer // iterate through ibc messages and call specific handler for each // will do things like mutate chainprocessor state and add relevant messages to foundMessages - // this can be parralelized also + // this can be parallelized also for _, m := range messages { if handler, ok := messageHandlers[m.EventType]; ok { handler(msgHandlerParams{ diff --git a/relayer/chains/penumbra/keys.go b/relayer/chains/penumbra/keys.go index 0c6131fda..8c112c7e5 100644 --- a/relayer/chains/penumbra/keys.go +++ b/relayer/chains/penumbra/keys.go @@ -211,7 +211,7 @@ func CreateMnemonic() (string, error) { } // EncodeBech32AccAddr returns the string bech32 representation for the specified account address. -// It returns an empty sting if the byte slice is 0-length. +// It returns an empty string if the byte slice is 0-length. // It returns an error if the bech32 conversion fails or the prefix is empty. func (cc *PenumbraProvider) EncodeBech32AccAddr(addr sdk.AccAddress) (string, error) { return sdk.Bech32ifyAddressBytes(cc.PCfg.AccountPrefix, addr) diff --git a/relayer/chains/penumbra/query.go b/relayer/chains/penumbra/query.go index 9aa86c5e3..391a006f9 100644 --- a/relayer/chains/penumbra/query.go +++ b/relayer/chains/penumbra/query.go @@ -166,7 +166,7 @@ func (cc *PenumbraProvider) QueryTendermintProof(ctx context.Context, height int // ABCI queries at heights 1, 2 or less than or equal to 0 are not supported. // Base app does not support queries for height less than or equal to 1. // Therefore, a query at height 2 would be equivalent to a query at height 3. - // A height of 0 will query with the lastest state. + // A height of 0 will query with the latest state. if height != 0 && height <= 2 { return nil, nil, clienttypes.Height{}, fmt.Errorf("proof queries at height <= 2 are not supported") } diff --git a/relayer/chains/penumbra/tx.go b/relayer/chains/penumbra/tx.go index 4475c89a7..7c99e4416 100644 --- a/relayer/chains/penumbra/tx.go +++ b/relayer/chains/penumbra/tx.go @@ -935,7 +935,7 @@ func (cc *PenumbraProvider) MsgSubmitMisbehaviour(clientID string, misbehaviour return NewPenumbraMessage(msg), nil } -// mustGetHeight takes the height inteface and returns the actual height +// mustGetHeight takes the height interface and returns the actual height func mustGetHeight(h ibcexported.Height) clienttypes.Height { height, ok := h.(clienttypes.Height) if !ok { diff --git a/relayer/client.go b/relayer/client.go index 085fe0aee..0ad34b1bc 100644 --- a/relayer/client.go +++ b/relayer/client.go @@ -494,7 +494,7 @@ func UpgradeClient( return nil } -// MustGetHeight takes the height inteface and returns the actual height +// MustGetHeight takes the height interface and returns the actual height func MustGetHeight(h ibcexported.Height) clienttypes.Height { height, ok := h.(clienttypes.Height) if !ok { diff --git a/relayer/processor/chain_processor.go b/relayer/processor/chain_processor.go index aaccbd06d..86ae75deb 100644 --- a/relayer/processor/chain_processor.go +++ b/relayer/processor/chain_processor.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/relayer/v2/relayer/provider" ) -// The ChainProcessor interface is reponsible for polling blocks and emitting IBC message events to the PathProcessors. +// The ChainProcessor interface is responsible for polling blocks and emitting IBC message events to the PathProcessors. // It is also responsible for tracking open channels and not sending messages to the PathProcessors for closed channels. type ChainProcessor interface { // Run starts the query loop for the chain which will gather applicable ibc messages and push events out to the relevant PathProcessors. diff --git a/relayer/processor/message_processor.go b/relayer/processor/message_processor.go index b13ffa7cc..602c588c8 100644 --- a/relayer/processor/message_processor.go +++ b/relayer/processor/message_processor.go @@ -34,7 +34,7 @@ type messageProcessor struct { isLocalhost bool } -// catagories of tx errors for a Prometheus counter. If the error doesnt fall into one of the below categories, it is labeled as "Tx Failure" +// categories of tx errors for a Prometheus counter. If the error doesn't fall into one of the below categories, it is labeled as "Tx Failure" var promErrorCatagories = []error{ chantypes.ErrRedundantTx, legacyerrors.ErrInsufficientFunds, diff --git a/relayer/processor/metrics.go b/relayer/processor/metrics.go index 2630fcd2b..37c6b9c74 100644 --- a/relayer/processor/metrics.go +++ b/relayer/processor/metrics.go @@ -101,7 +101,7 @@ func NewPrometheusMetrics() *PrometheusMetrics { }, walletLabels), TxFailureError: registerer.NewCounterVec(prometheus.CounterOpts{ Name: "cosmos_relayer_tx_errors_total", - Help: "The total number of tx failures broken up into categories. See https://github.com/cosmos/relayer/blob/main/docs/advanced_usage.md#monitoring for list of catagories. 'Tx Failure' is the catch-all category", + Help: "The total number of tx failures broken up into categories. See https://github.com/cosmos/relayer/blob/main/docs/advanced_usage.md#monitoring for list of categories. 'Tx Failure' is the catch-all category", }, txFailureLabels), BlockQueryFailure: registerer.NewCounterVec(prometheus.CounterOpts{ Name: "cosmos_relayer_block_query_errors_total", diff --git a/relayer/processor/path_end_test.go b/relayer/processor/path_end_test.go index c0a133463..7e3125f85 100644 --- a/relayer/processor/path_end_test.go +++ b/relayer/processor/path_end_test.go @@ -14,7 +14,7 @@ const ( testChannel1 = "test-channel-1" testChannel2 = "test-channel-2" - testPort = "trasnfer" + testPort = "transfer" testPort2 = "ica-XXX" ) @@ -64,8 +64,8 @@ func TestNoChannelFilter(t *testing.T) { }, } - require.False(t, mockPathEndRuntime.ShouldRelayChannel(mockChannel2), "allowed channel to be relayed, even though it was outside of cached state; this channel does not pertain to a src or dest chain in the path secion of the config") - require.False(t, mockPathEndRuntime.ShouldRelayChannel(mockCounterpartyChanne2), "allowed channel to be relayed, even though it was outside of cached state; this channel does not pertain to a src or dest chain in the path secion of the config") + require.False(t, mockPathEndRuntime.ShouldRelayChannel(mockChannel2), "allowed channel to be relayed, even though it was outside of cached state; this channel does not pertain to a src or dest chain in the path section of the config") + require.False(t, mockPathEndRuntime.ShouldRelayChannel(mockCounterpartyChanne2), "allowed channel to be relayed, even though it was outside of cached state; this channel does not pertain to a src or dest chain in the path section of the config") } diff --git a/relayer/processor/types_internal.go b/relayer/processor/types_internal.go index c3079cd12..24f91032d 100644 --- a/relayer/processor/types_internal.go +++ b/relayer/processor/types_internal.go @@ -74,7 +74,7 @@ func (msg packetIBCMessage) assemble( assembleMessage = dst.chainProvider.MsgTimeout default: - return nil, fmt.Errorf("unexepected packet message eventType for message assembly: %s", msg.eventType) + return nil, fmt.Errorf("unexpected packet message eventType for message assembly: %s", msg.eventType) } if src.clientState.ClientID == ibcexported.LocalhostClientID { packetProof = src.localhostSentinelProofPacket @@ -166,7 +166,7 @@ func (msg channelIBCMessage) assemble( chanProof = src.chainProvider.ChannelProof assembleMessage = dst.chainProvider.MsgChannelCloseConfirm default: - return nil, fmt.Errorf("unexepected channel message eventType for message assembly: %s", msg.eventType) + return nil, fmt.Errorf("unexpected channel message eventType for message assembly: %s", msg.eventType) } if src.clientState.ClientID == ibcexported.LocalhostClientID { chanProof = src.localhostSentinelProofChannel @@ -242,7 +242,7 @@ func (msg connectionIBCMessage) assemble( connProof = src.chainProvider.ConnectionProof assembleMessage = dst.chainProvider.MsgConnectionOpenConfirm default: - return nil, fmt.Errorf("unexepected connection message eventType for message assembly: %s", msg.eventType) + return nil, fmt.Errorf("unexpected connection message eventType for message assembly: %s", msg.eventType) } var proof provider.ConnectionProof diff --git a/relayer/relayMsgs.go b/relayer/relayMsgs.go index ac87734f9..23e55fdad 100644 --- a/relayer/relayMsgs.go +++ b/relayer/relayMsgs.go @@ -124,7 +124,7 @@ func (r SendMsgsResult) PartiallySent() bool { (r.SrcSendError != nil || r.DstSendError != nil) } -// Error returns any accumulated erors that occurred while sending messages. +// Error returns any accumulated errors that occurred while sending messages. func (r SendMsgsResult) Error() error { return multierr.Append(r.SrcSendError, r.DstSendError) } From bc46373aad07747bbc3c8e1e01d11664a042edba Mon Sep 17 00:00:00 2001 From: Dan Kanefsky <56059752+boojamya@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:32:27 -0700 Subject: [PATCH 2/2] fix wallet balance metric (#1433) Co-authored-by: Justin Tieri <37750742+jtieri@users.noreply.github.com> --- .../chains/cosmos/cosmos_chain_processor.go | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/relayer/chains/cosmos/cosmos_chain_processor.go b/relayer/chains/cosmos/cosmos_chain_processor.go index 26004e64c..4a95d66a3 100644 --- a/relayer/chains/cosmos/cosmos_chain_processor.go +++ b/relayer/chains/cosmos/cosmos_chain_processor.go @@ -538,7 +538,12 @@ func (ccp *CosmosChainProcessor) CollectMetrics(ctx context.Context, persistence // Wait a while before updating the balance if time.Since(persistence.lastBalanceUpdate) > persistence.balanceUpdateWaitDuration { - ccp.CurrentRelayerBalance(ctx) + err := ccp.CurrentRelayerBalance(ctx) + if err != nil { + ccp.log.Error(fmt.Sprintf("Failed to update wallet balance metric. Will retry in %v.", persistence.balanceUpdateWaitDuration), + zap.Error(err)) + return + } persistence.lastBalanceUpdate = time.Now() } } @@ -547,7 +552,7 @@ func (ccp *CosmosChainProcessor) CurrentBlockHeight(ctx context.Context, persist ccp.metrics.SetLatestHeight(ccp.chainProvider.ChainId(), persistence.latestHeight) } -func (ccp *CosmosChainProcessor) CurrentRelayerBalance(ctx context.Context) { +func (ccp *CosmosChainProcessor) CurrentRelayerBalance(ctx context.Context) error { // memoize the current gas prices to only show metrics for "interesting" denoms gasPrice := ccp.chainProvider.PCfg.GasPrices @@ -559,10 +564,7 @@ func (ccp *CosmosChainProcessor) CurrentRelayerBalance(ctx context.Context) { gp, err := sdk.ParseDecCoins(gasPrice) if err != nil { - ccp.log.Error( - "Failed to parse gas prices", - zap.Error(err), - ) + return fmt.Errorf("failed to parse gas prices: %w", err) } ccp.parsedGasPrices = &gp } @@ -570,17 +572,11 @@ func (ccp *CosmosChainProcessor) CurrentRelayerBalance(ctx context.Context) { // Get the balance for the chain provider's key relayerWalletBalances, err := ccp.chainProvider.QueryBalance(ctx, ccp.chainProvider.Key()) if err != nil { - ccp.log.Error( - "Failed to query relayer balance", - zap.Error(err), - ) + return fmt.Errorf("failed to query relayer balance: %w", err) } address, err := ccp.chainProvider.Address() if err != nil { - ccp.log.Error( - "Failed to get relayer bech32 wallet address", - zap.Error(err), - ) + return fmt.Errorf("failed to get relayer bech32 address: %w", err) } // Print the relevant gas prices @@ -591,4 +587,5 @@ func (ccp *CosmosChainProcessor) CurrentRelayerBalance(ctx context.Context) { f, _ := big.NewFloat(0.0).SetInt(bal.BigInt()).Float64() ccp.metrics.SetWalletBalance(ccp.chainProvider.ChainId(), gasPrice, ccp.chainProvider.Key(), address, gasDenom.Denom, f) } + return nil }