Chain specific message lane apis (#503)

* replace generic message lane APIs with chain-specific

* moved SubstrateHeadersSyncPipeline to headers_pipeline.rs

* substrate-specific message lane trait

* Update relays/substrate/src/messages_lane.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
This commit is contained in:
Svyatoslav Nikolsky
2020-11-23 10:55:47 +03:00
committed by Bastian Köcher
parent d2ab81340a
commit 53791a1d4a
16 changed files with 309 additions and 231 deletions
+3 -30
View File
@@ -18,12 +18,14 @@
//! runtime that implements `<BridgedChainName>HeaderApi` to allow bridging with
//! <BridgedName> chain.
use crate::headers_pipeline::SubstrateHeadersSyncPipeline;
use async_trait::async_trait;
use codec::{Decode, Encode};
use futures::TryFutureExt;
use headers_relay::{
sync_loop::TargetClient,
sync_types::{HeaderIdOf, HeadersSyncPipeline, QueuedHeader, SubmittedHeaders},
sync_types::{HeaderIdOf, QueuedHeader, SubmittedHeaders},
};
use relay_substrate_client::{Chain, Client, Error as SubstrateError};
use relay_utils::HeaderId;
@@ -31,35 +33,6 @@ use sp_core::Bytes;
use sp_runtime::Justification;
use std::collections::HashSet;
/// Headers sync pipeline for Substrate <-> Substrate relays.
#[async_trait]
pub trait SubstrateHeadersSyncPipeline: HeadersSyncPipeline {
/// Name of the `best_block` runtime method.
const BEST_BLOCK_METHOD: &'static str;
/// Name of the `finalized_block` runtime method.
const FINALIZED_BLOCK_METHOD: &'static str;
/// Name of the `is_known_block` runtime method.
const IS_KNOWN_BLOCK_METHOD: &'static str;
/// Name of the `incomplete_headers` runtime method.
const INCOMPLETE_HEADERS_METHOD: &'static str;
/// Signed transaction type.
type SignedTransaction: Send + Sync + Encode;
/// Make submit header transaction.
async fn make_submit_header_transaction(
&self,
header: QueuedHeader<Self>,
) -> Result<Self::SignedTransaction, SubstrateError>;
/// Make completion transaction for the header.
async fn make_complete_header_transaction(
&self,
id: HeaderIdOf<Self>,
completion: Justification,
) -> Result<Self::SignedTransaction, SubstrateError>;
}
/// Substrate client as Substrate headers target.
pub struct SubstrateHeadersTarget<C: Chain, P> {
client: Client<C>,