Skip to content

Commit

Permalink
Fix parsing of IBC-Go version in health check and improve health chec…
Browse files Browse the repository at this point in the history
…k reporting (#3888)
  • Loading branch information
romac authored Mar 12, 2024
1 parent e16dbb0 commit bb9d42e
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix parsing of IBC-Go version in health check and improve health check
reporting ([\#3880](https://github.com/informalsystems/hermes/issues/3880))
21 changes: 13 additions & 8 deletions crates/relayer/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ pub mod wait;
///
/// [tm-37-max]: https://github.com/tendermint/tendermint/blob/v0.37.0-rc1/types/params.go#L79
pub const BLOCK_MAX_BYTES_MAX_FRACTION: f64 = 0.9;

pub struct CosmosSdkChain {
config: config::CosmosSdkConfig,
tx_config: TxConfig,
Expand Down Expand Up @@ -292,19 +293,23 @@ impl CosmosSdkChain {
));
}

// Query /genesis RPC endpoint to retrieve the `max_expected_time_per_block` value
// to use as `max_block_time`.
// Query /genesis RPC endpoint to retrieve the `max_expected_time_per_block` value to use as `max_block_time`.
// If it is not found, keep the configured `max_block_time`.
match self.block_on(self.rpc_client.genesis::<GenesisAppState>()) {
Ok(genesis_reponse) => {
let old_max_block_time = self.config.max_block_time;
self.config.max_block_time =
let new_max_block_time =
Duration::from_nanos(genesis_reponse.app_state.max_expected_time_per_block());
info!(
"Updated `max_block_time` using /genesis endpoint. Old value: `{}s`, new value: `{}s`",
old_max_block_time.as_secs(),
self.config.max_block_time.as_secs()
);

if old_max_block_time.as_secs() != new_max_block_time.as_secs() {
self.config.max_block_time = new_max_block_time;

info!(
"Updated `max_block_time` using /genesis endpoint. Old value: `{}s`, new value: `{}s`",
old_max_block_time.as_secs(),
self.config.max_block_time.as_secs()
);
}
}
Err(e) => {
warn!(
Expand Down
7 changes: 4 additions & 3 deletions crates/relayer/src/chain/cosmos/estimate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async fn estimate_gas_with_tx(
gas_config: &GasConfig,
grpc_address: &Uri,
tx: Tx,
account: &Account,
_account: &Account,
) -> Result<EstimatedGas, Error> {
let simulated_gas = send_tx_simulate(grpc_address, tx)
.await
Expand Down Expand Up @@ -169,7 +169,7 @@ async fn estimate_gas_with_tx(

telemetry!(
simulate_errors,
&account.address.to_string(),
&_account.address.to_string(),
true,
get_error_text(&e),
);
Expand All @@ -185,7 +185,7 @@ async fn estimate_gas_with_tx(

telemetry!(
simulate_errors,
&account.address.to_string(),
&_account.address.to_string(),
false,
get_error_text(&e),
);
Expand All @@ -212,6 +212,7 @@ fn can_recover_from_simulation_failure(e: &Error) -> bool {
}
}

#[cfg(feature = "telemetry")]
fn get_error_text(e: &Error) -> String {
use crate::error::ErrorDetail::*;

Expand Down
Loading

0 comments on commit bb9d42e

Please sign in to comment.