Skip to content

Commit

Permalink
configurable trustingPeriod (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
quasystaty1 authored Oct 18, 2024
1 parent d16d26a commit 5ca5730
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
10 changes: 3 additions & 7 deletions crates/relayer/src/chain/astria/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
11 changes: 11 additions & 0 deletions crates/relayer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ pub mod default {
TrustThreshold::TWO_THIRDS
}

pub fn trusting_period() -> Option<Duration> {
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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5ca5730

Please sign in to comment.