Skip to content

Commit

Permalink
Remove one-for-all runtime constructs (#3542)
Browse files Browse the repository at this point in the history
* Implement runtime traits directly for TokioRuntimeContext

* Use AfoRuntime directly

* Remove OfaRuntime constructs

* Rename Log to LogEntries

* Implement telemetry traits directly

* Remove OfaTelemetry

* Slightly improve telemetry
  • Loading branch information
soareschen authored Aug 16, 2023
1 parent 9579ec6 commit 4238d6c
Show file tree
Hide file tree
Showing 76 changed files with 570 additions and 866 deletions.
3 changes: 2 additions & 1 deletion crates/relayer-all-in-one/src/all_for_one/birelay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use crate::all_for_one::relay::AfoRelay;
use crate::all_for_one::runtime::HasAfoRuntime;

pub trait AfoBiRelay:
HasAfoRuntime
Clone
+ HasAfoRuntime
+ HasLoggerWithBaseLevels
+ CanAutoRelay
+ HasTwoWayRelay<RelayAToB = Self::AfoRelayAToB, RelayBToA = Self::AfoRelayBToA>
Expand Down
11 changes: 9 additions & 2 deletions crates/relayer-all-in-one/src/all_for_one/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub trait CanBuildAfoBiRelayFromOfa:
impl<Build> CanBuildAfoBiRelayFromOfa for OfaBuilderWrapper<Build>
where
Build: OfaBuilder,
// OfaBuilderWrapper<Build>: CanBuildBiRelayFromRelays
{
type AfoBiRelay = OfaBiRelayWrapper<Build::BiRelay>;

Expand All @@ -72,7 +73,13 @@ where
client_id_a: &ClientIdA<Self>,
client_id_b: &ClientIdB<Self>,
) -> Result<OfaBiRelayWrapper<Build::BiRelay>, Build::Error> {
self.build_afo_birelay(chain_id_a, chain_id_b, client_id_a, client_id_b)
.await
<OfaBuilderWrapper<Build> as CanBuildAfoBiRelay>::build_afo_birelay(
self,
chain_id_a,
chain_id_b,
client_id_a,
client_id_b,
)
.await
}
}
27 changes: 24 additions & 3 deletions crates/relayer-all-in-one/src/all_for_one/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,44 @@ use ibc_relayer_components::runtime::traits::runtime::HasRuntime;
use ibc_relayer_components::runtime::traits::sleep::CanSleep;
use ibc_relayer_components::runtime::traits::time::HasTime;
use ibc_relayer_components_extra::runtime::traits::channel::{
CanCreateChannels, CanStreamReceiver, CanUseChannels,
CanCloneSender, CanCreateChannels, CanStreamReceiver, CanUseChannels, HasChannelTypes,
};
use ibc_relayer_components_extra::runtime::traits::channel_once::{
CanCreateChannelsOnce, CanUseChannelsOnce, HasChannelOnceTypes,
};
use ibc_relayer_components_extra::runtime::traits::spawn::HasSpawner;

pub trait AfoRuntime:
HasMutex + CanSleep + HasTime + HasSpawner + CanCreateChannels + CanStreamReceiver + CanUseChannels
Clone
+ HasMutex
+ CanSleep
+ HasTime
+ HasSpawner
+ HasChannelTypes
+ HasChannelOnceTypes
+ CanCreateChannels
+ CanCreateChannelsOnce
+ CanStreamReceiver
+ CanCloneSender
+ CanUseChannels
+ CanUseChannelsOnce
{
}

impl<Runtime> AfoRuntime for Runtime where
Runtime: HasMutex
Runtime: Clone
+ HasMutex
+ CanSleep
+ HasTime
+ HasSpawner
+ HasChannelTypes
+ HasChannelOnceTypes
+ CanCreateChannels
+ CanCreateChannelsOnce
+ CanStreamReceiver
+ CanCloneSender
+ CanUseChannels
+ CanUseChannelsOnce
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ use ibc_relayer_components::runtime::traits::runtime::HasRuntime;

use crate::one_for_all::traits::birelay::OfaBiRelay;
use crate::one_for_all::types::birelay::OfaBiRelayWrapper;
use crate::one_for_all::types::runtime::OfaRuntimeWrapper;

impl<BiRelay> HasRuntime for OfaBiRelayWrapper<BiRelay>
where
BiRelay: OfaBiRelay,
{
type Runtime = OfaRuntimeWrapper<BiRelay::Runtime>;
type Runtime = BiRelay::Runtime;

fn runtime(&self) -> &Self::Runtime {
self.birelay.runtime()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ use ibc_relayer_components::runtime::traits::runtime::HasRuntime;

use crate::one_for_all::traits::builder::OfaBuilder;
use crate::one_for_all::types::builder::OfaBuilderWrapper;
use crate::one_for_all::types::runtime::OfaRuntimeWrapper;

impl<Builder> HasRuntime for OfaBuilderWrapper<Builder>
where
Builder: OfaBuilder,
{
type Runtime = OfaRuntimeWrapper<Builder::Runtime>;
type Runtime = Builder::Runtime;

fn runtime(&self) -> &Self::Runtime {
self.builder.runtime()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ use ibc_relayer_components_extra::telemetry::traits::telemetry::HasTelemetry;

use crate::one_for_all::traits::chain::OfaChain;
use crate::one_for_all::types::chain::OfaChainWrapper;
use crate::one_for_all::types::telemetry::OfaTelemetryWrapper;

impl<Chain> HasTelemetry for OfaChainWrapper<Chain>
where
Chain: OfaChain,
{
type Telemetry = OfaTelemetryWrapper<Chain::Telemetry>;
type Telemetry = Chain::Telemetry;

fn telemetry(&self) -> &Self::Telemetry {
self.chain.telemetry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use ibc_relayer_components_extra::components::extra::chain::ExtraChainComponents
use crate::one_for_all::traits::chain::{OfaChain, OfaChainTypes, OfaIbcChain};
use crate::one_for_all::types::chain::OfaChainWrapper;
use crate::one_for_all::types::component::OfaComponents;
use crate::one_for_all::types::runtime::OfaRuntimeWrapper;
use crate::std_prelude::*;

impl<Chain, Name> DelegateComponent<Name> for OfaChainWrapper<Chain>
Expand All @@ -33,7 +32,7 @@ where
}

impl<Chain: OfaChain> HasRuntime for OfaChainWrapper<Chain> {
type Runtime = OfaRuntimeWrapper<Chain::Runtime>;
type Runtime = Chain::Runtime;

fn runtime(&self) -> &Self::Runtime {
self.chain.runtime()
Expand Down
2 changes: 0 additions & 2 deletions crates/relayer-all-in-one/src/one_for_all/impls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ pub mod birelay;
pub mod builder;
pub mod chain;
pub mod relay;
pub mod runtime;
pub mod telemetry;
pub mod transaction;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::one_for_all::traits::relay::OfaRelay;
use crate::one_for_all::types::chain::OfaChainWrapper;
use crate::one_for_all::types::component::OfaComponents;
use crate::one_for_all::types::relay::OfaRelayWrapper;
use crate::one_for_all::types::runtime::OfaRuntimeWrapper;

impl<Relay, Name> DelegateComponent<Name> for OfaRelayWrapper<Relay>
where
Expand All @@ -30,7 +29,7 @@ impl<Relay> HasRuntime for OfaRelayWrapper<Relay>
where
Relay: OfaRelay,
{
type Runtime = OfaRuntimeWrapper<Relay::Runtime>;
type Runtime = Relay::Runtime;

fn runtime(&self) -> &Self::Runtime {
self.relay.runtime()
Expand Down
126 changes: 0 additions & 126 deletions crates/relayer-all-in-one/src/one_for_all/impls/runtime/channel.rs

This file was deleted.

11 changes: 0 additions & 11 deletions crates/relayer-all-in-one/src/one_for_all/impls/runtime/error.rs

This file was deleted.

25 changes: 0 additions & 25 deletions crates/relayer-all-in-one/src/one_for_all/impls/runtime/mutex.rs

This file was deleted.

18 changes: 0 additions & 18 deletions crates/relayer-all-in-one/src/one_for_all/impls/runtime/sleep.rs

This file was deleted.

25 changes: 0 additions & 25 deletions crates/relayer-all-in-one/src/one_for_all/impls/runtime/spawn.rs

This file was deleted.

21 changes: 0 additions & 21 deletions crates/relayer-all-in-one/src/one_for_all/impls/runtime/time.rs

This file was deleted.

Loading

0 comments on commit 4238d6c

Please sign in to comment.