Skip to content

Commit

Permalink
Use new syntax for all calls to delegate_components!
Browse files Browse the repository at this point in the history
  • Loading branch information
soareschen committed Dec 19, 2023
1 parent faaf390 commit 47478d7
Show file tree
Hide file tree
Showing 27 changed files with 368 additions and 350 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,18 @@ ibc-derive = { git = "https://github.com/cosmos/ibc-rs.git", branch = "
basecoin-app = { git = "https://github.com/informalsystems/basecoin-rs.git", branch = "main" }
basecoin-store = { git = "https://github.com/informalsystems/basecoin-rs.git", branch = "main" }

cgp-core = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-component = { git = "https://github.com/informalsystems/cgp.git", branch = "soares/component-delegation-marker" }
# cgp-core = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
# cgp-component = { git = "https://github.com/informalsystems/cgp.git", branch = "soares/component-delegation-marker" }
cgp-component-macro = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-error = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-error-eyre = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-async = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-run = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }
cgp-inner = { git = "https://github.com/informalsystems/cgp.git", branch = "main" }

cgp-component = { path = "../cgp/crates/cgp-component" }
cgp-core = { path = "../cgp/crates/cgp-core" }

# ibc-relayer-types = { git = "https://github.com/informalsystems/hermes.git", branch = "master" }
# ibc-relayer = { git = "https://github.com/informalsystems/hermes.git", branch = "master" }
# ibc-telemetry = { git = "https://github.com/informalsystems/hermes.git", branch = "master" }
Expand Down
37 changes: 19 additions & 18 deletions crates/cosmos-integration-tests/src/contexts/bootstrap.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cgp_core::prelude::*;
use cgp_core::{ErrorRaiserComponent, ErrorTypeComponent, delegate_all};
use cgp_core::{delegate_all, ErrorRaiserComponent, ErrorTypeComponent};
use cgp_error_eyre::HandleErrorsWithEyre;
use cosmos_test_components::bootstrap::components::cosmos_sdk_legacy::LegacyCosmosSdkBootstrapComponents;
use cosmos_test_components::bootstrap::components::cosmos_sdk_legacy::{
Expand Down Expand Up @@ -64,23 +64,24 @@ delegate_all!(
CosmosStdBootstrapComponents,
);

delegate_components!(
CosmosStdBootstrapComponents;
[
ErrorTypeComponent,
ErrorRaiserComponent,
]:
HandleErrorsWithEyre,
RuntimeTypeComponent:
ProvideTokioRuntimeType,
ChainConfigTypeComponent: ProvideCosmosChainConfigType,
GenesisConfigTypeComponent: ProvideCosmosGenesisConfigType,
WalletConfigGeneratorComponent: GenerateStandardWalletConfig,
[
WalletConfigTypeComponent,
WalletConfigFieldsComponent,
]: ProvideCosmosWalletConfigType,
);
delegate_components! {
CosmosStdBootstrapComponents {
[
ErrorTypeComponent,
ErrorRaiserComponent,
]:
HandleErrorsWithEyre,
RuntimeTypeComponent:
ProvideTokioRuntimeType,
ChainConfigTypeComponent: ProvideCosmosChainConfigType,
GenesisConfigTypeComponent: ProvideCosmosGenesisConfigType,
WalletConfigGeneratorComponent: GenerateStandardWalletConfig,
[
WalletConfigTypeComponent,
WalletConfigFieldsComponent,
]: ProvideCosmosWalletConfigType,
}
}

impl ProvideChainType<CosmosStdBootstrapContext> for CosmosStdBootstrapComponents {
type Chain = CosmosTestChain;
Expand Down
41 changes: 21 additions & 20 deletions crates/cosmos-integration-tests/src/contexts/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,24 @@ impl HasComponents for CosmosTestChain {
type Components = CosmosTestChainComponents;
}

delegate_components!(
CosmosTestChainComponents;
[
ChainIdTypeProviderComponent,
]:
ProvideCosmosChainTypes,
[
WalletTypeComponent,
WalletSignerComponent,
]:
ProvideCosmosTestWallet,
ChainIdFromStringBuilderComponent:
BuildCosmosChainIdFromString,
AmountTypeComponent:
ProvideU128AmountWithDenom,
DenomTypeComponent:
ProvideIbcDenom,
AddressTypeComponent:
ProvideStringAddress,
);
delegate_components! {
CosmosTestChainComponents {
[
ChainIdTypeProviderComponent,
]:
ProvideCosmosChainTypes,
[
WalletTypeComponent,
WalletSignerComponent,
]:
ProvideCosmosTestWallet,
ChainIdFromStringBuilderComponent:
BuildCosmosChainIdFromString,
AmountTypeComponent:
ProvideU128AmountWithDenom,
DenomTypeComponent:
ProvideIbcDenom,
AddressTypeComponent:
ProvideStringAddress,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ use crate::chain::types::wallet::CosmosTestWallet;
pub struct CosmosSdkBootstrapComponents;

// Components that will be swapped in `LegacyCosmosSdkBootstrapComponents`
delegate_components!(
delegate_components! {
#[mark_component(IsCosmosSdkBootstrapComponent)]
#[mark_delegate(DelegatesToCosmosSdkBootstrapComponents)]
CosmosSdkBootstrapComponents {
Expand All @@ -82,7 +82,7 @@ delegate_components!(
ChainFullNodeStarterComponent: StartCosmosChain,
ChainBootstrapperComponent: BootstrapCosmosChain,
}
);
}

pub trait CanUseCosmosSdkChainBootstrapper: UseCosmosSdkChainBootstrapper {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use crate::chain::types::wallet::CosmosTestWallet;

pub struct LegacyCosmosSdkBootstrapComponents;

delegate_components!(
delegate_components! {
#[mark_component(IsLegacyCosmosSdkBootstrapComponent)]
#[mark_delegate(DelegatesToLegacyToCosmosSdkBootstrapComponents)]
LegacyCosmosSdkBootstrapComponents {
Expand All @@ -76,7 +76,7 @@ delegate_components!(
]:
CosmosSdkBootstrapComponents,
}
);
}

pub trait CanUseLegacyCosmosSdkChainBootstrapper: UseLegacyCosmosSdkChainBootstrapper {}

Expand Down
10 changes: 4 additions & 6 deletions crates/relayer-components-extra/src/components/extra/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::runtime::traits::channel_once::CanUseChannelsOnce;

pub struct ExtraBuildComponents<BaseComponents>(pub PhantomData<BaseComponents>);

delegate_components!(
delegate_components! {
#[mark_component(IsExtraBuildComponent)]
#[mark_delegate(DelegatesToExtraBuildComponents)]
ExtraBuildComponents<BaseComponents> {
Expand All @@ -43,10 +43,9 @@ delegate_components!(
]:
DefaultBuildComponents<BaseComponents>,
}
);
}

pub trait CanUseExtraBuildComponents:
UseExtraBuildComponents
pub trait CanUseExtraBuildComponents: UseExtraBuildComponents
where
ChainA<Self>: HasIbcChainTypes<ChainB<Self>>,
ChainB<Self>: HasIbcChainTypes<ChainA<Self>>,
Expand Down Expand Up @@ -96,8 +95,7 @@ where
ChainA::Runtime: CanCreateChannels + CanUseChannelsOnce + CanCloneSender,
ChainB::Runtime: CanCreateChannels + CanUseChannelsOnce + CanCloneSender,
Build::Runtime: HasMutex,
Components:
HasComponents<Components = BaseComponents>
Components: HasComponents<Components = BaseComponents>
+ DelegatesToExtraBuildComponents<BaseComponents>
+ BiRelayFromRelayBuilder<Build>
+ RelayWithBatchBuilder<Build, RelayAToBTarget>
Expand Down
4 changes: 2 additions & 2 deletions crates/relayer-components-extra/src/components/extra/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::telemetry::components::status::ChainStatusTelemetryQuerier;

pub struct ExtraChainComponents<BaseComponents>(pub PhantomData<BaseComponents>);

delegate_components!(
delegate_components! {
#[mark_component(IsExtraChainComponent)]
#[mark_delegate(DelegatesToExtraChainComponents)]
ExtraChainComponents<BaseComponents> {
Expand All @@ -18,4 +18,4 @@ delegate_components!(
ConsensusStateQuerierComponent:
ConsensusStateTelemetryQuerier<BaseComponents>,
}
);
}
4 changes: 2 additions & 2 deletions crates/relayer-components-extra/src/components/extra/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::relay::components::packet_relayers::retry::RetryRelayer;

pub struct ExtraRelayComponents;

delegate_components!(
delegate_components! {
#[mark_component(IsExtraRelayComponent)]
#[mark_delegate(DelegatesToExtraRelayComponents)]
ExtraRelayComponents {
Expand Down Expand Up @@ -68,4 +68,4 @@ delegate_components!(
]:
DefaultRelayComponents,
}
);
}
4 changes: 2 additions & 2 deletions crates/relayer-components/src/components/default/birelay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use crate::relay::components::auto_relayers::both_ways::RelayBothWays;

pub struct DefaultBiRelayComponents;

delegate_components!(
delegate_components! {
#[mark_component(IsDefaultBiRelayComponent)]
#[mark_delegate(DelegatesToDefaultBiRelayComponents)]
DefaultBiRelayComponents {
RunnerComponent: RelayBothWays,
}
);
}
10 changes: 5 additions & 5 deletions crates/relayer-components/src/components/default/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,22 @@ use crate::runtime::traits::mutex::HasMutex;

pub struct DefaultBuildComponents<BaseComponents>(pub PhantomData<BaseComponents>);

delegate_components!(
delegate_components! {
#[mark_component(IsDefaultBuildComponent)]
#[mark_delegate(DelegatesToDefaultBuildComponents)]
DefaultBuildComponents<BaseComponents> {
ChainBuilderComponent: BuildChainWithCache<BaseComponents>,
RelayBuilderComponent: BuildRelayWithCache<BuildRelayFromChains>,
BiRelayBuilderComponent: BuildBiRelayFromRelays,
}
);
}

pub trait CanUseDefaultBuildComponents: UseDefaultBuildComponents
where
ChainA<Self>: HasIbcChainTypes<ChainB<Self>>,
ChainB<Self>: HasIbcChainTypes<ChainA<Self>>,
{}
{
}

pub trait UseDefaultBuildComponents: CanBuildBiRelay
where
Expand Down Expand Up @@ -68,8 +69,7 @@ where
ChainA::ClientId: Ord + Clone,
ChainB::ClientId: Ord + Clone,
Build::Runtime: HasMutex,
Components:
HasComponents<Components = BaseComponents>
Components: HasComponents<Components = BaseComponents>
+ DelegatesToDefaultBuildComponents<BaseComponents>
+ BiRelayFromRelayBuilder<Build>
+ RelayFromChainsBuilder<Build, RelayAToBTarget>
Expand Down
4 changes: 2 additions & 2 deletions crates/relayer-components/src/components/default/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use crate::relay::traits::connection::open_try::ConnectionOpenTryRelayerComponen

pub struct DefaultRelayComponents;

delegate_components!(
delegate_components! {
#[mark_component(IsDefaultRelayComponent)]
#[mark_delegate(DelegatesToDefaultRelayComponents)]
DefaultRelayComponents {
Expand All @@ -80,4 +80,4 @@ delegate_components!(
ConnectionOpenTryRelayerComponent: RelayConnectionOpenTry,
ConnectionOpenHandshakeRelayerComponent: RelayConnectionOpenHandshake,
}
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crate::transaction::traits::types::HasTxTypes;

pub struct DefaultTxComponents;

delegate_components!(
delegate_components! {
#[mark_component(IsDefaultTxComponents)]
#[mark_delegate(DelegatesToDefaultTxComponents)]
DefaultTxComponents {
Expand All @@ -48,7 +48,8 @@ delegate_components!(
NonceAllocatorComponent: AllocateNonceWithMutex,
TxResponsePollerComponent: PollTxResponse,
}
);
}

pub trait CanUseDefaultTxComponents: UseDefaultTxComponents {}

pub trait UseDefaultTxComponents:
Expand Down
21 changes: 11 additions & 10 deletions crates/relayer-cosmos-mock/src/components/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ use ibc_relayer_runtime::impls::types::runtime::ProvideTokioRuntimeType;

pub struct MockCosmosChainComponents;

delegate_components!(
MockCosmosChainComponents;
[
LoggerTypeComponent,
LoggerFieldComponent,
]:
ProvideTracingLogger,
RuntimeTypeComponent:
ProvideTokioRuntimeType,
);
delegate_components! {
MockCosmosChainComponents {
[
LoggerTypeComponent,
LoggerFieldComponent,
]:
ProvideTracingLogger,
RuntimeTypeComponent:
ProvideTokioRuntimeType,
}
}
25 changes: 13 additions & 12 deletions crates/relayer-cosmos-mock/src/components/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ibc_relayer_components::relay::components::packet_filters::allow_all::AllowA

use ibc_relayer_components::relay::traits::components::packet_filter::PacketFilterComponent;

use cgp_core::{delegate_components, DelegateComponent, delegate_all};
use cgp_core::{delegate_all, delegate_components, DelegateComponent};
use ibc_relayer_components::runtime::traits::runtime::RuntimeTypeComponent;
use ibc_relayer_runtime::impls::logger::components::ProvideTracingLogger;
use ibc_relayer_runtime::impls::types::runtime::ProvideTokioRuntimeType;
Expand All @@ -22,14 +22,15 @@ delegate_all!(
MockCosmosRelayComponents,
);

delegate_components!(
MockCosmosRelayComponents;
PacketFilterComponent: AllowAll,
RuntimeTypeComponent:
ProvideTokioRuntimeType,
[
LoggerTypeComponent,
LoggerFieldComponent,
]:
ProvideTracingLogger,
);
delegate_components! {
MockCosmosRelayComponents {
PacketFilterComponent: AllowAll,
RuntimeTypeComponent:
ProvideTokioRuntimeType,
[
LoggerTypeComponent,
LoggerFieldComponent,
]:
ProvideTracingLogger,
}
}
Loading

0 comments on commit 47478d7

Please sign in to comment.