diff --git a/common/cf-guest/src/client/impls.rs b/common/cf-guest/src/client/impls.rs index 95fd8705..1cbd3406 100644 --- a/common/cf-guest/src/client/impls.rs +++ b/common/cf-guest/src/client/impls.rs @@ -239,7 +239,6 @@ impl ibc::ClientStateCommon for ClientState { } } - impl From for ibc::ClientError { fn from(err: proof::VerifyError) -> Self { use ibc::CommitmentError::EncodingFailure; @@ -371,39 +370,44 @@ where fn status( &self, - ctx: &V, - client_id: &ibc::ClientId, + _ctx: &V, + _client_id: &ibc::ClientId, ) -> Result { if self.is_frozen { return Ok(ibc::Status::Frozen); } - let height = ibc::Height::new(1, self.latest_height.into())?; - let consensus = CommonContext::consensus_state(ctx, client_id, height) - .and_then(|state| state.try_into().map_err(error)); - let consensus = match consensus { - Ok(consensus) => consensus, - Err(ibc::ClientError::ConsensusStateNotFound { .. }) => { - return Ok(ibc::Status::Expired) - } - // If the client state is not found, then a new client is going to be created and since its known from - // above that the client state is not frozen, we return the client state as active. - Err(ibc::ClientError::ClientStateNotFound { .. }) => { - return Ok(ibc::Status::Active) - } - Err(err) => return Err(err), - }; - - let (host_timestamp, _) = CommonContext::host_metadata(ctx)?; - Ok(if self.consensus_has_expired(&consensus, host_timestamp) { - ibc::Status::Expired - } else { - ibc::Status::Active - }) + // let height = ibc::Height::new(1, self.latest_height.into())?; + // let consensus = CommonContext::consensus_state(ctx, client_id, height) + // .and_then(|state| state.try_into().map_err(error)); + // let consensus = match consensus { + // Ok(consensus) => consensus, + // Err(ibc::ClientError::ConsensusStateNotFound { .. }) => { + // return Ok(ibc::Status::Expired) + // } + // // If the client state is not found, then a new client is going to be created and since its known from + // // above that the client state is not frozen, we return the client state as active. + // Err(ibc::ClientError::ClientStateNotFound { .. }) => { + // return Ok(ibc::Status::Active) + // } + // Err(err) => return Err(err), + // }; + + // let (host_timestamp, _) = CommonContext::host_metadata(ctx)?; + // Ok(if self.consensus_has_expired(&consensus, host_timestamp) { + // ibc::Status::Expired + // } else { + // ibc::Status::Active + // }) + + // TODO: Since there is no way of reviving client once expired in the current version of ibc-rs, + // we will always return active. + // + // Once the ibc-rs is updated, client update to revive a client will be supported which should be used. + Ok(ibc::Status::Active) } } - impl ClientState { pub fn do_update_state( &self, @@ -648,12 +652,10 @@ impl ClientState { } } - fn error(msg: impl ToString) -> ibc::ClientError { ibc::ClientError::Other { description: msg.to_string() } } - /// Checks client id’s client type is what’s expected and then parses the id as /// `ClientIdx`. /// @@ -673,7 +675,6 @@ fn parse_client_id(client_id: &ibc::ClientId) -> Result { Err(ibc::ClientError::ClientSpecific { description }) } - #[test] fn test_verify_client_type() { use core::str::FromStr; diff --git a/common/cf-solana/src/client/impls.rs b/common/cf-solana/src/client/impls.rs index b02e15d7..e37d8faa 100644 --- a/common/cf-solana/src/client/impls.rs +++ b/common/cf-solana/src/client/impls.rs @@ -279,35 +279,41 @@ where fn status( &self, - ctx: &V, - client_id: &ibc::ClientId, + _ctx: &V, + _client_id: &ibc::ClientId, ) -> Result { if self.is_frozen { return Ok(ibc::Status::Frozen); } - let height = self.latest_height(); - let consensus = CommonContext::consensus_state(ctx, client_id, height) - .and_then(|state| state.try_into().map_err(error)); - let consensus = match consensus { - Ok(consensus) => consensus, - Err(ibc::ClientError::ConsensusStateNotFound { .. }) => { - return Ok(ibc::Status::Expired) - } - // If the client state is not found, then a new client is going to be created and since its known from - // above that the client state is not frozen, we return the client state as active. - Err(ibc::ClientError::ClientStateNotFound { .. }) => { - return Ok(ibc::Status::Active) - } - Err(err) => return Err(err), - }; - - let (host_timestamp, _) = CommonContext::host_metadata(ctx)?; - Ok(if self.consensus_has_expired(&consensus, host_timestamp) { - ibc::Status::Expired - } else { - ibc::Status::Active - }) + // let height = self.latest_height(); + // let consensus = CommonContext::consensus_state(ctx, client_id, height) + // .and_then(|state| state.try_into().map_err(error)); + // let consensus = match consensus { + // Ok(consensus) => consensus, + // Err(ibc::ClientError::ConsensusStateNotFound { .. }) => { + // return Ok(ibc::Status::Expired) + // } + // // If the client state is not found, then a new client is going to be created and since its known from + // // above that the client state is not frozen, we return the client state as active. + // Err(ibc::ClientError::ClientStateNotFound { .. }) => { + // return Ok(ibc::Status::Active) + // } + // Err(err) => return Err(err), + // }; + + // let (host_timestamp, _) = CommonContext::host_metadata(ctx)?; + // Ok(if self.consensus_has_expired(&consensus, host_timestamp) { + // ibc::Status::Expired + // } else { + // ibc::Status::Active + // }) + + // TODO: Since there is no way of reviving client once expired in the current version of ibc-rs, + // we will always return active. + // + // Once the ibc-rs is updated, client update to revive a client will be supported which should be used. + Ok(ibc::Status::Active) } }