Skip to content

Commit

Permalink
fix: fixed minimum-gas-prices healthcheck messages and make it more v…
Browse files Browse the repository at this point in the history
…erbose/clear (#3898)

* fix: fixed minimum-gas-prices healthcheck messages and make it more verbose/clear

* Update changelog entry

* Small refactor

---------

Co-authored-by: Romain Ruetschi <romain@informal.systems>
  • Loading branch information
freak12techno and romac authored Mar 17, 2024
1 parent 06dfbaf commit 6ffb295
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -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))
67 changes: 36 additions & 31 deletions crates/relayer/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,18 +481,17 @@ impl CosmosSdkChain {
}

/// The minimum gas price that this node accepts
pub fn min_gas_price(&self) -> Result<Vec<GasPrice>, Error> {
pub fn min_gas_price(&self) -> Result<Option<Vec<GasPrice>>, Error> {
crate::time!(
"min_gas_price",
{
"src_chain": self.config().id.to_string(),
}
);

let min_gas_price: Vec<GasPrice> =
self.query_config_params()?.map_or(vec![], |cfg_response| {
parse_gas_prices(cfg_response.minimum_gas_price)
});
let min_gas_price: Option<Vec<GasPrice>> = self
.query_config_params()?
.map(|cfg_response| parse_gas_prices(cfg_response.minimum_gas_price));

Ok(min_gas_price)
}
Expand Down Expand Up @@ -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))?;
Expand Down

0 comments on commit 6ffb295

Please sign in to comment.