Skip to content

Commit

Permalink
Add docstring to channel handshake steps implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ljoss17 committed Jul 7, 2023
1 parent 01dbb6a commit d0f3fec
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 0 deletions.
13 changes: 13 additions & 0 deletions crates/relayer-components/src/relay/impls/channel/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ use crate::relay::traits::channel::open_init::CanInitChannel;
use crate::relay::types::aliases::{DstChannelId, DstPortId, SrcChannelId, SrcPortId};
use crate::std_prelude::*;

/**
This is an autotrait implementation by the relay context to allow bootstrapping
of new IBC channels as initiated by the relayer.
This can be used by the users of the relayer to create new channels. It can
also be used in integration tests to create new channels.
Note that this should _not_ be used when relaying channel creation that
are initiated by external users. For that purpose, use
[`RelayChannelOpenHandshake`](crate::relay::impls::channel::open_handshake::RelayChannelOpenHandshake),
which would reuse the given channel ID instead of creating new ones.
*/

#[async_trait]
pub trait CanBootstrapChannel: HasRelayChains
where
Expand Down
13 changes: 13 additions & 0 deletions crates/relayer-components/src/relay/impls/channel/open_ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ use crate::relay::traits::target::SourceTarget;
use crate::relay::types::aliases::{DstChannelId, DstPortId, SrcChannelId, SrcPortId};
use crate::std_prelude::*;

/**
A base implementation of [`ChannelOpenAckRelayer`] that relays a new channel
at the destination chain that is in `OPEN_TRY` state, and submits it as a
`ChannelOpenAck` message to the destination chain.
This implements the `ChanOpenAck` step of the IBC channel handshake protocol.
Note that this implementation does not check that the connection exists on
the destination chain. It also doesn't check that the channel end at the
destination chain is really in the `OPEN_TRY` state. This will be implemented
as a separate wrapper component. (TODO)
*/

pub struct RelayChannelOpenAck;

#[async_trait]
Expand Down
13 changes: 13 additions & 0 deletions crates/relayer-components/src/relay/impls/channel/open_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ use crate::relay::traits::target::DestinationTarget;
use crate::relay::types::aliases::{DstChannelId, DstPortId, SrcChannelId, SrcPortId};
use crate::std_prelude::*;

/**
A base implementation of [`ChannelOpenConfirmRelayer`] that relays a new channel
at the source chain that is in `OPEN` state, and submits it as a
`ChannelOpenConfirm` message to the destination chain.
This implements the `ChanOpenConfirm` step of the IBC channel handshake protocol.
Note that this implementation does not check that the connection exists on
the destination chain, that a channel exists on the source chain, and that the
channel end at the source chain is really in the `OPEN` state. This will be implemented
as a separate wrapper component. (TODO)
*/

pub struct RelayChannelOpenConfirm;

#[async_trait]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ use crate::relay::traits::channel::open_handshake::ChannelOpenHandshakeRelayer;
use crate::relay::traits::channel::open_try::CanRelayChannelOpenTry;
use crate::std_prelude::*;

/**
Relays a connection open handshake using a channel ID that has been
initialized at the source chain, and the port IDs used.
Specifically, the `ChanOpenTry`, `ChanOpenAck`, and `ChanOpenConfirm` steps of
the handshake protocol are performed between both chains. Upon successful
completion of the handshake protocol, a channel will have been established
between both chains.
This can be used for relaying of channels that are created by external
users.
*/
pub struct RelayChannelOpenHandshake;

#[async_trait]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ pub trait InjectMissingChannelInitEventError: HasRelayChains {
fn missing_channel_init_event_error(&self) -> Self::Error;
}

/**
A base implementation for [`ChannelInitializer`] which submits a
`ChannelOpenInit` message to the source chain.
This implements the `ChanOpenInit` step in the IBC channel handshake protocol.
*/

pub struct InitializeChannel;

#[async_trait]
Expand Down
13 changes: 13 additions & 0 deletions crates/relayer-components/src/relay/impls/channel/open_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ pub trait InjectMissingChannelTryEventError: HasRelayChains {
) -> Self::Error;
}

/**
A base implementation of [`ChannelOpenTryRelayer`] that relays a new channel
at the source chain that is in `OPEN_INIT` state, and submits it as a
`ChannelOpenTry` message to the destination chain.
This implements the `ChanOpenTry` step of the IBC channel handshake protocol.
Note that this implementation does not check that the connection exists on
the destination chain. It also doesn't check that the channel end at the
source chain is really in the `OPEN_INIT` state. This will be implemented as
a separate wrapper component. (TODO)
*/

pub struct RelayChannelOpenTry;

#[async_trait]
Expand Down

0 comments on commit d0f3fec

Please sign in to comment.