From 21ee9c6027c606aab76df1fd4dec4b371280887d Mon Sep 17 00:00:00 2001 From: ido Date: Fri, 18 Oct 2024 13:45:06 +0300 Subject: [PATCH] configurable trustingPeriod --- crates/relayer/src/chain/astria/endpoint.rs | 10 +++------- crates/relayer/src/config.rs | 11 +++++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/relayer/src/chain/astria/endpoint.rs b/crates/relayer/src/chain/astria/endpoint.rs index 64306fe15f..1bccf16189 100644 --- a/crates/relayer/src/chain/astria/endpoint.rs +++ b/crates/relayer/src/chain/astria/endpoint.rs @@ -1456,13 +1456,9 @@ impl ChainEndpoint for AstriaEndpoint { let ClientSettings::Tendermint(settings) = settings; - // two hour duration - // TODO what is this? - let two_hours = Duration::from_secs(2 * 60 * 60); - let unbonding_period = two_hours; - let trusting_period_default = 2 * unbonding_period / 3; - let trusting_period = settings.trusting_period.unwrap_or(trusting_period_default); - + let trusting_period = self.config.trusting_period(); + // Note: Astria does not have an unbonding period, so we set it to 3/2 of the trusting period. + let unbonding_period = trusting_period * 3 / 2; let proof_specs = crate::chain::astria::proof_specs::proof_spec_with_prehash(); Self::ClientState::new( diff --git a/crates/relayer/src/config.rs b/crates/relayer/src/config.rs index aee6a3ca64..e4f04df743 100644 --- a/crates/relayer/src/config.rs +++ b/crates/relayer/src/config.rs @@ -237,6 +237,10 @@ pub mod default { TrustThreshold::TWO_THIRDS } + pub fn trusting_period() -> Option { + Some(Duration::from_secs(60 * 60 * 24)) // 1 day + } + pub fn client_refresh_rate() -> RefreshRate { // Refresh the client three times per trusting period RefreshRate::new(1, 3) @@ -688,6 +692,13 @@ impl ChainConfig { } } + pub fn trusting_period(&self) -> Duration { + match self { + Self::CosmosSdk(config) => config.trusting_period.unwrap_or_default(), + Self::Astria(config) => config.trusting_period.unwrap_or_default(), + } + } + pub fn key_name(&self) -> &String { match self { Self::CosmosSdk(config) => &config.key_name,