Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change config format to scope configs by type #3644

Merged
merged 34 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
92ea480
wip: make config an endpoint-specific enum
hdevalence Oct 1, 2023
f315763
propagate changes into relayer-cli and add questions
hdevalence Oct 3, 2023
362f4a7
relayer-cli: propagate enum chain config changes
erwanor Oct 11, 2023
9b25ce6
relayer: add `ChainConfig::set_key_name`
erwanor Oct 11, 2023
4b6f769
test-framework: begin propagating config changes
erwanor Oct 11, 2023
71cf297
relayer-cli: momentarily allow irrefutable patterns
erwanor Oct 11, 2023
baad978
relayer: run cargo fmt
erwanor Oct 11, 2023
6b5f8fb
integration-tests: propagate config enum api changes
erwanor Oct 11, 2023
4457c2b
Merge remote-tracking branch 'upstream/master' into config-enum
erwanor Oct 12, 2023
02f9a87
integration-tests: fix errors with `ica` feature
erwanor Oct 12, 2023
c259910
integration-tests: fix errors with `ics29` feature
erwanor Oct 12, 2023
0a6baeb
integration-tests: fix errors with `fee-grant` feature
erwanor Oct 12, 2023
ed1ff5f
integration-tests: fix errors with `mbt` feature
erwanor Oct 13, 2023
25c7cf8
integration-tests: fix errors with `ordered` feature
erwanor Oct 13, 2023
a6eadc0
Merge remote-tracking branch 'upstream/master' into config-enum
erwanor Oct 13, 2023
e891697
relayer-cli: fix conflict introduced by merge
erwanor Oct 13, 2023
29b1bde
integration-test: fix simulation:
erwanor Oct 13, 2023
12c02de
hermes: various linting fixes
erwanor Oct 13, 2023
f28601b
hermes: include chain type in default config file
erwanor Oct 13, 2023
64083a3
hermes: add chain type to all config examples
erwanor Oct 13, 2023
8f02d10
ci: update misbehavior config
erwanor Oct 13, 2023
44032e5
relayer-rest(tests): add chain type to mock config
erwanor Oct 13, 2023
0a09a0c
ci(misbehavior): edit config of forked chain
erwanor Oct 13, 2023
b1a39d7
relayer(config): remove dead code
erwanor Oct 14, 2023
c158cba
relayer: lift keys to `ChainConfig::list_keys`
erwanor Oct 14, 2023
e7028fc
relayer: move config validation to `ibc_relayer::config`
erwanor Oct 14, 2023
3cb9db3
relayer: move cosmos config to `chain::cosmos::config`
erwanor Oct 17, 2023
33e2cf5
relayer: add `chain::cosmos::config` module
erwanor Oct 17, 2023
cddce8d
relayer-cli(chain-registry): update path to `CosmosSdkConfig`
erwanor Oct 17, 2023
4e7b5ee
Merge remote-tracking branch 'upstream/master' into config-enum
erwanor Oct 23, 2023
c42de92
ci(misbehavior-ics): add chain type to config file
erwanor Oct 23, 2023
e588311
relayer(evidence): exit early if chain type is not cosmos sdk
erwanor Oct 23, 2023
979cef4
relayer(cosmos): refactor cosmos-specific config validation
erwanor Oct 23, 2023
d7f8674
Add changelog entries
romac Oct 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- The `type` key in the `[[chains]]` section is now required. ([\#3636](https://github.com/informalsystems/hermes/issues/3636))
If you previously did not specify that key, you must now set it to `type = "CosmosSdk"`, eg.

```rust
[[chains]]
id = "osmosis-1"
type = "CosmosSdk"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Change config format to scope configs by type. This enables adding support for
more types of chain, even when those have different config options than each
other. ([\#3636](https://github.com/informalsystems/hermes/issues/3636))
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ci/misbehaviour-ics/double_sign_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ enabled = true

[[chains]]
id = "consumer"
type = "CosmosSdk"
rpc_addr = "http://${NODE_IP}:${CRPC_LADDR_PORT}"
event_source = { mode = 'push', url = 'ws://${NODE_IP}:${CRPC_LADDR_PORT}/websocket' , batch_delay = '50ms' }
grpc_addr = "tcp://${NODE_IP}:${CGRPC_LADDR_PORT}"
Expand All @@ -491,6 +492,7 @@ ccv_consumer_chain = true

[[chains]]
id = "provider"
type = "CosmosSdk"
rpc_addr = "http://${NODE_IP}:${PRPC_LADDR_PORT}"
event_source = { mode = 'push', url = 'ws://${NODE_IP}:${PRPC_LADDR_PORT}/websocket' , batch_delay = '50ms' }
grpc_addr = "tcp://${NODE_IP}:${PGRPC_LADDR_PORT}"
Expand Down
4 changes: 4 additions & 0 deletions ci/misbehaviour-ics/light_client_attack_freeze_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ enabled = true

[[chains]]
id = "consumer"
type = "CosmosSdk"
ccv_consumer_chain = true
account_prefix = "cosmos"
clock_drift = "5s"
Expand All @@ -279,6 +280,7 @@ event_source = { mode = 'push', url = 'ws://${NODE_IP}:26648/websocket' , batch_

[[chains]]
id = "provider"
type = "CosmosSdk"
account_prefix = "cosmos"
clock_drift = "5s"
gas_multiplier = 1.1
Expand Down Expand Up @@ -377,6 +379,7 @@ enabled = true

[[chains]]
id = "consumer"
type = "CosmosSdk"
ccv_consumer_chain = true
account_prefix = "cosmos"
clock_drift = "5s"
Expand All @@ -400,6 +403,7 @@ event_source = { mode = 'push', url = 'ws://${NODE_IP}:26638/websocket' , batch_

[[chains]]
id = "provider"
type = "CosmosSdk"
account_prefix = "cosmos"
clock_drift = "5s"
gas_multiplier = 1.1
Expand Down
3 changes: 3 additions & 0 deletions ci/misbehaviour-ics/light_client_attack_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ enabled = true

[[chains]]
id = "consumer"
type = "CosmosSdk"
ccv_consumer_chain = true
account_prefix = "cosmos"
clock_drift = "5s"
Expand All @@ -293,6 +294,7 @@ event_source = { mode = 'push', url = 'ws://${NODE_IP}:26648/websocket' , batch_

[[chains]]
id = "provider"
type = "CosmosSdk"
account_prefix = "cosmos"
clock_drift = "5s"
gas_multiplier = 1.1
Expand Down Expand Up @@ -408,6 +410,7 @@ enabled = true

[[chains]]
id = "consumer"
type = "CosmosSdk"
ccv_consumer_chain = true
account_prefix = "cosmos"
clock_drift = "5s"
Expand Down
4 changes: 4 additions & 0 deletions ci/misbehaviour/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ port = 3001
# Specify the chain ID. Required
id = 'ibc-0'

# Specify the type of chain, currently only "CosmosSdk" is supported.
type = "CosmosSdk"

# Specify the RPC address and port where the chain RPC server listens on. Required
rpc_addr = 'http://127.0.0.1:26657'

Expand Down Expand Up @@ -299,6 +302,7 @@ memo_prefix = ''

[[chains]]
id = 'ibc-1'
type = "CosmosSdk"
rpc_addr = 'http://127.0.0.1:26557'
grpc_addr = 'http://127.0.0.1:9091'
event_source = { mode = 'push', url = 'ws://127.0.0.1:26557/websocket', batch_delay = '500ms' }
Expand Down
4 changes: 4 additions & 0 deletions ci/misbehaviour/config_fork.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ port = 3001
# Specify the chain ID. Required
id = 'ibc-0'

# Specify the chain type, currently only 'CosmosSdk' is supported.
type = 'CosmosSdk'

# Specify the RPC address and port where the chain RPC server listens on. Required
rpc_addr = 'http://127.0.0.1:26657'

Expand Down Expand Up @@ -298,6 +301,7 @@ memo_prefix = ''

[[chains]]
id = 'ibc-1'
type = 'CosmosSdk'
rpc_addr = 'http://127.0.0.1:26457'
grpc_addr = 'http://127.0.0.1:9092'
event_source = { mode = 'push', url = 'ws://127.0.0.1:26457/websocket', batch_delay = '500ms' }
Expand Down
4 changes: 4 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ port = 5555
# Specify the chain ID. Required
id = 'ibc-0'

# Specify the chain type, currently only `"CosmosSdk"` is supported.
type = "CosmosSdk"

# Whether or not this is a CCV consumer chain. Default: false
# Only specifiy true for CCV consumer chain, but NOT for sovereign chains.
ccv_consumer_chain = false
Expand Down Expand Up @@ -379,6 +382,7 @@ memo_prefix = ''

[[chains]]
id = 'ibc-1'
type = "CosmosSdk"
rpc_addr = 'http://127.0.0.1:26557'
grpc_addr = 'http://127.0.0.1:9091'
event_source = { mode = 'push', url = 'ws://127.0.0.1:26557/websocket', batch_delay = '500ms' }
Expand Down
5 changes: 2 additions & 3 deletions crates/relayer-cli/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use ibc_relayer::{
use crate::{
commands::CliCmd,
components::{JsonTracing, PrettyTracing},
config::validate_config,
entry::EntryPoint,
tracing_handle::{spawn_reload_handler, ReloadHandle},
};
Expand Down Expand Up @@ -134,13 +133,13 @@ impl Application for CliApp {
/// time in app lifecycle when configuration would be loaded if
/// possible.
fn after_config(&mut self, config: Self::Cfg) -> Result<(), FrameworkError> {
use crate::config::Diagnostic;
use ibc_relayer::config::Diagnostic;

// Configure components
let mut components = self.state.components_mut();
components.after_config(&config)?;

if let Err(diagnostic) = validate_config(&config) {
if let Err(diagnostic) = config.validate_config() {
match diagnostic {
Diagnostic::Warning(e) => {
tracing::warn!("relayer may be misconfigured: {}", e);
Expand Down
19 changes: 11 additions & 8 deletions crates/relayer-cli/src/chain_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use ibc_chain_registry::fetchable::Fetchable;
use ibc_chain_registry::formatter::{SimpleGrpcFormatter, UriFormatter};
use ibc_chain_registry::paths::IBCPath;
use ibc_chain_registry::querier::*;
use ibc_relayer::chain::cosmos::config::CosmosSdkConfig;
use ibc_relayer::config::filter::{FilterPattern, PacketFilter};
use ibc_relayer::config::gas_multiplier::GasMultiplier;
use ibc_relayer::config::types::{MaxMsgNum, MaxTxSize, Memo};
Expand Down Expand Up @@ -120,9 +121,8 @@ where
0.1
};

Ok(ChainConfig {
Ok(ChainConfig::CosmosSdk(CosmosSdkConfig {
id: chain_data.chain_id,
r#type: default::chain_type(),
rpc_addr: rpc_data.rpc_address,
grpc_addr: grpc_address,
event_source: EventSourceMode::Push {
Expand Down Expand Up @@ -160,7 +160,7 @@ where
address_type: AddressType::default(),
sequential_batch_tx: false,
extension_options: Vec::new(),
})
}))
}

/// Concurrent `query_healthy` might fail, this is a helper function which will retry a failed query a fixed
Expand Down Expand Up @@ -341,7 +341,10 @@ mod tests {
for config in configs {
match config {
Ok(config) => {
assert_eq!(config.packet_filter.channel_policy, ChannelPolicy::AllowAll);
assert_eq!(
config.packet_filter().channel_policy,
ChannelPolicy::AllowAll
);
}
Err(e) => panic!(
"Encountered an unexpected error in chain registry test: {}",
Expand All @@ -367,9 +370,9 @@ mod tests {

for config in configs {
match config {
Ok(config) => match config.packet_filter.channel_policy {
Ok(config) => match &config.packet_filter().channel_policy {
ChannelPolicy::Allow(channel_filter) => {
if config.id.as_str().contains("cosmoshub") {
if config.id().as_str().contains("cosmoshub") {
assert!(channel_filter.is_exact());

let cosmoshub_juno = (
Expand All @@ -385,7 +388,7 @@ mod tests {
assert!(channel_filter.matches(cosmoshub_juno));
assert!(channel_filter.matches(cosmoshub_osmosis));
assert!(channel_filter.len() == 2);
} else if config.id.as_str().contains("juno") {
} else if config.id().as_str().contains("juno") {
assert!(channel_filter.is_exact());

let juno_cosmoshub = (
Expand All @@ -407,7 +410,7 @@ mod tests {
assert!(channel_filter.matches(juno_osmosis_1));
assert!(channel_filter.matches(juno_osmosis_2));
assert!(channel_filter.len() == 3);
} else if config.id.as_str().contains("osmosis") {
} else if config.id().as_str().contains("osmosis") {
assert!(channel_filter.is_exact());

let osmosis_cosmoshub = (
Expand Down
12 changes: 9 additions & 3 deletions crates/relayer-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use abscissa_core::{config::Override, Command, Configurable, FrameworkError, Run
use tracing::{error, info};

use crate::DEFAULT_CONFIG_PATH;
use ibc_relayer::config::Config;
use ibc_relayer::config::{ChainConfig, Config};

/// Default configuration file path
pub fn default_config_file() -> Option<PathBuf> {
Expand Down Expand Up @@ -149,14 +149,20 @@ impl Configurable<Config> for CliCmd {
let web = "https://hermes.informal.systems";
let suffix = format!("{} {} ({})", CliCmd::name(), clap::crate_version!(), web);
for ccfg in config.chains.iter_mut() {
ccfg.memo_prefix.apply_suffix(&suffix);
#[allow(irrefutable_let_patterns)]
if let ChainConfig::CosmosSdk(ref mut cosmos_ccfg) = ccfg {
cosmos_ccfg.memo_prefix.apply_suffix(&suffix);
}
}

// For all commands except for `start` Hermes retries
// for a prolonged period of time.
if !matches!(self, CliCmd::Start(_)) {
for c in config.chains.iter_mut() {
c.rpc_timeout = Duration::from_secs(120);
#[allow(irrefutable_let_patterns)]
if let ChainConfig::CosmosSdk(ref mut cosmos_ccfg) = c {
cosmos_ccfg.rpc_timeout = Duration::from_secs(120);
}
}
}

Expand Down
9 changes: 7 additions & 2 deletions crates/relayer-cli/src/commands/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ impl Override<Config> for ClearPacketsCmd {
})?;

if let Some(ref key_name) = self.key_name {
chain_config.key_name = key_name.to_string();
// Q: should the key name be required across chain types, meaning that
// key management is common to all chain types, or should key management
// be the responsibility of the backend? If key management is common
// across backends, how should it be agnostic to the key type? Can it
// just be an opaque byte string handled by the backend?
Comment on lines +78 to +82
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ties in to #3641

Perhaps the key manager should only support opaque byte strings, and let the rest be handled by the backend?

chain_config.set_key_name(key_name.to_string());
}

Ok(config)
Expand All @@ -101,7 +106,7 @@ impl Runnable for ClearPacketsCmd {
if let Some(ref counterparty_key_name) = self.counterparty_key_name {
match chains.dst.config() {
Ok(mut dst_chain_cfg) => {
dst_chain_cfg.key_name = counterparty_key_name.to_string();
dst_chain_cfg.set_key_name(counterparty_key_name.to_string());
}
Err(e) => Output::error(e).exit(),
}
Expand Down
17 changes: 8 additions & 9 deletions crates/relayer-cli/src/commands/config/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ use abscissa_core::{Command, Runnable};
use crate::conclude::Output;

use ibc_relayer::config::{store, ChainConfig, Config};
use ibc_relayer::keyring::list_keys;

use std::collections::HashSet;
use std::path::PathBuf;
use tracing::{info, warn};

fn find_key(chain_config: &ChainConfig) -> Option<String> {
let keys = list_keys(chain_config).ok()?;
let keys = chain_config.list_keys().ok()?;
keys.into_iter().next().map(|(name, _)| name)
}

Expand Down Expand Up @@ -117,7 +116,7 @@ impl Runnable for AutoCmd {
.collect();

// Determine which chains were not fetched
let fetched_chains_set = HashSet::from_iter(chain_configs.iter().map(|c| c.id.name()));
let fetched_chains_set = HashSet::from_iter(chain_configs.iter().map(|c| c.id().name()));
let missing_chains_set: HashSet<_> =
sorted_names_set.difference(&fetched_chains_set).collect();

Expand All @@ -128,15 +127,15 @@ impl Runnable for AutoCmd {
for (chain_config, key_option) in configs_and_keys {
// If a key is provided, use it
if let Some(key_name) = key_option {
info!("{}: uses key \"{}\"", &chain_config.id, &key_name);
chain_config.key_name = key_name;
info!("{}: uses key \"{}\"", &chain_config.id(), &key_name);
chain_config.set_key_name(key_name);
} else {
// Otherwise, find the key in the keystore
let chain_id = &chain_config.id;
let chain_id = &chain_config.id();
let key = find_key(chain_config);
if let Some(key) = key {
info!("{}: uses key '{}'", &chain_id, &key);
chain_config.key_name = key;
if let Some(key_name) = key {
info!("{}: uses key '{}'", &chain_id, &key_name);
chain_config.set_key_name(key_name);
} else {
// If no key is found, warn the user and continue
warn!("No key found for chain: {}", chain_id);
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer-cli/src/commands/config/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Runnable for ValidateCmd {

// No need to output the underlying error, this is done already when the application boots.
// See `application::CliApp::after_config`.
match config::validate_config(&config) {
match config.validate_config() {
Ok(_) => Output::success("configuration is valid").exit(),
Err(_) => Output::error("configuration is invalid").exit(),
}
Expand Down
Loading
Loading