diff --git a/.changelog/unreleased/bug-fixes/ibc-relayer-cli/3893-fix-min-gas-price-healthcheck.md b/.changelog/unreleased/bug-fixes/ibc-relayer-cli/3893-fix-min-gas-price-healthcheck.md new file mode 100644 index 0000000000..abe83a3a1a --- /dev/null +++ b/.changelog/unreleased/bug-fixes/ibc-relayer-cli/3893-fix-min-gas-price-healthcheck.md @@ -0,0 +1,2 @@ +- Fixed `minimum-gas-prices` health-check messages and make it more verbose and legible + ([\#3893](https://github.com/informalsystems/hermes/issues/3893)) diff --git a/crates/relayer/src/chain/cosmos.rs b/crates/relayer/src/chain/cosmos.rs index eec3a6b7dd..42eac96933 100644 --- a/crates/relayer/src/chain/cosmos.rs +++ b/crates/relayer/src/chain/cosmos.rs @@ -481,7 +481,7 @@ impl CosmosSdkChain { } /// The minimum gas price that this node accepts - pub fn min_gas_price(&self) -> Result, Error> { + pub fn min_gas_price(&self) -> Result>, Error> { crate::time!( "min_gas_price", { @@ -489,10 +489,9 @@ impl CosmosSdkChain { } ); - let min_gas_price: Vec = - self.query_config_params()?.map_or(vec![], |cfg_response| { - parse_gas_prices(cfg_response.minimum_gas_price) - }); + let min_gas_price: Option> = self + .query_config_params()? + .map(|cfg_response| parse_gas_prices(cfg_response.minimum_gas_price)); Ok(min_gas_price) } @@ -2467,38 +2466,44 @@ fn do_health_check(chain: &CosmosSdkChain) -> Result<(), Error> { } let relayer_gas_price = &chain.config.gas_price; - let node_min_gas_prices = chain.min_gas_price()?; - - if !node_min_gas_prices.is_empty() { - let mut found_matching_denom = false; - - for price in node_min_gas_prices { - match relayer_gas_price.partial_cmp(&price) { - Some(Ordering::Less) => return Err(Error::gas_price_too_low(chain_id.clone())), - Some(_) => { - found_matching_denom = true; - break; + let node_min_gas_prices_result = chain.min_gas_price()?; + + match node_min_gas_prices_result { + Some(node_min_gas_prices) if !node_min_gas_prices.is_empty() => { + let mut found_matching_denom = false; + + for price in node_min_gas_prices { + match relayer_gas_price.partial_cmp(&price) { + Some(Ordering::Less) => return Err(Error::gas_price_too_low(chain_id.clone())), + Some(_) => { + found_matching_denom = true; + break; + } + None => continue, } - None => continue, } - } - if !found_matching_denom { - warn!( - "chain '{}' has no minimum gas price of denomination '{}' \ - that is strictly less than the `gas_price` specified for \ - that chain in the Hermes configuration. \ - This is usually a sign of misconfiguration, please check your chain and Hermes configurations", - chain_id, relayer_gas_price.denom - ); + if !found_matching_denom { + warn!( + "chain '{}' has no minimum gas price of denomination '{}' \ + that is strictly less than the `gas_price` specified for that chain in the Hermes configuration. \ + This is usually a sign of misconfiguration, please check your chain and Hermes configurations", + chain_id, relayer_gas_price.denom + ); + } } - } else { - warn!( + + Some(_) => warn!( "chain '{}' has no minimum gas price value configured for denomination '{}'. \ - This is usually a sign of misconfiguration, please check your chain and \ - relayer configurations", + This is usually a sign of misconfiguration, please check your chain and relayer configurations", chain_id, relayer_gas_price.denom - ); + ), + + None => warn!( + "chain '{}' does not implement the `cosmos.base.node.v1beta1.Service/Params` endpoint. \ + It is impossible to check whether the chain's minimum-gas-prices matches the ones specified in config", + chain_id, + ), } let version_specs = chain.block_on(fetch_version_specs(&chain.config.id, &chain.grpc_addr))?;