diff --git a/src/client_state/common.rs b/src/client_state/common.rs index c0446b9..605ca2e 100644 --- a/src/client_state/common.rs +++ b/src/client_state/common.rs @@ -15,7 +15,8 @@ use crate::client_state::{rollkit_client_type, ClientState}; impl ClientStateCommon for ClientState { fn verify_consensus_state(&self, consensus_state: Any) -> Result<(), ClientError> { - self.tendermint_client_state.verify_consensus_state(consensus_state) + self.tendermint_client_state + .verify_consensus_state(consensus_state) } fn client_type(&self) -> ClientType { @@ -27,7 +28,8 @@ impl ClientStateCommon for ClientState { } fn validate_proof_height(&self, proof_height: Height) -> Result<(), ClientError> { - self.tendermint_client_state.validate_proof_height(proof_height) + self.tendermint_client_state + .validate_proof_height(proof_height) } fn verify_upgrade_client( @@ -113,7 +115,11 @@ pub fn verify_upgrade_client( // TODO: is it ok if we use the upgrade path from the tendermint client state? // TODO: is it ok that in the tendermint upgrade path the chain commits to a rollkit client state? // Check to see if the upgrade path is set - let mut upgrade_path = client_state.tendermint_client_state.inner().upgrade_path.clone(); + let mut upgrade_path = client_state + .tendermint_client_state + .inner() + .upgrade_path + .clone(); if upgrade_path.pop().is_none() { return Err(ClientError::ClientSpecific { @@ -128,7 +134,7 @@ pub fn verify_upgrade_client( // Verify the proof of the upgraded client state verify_membership( - &client_state, + client_state, &upgrade_path_prefix, &proof_upgrade_client, root, @@ -138,7 +144,7 @@ pub fn verify_upgrade_client( // Verify the proof of the upgraded consensus state verify_membership( - &client_state, + client_state, &upgrade_path_prefix, &proof_upgrade_consensus_state, root, @@ -182,4 +188,4 @@ pub fn verify_non_membership( client_state .tendermint_client_state .verify_non_membership(prefix, proof, root, path) -} \ No newline at end of file +} diff --git a/src/client_state/definition.rs b/src/client_state/definition.rs index ff6acc6..0d7f041 100644 --- a/src/client_state/definition.rs +++ b/src/client_state/definition.rs @@ -22,10 +22,13 @@ pub struct ClientState { } impl ClientState { - pub fn new(tendermint_client_state: TendermintClientState, da_params: Option) -> Self { + pub fn new( + tendermint_client_state: TendermintClientState, + da_params: Option, + ) -> Self { Self { tendermint_client_state, - da_params: da_params, + da_params, } } @@ -44,14 +47,17 @@ impl ClientState { pub fn with_header(self, header: RollkitHeader) -> Result { let tendermint_header = header.tendermint_header; - match self.tendermint_client_state.inner().clone().with_header(tendermint_header) { + match self + .tendermint_client_state + .inner() + .clone() + .with_header(tendermint_header) + { Err(e) => Err(Error::invalid(e.to_string())), - Ok(tendermint_client_state) => { - Ok(Self { - tendermint_client_state: tendermint_client_state.into(), - ..self - }) - } + Ok(tendermint_client_state) => Ok(Self { + tendermint_client_state: tendermint_client_state.into(), + ..self + }), } } diff --git a/src/client_state/execution.rs b/src/client_state/execution.rs index 23f8bb4..94edf1c 100644 --- a/src/client_state/execution.rs +++ b/src/client_state/execution.rs @@ -2,7 +2,7 @@ use ibc_client_tendermint::types::ClientState as TendermintClientStateType; use ibc_client_tendermint::types::ConsensusState as TendermintConsensusStateType; use ibc_core::client::context::client_state::{ClientStateCommon, ClientStateExecution}; use ibc_core::client::context::{ - Convertible, ClientExecutionContext, ExtClientExecutionContext, ExtClientValidationContext, + ClientExecutionContext, Convertible, ExtClientExecutionContext, ExtClientValidationContext, }; use ibc_core::client::types::error::ClientError; use ibc_core::client::types::Height; @@ -183,7 +183,8 @@ where let host_timestamp = ExtClientValidationContext::host_timestamp(ctx)?; let host_height = ExtClientValidationContext::host_height(ctx)?; - let new_tendermint_consensus_state = TendermintConsensusStateType::from(rollkit_header.tendermint_header.clone()); + let new_tendermint_consensus_state = + TendermintConsensusStateType::from(rollkit_header.tendermint_header.clone()); let new_rollkit_client_state = client_state.clone().with_header(rollkit_header)?; ctx.store_consensus_state( @@ -314,10 +315,14 @@ where TendermintConsensusStateType: Convertible, { let upgraded_rollkit_client_state = ClientState::try_from(upgraded_client_state)?; - let upgraded_tendermint_consensus_state: TendermintConsensusStateType = upgraded_consensus_state.try_into()?; + let upgraded_tendermint_consensus_state: TendermintConsensusStateType = + upgraded_consensus_state.try_into()?; let tendermint_client_state = client_state.tendermint_client_state.inner(); - let upgraded_tendermint_client_state = upgraded_rollkit_client_state.tendermint_client_state.inner().clone(); + let upgraded_tendermint_client_state = upgraded_rollkit_client_state + .tendermint_client_state + .inner() + .clone(); let new_tendermint_client_state = TendermintClientStateType::new( upgraded_tendermint_client_state.chain_id, @@ -411,11 +416,15 @@ where E::ClientStateRef: From, TendermintConsensusStateType: Convertible, { - let subject_tendermint_client_state = subject_client_state.tendermint_client_state.inner().clone(); + let subject_tendermint_client_state = + subject_client_state.tendermint_client_state.inner().clone(); let substitute_rollkit_client_state = ClientState::try_from(substitute_client_state)?; - let substitute_tendermint_client_state = substitute_rollkit_client_state.tendermint_client_state.inner().clone(); - + let substitute_tendermint_client_state = substitute_rollkit_client_state + .tendermint_client_state + .inner() + .clone(); + // tendermint client state parameters that are allowed to change let chain_id = substitute_tendermint_client_state.chain_id; let trusting_period = substitute_tendermint_client_state.trusting_period; @@ -439,7 +448,8 @@ where let host_timestamp = E::host_timestamp(ctx)?; let host_height = E::host_height(ctx)?; - let tendermint_consensus_state: TendermintConsensusStateType = substitute_consensus_state.try_into()?; + let tendermint_consensus_state: TendermintConsensusStateType = + substitute_consensus_state.try_into()?; ctx.store_consensus_state( ClientConsensusStatePath::new( diff --git a/src/client_state/validation.rs b/src/client_state/validation.rs index da1172a..ca28a9a 100644 --- a/src/client_state/validation.rs +++ b/src/client_state/validation.rs @@ -131,11 +131,9 @@ where TendermintConsensusStateType: Convertible, ClientError: From<>::Error>, { - client_state.tendermint_client_state.check_for_misbehaviour( - ctx, - client_id, - client_message, - ) + client_state + .tendermint_client_state + .check_for_misbehaviour(ctx, client_id, client_message) } /// Query the status of the client state. @@ -173,5 +171,7 @@ where ClientError: From<>::Error>, { // TODO: discuss if da params are allowed to differ. - subject_client_state.tendermint_client_state.check_substitute(ctx, substitute_client_state) + subject_client_state + .tendermint_client_state + .check_substitute(ctx, substitute_client_state) }