diff --git a/group_vars/all.yml b/group_vars/all.yml index 6aa5d55..528452e 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -3,3 +3,6 @@ hermes_version: '1.0.0' # rly rly_version: '2.0.0' + +# Relay Memo +memo: 'Relayed by Polkachu' diff --git a/group_vars/injective.yml b/group_vars/injective.yml new file mode 100644 index 0000000..95cb5c9 --- /dev/null +++ b/group_vars/injective.yml @@ -0,0 +1,2 @@ +rest_port: 3004 +telemetry_port: 4004 diff --git a/main_hermes_config.yml b/main_hermes_config.yml new file mode 100644 index 0000000..2f565d0 --- /dev/null +++ b/main_hermes_config.yml @@ -0,0 +1,8 @@ +--- +- name: Main + hosts: 'relayer' + gather_facts: false + vars_files: + - 'group_vars/{{ target }}.yml' + roles: + - hermes_config diff --git a/roles/hermes_config/tasks/main.yml b/roles/hermes_config/tasks/main.yml new file mode 100644 index 0000000..ce80574 --- /dev/null +++ b/roles/hermes_config/tasks/main.yml @@ -0,0 +1,33 @@ +--- +- name: Copy hermes config script + template: + src: 'configs/{{ target }}.toml.j2' + dest: '/home/{{ ansible_user }}/.hermes/{{ target }}.toml' + owner: '{{ ansible_user }}' + group: '{{ ansible_user }}' + mode: '0644' + +- name: create hermes systemd unit + become: true + template: + src: 'hermes.service.j2' + dest: '/etc/systemd/system/hermes_{{ target }}.service' + owner: root + group: root + mode: '600' + +- name: Open hermes telemetry port + become: true + ufw: + rule: allow + proto: tcp + port: '{{ telemetry_port }}' + +- name: start hermes service + become: true + systemd: + name: 'hermes_{{ target }}' + state: restarted + daemon_reload: yes + enabled: yes + changed_when: false diff --git a/roles/hermes_config/templates/configs/injective.toml.j2 b/roles/hermes_config/templates/configs/injective.toml.j2 new file mode 100644 index 0000000..716bde8 --- /dev/null +++ b/roles/hermes_config/templates/configs/injective.toml.j2 @@ -0,0 +1,45 @@ +{% include 'fragments/header.toml.j2' %} + + +{% include 'fragments/injective.toml.j2' %} + +[chains.packet_filter] +policy = 'allow' +list = [ + ['transfer', 'channel-8'], # Osmosis + ['transfer', 'channel-76'], # Chihuahua + ['transfer', 'channel-83'], # Evmos + ['transfer', 'channel-1'], # Cosmos +] + +{% include 'fragments/osmosis.toml.j2' %} + +[chains.packet_filter] +policy = 'allow' +list = [ + ['transfer', 'channel-122'], # Injective +] + +{% include 'fragments/chihuahua.toml.j2' %} + +[chains.packet_filter] +policy = 'allow' +list = [ + ['transfer', 'channel-12'], # Injective +] + +{% include 'fragments/cosmos.toml.j2' %} + +[chains.packet_filter] +policy = 'allow' +list = [ + ['transfer', 'channel-220'], # Injective +] + +{% include 'fragments/evmos.toml.j2' %} + +[chains.packet_filter] +policy = 'allow' +list = [ + ['transfer', 'channel-10'], # Injective +] \ No newline at end of file diff --git a/roles/hermes_config/templates/fragments/chihuahua.toml.j2 b/roles/hermes_config/templates/fragments/chihuahua.toml.j2 new file mode 100644 index 0000000..cb66911 --- /dev/null +++ b/roles/hermes_config/templates/fragments/chihuahua.toml.j2 @@ -0,0 +1,22 @@ +[[chains]] +id = 'chihuahua-1' +rpc_addr = 'http://{{ relayer2_ip }}:12957' +grpc_addr = 'http://{{ relayer2_ip }}:12990' +websocket_addr = 'ws://{{ relayer2_ip }}:12957/websocket' + +rpc_timeout = '20s' +account_prefix = 'chihuahua' +key_name = 'relayer' +address_type = { derivation = 'cosmos' } +store_prefix = 'ibc' +default_gas = 100000 +max_gas = 3500000 +gas_price = { price = 0.05, denom = 'uhuahua' } +gas_multiplier = 1.2 +max_msg_num = 30 +max_tx_size = 1800000 +clock_drift = '10s' +max_block_time = '10s' +trusting_period = '7days' +memo_prefix = '{{ memo }}' +trust_threshold = { numerator = '1', denominator = '3' } diff --git a/roles/hermes_config/templates/fragments/cosmos.toml.j2 b/roles/hermes_config/templates/fragments/cosmos.toml.j2 new file mode 100644 index 0000000..d586a4d --- /dev/null +++ b/roles/hermes_config/templates/fragments/cosmos.toml.j2 @@ -0,0 +1,22 @@ +[[chains]] +id = 'cosmoshub-4' +rpc_addr = 'http://{{ relayer3_ip }}:14957' +grpc_addr = 'http://{{ relayer3_ip }}:14990' +websocket_addr = 'ws://{{ relayer3_ip }}:14957/websocket' + +rpc_timeout = '20s' +account_prefix = 'cosmos' +key_name = 'relayer' +address_type = { derivation = 'cosmos' } +store_prefix = 'ibc' +default_gas = 150000 +max_gas = 3500000 +gas_price = { price = 0.0025, denom = 'uatom' } +gas_multiplier = 1.2 +max_msg_num = 30 +max_tx_size = 1800000 +clock_drift = '10s' +max_block_time = '10s' +trusting_period = '7days' +memo_prefix = '{{ memo }}' +trust_threshold = { numerator = '1', denominator = '3' } diff --git a/roles/hermes_config/templates/fragments/evmos.toml.j2 b/roles/hermes_config/templates/fragments/evmos.toml.j2 new file mode 100644 index 0000000..e8288d8 --- /dev/null +++ b/roles/hermes_config/templates/fragments/evmos.toml.j2 @@ -0,0 +1,22 @@ +[[chains]] +id = 'evmos_9001-2' +rpc_addr = 'http://{{ relayer3_ip }}:13457' +grpc_addr = 'http://{{ relayer3_ip }}:13490' +websocket_addr = 'ws://{{ relayer3_ip }}:13457/websocket' + +rpc_timeout = '20s' +account_prefix = 'evmos' +key_name = 'relayer' +store_prefix = 'ibc' +address_type = { derivation = 'ethermint', proto_type = { pk_type = '/ethermint.crypto.v1.ethsecp256k1.PubKey' } } +default_gas = 1000000 +max_gas = 4000000 +gas_price = { price = 20000000000, denom = 'aevmos' } +gas_multiplier = 1.2 +max_msg_num = 15 +max_tx_size = 180000 +clock_drift = '15s' +max_block_time = '10s' +trusting_period = '7days' +memo_prefix = '{{ memo }}' +trust_threshold = { numerator = '1', denominator = '3'} \ No newline at end of file diff --git a/roles/hermes_config/templates/fragments/header.toml.j2 b/roles/hermes_config/templates/fragments/header.toml.j2 new file mode 100644 index 0000000..cf643ba --- /dev/null +++ b/roles/hermes_config/templates/fragments/header.toml.j2 @@ -0,0 +1,39 @@ +# The global section has parameters that apply globally to the relayer operation. +[global] +log_level = 'info' + +# Specify the mode to be used by the relayer. [Required] +[mode] + +# Specify the client mode. +[mode.clients] +enabled = false +refresh = true +misbehaviour = false + +# Specify the connections mode. +[mode.connections] +enabled = false + +# Specify the channels mode. +[mode.channels] +enabled = false + +# Specify the packets mode. +[mode.packets] +enabled = true +clear_interval = 200 +clear_on_start = true +tx_confirmation = true + +# The REST section defines parameters for Hermes' built-in RESTful API. +# https://hermes.informal.systems/rest.html +[rest] +enabled = true +host = '0.0.0.0' +port = {{ rest_port }} + +[telemetry] +enabled = true +host = '0.0.0.0' +port = {{ telemetry_port }} diff --git a/roles/hermes_config/templates/fragments/injective.toml.j2 b/roles/hermes_config/templates/fragments/injective.toml.j2 new file mode 100644 index 0000000..4864354 --- /dev/null +++ b/roles/hermes_config/templates/fragments/injective.toml.j2 @@ -0,0 +1,22 @@ +[[chains]] +id = 'injective-1' +rpc_addr = 'http://{{ relayer4_ip }}:14357' +grpc_addr = 'http://{{ relayer4_ip }}:14390' +websocket_addr = 'ws://{{ relayer4_ip }}:14357/websocket' + +rpc_timeout = '20s' +account_prefix = 'inj' +key_name = 'relayer' +address_type = { derivation = 'ethermint', proto_type = { pk_type = '/injective.crypto.v1beta1.ethsecp256k1.PubKey' } } +store_prefix = 'ibc' +default_gas = 100000 +max_gas = 5000000 +gas_price = { price = 500000000, denom = 'inj' } +gas_multiplier = 1.2 +max_msg_num = 30 +max_tx_size = 1800000 +clock_drift = '15s' +max_block_time = '10s' +trusting_period = '7days' +memo_prefix = '{{ memo }}' +trust_threshold = { numerator = '1', denominator = '3' } diff --git a/roles/hermes_config/templates/fragments/osmosis.toml.j2 b/roles/hermes_config/templates/fragments/osmosis.toml.j2 new file mode 100644 index 0000000..2a48666 --- /dev/null +++ b/roles/hermes_config/templates/fragments/osmosis.toml.j2 @@ -0,0 +1,22 @@ +[[chains]] +id = 'osmosis-1' +rpc_addr = 'http://{{ relayer2_ip }}:12557' +grpc_addr = 'http://{{ relayer2_ip }}:12590' +websocket_addr = 'ws://{{ relayer2_ip }}:12557/websocket' + +rpc_timeout = '20s' +account_prefix = 'osmo' +key_name = 'relayer' +address_type = { derivation = 'cosmos' } +store_prefix = 'ibc' +default_gas = 300000 +max_gas = 3500000 +gas_price = { price = 0.000, denom = 'uosmo' } +gas_multiplier = 1.2 +max_msg_num = 30 +max_tx_size = 1800000 +clock_drift = '15s' +max_block_time = '10s' +trusting_period = '7days' +memo_prefix = '{{ memo }}' +trust_threshold = { numerator = '1', denominator = '3' } diff --git a/roles/hermes_config/templates/hermes.service.j2 b/roles/hermes_config/templates/hermes.service.j2 new file mode 100644 index 0000000..fdc54a8 --- /dev/null +++ b/roles/hermes_config/templates/hermes.service.j2 @@ -0,0 +1,12 @@ +Description=Hermes IBC relayer for {{ target }} +After=network.target + +[Service] +Type=simple +User={{ ansible_user }} +ExecStart=/usr/local/bin/hermes --config /home/ubuntu/.hermes/{{ target }}.toml start +Restart=always +RestartSec=5 + +[Install] +WantedBy=multi-user.target \ No newline at end of file