-
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.
Use component delegation pattern for core relayer components (#3539)
* Define ForwardComponent to auto forward component with less macros * Forward IBC message sender components * Auto derive from HasComponent for both provider and consumer traits. * Use new component pattern for chain status and consensus state querier * Use new component pattern for all other components * Remove HasComponents trait * Add forward_components! macro to forward multiple components at once * Reorder macro arguments and rename forward_component to delegate_component * Rename HasComponent to DelegateComponent * Separate out component graphs for each context * Remove generic Mode argument from AutoRelayer * Delegate event relayer component * Rearrange modules * Turn CreateClient into a component * Remove unused traits * Use component delegation for PacketClearer * Do not retry failed tests in CI * Use component delegation for chain builder * Use component delegation for RelayBuilder * Use component delegation for RelayFromChainsBuilder * Use component delegation for RelayWithBatchBuilder * Rearrange modules * Rearrange birelay traits * Use component delegation for BiRelayBuilder * Allow delegate_components! to match without trailing comma * Use component delegation for BiRelayFromRelayBuilder * Fix CI
- Loading branch information
1 parent
bf1407d
commit 9579ec6
Showing
125 changed files
with
1,568 additions
and
1,381 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
10 changes: 4 additions & 6 deletions
10
crates/relayer-all-in-one/src/one_for_all/impls/birelay/components.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,15 +1,13 @@ | ||
use async_trait::async_trait; | ||
use ibc_relayer_components::core::traits::component::HasComponents; | ||
use ibc_relayer_components::core::traits::component::DelegateComponent; | ||
use ibc_relayer_components::core::traits::sync::Async; | ||
use ibc_relayer_components_extra::components::extra::ExtraComponents; | ||
use ibc_relayer_components_extra::components::extra::birelay::ExtraBiRelayComponents; | ||
|
||
use crate::one_for_all::types::birelay::OfaBiRelayWrapper; | ||
use crate::one_for_all::types::component::OfaComponents; | ||
|
||
#[async_trait] | ||
impl<BiRelay> HasComponents for OfaBiRelayWrapper<BiRelay> | ||
impl<BiRelay, Name> DelegateComponent<Name> for OfaBiRelayWrapper<BiRelay> | ||
where | ||
BiRelay: Async, | ||
{ | ||
type Components = ExtraComponents<OfaComponents>; | ||
type Delegate = ExtraBiRelayComponents<OfaComponents>; | ||
} |
47 changes: 10 additions & 37 deletions
47
crates/relayer-all-in-one/src/one_for_all/impls/builder/birelay.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,53 +1,26 @@ | ||
use async_trait::async_trait; | ||
use ibc_relayer_components::builder::impls::birelay::BuildBiRelayFromRelays; | ||
use ibc_relayer_components::builder::traits::birelay::{ | ||
BiRelayBuilder, CanBuildBiRelay, CanBuildBiRelayFromRelays, | ||
}; | ||
use ibc_relayer_components::builder::traits::birelay::from_relays::BiRelayFromRelayBuilder; | ||
|
||
use crate::one_for_all::traits::builder::{ | ||
ChainIdA, ChainIdB, ClientIdA, ClientIdB, OfaBuilder, RelayAToB, RelayBToA, | ||
}; | ||
use crate::one_for_all::traits::builder::{OfaBuilder, RelayAToB, RelayBToA}; | ||
use crate::one_for_all::types::birelay::OfaBiRelayWrapper; | ||
use crate::one_for_all::types::builder::OfaBuilderWrapper; | ||
use crate::one_for_all::types::component::OfaComponents; | ||
use crate::one_for_all::types::relay::OfaRelayWrapper; | ||
use crate::std_prelude::*; | ||
|
||
#[async_trait] | ||
impl<Builder> CanBuildBiRelayFromRelays for OfaBuilderWrapper<Builder> | ||
impl<Build> BiRelayFromRelayBuilder<OfaBuilderWrapper<Build>> for OfaComponents | ||
where | ||
Builder: OfaBuilder, | ||
Build: OfaBuilder, | ||
{ | ||
async fn build_birelay_from_relays( | ||
&self, | ||
relay_a_to_b: OfaRelayWrapper<RelayAToB<Builder>>, | ||
relay_b_to_a: OfaRelayWrapper<RelayBToA<Builder>>, | ||
) -> Result<OfaBiRelayWrapper<Builder::BiRelay>, Builder::Error> { | ||
build: &OfaBuilderWrapper<Build>, | ||
relay_a_to_b: OfaRelayWrapper<RelayAToB<Build>>, | ||
relay_b_to_a: OfaRelayWrapper<RelayBToA<Build>>, | ||
) -> Result<OfaBiRelayWrapper<Build::BiRelay>, Build::Error> { | ||
let birelay = | ||
OfaBuilder::build_birelay(self.builder.as_ref(), relay_a_to_b, relay_b_to_a).await?; | ||
OfaBuilder::build_birelay(build.builder.as_ref(), relay_a_to_b, relay_b_to_a).await?; | ||
|
||
Ok(OfaBiRelayWrapper::new(birelay)) | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl<Builder> CanBuildBiRelay for OfaBuilderWrapper<Builder> | ||
where | ||
Builder: OfaBuilder, | ||
{ | ||
async fn build_birelay( | ||
&self, | ||
chain_id_a: &ChainIdA<Builder>, | ||
chain_id_b: &ChainIdB<Builder>, | ||
client_id_a: &ClientIdA<Builder>, | ||
client_id_b: &ClientIdB<Builder>, | ||
) -> Result<Self::BiRelay, Self::Error> { | ||
BuildBiRelayFromRelays::build_birelay( | ||
self, | ||
chain_id_a, | ||
chain_id_b, | ||
client_id_a, | ||
client_id_b, | ||
) | ||
.await | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
crates/relayer-all-in-one/src/one_for_all/impls/builder/component.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,13 @@ | ||
use ibc_relayer_components::core::traits::component::DelegateComponent; | ||
use ibc_relayer_components_extra::components::extra::build::ExtraBuildComponents; | ||
|
||
use crate::one_for_all::traits::builder::OfaBuilder; | ||
use crate::one_for_all::types::builder::OfaBuilderWrapper; | ||
use crate::one_for_all::types::component::OfaComponents; | ||
|
||
impl<Build, Name> DelegateComponent<Name> for OfaBuilderWrapper<Build> | ||
where | ||
Build: OfaBuilder, | ||
{ | ||
type Delegate = ExtraBuildComponents<OfaComponents>; | ||
} |
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
Oops, something went wrong.