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

feat: set trusting period in hermes configuration #13

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 3 additions & 8 deletions crates/relayer/src/chain/astria/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1428,14 +1428,9 @@ impl ChainEndpoint for AstriaEndpoint {
use ibc_relayer_types::clients::ics07_tendermint::client_state::AllowUpdate;

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);

// This is a hack to set the trusting and unbonding periods.
let unbonding_period = self.config.trusting_period();
let trusting_period = 2 * unbonding_period / 3;
let proof_specs = crate::chain::astria::proof_specs::proof_spec_with_prehash();

Self::ClientState::new(
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer/src/chain/cosmos/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
pub max_gas: Option<u64>,

// This field is only meant to be set via the `update client` command,
// for when we need to ugprade a client across a genesis restart and

Check failure on line 74 in crates/relayer/src/chain/cosmos/config.rs

View workflow job for this annotation

GitHub Actions / Check spelling

ugprade ==> upgrade
// therefore need and archive node to fetch blocks from.
pub genesis_restart: Option<GenesisRestart>,

Expand Down Expand Up @@ -108,7 +108,7 @@

/// The trusting period specifies how long a validator set is trusted for
/// (must be shorter than the chain's unbonding period).
#[serde(default, with = "humantime_serde")]
#[serde(default = "default::trusting_period", with = "humantime_serde")]
pub trusting_period: Option<Duration>,

/// The rate at which to refresh the client referencing this chain,
Expand Down
10 changes: 10 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 @@ -660,6 +664,12 @@ pub enum ChainConfig {
}

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 id(&self) -> &ChainId {
match self {
Self::CosmosSdk(config) => &config.id,
Expand Down
Loading