diff --git a/.changelog/unreleased/improvements/1936-missing-chain-warn.md b/.changelog/unreleased/improvements/1936-missing-chain-warn.md new file mode 100644 index 0000000000..eb510e28df --- /dev/null +++ b/.changelog/unreleased/improvements/1936-missing-chain-warn.md @@ -0,0 +1,2 @@ +- Log `missing chain in configuration` errors emitted during event processing at + debug level ([#1936](https://github.com/informalsystems/ibc-rs/issues/1936)) diff --git a/relayer-cli/src/cli_utils.rs b/relayer-cli/src/cli_utils.rs index 5e59a954a9..9a4d0e408e 100644 --- a/relayer-cli/src/cli_utils.rs +++ b/relayer-cli/src/cli_utils.rs @@ -63,7 +63,7 @@ pub fn spawn_chain_runtime_generic( let chain_config = config .find_chain(chain_id) .cloned() - .ok_or_else(|| Error::missing_config(chain_id.clone()))?; + .ok_or_else(|| Error::missing_chain_config(chain_id.clone()))?; let rt = Arc::new(TokioRuntime::new().unwrap()); let handle = diff --git a/relayer-cli/src/error.rs b/relayer-cli/src/error.rs index 8565a1f7b8..99f5456d18 100644 --- a/relayer-cli/src/error.rs +++ b/relayer-cli/src/error.rs @@ -47,17 +47,17 @@ define_error! { Keys |_| { "keys error" }, - MissingConfig + MissingChainConfig { chain_id: ChainId } | e | { - format_args!("missing chain for id ({}) in configuration file", + format_args!("missing chain with id '{}' in configuration file", e.chain_id) }, MissingCounterpartyChannelId { channel_end: IdentifiedChannelEnd } | e | { - format_args!("the channel {:?} counterparty has no channel id", + format_args!("this channel's counterparty has no channel id: {:?}", e.channel_end) }, diff --git a/relayer/src/registry.rs b/relayer/src/registry.rs index 5468db5ce3..26f857fa83 100644 --- a/relayer/src/registry.rs +++ b/relayer/src/registry.rs @@ -26,15 +26,27 @@ define_error! { RuntimeNotFound | _ | { "expected runtime to be found in registry" }, - MissingChain + MissingChainConfig { chain_id: ChainId } | e | { - format_args!("missing chain for id ({}) in configuration file", + format_args!("missing chain config for '{}' in configuration file", e.chain_id) } } } +impl SpawnError { + pub fn log_as_debug(&self) -> bool { + self.detail().log_as_debug() + } +} + +impl SpawnErrorDetail { + pub fn log_as_debug(&self) -> bool { + matches!(self, SpawnErrorDetail::MissingChainConfig(_)) + } +} + /// Registry for keeping track of [`ChainHandle`]s indexed by a `ChainId`. /// /// The purpose of this type is to avoid spawning multiple runtimes for a single `ChainId`. @@ -150,7 +162,7 @@ pub fn spawn_chain_runtime( let chain_config = config .find_chain(chain_id) .cloned() - .ok_or_else(|| SpawnError::missing_chain(chain_id.clone()))?; + .ok_or_else(|| SpawnError::missing_chain_config(chain_id.clone()))?; let handle = ChainRuntime::::spawn(chain_config, rt).map_err(SpawnError::relayer)?; diff --git a/relayer/src/supervisor.rs b/relayer/src/supervisor.rs index 689765eaa2..89b05af381 100644 --- a/relayer/src/supervisor.rs +++ b/relayer/src/supervisor.rs @@ -7,7 +7,7 @@ use std::sync::RwLock; use crossbeam_channel::{unbounded, Receiver, Sender}; use itertools::Itertools; -use tracing::{error, error_span, info, trace, warn}; +use tracing::{debug, error, error_span, info, trace, warn}; use ibc::{ core::ics24_host::identifier::{ChainId, ChannelId, PortId}, @@ -18,10 +18,7 @@ use ibc::{ use crate::{ chain::{handle::ChainHandle, HealthCheck}, config::Config, - event::{ - self, - monitor::{Error as EventError, ErrorDetail as EventErrorDetail, EventBatch}, - }, + event::monitor::{self, Error as EventError, ErrorDetail as EventErrorDetail, EventBatch}, object::Object, registry::{Registry, SharedRegistry}, rest, @@ -50,7 +47,7 @@ use cmd::SupervisorCmd; use self::{scan::ChainScanner, spawn::SpawnContext}; -type ArcBatch = Arc>; +type ArcBatch = Arc>; type Subscription = Receiver; /** @@ -332,6 +329,15 @@ fn relay_on_object( false } + Err(e) if e.log_as_debug() => { + debug!( + "denying relaying on object {}, caused by: {}", + object.short_name(), + e + ); + + false + } Err(e) => { warn!( "denying relaying on object {}, caused by: {}", diff --git a/relayer/src/supervisor/client_state_filter.rs b/relayer/src/supervisor/client_state_filter.rs index e34776dfed..46525ea75e 100644 --- a/relayer/src/supervisor/client_state_filter.rs +++ b/relayer/src/supervisor/client_state_filter.rs @@ -55,6 +55,12 @@ define_error! { } } +impl FilterError { + pub fn log_as_debug(&self) -> bool { + matches!(self.detail(), FilterErrorDetail::Spawn(e) if e.source.log_as_debug()) + } +} + /// A cache storing filtering status (allow or deny) for /// arbitrary identifiers. #[derive(Default, Debug)] diff --git a/relayer/src/supervisor/error.rs b/relayer/src/supervisor/error.rs index 0da9b6d48f..a05235712a 100644 --- a/relayer/src/supervisor/error.rs +++ b/relayer/src/supervisor/error.rs @@ -64,10 +64,16 @@ define_error! { Spawn [ SpawnError ] - |_| { "supervisor was not able to connect to any chains" }, + |_| { "supervisor was not able to spawn chain runtime" }, Scan [ ScanError ] |_| { "supervisor encountered an error when scanning chains" }, } } + +impl Error { + pub fn log_as_debug(&self) -> bool { + matches!(self.detail(), ErrorDetail::Spawn(e) if e.source.log_as_debug()) + } +}