informalsystems / hermes

IBC Relayer in Rust
https://hermes.informal.systems
Apache License 2.0
444 stars 328 forks source link

Support splitting the configuration over multiple files #3135

Open dylanschultzie opened 1 year ago

dylanschultzie commented 1 year ago

Summary

The current implementation necessitates a single config.toml file under ~/.hermes/config.toml. It'd be wildly helpful to allow for having a chains directory that contains each individual chains configuration.

Problem Definition

When supporting more than a few chains, a single config file becomes cumbersome. To help mitigate that, splitting up the config file would be beneficial for ease of modification.

Proposal

Add a separate config dir that the config.toml file can access.

$ tree .hermes/
.hermes/
├── config.toml
├── chains.d
│   ├── agoric-3.toml
│   ├── osmosis-1.toml

Where config.toml would maintain the header portion:

# 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 = true
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 = 100
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 = 3001

[telemetry]
enabled = true
host = '0.0.0.0'
port = 4001

And then each individual chain would have its own file under ~/.hermes/chains.d/{{ CHAIN }}:

# Begin block: akash
[[chains]]
id = 'akashnet-2'

rpc_addr = 'http://1.2.3.4:12857'
grpc_addr = 'http://1.2.3.4:12890'
websocket_addr = 'ws://1.2.3.4:12857/websocket'

rpc_timeout = '20s'
account_prefix = 'akash'
key_name = 'relayer'
address_type = { derivation = 'cosmos' }
store_prefix = 'ibc'
default_gas = 100000
max_gas =  1000000
gas_price = { price = 0.025, denom = 'uakt' }
gas_multiplier = 1.2
max_msg_num = 30
max_tx_size = 2097152
clock_drift = '15s'
max_block_time = '10s'
trusting_period = '7days'
memo_prefix = 'Relayed with 💜 by Lavender.Five Nodes 🐝'
trust_threshold = { numerator = '1', denominator = '3' }

[chains.packet_filter]
policy = 'allow'
list = [
  ['transfer', 'channel-9'], # Osmosis
  ['transfer', 'channel-35'], # Juno
  ['transfer', 'channel-43'], # Secret
  ['transfer', 'channel-56'], # Terra2
]
# End block: akash

Acceptance Criteria


For Admin Use

romac commented 1 year ago

Thanks for the suggestion, we will definitely consider it!

baabeetaa commented 4 months ago

cool to have this feature, where config for each chain on a separated file. And great if its possible to override values in the main config file. Atm I have to implement it using bash script; there is a bash file to store configs for all chains as vars. https://github.com/notional-labs/cosmosia/blob/main/relay/chains.sh

Then include them into the main config template https://github.com/notional-labs/cosmosia/blob/main/relay/osmosis_config.toml#L5

Then using envsubst to make the final config file