Skip to content

Commit 46e043e

Browse files
initial release
1 parent 943d36d commit 46e043e

File tree

12 files changed

+222
-2
lines changed

12 files changed

+222
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
inventory.ini
2+
group_vars/mainnet.yml
3+
group_vars/testnet.yml

README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
1-
# gm-ibc
1+
# GM IBC
22

3-
Every day we wake up, you say "GM IBC".
3+
Every day we wake up, we say "GM IBC". -Polkachu, probably
4+
5+
**THIS PRODUCT IS NOT READY FOR PUBLIC**
6+
7+
## Problem Statement
8+
9+
IBC is good but complex. Every relayer ends up maintaining their own infrastructure. Config file templates are shared everywhere such as GitHub Gist and Discord. There is no single point of reliable truth about canonical channels, gas prices, and various other config params. When a chain makes a change, every relayer scrabbles to update config files. Sometimes a channel can be broken for days before people realize it.
10+
11+
Chain Registry solves some problems, but it is not enough for IBC relayers. It is so decentralized that it is difficult to make opinionated and radical changes when situations emerge. It is maintained as many json files and updated via PRs. It is fully transparency, but can be at times brittle.
12+
13+
## What's GM-IBC?
14+
15+
GM IBC is to maintain a source of truth for IBC with an opinionated and centralized design. We will be inferior to Chain Registry when if you value openness and community participation, but we will make it up by offering better tools to make relayer's life easier. We dog-food these tools ourselves so it is a worthwhile effort even if we are the only users.
16+
17+
- A public API endpoint to fetch all IBC config data
18+
- An open-sourced Ansible playbook to use the API data to compose and deploy a Hermes relayer in a few seconds.
19+
- A frontend tool to help a relayer to generate Hermes config snippets on the fly.
20+
21+
## Design Philosophy
22+
23+
1. Support Hermes relayer only for now
24+
1. Decouple data and config template
25+
1. Data is stored in a structured database
26+
1. Keep config template extremely simple but compose the Hermes config file with remote API data
27+
1. API data can be called by any relayers regardless whether they choose to use Polkachu playbook
28+
1. Offer a frontend tool for relayer to generate one-off config snippets manually
29+
30+
## How it works
31+
32+
First, copy inventory file and customize to suit your need.
33+
34+
```bash
35+
cp inventory.ini.sample inventory.ini
36+
```
37+
38+
Second copy mainnet group_vars file and customize to suit your need
39+
40+
```bash
41+
cp group_vars/sample.yml group_vars/mainnet.yml
42+
```
43+
44+
Finally run the playbook. If you make some minimum changes to the config files, you should have a relayer between CosmosHub and Osmosis running now.
45+
46+
```bash
47+
ansible-playbook main.yml -e "target=mainnet"
48+
```
49+
50+
# Conclusion
51+
52+
GM, IBC!

ansible.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[defaults]
2+
inventory=inventory.ini

group_vars/all.yml

Whitespace-only changes.

group_vars/sample.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
hermes_directory: '.hermes'
3+
rest_port: 3001
4+
telemetry_port: 4001
5+
chains_api: https://polkachu.com/api/v1/chains_test
6+
routes:
7+
- chain: cosmos
8+
ip: 'YOUR IP'
9+
connections: ['osmosis']
10+
- chain: osmosis
11+
ip: 'YOUR IP'
12+
connections: ['cosmos']

inventory.ini.sample

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[relayer]
2+
10.0.0.1
3+
4+
[all:vars]
5+
ansible_user=ubuntu
6+
ansible_port=22
7+
ansible_ssh_private_key_file="~/.ssh/id_rsa"
8+
user_dir="/home/{{ansible_user}}"
9+
10+
key_name="relayer"
11+
memo='Relayed by Polkachu'

main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- name: Main
3+
hosts: 'relayer'
4+
gather_facts: false
5+
vars_files:
6+
- 'group_vars/{{ target }}.yml'
7+
roles:
8+
- hermes

