Hermes Relayer (IBC)

Overview

This guide provides a comprehensive walkthrough on configuring a relayer using Hermes, an IBC relayer that operates as a pivotal off-chain mechanism within the IBC architecture, tasked with facilitating the relay of IBC datagrams between two distinct blockchain chains. This process involves a meticulous procedure of monitoring the state of each chain, constructing transactions based on these observations, and subsequently submitting these transactions to the relevant chains within the network.

Prerequisites

Tutorial

Step 1: Clone the Hermes Repository

git clone https://github.com/informalsystems/hermes.git
cd hermes

Step 2: Install and Set Up Hermes

cargo build --release --bin hermes

# move hermes to cargo bin
cp ./target/release/hermes ~/.cargo/bin

# check installed herems
hermes --version

# create working directory and config file for herems
mkdir ~/.hermes
touch ~/.hermes/config.toml

Step 3: Update Chain Configs

  1. Open ~/.hermes/config.toml in a text editor.

  2. Please fill in the configurations for L1 and L2 like the example below, replacing placeholder values (<...>) with actual values. You can find information on the configurations of each in the offical hermes documentation.

Make sure to use your own RPC endpoints for enhanced security and reliability.

When you setup hermes, l2'smax_block_time should be configured as 2 * create_empty_blocks_interval in your ~/.minitia/config/config.toml.

Config Example
[global]
log_level = 'info'

[mode]

[mode.clients]
enabled = true
refresh = true
misbehaviour = true

[mode.connections]
enabled = true

[mode.channels]
enabled = false

[mode.packets]
enabled = true
clear_interval = 10
clear_on_start = true
tx_confirmation = true

[rest]
enabled = true
host = '127.0.0.1'
port = 3000

[telemetry]
enabled = true
host = '127.0.0.1'
port = 3001

[[chains]]
id = '<l1-chain-id>' # mahalo-1
type = "CosmosSdk"
rpc_addr = '<l1-rpc-endpoint>' # https://rpc.mahalo-1.initia.xyz (mahalo-1)
grpc_addr = '<l1-grpc-endpoint>' # http://34.143.171.2:9090 (mahalo-1)
event_source = { mode = 'push', url = '<l1-websocket-endpoint>', batch_delay = '500ms' } # wss://rpc.mahalo-1.initia.xyz/websocket (mahalo-1)
rpc_timeout = '10s'
trusted_node = false
account_prefix = 'init'
key_name = 'relayer'
store_prefix = 'ibc'
default_gas = 100000
max_gas = 3000000
gas_price = { price = 0.15, denom = 'uinit' }
gas_multiplier = 1.5
max_msg_num = 10 # recommend set it to 10 or increase max_gas
max_tx_size = 2097152
clock_drift = '5s'
max_block_time = '10s'
address_type = { derivation = 'cosmos' }

[[chains]]
id = '<l2-chain-id>' # $L2_CHAIN_ID
type = "CosmosSdk"
rpc_addr = '<l2-rpc-endpoint>' # http://127.0.0.1:26657
grpc_addr = '<l2-grpc-endpoint>' # http://127.0.0.1:9090
# must be pull mode for miniwasm ex) event_source = { mode = 'pull', interval = '500ms' }
event_source = { mode = 'push', url = '<l2-websocket-endpoint>', batch_delay = '500ms' } # ws://127.0.0.1:26657/websocket
rpc_timeout = '10s'
trusted_node = false
account_prefix = 'init'
key_name = 'relayer'
store_prefix = 'ibc'
default_gas = 100000
max_gas = 3000000
gas_price = { price = 0.15, denom = '<denom>' } # $DENOM
gas_multiplier = 1.5
max_msg_num = 10 # recommend set it to 10 or increase max_gas
max_tx_size = 2097152
clock_drift = '5s'
# max_block_time should be configured as `2 * create_empty_blocks_interval`
# in your ~/.minitia/config/config.toml
max_block_time = '2m0s' 
address_type = { derivation = 'cosmos' }

Step 4: Create Relayer Key

  1. Ensure the relayer account has sufficient funds on both L1 and L2 chains.

  2. Set Up Relayer Keys

# create temporal keyfile for herems
echo $RELAYER_MNEMONIC > mnemonic.key

# add relayer key for the chains
hermes keys add --key-name relayer --chain $L1_CHAIN_ID --mnemonic-file ./mnemonic.key
hermes keys add --key-name relayer --chain $L2_CHAIN_ID --mnemonic-file ./mnemonic.key

rm ./mnemonic.key

Step 5: Transfer Channel

If you used minitia launch command, you can skip this step.

Create a Channel with clients and connections. This process may take up to 5 minutes.

hermes create channel \
  --a-chain $L1_CHAIN_ID \
  --b-chain $L2_CHAIN_ID \
  --a-port transfer \
  --b-port transfer \
  --new-client-connection 

SUCCESS Channel {
    ...
}

Step 6: Start Hermes

hermes start

Last updated

Logo

© 2024 Initia Foundation, All rights reserved.