-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
UpdateClient
chain components and remove depdency to `For…
…eignClient` (#3480) * Finish abstract implementation of UpdateClient * Implement Cosmos methods for building UpdateClient message * Implement find_consensus_state_height_before in Cosmos chain * New UpdateClient component is now working * Remove OFA relay build_update_client method and dependency to ForeignClient
- Loading branch information
1 parent
cc1c1a8
commit c7763f5
Showing
21 changed files
with
459 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 10 additions & 6 deletions
16
crates/relayer-components/src/chain/traits/client/client_state.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
use async_trait::async_trait; | ||
|
||
use crate::chain::traits::types::client_state::HasClientStateSettingsType; | ||
use crate::chain::traits::types::client_state::HasClientStateType; | ||
use crate::chain::traits::types::ibc::HasIbcChainTypes; | ||
use crate::core::traits::error::HasErrorType; | ||
use crate::std_prelude::*; | ||
|
||
#[async_trait] | ||
pub trait CanBuildClientState<Counterparty>: HasClientStateSettingsType<Counterparty> { | ||
async fn build_client_state( | ||
pub trait CanQueryClientState<Counterparty>: HasIbcChainTypes<Counterparty> + HasErrorType | ||
where | ||
Counterparty: HasClientStateType<Self>, | ||
{ | ||
async fn query_client_state( | ||
&self, | ||
height: &Self::Height, | ||
settings: &Self::ClientStateSettings, | ||
) -> Self::ClientState; | ||
client_id: &Self::ClientId, | ||
) -> Result<Counterparty::ClientState, Self::Error>; | ||
} |
28 changes: 19 additions & 9 deletions
28
crates/relayer-components/src/chain/traits/client/consensus_state.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
use async_trait::async_trait; | ||
|
||
use crate::chain::traits::types::client_state::HasClientStateType; | ||
use crate::chain::traits::types::consensus_state::HasConsensusStateType; | ||
use crate::chain::traits::types::height::HasHeightType; | ||
use crate::chain::traits::types::ibc::HasIbcChainTypes; | ||
use crate::core::traits::error::HasErrorType; | ||
use crate::std_prelude::*; | ||
|
||
#[async_trait] | ||
pub trait CanBuildConsensusState<Counterparty>: | ||
HasConsensusStateType<Counterparty> + HasClientStateType<Counterparty> + HasErrorType | ||
pub trait CanFindConsensusStateHeight<Counterparty>: | ||
HasIbcChainTypes<Counterparty> + HasErrorType | ||
where | ||
Counterparty: HasHeightType, | ||
{ | ||
async fn build_consensus_state( | ||
trusted_height: &Self::Height, | ||
target_height: &Self::Height, | ||
client_state: &Self::ClientState, | ||
) -> Result<Self::ConsensusState, Self::Error>; | ||
/** | ||
Query the chain to find a consensus state that has a height that is | ||
less than or equal the target height. This is needed as a base trusted | ||
height to build the headers for UpdateClient. | ||
Invariant: the returned height must be less than or equal to the given | ||
target height. | ||
*/ | ||
async fn find_consensus_state_height_before( | ||
&self, | ||
client_id: &Self::ClientId, | ||
target_height: &Counterparty::Height, | ||
) -> Result<Counterparty::Height, Self::Error>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod client_state; | ||
pub mod consensus_state; | ||
pub mod create; | ||
pub mod update; |
36 changes: 36 additions & 0 deletions
36
crates/relayer-components/src/chain/traits/client/update.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use async_trait::async_trait; | ||
|
||
use crate::chain::traits::types::client_state::HasClientStateType; | ||
use crate::chain::traits::types::ibc::HasIbcChainTypes; | ||
use crate::core::traits::error::HasErrorType; | ||
use crate::core::traits::sync::Async; | ||
use crate::std_prelude::*; | ||
|
||
pub trait HasUpdateClientPayload<Counterparty>: HasIbcChainTypes<Counterparty> { | ||
type UpdateClientPayload: Async; | ||
} | ||
|
||
#[async_trait] | ||
pub trait CanBuildUpdateClientPayload<Counterparty>: | ||
HasUpdateClientPayload<Counterparty> + HasClientStateType<Counterparty> + HasErrorType | ||
{ | ||
async fn build_update_client_payload( | ||
&self, | ||
trusted_height: &Self::Height, | ||
target_height: &Self::Height, | ||
client_state: Self::ClientState, | ||
) -> Result<Self::UpdateClientPayload, Self::Error>; | ||
} | ||
|
||
#[async_trait] | ||
pub trait CanBuildUpdateClientMessage<Counterparty>: | ||
HasIbcChainTypes<Counterparty> + HasErrorType | ||
where | ||
Counterparty: HasUpdateClientPayload<Self>, | ||
{ | ||
async fn build_update_client_message( | ||
&self, | ||
client_id: &Self::ClientId, | ||
payload: Counterparty::UpdateClientPayload, | ||
) -> Result<Vec<Self::Message>, Self::Error>; | ||
} |
Oops, something went wrong.