From 47478d7519db32362bd98fd3fc6d7ab1dbf8745b Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Tue, 19 Dec 2023 12:48:25 +0100 Subject: [PATCH] Use new syntax for all calls to delegate_components! --- Cargo.lock | 2 - Cargo.toml | 7 +- .../src/contexts/bootstrap.rs | 37 ++-- .../src/contexts/chain.rs | 41 +++-- .../src/bootstrap/components/cosmos_sdk.rs | 4 +- .../bootstrap/components/cosmos_sdk_legacy.rs | 4 +- .../src/components/extra/build.rs | 10 +- .../src/components/extra/chain.rs | 4 +- .../src/components/extra/relay.rs | 4 +- .../src/components/default/birelay.rs | 4 +- .../src/components/default/build.rs | 10 +- .../src/components/default/relay.rs | 4 +- .../src/components/default/transaction.rs | 5 +- .../src/components/chain.rs | 21 ++- .../src/components/relay.rs | 25 +-- .../src/impls/birelay/components.rs | 31 ++-- .../src/impls/build/components.rs | 31 ++-- .../src/impls/chain/component.rs | 172 +++++++++--------- .../src/impls/relay/component.rs | 31 ++-- .../src/impls/transaction/component.rs | 46 ++--- .../src/relayer_mock/base/impls/chain.rs | 17 +- .../src/relayer_mock/base/impls/relay.rs | 17 +- .../src/relayer_mock/components/chain.rs | 17 +- .../src/relayer_mock/components/relay.rs | 39 ++-- .../src/impls/runtime/components.rs | 21 ++- .../src/impls/chain/component.rs | 103 +++++------ .../src/impls/relay/component.rs | 11 +- 27 files changed, 368 insertions(+), 350 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca0c7c9b1..a16ace8b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -521,7 +521,6 @@ dependencies = [ [[package]] name = "cgp-component" version = "0.1.0" -source = "git+https://github.com/informalsystems/cgp.git?branch=soares/component-delegation-marker#6f4bfc2c7d6f5cd015916c02ccb69e7c9040f342" dependencies = [ "cgp-async", "cgp-component-macro", @@ -541,7 +540,6 @@ dependencies = [ [[package]] name = "cgp-core" version = "0.1.0" -source = "git+https://github.com/informalsystems/cgp.git?branch=main#ea5ea3aafe336e64e163cfd940f771fb6f108734" dependencies = [ "cgp-async", "cgp-component", diff --git a/Cargo.toml b/Cargo.toml index fe139eda8..d0639540c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,8 +80,8 @@ 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" } @@ -89,6 +89,9 @@ cgp-async = { git = "https://github.com/informalsystems/cgp.git", bran 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" } diff --git a/crates/cosmos-integration-tests/src/contexts/bootstrap.rs b/crates/cosmos-integration-tests/src/contexts/bootstrap.rs index b1e7d9633..ed0b2432e 100644 --- a/crates/cosmos-integration-tests/src/contexts/bootstrap.rs +++ b/crates/cosmos-integration-tests/src/contexts/bootstrap.rs @@ -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::{ @@ -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 for CosmosStdBootstrapComponents { type Chain = CosmosTestChain; diff --git a/crates/cosmos-integration-tests/src/contexts/chain.rs b/crates/cosmos-integration-tests/src/contexts/chain.rs index ffdaa501c..fe3cee1f6 100644 --- a/crates/cosmos-integration-tests/src/contexts/chain.rs +++ b/crates/cosmos-integration-tests/src/contexts/chain.rs @@ -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, + } +} diff --git a/crates/cosmos-test-components/src/bootstrap/components/cosmos_sdk.rs b/crates/cosmos-test-components/src/bootstrap/components/cosmos_sdk.rs index 81e08bf73..d23a86748 100644 --- a/crates/cosmos-test-components/src/bootstrap/components/cosmos_sdk.rs +++ b/crates/cosmos-test-components/src/bootstrap/components/cosmos_sdk.rs @@ -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 { @@ -82,7 +82,7 @@ delegate_components!( ChainFullNodeStarterComponent: StartCosmosChain, ChainBootstrapperComponent: BootstrapCosmosChain, } -); +} pub trait CanUseCosmosSdkChainBootstrapper: UseCosmosSdkChainBootstrapper {} diff --git a/crates/cosmos-test-components/src/bootstrap/components/cosmos_sdk_legacy.rs b/crates/cosmos-test-components/src/bootstrap/components/cosmos_sdk_legacy.rs index 27d1d6e02..327ad42eb 100644 --- a/crates/cosmos-test-components/src/bootstrap/components/cosmos_sdk_legacy.rs +++ b/crates/cosmos-test-components/src/bootstrap/components/cosmos_sdk_legacy.rs @@ -53,7 +53,7 @@ use crate::chain::types::wallet::CosmosTestWallet; pub struct LegacyCosmosSdkBootstrapComponents; -delegate_components!( +delegate_components! { #[mark_component(IsLegacyCosmosSdkBootstrapComponent)] #[mark_delegate(DelegatesToLegacyToCosmosSdkBootstrapComponents)] LegacyCosmosSdkBootstrapComponents { @@ -76,7 +76,7 @@ delegate_components!( ]: CosmosSdkBootstrapComponents, } -); +} pub trait CanUseLegacyCosmosSdkChainBootstrapper: UseLegacyCosmosSdkChainBootstrapper {} diff --git a/crates/relayer-components-extra/src/components/extra/build.rs b/crates/relayer-components-extra/src/components/extra/build.rs index c3f5b0f20..7f420563a 100644 --- a/crates/relayer-components-extra/src/components/extra/build.rs +++ b/crates/relayer-components-extra/src/components/extra/build.rs @@ -31,7 +31,7 @@ use crate::runtime::traits::channel_once::CanUseChannelsOnce; pub struct ExtraBuildComponents(pub PhantomData); -delegate_components!( +delegate_components! { #[mark_component(IsExtraBuildComponent)] #[mark_delegate(DelegatesToExtraBuildComponents)] ExtraBuildComponents { @@ -43,10 +43,9 @@ delegate_components!( ]: DefaultBuildComponents, } -); +} -pub trait CanUseExtraBuildComponents: - UseExtraBuildComponents +pub trait CanUseExtraBuildComponents: UseExtraBuildComponents where ChainA: HasIbcChainTypes>, ChainB: HasIbcChainTypes>, @@ -96,8 +95,7 @@ where ChainA::Runtime: CanCreateChannels + CanUseChannelsOnce + CanCloneSender, ChainB::Runtime: CanCreateChannels + CanUseChannelsOnce + CanCloneSender, Build::Runtime: HasMutex, - Components: - HasComponents + Components: HasComponents + DelegatesToExtraBuildComponents + BiRelayFromRelayBuilder + RelayWithBatchBuilder diff --git a/crates/relayer-components-extra/src/components/extra/chain.rs b/crates/relayer-components-extra/src/components/extra/chain.rs index 63ce405f4..5cf8a81ae 100644 --- a/crates/relayer-components-extra/src/components/extra/chain.rs +++ b/crates/relayer-components-extra/src/components/extra/chain.rs @@ -9,7 +9,7 @@ use crate::telemetry::components::status::ChainStatusTelemetryQuerier; pub struct ExtraChainComponents(pub PhantomData); -delegate_components!( +delegate_components! { #[mark_component(IsExtraChainComponent)] #[mark_delegate(DelegatesToExtraChainComponents)] ExtraChainComponents { @@ -18,4 +18,4 @@ delegate_components!( ConsensusStateQuerierComponent: ConsensusStateTelemetryQuerier, } -); +} diff --git a/crates/relayer-components-extra/src/components/extra/relay.rs b/crates/relayer-components-extra/src/components/extra/relay.rs index 2522c6adf..60551697b 100644 --- a/crates/relayer-components-extra/src/components/extra/relay.rs +++ b/crates/relayer-components-extra/src/components/extra/relay.rs @@ -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 { @@ -68,4 +68,4 @@ delegate_components!( ]: DefaultRelayComponents, } -); +} diff --git a/crates/relayer-components/src/components/default/birelay.rs b/crates/relayer-components/src/components/default/birelay.rs index 375d1e482..e6ddea2f6 100644 --- a/crates/relayer-components/src/components/default/birelay.rs +++ b/crates/relayer-components/src/components/default/birelay.rs @@ -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, } -); +} diff --git a/crates/relayer-components/src/components/default/build.rs b/crates/relayer-components/src/components/default/build.rs index 5c74b689d..489d81c32 100644 --- a/crates/relayer-components/src/components/default/build.rs +++ b/crates/relayer-components/src/components/default/build.rs @@ -25,7 +25,7 @@ use crate::runtime::traits::mutex::HasMutex; pub struct DefaultBuildComponents(pub PhantomData); -delegate_components!( +delegate_components! { #[mark_component(IsDefaultBuildComponent)] #[mark_delegate(DelegatesToDefaultBuildComponents)] DefaultBuildComponents { @@ -33,13 +33,14 @@ delegate_components!( RelayBuilderComponent: BuildRelayWithCache, BiRelayBuilderComponent: BuildBiRelayFromRelays, } -); +} pub trait CanUseDefaultBuildComponents: UseDefaultBuildComponents where ChainA: HasIbcChainTypes>, ChainB: HasIbcChainTypes>, -{} +{ +} pub trait UseDefaultBuildComponents: CanBuildBiRelay where @@ -68,8 +69,7 @@ where ChainA::ClientId: Ord + Clone, ChainB::ClientId: Ord + Clone, Build::Runtime: HasMutex, - Components: - HasComponents + Components: HasComponents + DelegatesToDefaultBuildComponents + BiRelayFromRelayBuilder + RelayFromChainsBuilder diff --git a/crates/relayer-components/src/components/default/relay.rs b/crates/relayer-components/src/components/default/relay.rs index bc1c363b9..f500f1927 100644 --- a/crates/relayer-components/src/components/default/relay.rs +++ b/crates/relayer-components/src/components/default/relay.rs @@ -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 { @@ -80,4 +80,4 @@ delegate_components!( ConnectionOpenTryRelayerComponent: RelayConnectionOpenTry, ConnectionOpenHandshakeRelayerComponent: RelayConnectionOpenHandshake, } -); +} diff --git a/crates/relayer-components/src/components/default/transaction.rs b/crates/relayer-components/src/components/default/transaction.rs index 24c9caa9e..48e411446 100644 --- a/crates/relayer-components/src/components/default/transaction.rs +++ b/crates/relayer-components/src/components/default/transaction.rs @@ -38,7 +38,7 @@ use crate::transaction::traits::types::HasTxTypes; pub struct DefaultTxComponents; -delegate_components!( +delegate_components! { #[mark_component(IsDefaultTxComponents)] #[mark_delegate(DelegatesToDefaultTxComponents)] DefaultTxComponents { @@ -48,7 +48,8 @@ delegate_components!( NonceAllocatorComponent: AllocateNonceWithMutex, TxResponsePollerComponent: PollTxResponse, } -); +} + pub trait CanUseDefaultTxComponents: UseDefaultTxComponents {} pub trait UseDefaultTxComponents: diff --git a/crates/relayer-cosmos-mock/src/components/chain.rs b/crates/relayer-cosmos-mock/src/components/chain.rs index e6d753bb4..2852ee259 100644 --- a/crates/relayer-cosmos-mock/src/components/chain.rs +++ b/crates/relayer-cosmos-mock/src/components/chain.rs @@ -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, + } +} diff --git a/crates/relayer-cosmos-mock/src/components/relay.rs b/crates/relayer-cosmos-mock/src/components/relay.rs index ce264e763..0d03c9949 100644 --- a/crates/relayer-cosmos-mock/src/components/relay.rs +++ b/crates/relayer-cosmos-mock/src/components/relay.rs @@ -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; @@ -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, + } +} diff --git a/crates/relayer-cosmos/src/impls/birelay/components.rs b/crates/relayer-cosmos/src/impls/birelay/components.rs index 1adf62a93..ce4b39c74 100644 --- a/crates/relayer-cosmos/src/impls/birelay/components.rs +++ b/crates/relayer-cosmos/src/impls/birelay/components.rs @@ -30,18 +30,19 @@ delegate_all!( CosmosBiRelayComponents, ); -delegate_components!( - CosmosBiRelayComponents; - [ - ErrorTypeComponent, - ErrorRaiserComponent, - ]: - HandleCosmosError, - RuntimeTypeComponent: - ProvideTokioRuntimeType, - [ - LoggerTypeComponent, - LoggerFieldComponent, - ]: - ProvideTracingLogger, -); +delegate_components! { + CosmosBiRelayComponents { + [ + ErrorTypeComponent, + ErrorRaiserComponent, + ]: + HandleCosmosError, + RuntimeTypeComponent: + ProvideTokioRuntimeType, + [ + LoggerTypeComponent, + LoggerFieldComponent, + ]: + ProvideTracingLogger, + } +} diff --git a/crates/relayer-cosmos/src/impls/build/components.rs b/crates/relayer-cosmos/src/impls/build/components.rs index 9c7ed6cbf..5502891f3 100644 --- a/crates/relayer-cosmos/src/impls/build/components.rs +++ b/crates/relayer-cosmos/src/impls/build/components.rs @@ -35,18 +35,19 @@ delegate_all!( impl CanUseExtraBuildComponents for CosmosBuilder {} -delegate_components!( - CosmosBuildComponents; - [ - ErrorTypeComponent, - ErrorRaiserComponent, - ]: - HandleCosmosError, - RuntimeTypeComponent: - ProvideTokioRuntimeType, - [ - LoggerTypeComponent, - LoggerFieldComponent, - ]: - ProvideTracingLogger, -); +delegate_components! { + CosmosBuildComponents { + [ + ErrorTypeComponent, + ErrorRaiserComponent, + ]: + HandleCosmosError, + RuntimeTypeComponent: + ProvideTokioRuntimeType, + [ + LoggerTypeComponent, + LoggerFieldComponent, + ]: + ProvideTracingLogger, + } +} diff --git a/crates/relayer-cosmos/src/impls/chain/component.rs b/crates/relayer-cosmos/src/impls/chain/component.rs index 508b0f9f0..aa4aad402 100644 --- a/crates/relayer-cosmos/src/impls/chain/component.rs +++ b/crates/relayer-cosmos/src/impls/chain/component.rs @@ -112,89 +112,91 @@ where { } -delegate_components!( - CosmosChainComponents; - [ - ErrorTypeComponent, - ErrorRaiserComponent, - ]: - HandleCosmosError, - RuntimeTypeComponent: - ProvideTokioRuntimeType, - [ - HeightTypeProviderComponent, - TimestampTypeProviderComponent, - ChainIdTypeProviderComponent, - MessageTypeProviderComponent, - EventTypeProviderComponent, - IbcChainTypesProviderComponent, - IbcPacketTypesProviderComponent, - ChainStatusTypeProviderComponent, - ]: - ProvideCosmosChainTypes, - [ - LoggerTypeComponent, - LoggerFieldComponent, - ]: - ProvideTracingLogger, - MessageSenderComponent: - SendMessagesToTxContext, - PacketFieldsReaderComponent: - CosmosPacketFieldReader, - ClientStateQuerierComponent: - DelegateCosmosClientStateQuerier, - ConsensusStateHeightQuerierComponent: - QueryConsensusStateHeightFromChainHandle, - WriteAckQuerierComponent: - QueryWriteAckEventFromChainHandle, - CreateClientMessageBuilderComponent: - DelegateCosmosCreateClientMessageBuilder, - CreateClientPayloadBuilderComponent: - BuildCreateClientPayloadWithChainHandle, - UpdateClientPayloadBuilderComponent: - BuildUpdateClientPayloadWithChainHandle, - UpdateClientMessageBuilderComponent: - BuildCosmosUpdateClientMessage, - CounterpartyChainIdQuerierComponent: - QueryChainIdWithChainHandle, - ConnectionHandshakePayloadBuilderComponent: - BuildCosmosConnectionHandshakePayload, - ChannelHandshakePayloadBuilderComponent: - BuildCosmosChannelHandshakePayload, - ConnectionHandshakeMessageBuilderComponent: - DelegateCosmosConnectionHandshakeBuilder, - ChannelHandshakeMessageBuilderComponent: - BuildCosmosChannelHandshakeMessage, - PacketCommitmentsQuerierComponent: - QueryCosmosPacketCommitments, - ReceivedPacketQuerierComponent: - QueryReceivedPacketWithChainHandle, - ReceivePacketPayloadBuilderComponent: - BuildCosmosReceivePacketPayload, - ReceivePacketMessageBuilderComponent: - BuildCosmosReceivePacketMessage, - AckPacketPayloadBuilderComponent: - BuildCosmosAckPacketPayload, - AckPacketMessageBuilderComponent: - BuildCosmosAckPacketMessage, - TimeoutUnorderedPacketPayloadBuilderComponent: - BuildCosmosTimeoutPacketPayload, - TimeoutUnorderedPacketMessageBuilderComponent: - BuildCosmosTimeoutPacketMessage, - UnreceivedPacketSequencesQuerierComponent: - QueryUnreceivedCosmosPacketSequences, - SendPacketQuerierComponent: - QueryCosmosSendPacket, - SendPacketsQuerierComponent: - QuerySendPacketsConcurrently, - PacketFromWriteAckBuilderComponent: - BuildCosmosPacketFromWriteAck, -); +delegate_components! { + CosmosChainComponents { + [ + ErrorTypeComponent, + ErrorRaiserComponent, + ]: + HandleCosmosError, + RuntimeTypeComponent: + ProvideTokioRuntimeType, + [ + HeightTypeProviderComponent, + TimestampTypeProviderComponent, + ChainIdTypeProviderComponent, + MessageTypeProviderComponent, + EventTypeProviderComponent, + IbcChainTypesProviderComponent, + IbcPacketTypesProviderComponent, + ChainStatusTypeProviderComponent, + ]: + ProvideCosmosChainTypes, + [ + LoggerTypeComponent, + LoggerFieldComponent, + ]: + ProvideTracingLogger, + MessageSenderComponent: + SendMessagesToTxContext, + PacketFieldsReaderComponent: + CosmosPacketFieldReader, + ClientStateQuerierComponent: + DelegateCosmosClientStateQuerier, + ConsensusStateHeightQuerierComponent: + QueryConsensusStateHeightFromChainHandle, + WriteAckQuerierComponent: + QueryWriteAckEventFromChainHandle, + CreateClientMessageBuilderComponent: + DelegateCosmosCreateClientMessageBuilder, + CreateClientPayloadBuilderComponent: + BuildCreateClientPayloadWithChainHandle, + UpdateClientPayloadBuilderComponent: + BuildUpdateClientPayloadWithChainHandle, + UpdateClientMessageBuilderComponent: + BuildCosmosUpdateClientMessage, + CounterpartyChainIdQuerierComponent: + QueryChainIdWithChainHandle, + ConnectionHandshakePayloadBuilderComponent: + BuildCosmosConnectionHandshakePayload, + ChannelHandshakePayloadBuilderComponent: + BuildCosmosChannelHandshakePayload, + ConnectionHandshakeMessageBuilderComponent: + DelegateCosmosConnectionHandshakeBuilder, + ChannelHandshakeMessageBuilderComponent: + BuildCosmosChannelHandshakeMessage, + PacketCommitmentsQuerierComponent: + QueryCosmosPacketCommitments, + ReceivedPacketQuerierComponent: + QueryReceivedPacketWithChainHandle, + ReceivePacketPayloadBuilderComponent: + BuildCosmosReceivePacketPayload, + ReceivePacketMessageBuilderComponent: + BuildCosmosReceivePacketMessage, + AckPacketPayloadBuilderComponent: + BuildCosmosAckPacketPayload, + AckPacketMessageBuilderComponent: + BuildCosmosAckPacketMessage, + TimeoutUnorderedPacketPayloadBuilderComponent: + BuildCosmosTimeoutPacketPayload, + TimeoutUnorderedPacketMessageBuilderComponent: + BuildCosmosTimeoutPacketMessage, + UnreceivedPacketSequencesQuerierComponent: + QueryUnreceivedCosmosPacketSequences, + SendPacketQuerierComponent: + QueryCosmosSendPacket, + SendPacketsQuerierComponent: + QuerySendPacketsConcurrently, + PacketFromWriteAckBuilderComponent: + BuildCosmosPacketFromWriteAck, + } +} -delegate_components!( - CosmosBaseChainComponents; - ChainStatusQuerierComponent: - QueryChainStatusWithChainHandle, - ConsensusStateQuerierComponent: - DelegateCosmosConsensusStateQuerier, -); +delegate_components! { + CosmosBaseChainComponents { + ChainStatusQuerierComponent: + QueryChainStatusWithChainHandle, + ConsensusStateQuerierComponent: + DelegateCosmosConsensusStateQuerier, + } +} diff --git a/crates/relayer-cosmos/src/impls/relay/component.rs b/crates/relayer-cosmos/src/impls/relay/component.rs index c18fd23c3..f2f211a51 100644 --- a/crates/relayer-cosmos/src/impls/relay/component.rs +++ b/crates/relayer-cosmos/src/impls/relay/component.rs @@ -18,21 +18,22 @@ use crate::impls::error::HandleCosmosError; pub struct CosmosRelayComponents; -delegate_components!( - CosmosRelayComponents; - [ - ErrorTypeComponent, - ErrorRaiserComponent, - ]: - HandleCosmosError, - RuntimeTypeComponent: - ProvideTokioRuntimeType, - [ - LoggerTypeComponent, - LoggerFieldComponent, - ]: - ProvideTracingLogger, -); +delegate_components! { + CosmosRelayComponents { + [ + ErrorTypeComponent, + ErrorRaiserComponent, + ]: + HandleCosmosError, + RuntimeTypeComponent: + ProvideTokioRuntimeType, + [ + LoggerTypeComponent, + LoggerFieldComponent, + ]: + ProvideTracingLogger, + } +} delegate_all!( IsExtraRelayComponent, diff --git a/crates/relayer-cosmos/src/impls/transaction/component.rs b/crates/relayer-cosmos/src/impls/transaction/component.rs index 4642472b4..9466be06a 100644 --- a/crates/relayer-cosmos/src/impls/transaction/component.rs +++ b/crates/relayer-cosmos/src/impls/transaction/component.rs @@ -1,5 +1,6 @@ use cgp_core::{ - delegate_components, DelegateComponent, ErrorRaiserComponent, ErrorTypeComponent, HasComponents, delegate_all, + delegate_all, delegate_components, DelegateComponent, ErrorRaiserComponent, ErrorTypeComponent, + HasComponents, }; use cosmos_client_components::components::types::chain::ProvideCosmosChainTypes; use ibc_relayer_components::chain::traits::types::chain_id::ChainIdTypeProviderComponent; @@ -32,24 +33,25 @@ delegate_all!( impl CanUseDefaultTxComponents for CosmosTxContext {} -delegate_components!( - CosmosTxComponents; - [ - ErrorTypeComponent, - ErrorRaiserComponent, - ]: - HandleCosmosError, - RuntimeTypeComponent: - ProvideTokioRuntimeType, - [ - ChainIdTypeProviderComponent, - MessageTypeProviderComponent, - EventTypeProviderComponent, - ]: - ProvideCosmosChainTypes, - [ - LoggerTypeComponent, - LoggerFieldComponent, - ]: - ProvideTracingLogger, -); +delegate_components! { + CosmosTxComponents { + [ + ErrorTypeComponent, + ErrorRaiserComponent, + ]: + HandleCosmosError, + RuntimeTypeComponent: + ProvideTokioRuntimeType, + [ + ChainIdTypeProviderComponent, + MessageTypeProviderComponent, + EventTypeProviderComponent, + ]: + ProvideCosmosChainTypes, + [ + LoggerTypeComponent, + LoggerFieldComponent, + ]: + ProvideTracingLogger, + } +} diff --git a/crates/relayer-mock/src/relayer_mock/base/impls/chain.rs b/crates/relayer-mock/src/relayer_mock/base/impls/chain.rs index 5ee6fa9d9..b748ec89f 100644 --- a/crates/relayer-mock/src/relayer_mock/base/impls/chain.rs +++ b/crates/relayer-mock/src/relayer_mock/base/impls/chain.rs @@ -72,14 +72,15 @@ impl HasComponents for MockChainContext { type Components = MockChainComponents; } -delegate_components!( - MockChainComponents; - [ - ErrorTypeComponent, - ErrorRaiserComponent, - ]: - HandleMockError, -); +delegate_components! { + MockChainComponents { + [ + ErrorTypeComponent, + ErrorRaiserComponent, + ]: + HandleMockError, + } +} impl ProvideRuntimeType for MockChainComponents { type Runtime = MockRuntimeContext; diff --git a/crates/relayer-mock/src/relayer_mock/base/impls/relay.rs b/crates/relayer-mock/src/relayer_mock/base/impls/relay.rs index 417d8001c..47d571bb5 100644 --- a/crates/relayer-mock/src/relayer_mock/base/impls/relay.rs +++ b/crates/relayer-mock/src/relayer_mock/base/impls/relay.rs @@ -27,14 +27,15 @@ impl HasComponents for MockRelayContext { type Components = MockRelayComponents; } -delegate_components!( - MockRelayComponents; - [ - ErrorTypeComponent, - ErrorRaiserComponent, - ]: - HandleMockError, -); +delegate_components! { + MockRelayComponents { + [ + ErrorTypeComponent, + ErrorRaiserComponent, + ]: + HandleMockError, + } +} impl ProvideRuntimeType for MockRelayComponents { type Runtime = MockRuntimeContext; diff --git a/crates/relayer-mock/src/relayer_mock/components/chain.rs b/crates/relayer-mock/src/relayer_mock/components/chain.rs index 3d39f2f8e..fd64cdc3b 100644 --- a/crates/relayer-mock/src/relayer_mock/components/chain.rs +++ b/crates/relayer-mock/src/relayer_mock/components/chain.rs @@ -6,11 +6,12 @@ use ibc_relayer_runtime::impls::logger::components::ProvideTracingLogger; pub struct MockChainComponents; -delegate_components!( - MockChainComponents; - [ - LoggerTypeComponent, - LoggerFieldComponent, - ]: - ProvideTracingLogger, -); +delegate_components! { + MockChainComponents { + [ + LoggerTypeComponent, + LoggerFieldComponent, + ]: + ProvideTracingLogger, + } +} diff --git a/crates/relayer-mock/src/relayer_mock/components/relay.rs b/crates/relayer-mock/src/relayer_mock/components/relay.rs index e1de79e72..a4f7b8b75 100644 --- a/crates/relayer-mock/src/relayer_mock/components/relay.rs +++ b/crates/relayer-mock/src/relayer_mock/components/relay.rs @@ -21,22 +21,23 @@ use crate::relayer_mock::base::impls::relay::MockBuildUpdateClientMessage; pub struct MockRelayComponents; -delegate_components!( - MockRelayComponents; - [ - LoggerTypeComponent, - LoggerFieldComponent, - ]: - ProvideTracingLogger, - IbcMessageSenderComponent: - SendIbcMessagesWithUpdateClient, - PacketRelayerComponent: FullCycleRelayer, - ReceivePacketRelayerComponnent: - SkipReceivedPacketRelayer, - AckPacketRelayerComponent: - BaseAckPacketRelayer, - TimeoutUnorderedPacketRelayerComponent: - BaseTimeoutUnorderedPacketRelayer, - UpdateClientMessageBuilderComponent: - SkipUpdateClient>, -); +delegate_components! { + MockRelayComponents { + [ + LoggerTypeComponent, + LoggerFieldComponent, + ]: + ProvideTracingLogger, + IbcMessageSenderComponent: + SendIbcMessagesWithUpdateClient, + PacketRelayerComponent: FullCycleRelayer, + ReceivePacketRelayerComponnent: + SkipReceivedPacketRelayer, + AckPacketRelayerComponent: + BaseAckPacketRelayer, + TimeoutUnorderedPacketRelayerComponent: + BaseTimeoutUnorderedPacketRelayer, + UpdateClientMessageBuilderComponent: + SkipUpdateClient>, + } +} diff --git a/crates/relayer-runtime/src/impls/runtime/components.rs b/crates/relayer-runtime/src/impls/runtime/components.rs index 4b72b1ca2..26a251230 100644 --- a/crates/relayer-runtime/src/impls/runtime/components.rs +++ b/crates/relayer-runtime/src/impls/runtime/components.rs @@ -22,13 +22,14 @@ impl HasComponents for TokioRuntimeContext { type Components = TokioRuntimeComponents; } -delegate_components!( - TokioRuntimeComponents; - FilePathTypeComponent: ProvideStdPathType, - ChildProcessTypeComponent: ProvideTokioChildProcessType, - ChildProcessStarterComponent: StartTokioChildProcess, - FileAsStringReaderComponent: TokioReadFileAsString, - CommandExecutorComponent: TokioExecCommand, - StringToFileWriterComponent: TokioWriteStringToFile, - TcpPortReserverComponent: TokioReserveTcpPort, -); +delegate_components! { + TokioRuntimeComponents { + FilePathTypeComponent: ProvideStdPathType, + ChildProcessTypeComponent: ProvideTokioChildProcessType, + ChildProcessStarterComponent: StartTokioChildProcess, + FileAsStringReaderComponent: TokioReadFileAsString, + CommandExecutorComponent: TokioExecCommand, + StringToFileWriterComponent: TokioWriteStringToFile, + TcpPortReserverComponent: TokioReserveTcpPort, + } +} diff --git a/crates/relayer-solomachine/src/impls/chain/component.rs b/crates/relayer-solomachine/src/impls/chain/component.rs index f73b7f625..d20a80c27 100644 --- a/crates/relayer-solomachine/src/impls/chain/component.rs +++ b/crates/relayer-solomachine/src/impls/chain/component.rs @@ -54,54 +54,55 @@ where type Components = SolomachineChainComponents; } -delegate_components!( - SolomachineChainComponents; - RuntimeTypeComponent: - ProvideTokioRuntimeType, - [ - HeightTypeProviderComponent, - TimestampTypeProviderComponent, - ChainIdTypeProviderComponent, - IbcChainTypesProviderComponent, - IbcPacketTypesProviderComponent, - ]: - ProvideCosmosChainTypes, - [ - LoggerTypeComponent, - LoggerFieldComponent, - ]: - ProvideTracingLogger, - [ - MessageTypeProviderComponent, - EventTypeProviderComponent, - ]: - ProvideSolomachineChainTypes, - PacketFieldsReaderComponent: - CosmosPacketFieldReader, - MessageSenderComponent: - ProcessSolomachineMessages, - ClientStateQuerierComponent: - QueryCosmosClientStateFromSolomachine, - ConsensusStateQuerierComponent: - QueryCosmosConsensusStateFromSolomachine, - ChannelHandshakePayloadBuilderComponent: - BuildSolomachineChannelHandshakePayloads, - ChannelHandshakeMessageBuilderComponent: - BuildCosmosToSolomachineChannelHandshakeMessage, - ConnectionHandshakePayloadBuilderComponent: - BuildSolomachineConnectionHandshakePayloads, - ConnectionHandshakeMessageBuilderComponent: - BuildCosmosToSolomachineConnectionHandshakeMessage, - CreateClientPayloadBuilderComponent: - BuildSolomachineCreateClientPayload, - CreateClientMessageBuilderComponent: - BuildCreateCosmosClientMessage, - ReceivePacketPayloadBuilderComponent: - BuildSolomachineReceivePacketPayload, - TimeoutUnorderedPacketMessageBuilderComponent: - BuildSolomachineTimeoutPacketPayload, - UpdateClientPayloadBuilderComponent: - BuildSolomachineUpdateClientPayload, - UpdateClientMessageBuilderComponent: - BuildCosmosUpdateClientMessage, -); +delegate_components! { + SolomachineChainComponents { + RuntimeTypeComponent: + ProvideTokioRuntimeType, + [ + HeightTypeProviderComponent, + TimestampTypeProviderComponent, + ChainIdTypeProviderComponent, + IbcChainTypesProviderComponent, + IbcPacketTypesProviderComponent, + ]: + ProvideCosmosChainTypes, + [ + LoggerTypeComponent, + LoggerFieldComponent, + ]: + ProvideTracingLogger, + [ + MessageTypeProviderComponent, + EventTypeProviderComponent, + ]: + ProvideSolomachineChainTypes, + PacketFieldsReaderComponent: + CosmosPacketFieldReader, + MessageSenderComponent: + ProcessSolomachineMessages, + ClientStateQuerierComponent: + QueryCosmosClientStateFromSolomachine, + ConsensusStateQuerierComponent: + QueryCosmosConsensusStateFromSolomachine, + ChannelHandshakePayloadBuilderComponent: + BuildSolomachineChannelHandshakePayloads, + ChannelHandshakeMessageBuilderComponent: + BuildCosmosToSolomachineChannelHandshakeMessage, + ConnectionHandshakePayloadBuilderComponent: + BuildSolomachineConnectionHandshakePayloads, + ConnectionHandshakeMessageBuilderComponent: + BuildCosmosToSolomachineConnectionHandshakeMessage, + CreateClientPayloadBuilderComponent: + BuildSolomachineCreateClientPayload, + CreateClientMessageBuilderComponent: + BuildCreateCosmosClientMessage, + ReceivePacketPayloadBuilderComponent: + BuildSolomachineReceivePacketPayload, + TimeoutUnorderedPacketMessageBuilderComponent: + BuildSolomachineTimeoutPacketPayload, + UpdateClientPayloadBuilderComponent: + BuildSolomachineUpdateClientPayload, + UpdateClientMessageBuilderComponent: + BuildCosmosUpdateClientMessage, + } +} diff --git a/crates/relayer-solomachine/src/impls/relay/component.rs b/crates/relayer-solomachine/src/impls/relay/component.rs index 2c2afb8f0..1ae69646b 100644 --- a/crates/relayer-solomachine/src/impls/relay/component.rs +++ b/crates/relayer-solomachine/src/impls/relay/component.rs @@ -23,8 +23,9 @@ where type Components = SolomachineRelayComponents; } -delegate_components!( - SolomachineRelayComponents; - RuntimeTypeComponent: - ProvideTokioRuntimeType, -); +delegate_components! { + SolomachineRelayComponents { + RuntimeTypeComponent: + ProvideTokioRuntimeType, + } +}