roles/hermes/tasks/main.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
- name: make hermes dir
3+
file:
4+
path: '/home/{{ ansible_user }}/{{ hermes_directory }}/'
5+
owner: '{{ ansible_user }}'
6+
group: '{{ ansible_user }}'
7+
state: directory
8+
9+
- name: Get the chain data
10+
uri:
11+
url: '{{ chains_api }}'
12+
status_code: 200
13+
body_format: json
14+
register: chains_data
15+
16+
- name: Parse the chain data and set fact
17+
set_fact:
18+
chains: '{{ chains_data.json }}'
19+
20+
- name: Copy hermes config script with customization
21+
template:
22+
src: '{{ target }}.toml.j2'
23+
dest: '/home/{{ ansible_user }}/{{ hermes_directory }}/{{ target }}.toml'
24+
owner: '{{ ansible_user }}'
25+
group: '{{ ansible_user }}'
26+
mode: '0644'
27+
28+
- name: create hermes systemd unit
29+
become: true
30+
template:
31+
src: 'hermes.service.j2'
32+
dest: '/etc/systemd/system/hermes_{{ target }}.service'
33+
owner: root
34+
group: root
35+
mode: '644'
36+
37+
- name: Open hermes telemetry port
38+
become: true
39+
ufw:
40+
rule: allow
41+
proto: tcp
42+
port: '{{ telemetry_port }}'
43+
44+
- name: start hermes service
45+
become: true
46+
systemd:
47+
name: 'hermes_{{ target }}'
48+
state: restarted
49+
daemon_reload: yes
50+
enabled: yes
51+
changed_when: false
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
[[chains]]
3+
id = "{{ chain['chain_id'] }}"
4+
rpc_addr = "http://{{ route['ip'] }}:{{ chain['port_prefix'] }}57"
5+
grpc_addr = "http://{{ route['ip'] }}:{{ chain['port_prefix'] }}90"
6+
event_source = { mode = 'push', url = "ws://{{ route['ip'] }}:{{ chain['port_prefix'] }}57/websocket", batch_delay = '500ms' }
7+
8+
rpc_timeout = "20s"
9+
account_prefix = "{{ chain['account_prefix'] }}"
10+
key_name = "{{ key_name }}"
11+
address_type = { derivation = "cosmos" }
12+
store_prefix = "ibc"
13+
default_gas = {{ chain['default_gas'] }}
14+
max_gas = {{ chain['max_gas'] }}
15+
gas_multiplier = {{ chain['gas_multiplier'] }}
16+
gas_price = { price = {{ chain['gas_price'] }}, denom = "{{ chain['denom'] }}" }
17+
max_msg_num = 30
18+
max_tx_size = 1800000
19+
clock_drift = "15s"
20+
max_block_time = "10s"
21+
trusting_period = "{{ chain['trusting_period'] }}"
22+
memo_prefix = "{{ memo }}"
23+
trust_threshold = { numerator = '1', denominator = '3' }
24+
25+
[chains.packet_filter]
26+
policy = 'allow'
27+
list = [
28+
{% for channel in chain['channels'] %}
29+
{% if channel['dest'] in route['connections'] %}
30+
['{{ channel['port'] }}', '{{ channel['channel'] }}'], {{ "#" }} {{ channel['dest'] }}
31+
{% endif %}
32+
{% endfor %}
33+
]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[global]
2+
log_level = 'info'
3+
4+
[mode]
5+
[mode.clients]
6+
enabled = true
7+
refresh = true
8+
misbehaviour = false
9+
10+
[mode.connections]
11+
enabled = true
12+
13+
[mode.channels]
14+
enabled = true
15+
16+
[mode.packets]
17+
enabled = true
18+
clear_interval = 200
19+
clear_on_start = true
20+
tx_confirmation = true
21+
22+
[rest]
23+
enabled = true
24+
host = '0.0.0.0'
25+
port = {{ rest_port }}
26+
27+
[telemetry]
28+
enabled = true
29+
host = '0.0.0.0'
30+
port = {{ telemetry_port }}

0 commit comments

Comments
 (0)