Skip to content

Instantly share code, notes, and snippets.

@Galadrin
Last active June 26, 2022 17:47
Show Gist options
  • Save Galadrin/60f95a5714c334bb892ae99c1d6775c7 to your computer and use it in GitHub Desktop.
Save Galadrin/60f95a5714c334bb892ae99c1d6775c7 to your computer and use it in GitHub Desktop.
AssetMantle <> Osmosis relayer setup

Hermes

Assumptions

We assume that you already have access to AssetMantle and Osmosis nodes. These can be either local nodes, or you can access them over the network. However, for networked version, you will need to adjust the systemd configuration not to depend on the chains that are run on other servers. And naturally the hermes configuration needs to adjust the addressing of each chain as well.

The given example has all relayed chains run locally, AssetMantle is on standard ports, other chains are configured as follows:

  • Osmosis: RPC 16657 and GRPC 19090
  • Juno: RPC 36657 and GRPC 39090

In these instructions, Hermes is installed under /srv/hermes, adjust the paths according to your setup.

These instructions are based on installation on Debian 10, but should work the same on Debian 11 or recent Ubuntu.

You will need rust, build-essential and git installed to follow these instructions.

Building Hermes

For preparation, we will create a dedicated user to run Hermes. Following command will also create home directory for the new user.

sudo useradd -m -d /srv/hermes hermes

We will next switch to the hermes user and create a directory where we will compile the relayer software.

sudo sudo -u hermes -s
mkdir /srv/hermes/source
mkdir /srv/hermes/bin
cd /srv/hermes/source

Now is time to clone the source repository and build it. Note that we need to checkout the latest release.

git clone https://github.com/informalsystems/ibc-rs.git hermes
cd hermes
git checkout v0.13.0
cargo build --release
cp target/release/hermes ~/bin
cd

Next we will check that the newly built hermes version is the correct one:

hermes@demo:~$ bin/hermes version
hermes 0.13.0+f9cece40

Configuring Hermes

Choose your favourite editor and edit the following configuration template to mach your setup. There are features like telemetry and rest API that you can enable, but they are not necessary, so they are left out from this tutorial.

[global]
log_level = 'info'
[mode]
[mode.clients]
enabled = true
refresh = true
misbehaviour = false
[mode.connections]
enabled = false
[mode.channels]
enabled = false
[mode.packets]
enabled = true
clear_interval = 150
clear_on_start = false
tx_confirmation = false
[rest]
enabled = true
host = '127.0.0.1'
port = 3000
[telemetry]
enabled = true
host = '127.0.0.1'
port = 3001


[[chains]]
id = 'osmosis-1'
memo_prefix = ''

# Main chain
rpc_addr = 'http://127.0.0.1:26657'
grpc_addr = 'http://127.0.0.1:9090'
websocket_addr = 'ws://127.0.0.1:26657/websocket'

rpc_timeout = '20s'
account_prefix = 'osmo'
key_name = 'osmo-relayer'
store_prefix = 'ibc'
max_gas = 35000000
max_msg_num= 15
max_tx_size = 2097152
gas_price = { price = 0.000, denom = 'uosmo' }
gas_adjustment = 0.2
max_block_time = '10s'

clock_drift = '10s'
trusting_period = '10days'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'cosmos' }

[chains.packet_filter]
policy = 'allow'
list = [
  # AssetMantle
  ['transfer', 'channel-232'],
]


[[chains]]
id = 'juno-1'
memo_prefix = ''

rpc_addr = 'http://127.0.0.1:36657'
grpc_addr = 'http://127.0.0.1:39090'
websocket_addr = 'ws://127.0.0.1:36657/websocket'

rpc_timeout = '20s'
account_prefix = 'juno'
key_name = 'juno-relayer'
store_prefix = 'ibc'
max_tx_size = 180000
max_msg_num=15
max_gas = 2000000
gas_price = { price = 0.0025, denom = 'ujuno' }
gas_adjustment = 0.1

max_block_time = '10s'
clock_drift = '5s'
trusting_period = '14days'
trust_threshold = { numerator = '1', denominator = '3' }

[chains.packet_filter]
policy = 'allow'
list = [
  # AssetMantle
  ['transfer', 'channel-83'],
]

[[chains]]
id = 'mantle-1'
memo_prefix = ''

rpc_addr = 'http://127.0.0.1:16657'
grpc_addr = 'http://127.0.0.1:19090'
websocket_addr = 'ws://127.0.0.1:16657/websocket'

rpc_timeout = '20s'
account_prefix = 'mantle'
key_name = 'mantle-relayer'
store_prefix = 'ibc'
max_tx_size = 180000
max_msg_num=15
max_gas = 2000000
gas_price = { price = 0, denom = 'umntl' }
gas_adjustment = 0.1

max_block_time = '10s'
clock_drift = '5s'
trusting_period = '14days'
trust_threshold = { numerator = '1', denominator = '3' }

[chains.packet_filter]
policy = 'allow'
list = [
  # Osmosis
  ['transfer', 'channel-0'],
  # Juno
  ['transfer', 'channel-2'],
]

You can validate the configuration with following:

hermes@Demo:~$ bin/hermes -c .hermes/config.toml  config validate
Success: "configuration is valid"

Setting up wallets

We do this by invocing key configuration command.

bin/hermes keys restore --mnemonic "my 24 words mnemonics" mantle-1
bin/hermes keys restore --mnemonic "my 24 words mnemonics" osmosis-1
bin/hermes keys restore --mnemonic "my 24 words mnemonics" juno-1

If you want to make sure the keys got imported, you can check them with following command (smart thing to run it before shredding the json file):

bin/hermes keys list mantle-1

Testing the setup

Let's do a quick test to see things work properly.

bin/hermes start

Once we see things load up correctly and there are no fatal errors, we can break out of hermes with ctrl-c.

Configuring systemd

Now we will setup hermes to be run by systemd, and to start automatically on reboots.

Create the following configuration to /etc/systemd/system/hermes.service

[Unit]
Description=Hermes IBC relayer
ConditionPathExists=/srv/hermes/.hermes
After=network.target mantle.service osmosis.service

[Service]
Type=simple
User=hermes
WorkingDirectory=/srv/hermes
ExecStart=/srv/hermes/bin/hermes start
Restart=always
RestartSec=2

[Install]
WantedBy=multi-user.target

Then we well start hermes with the newly created service and enable it. Note that this step is done from your normal user account that has sudo privileges, so no longer as hermes.

sudo systemctl start hermes.service
sudo systemctl enable hermes.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment