, Self::Error>;
/// Get nonce of instance of latest generated message.
async fn latest_generated_nonce(
&self,
id: SourceHeaderIdOf,
) -> Result<(SourceHeaderIdOf
, MessageNonce), Self::Error>;
/// Get nonce of the latest message, which receiving has been confirmed by the target chain.
async fn latest_confirmed_received_nonce(
&self,
id: SourceHeaderIdOf
,
) -> Result<(SourceHeaderIdOf
, MessageNonce), Self::Error>;
/// Returns mapping of message nonces, generated on this client, to their weights.
///
/// Some weights may be missing from returned map, if corresponding messages were pruned at
/// the source chain.
async fn generated_messages_weights(
&self,
id: SourceHeaderIdOf
,
nonces: RangeInclusive,
) -> Result;
/// Prove messages in inclusive range [begin; end].
async fn prove_messages(
&self,
id: SourceHeaderIdOf,
nonces: RangeInclusive,
proof_parameters: MessageProofParameters,
) -> Result<(SourceHeaderIdOf, RangeInclusive, P::MessagesProof), Self::Error>;
/// Submit messages receiving proof.
async fn submit_messages_receiving_proof(
&self,
generated_at_block: TargetHeaderIdOf,
proof: P::MessagesReceivingProof,
) -> Result<(), Self::Error>;
/// Activate (or deactivate) headers relay that relays target headers to source node.
async fn activate_target_to_source_headers_relay(&self, activate: bool);
}
/// Target client trait.
#[async_trait]
pub trait TargetClient: RelayClient {
/// Returns state of the client.
async fn state(&self) -> Result, Self::Error>;
/// Get nonce of latest received message.
async fn latest_received_nonce(
&self,
id: TargetHeaderIdOf,
) -> Result<(TargetHeaderIdOf
, MessageNonce), Self::Error>;
/// Get nonce of latest confirmed message.
async fn latest_confirmed_received_nonce(
&self,
id: TargetHeaderIdOf
,
) -> Result<(TargetHeaderIdOf
, MessageNonce), Self::Error>;
/// Get state of unrewarded relayers set at the inbound lane.
async fn unrewarded_relayers_state(
&self,
id: TargetHeaderIdOf
,
) -> Result<(TargetHeaderIdOf
, UnrewardedRelayersState), Self::Error>;
/// Prove messages receiving at given block.
async fn prove_messages_receiving(
&self,
id: TargetHeaderIdOf
,
) -> Result<(TargetHeaderIdOf
, P::MessagesReceivingProof), Self::Error>;
/// Submit messages proof.
async fn submit_messages_proof(
&self,
generated_at_header: SourceHeaderIdOf
,
nonces: RangeInclusive,
proof: P::MessagesProof,
) -> Result, Self::Error>;
/// Activate (or deactivate) headers relay that relays source headers to target node.
async fn activate_source_to_target_headers_relay(&self, activate: bool);
}
/// State of the client.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ClientState {
/// Best header id of this chain.
pub best_self: SelfHeaderId,
/// Best finalized header id of this chain.
pub best_finalized_self: SelfHeaderId,
/// Best finalized header id of the peer chain read at the best block of this chain (at `best_finalized_self`).
pub best_finalized_peer_at_best_self: PeerHeaderId,
}
/// State of source client in one-way message lane.
pub type SourceClientState = ClientState, TargetHeaderIdOf>;
/// State of target client in one-way message lane.
pub type TargetClientState
= ClientState, SourceHeaderIdOf>;
/// Both clients state.
#[derive(Debug, Default)]
pub struct ClientsState {
/// Source client state.
pub source: Option>,
/// Target client state.
pub target: Option>,
}
/// Run message lane service loop.
pub async fn run(
params: Params,
source_client: impl SourceClient,
target_client: impl TargetClient
,
metrics_params: Option,
exit_signal: impl Future