diff --git a/.changelog/unreleased/improvements/ibc-relayer/3864-handshake-retry.md b/.changelog/unreleased/improvements/ibc-relayer/3864-handshake-retry.md new file mode 100644 index 0000000000..45f5e18c86 --- /dev/null +++ b/.changelog/unreleased/improvements/ibc-relayer/3864-handshake-retry.md @@ -0,0 +1,3 @@ +- Change connection and channel handshake retry strategy + to retry at most 10 times (5 times per block max) + ([\#3864](https://github.com/informalsystems/hermes/issues/3864)) \ No newline at end of file diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index c0ee15083f..a2075baa78 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -47,29 +47,29 @@ pub mod channel_handshake_retry { //! for the channel handshake algorithm. use crate::channel::ChannelError; - use crate::util::retry::{clamp_total, ConstantGrowth}; + use crate::util::retry::{clamp, ConstantGrowth}; use core::time::Duration; /// Approximate number of retries per block. - const PER_BLOCK_RETRIES: u32 = 10; + const PER_BLOCK_RETRIES: u32 = 5; /// Defines the increment in delay between subsequent retries. /// A value of `0` will make the retry delay constant. - const DELAY_INCREMENT: u64 = 0; + const DELAY_INCREMENT: Duration = Duration::from_secs(1); - /// Maximum retry delay expressed in number of blocks - const BLOCK_NUMBER_DELAY: u32 = 10; + /// Maximum number of retries + const MAX_RETRIES: u32 = 10; /// The default retry strategy. - /// We retry with a constant backoff strategy. The strategy is parametrized by the + /// We retry with a growing backoff strategy. The strategy is parametrized by the /// maximum block time expressed as a `Duration`. - pub fn default_strategy(max_block_times: Duration) -> impl Iterator { - let retry_delay = max_block_times / PER_BLOCK_RETRIES; + pub fn default_strategy(max_block_time: Duration) -> impl Iterator { + let retry_delay = max_block_time / PER_BLOCK_RETRIES; - clamp_total( - ConstantGrowth::new(retry_delay, Duration::from_secs(DELAY_INCREMENT)), - retry_delay, - max_block_times * BLOCK_NUMBER_DELAY, + clamp( + ConstantGrowth::new(retry_delay, DELAY_INCREMENT), + retry_delay + DELAY_INCREMENT * MAX_RETRIES, + MAX_RETRIES as usize, ) } diff --git a/crates/relayer/src/connection.rs b/crates/relayer/src/connection.rs index 5e1ee140be..5b3ce0c084 100644 --- a/crates/relayer/src/connection.rs +++ b/crates/relayer/src/connection.rs @@ -42,29 +42,29 @@ mod handshake_retry { //! for the connection handshake algorithm. use crate::connection::ConnectionError; - use crate::util::retry::{clamp_total, ConstantGrowth}; + use crate::util::retry::{clamp, ConstantGrowth}; use core::time::Duration; /// Approximate number of retries per block. - const PER_BLOCK_RETRIES: u32 = 10; + const PER_BLOCK_RETRIES: u32 = 5; /// Defines the increment in delay between subsequent retries. /// A value of `0` will make the retry delay constant. - const DELAY_INCREMENT: u64 = 0; + const DELAY_INCREMENT: Duration = Duration::from_secs(1); - /// Maximum retry delay expressed in number of blocks - const BLOCK_NUMBER_DELAY: u32 = 10; + /// Maximum number of retries + const MAX_RETRIES: u32 = 10; /// The default retry strategy. - /// We retry with a constant backoff strategy. The strategy is parametrized by the + /// We retry with a growing backoff strategy. The strategy is parametrized by the /// maximum block time expressed as a `Duration`. - pub fn default_strategy(max_block_times: Duration) -> impl Iterator { - let retry_delay = max_block_times / PER_BLOCK_RETRIES; + pub fn default_strategy(max_block_time: Duration) -> impl Iterator { + let retry_delay = max_block_time / PER_BLOCK_RETRIES; - clamp_total( - ConstantGrowth::new(retry_delay, Duration::from_secs(DELAY_INCREMENT)), - retry_delay, - max_block_times * BLOCK_NUMBER_DELAY, + clamp( + ConstantGrowth::new(retry_delay, DELAY_INCREMENT), + retry_delay + DELAY_INCREMENT * MAX_RETRIES, + MAX_RETRIES as usize, ) }