Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: configurable trusting period #21

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading