-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use GAT to define generic MPSC channel context (#2935)
* Use explicit injection for runtime error * Allow Src/Dst chain Error type to be different from Relay::Error Only remaining fix needed is the same error constraint in BatchContext, which can be fixed in #2816. * Initial draft for GAT channels * Add type alias for batch channel types * Add new HasBatchChannelTypes trait * Add HasBatchSender/Receiver traits * Refactor SendMessagetoBatchWorker * Refactor batch worker * Remove old batch traits and types * Separate OfaRuntimeWrapper impls into separate files * Implement channel traits for OfaRuntimeWrapper * Abstract batch components working in relayer framework * Fix all compile errors * Remove unused HasBatchChannelTypes trait * Refactor batch type aliases to be based on Chain and Error * Reorganize batch module definitions * Separate Channel and ChannelOnce types * Put Channel and ChannelOnce into separate modules * Fix clippy * Remove From<TokioError> which is no longer needed * Resolve merge conflicts in soares/gat-batch-context * Move OfaRuntimeWrapper to types module * Adding documentation for GAT channel traits * Fix merge errors
- Loading branch information
1 parent
6c9ea21
commit 869278d
Showing
64 changed files
with
956 additions
and
554 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
use alloc::sync::Arc; | ||
use ibc_relayer_framework::base::one_for_all::traits::runtime::OfaRuntimeContext; | ||
use ibc_relayer_framework::base::one_for_all::types::runtime::OfaRuntimeWrapper; | ||
use ibc_relayer_runtime::tokio::context::TokioRuntimeContext; | ||
|
||
#[derive(Clone)] | ||
pub struct CosmosChainWrapper<Chain> { | ||
pub chain: Arc<Chain>, | ||
pub runtime: OfaRuntimeContext<TokioRuntimeContext>, | ||
pub runtime: OfaRuntimeWrapper<TokioRuntimeContext>, | ||
} | ||
|
||
impl<Chain> CosmosChainWrapper<Chain> { | ||
pub fn new(chain: Arc<Chain>, runtime: TokioRuntimeContext) -> Self { | ||
Self { | ||
chain, | ||
runtime: OfaRuntimeContext::new(runtime), | ||
runtime: OfaRuntimeWrapper::new(runtime), | ||
} | ||
} | ||
} |
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
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,11 +1,8 @@ | ||
use ibc_relayer_framework::full::one_for_all::traits::telemetry::OfaTelemetryWrapper; | ||
|
||
use crate::base::traits::chain::CosmosChain; | ||
use crate::full::types::batch::CosmosBatchChannel; | ||
use crate::full::types::telemetry::CosmosTelemetry; | ||
|
||
pub trait CosmosFullChain: CosmosChain { | ||
fn batch_channel(&self) -> &CosmosBatchChannel; | ||
|
||
fn telemetry(&self) -> &OfaTelemetryWrapper<CosmosTelemetry>; | ||
} |
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,7 +1,16 @@ | ||
use ibc_relayer::config::filter::PacketFilter; | ||
|
||
use crate::base::traits::relay::CosmosRelay; | ||
use crate::full::types::batch::{CosmosBatchReceiver, CosmosBatchSender}; | ||
|
||
pub trait CosmosFullRelay: CosmosRelay { | ||
fn packet_filter(&self) -> &PacketFilter; | ||
|
||
fn src_chain_message_batch_sender(&self) -> &CosmosBatchSender; | ||
|
||
fn src_chain_message_batch_receiver(&self) -> &CosmosBatchReceiver; | ||
|
||
fn dst_chain_message_batch_sender(&self) -> &CosmosBatchSender; | ||
|
||
fn dst_chain_message_batch_receiver(&self) -> &CosmosBatchReceiver; | ||
} |
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,18 +1,17 @@ | ||
use ibc_relayer_framework::full::batch::context::BatchChannel; | ||
use std::sync::{Arc, Mutex}; | ||
use std::sync::Arc; | ||
use tendermint::abci::Event; | ||
use tokio::sync::{mpsc, oneshot}; | ||
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; | ||
use tokio::sync::oneshot::Sender as SenderOnce; | ||
use tokio::sync::Mutex; | ||
|
||
use crate::base::error::Error; | ||
use crate::base::types::message::CosmosIbcMessage; | ||
|
||
pub type CosmosBatchPayload = ( | ||
Vec<CosmosIbcMessage>, | ||
oneshot::Sender<Result<Vec<Vec<Event>>, Error>>, | ||
SenderOnce<Result<Vec<Vec<Event>>, Error>>, | ||
); | ||
|
||
pub type CosmosBatchSender = mpsc::UnboundedSender<CosmosBatchPayload>; | ||
pub type CosmosBatchSender = UnboundedSender<CosmosBatchPayload>; | ||
|
||
pub type CosmosBatchReceiver = Arc<Mutex<mpsc::UnboundedReceiver<CosmosBatchPayload>>>; | ||
|
||
pub type CosmosBatchChannel = BatchChannel<CosmosBatchSender, CosmosBatchReceiver>; | ||
pub type CosmosBatchReceiver = Arc<Mutex<UnboundedReceiver<CosmosBatchPayload>>>; |
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
Oops, something went wrong.