IBC Relaying Guide
CosVM uses IBC (Inter-Blockchain Communication protocol) to enable cross-chain transfer of tokens. To support this capability it relies on relayers, processes that can be run by anyone which constantly scan for outbound packets on one chain and submits these packets alongside corresponding proofs on the destination chain. This section describes how one can setup a relayer and create new connections between chains. There are two standard implementations:
Hermes built in Rust
Go Relayer built in Go
The following guide explains how to establish IBC connections and relay packets between Mocha testnet and Cosmos hub testnet networks by using the Hermes relayer.
Check the latest cvmd release's go.mod
for the version of ibc-go that is currently used.
Hermes
Hermes is an open-source Rust implementation of an IBC relayer released as part of the ibc-relayer-cli
crate. It includes a CLI for relaying packets between Cosmos SDK chains, as well as Prometheus metrics and a REST API.
Please follow the steps at Hermes Quick Start to install Hermes. Before proceeding, verify that Hermes is installed correctly by running hermes version
.
TIP
Hermes currently doesn't support configuring the Tendermint CompatMode
in chain config (see hermes#3623). Until that issue is resolved, please use Hermes v1.7.0+ because it falls back to Tendermint CompatMode
v0.34 (see hermes#3663) which is compatible with CosVM.
Configuration
After you have successfully installed Hermes and created the necessary folders, you now have to edit config.toml
and add the appropriate configurations for the chains you want to relay between.
For this tutorial, we will be using the following chains:
Edit the Hermes configuration.
bash
toml
Add relayer wallets
Now that we have successfully configured our relaying chains, we need to import the wallets that will be used for relaying. Please note that both wallets need to be funded with the native tokens of each chain.
You can get testnet tokens from faucets for bot testnets via Discord:
COSVM: https://discord.gg/cosvmlabc
Cosmos Hub: https://discord.gg/cosmosnetwork
Add your seed phrase to a file and upload it to the server. Do not use wallets for anything else but relaying to avoid running into account sequence errors.
Follow the steps at adding-keys-to-hermes to add keys for each chain
bash
Verify configuration files
After editing config.toml
and adding wallet keys, it’s time to test the configurations and ensure the system is healthy. Run the following:
bash
If everything was set up correctly, you should see output like:
bash
Create a connection between 2 chains
If you’re attempting to create new connections, verify that the chains in question don’t already have connections and clients in place and use the existing ones if they do. In that case you can skip this step and go to Configure channels in Hermes section.
In this example, we are creating new clients and a new connection between mocha-4
and theta-testnet-001
networks.
Create clients
To learn if a client already exists, you can use the following command:
bash
To create a new client, use the create-client
command:
bash
Create a second client:
bash
Open connection over new clients
To create a new connection over clients, use the following command:
bash
You should be seeing a similar output to this:
bash
Now that the connection has been established over the clients, we need to create a new channel, by leveraging an existing connection:
bash
You should be seeing a similar output to this:
bash
Congratulations!
You have successfully created a new IBC connection between two networks.
Configure channels in Hermes
Now that we have created new connections and opened channels, we need to edit config.toml
again and add the newly created channels, or use the already existing ones.
For mocha-4
add:
bash
For theta-testnet-001
add:
bash
Start the relayer
Start the relayer via hermes start
Transfer
The CosVM state machine is built with the IBC transfer module, allowing for the native CosVM token to be transferred to any other IBC enabled chain. Transfer can be initialized through the cvmd
CLI. Information can be found via the help label as follows:
bash
Token filter
The transfer module uses a token filter middleware which serves to prevent non-native CosVM tokens from being on CosVM. If a user is to try to send a token from another chain across, it will be simply rejected and the token returned back to the user.
Last updated