Remove SOURCE_PARACHAIN_PARA_ID (#1716)

* Remove SOURCE_PARACHAIN_PARA_ID

Remove SubstrateParachainsPipeline::SOURCE_PARACHAIN_PARA_ID

* Avoid duplicate ChainBase and ParachainBase implementations

* Replace ChainShadow with UnderlyingChainProvider
This commit is contained in:
Serban Iorga
2022-12-14 12:29:09 +02:00
committed by Bastian Köcher
parent 7d55a0ffe2
commit bde1629f86
27 changed files with 154 additions and 272 deletions
+1 -8
View File
@@ -27,6 +27,7 @@ use bp_messages::{
InboundLaneData, LaneId, Message, MessageKey, MessageNonce, MessagePayload, OutboundLaneData, InboundLaneData, LaneId, Message, MessageKey, MessageNonce, MessagePayload, OutboundLaneData,
}; };
use bp_runtime::{messages::MessageDispatchResult, Chain, ChainId, Size, StorageProofChecker}; use bp_runtime::{messages::MessageDispatchResult, Chain, ChainId, Size, StorageProofChecker};
pub use bp_runtime::{UnderlyingChainOf, UnderlyingChainProvider};
use codec::{Decode, DecodeLimit, Encode}; use codec::{Decode, DecodeLimit, Encode};
use frame_support::{traits::Get, weights::Weight, RuntimeDebug}; use frame_support::{traits::Get, weights::Weight, RuntimeDebug};
use hash_db::Hasher; use hash_db::Hasher;
@@ -54,12 +55,6 @@ pub trait MessageBridge {
type BridgedHeaderChain: HeaderChain<UnderlyingChainOf<Self::BridgedChain>>; type BridgedHeaderChain: HeaderChain<UnderlyingChainOf<Self::BridgedChain>>;
} }
/// A trait that provides the type of the underlying chain.
pub trait UnderlyingChainProvider {
/// Underlying chain type.
type Chain: Chain;
}
/// This chain that has `pallet-bridge-messages` module. /// This chain that has `pallet-bridge-messages` module.
pub trait ThisChainWithMessages: UnderlyingChainProvider { pub trait ThisChainWithMessages: UnderlyingChainProvider {
/// Call origin on the chain. /// Call origin on the chain.
@@ -87,8 +82,6 @@ pub trait BridgedChainWithMessages: UnderlyingChainProvider {
pub type ThisChain<B> = <B as MessageBridge>::ThisChain; pub type ThisChain<B> = <B as MessageBridge>::ThisChain;
/// Bridged chain in context of message bridge. /// Bridged chain in context of message bridge.
pub type BridgedChain<B> = <B as MessageBridge>::BridgedChain; pub type BridgedChain<B> = <B as MessageBridge>::BridgedChain;
/// Underlying chain type.
pub type UnderlyingChainOf<C> = <C as UnderlyingChainProvider>::Chain;
/// Hash used on the chain. /// Hash used on the chain.
pub type HashOf<C> = bp_runtime::HashOf<<C as UnderlyingChainProvider>::Chain>; pub type HashOf<C> = bp_runtime::HashOf<<C as UnderlyingChainProvider>::Chain>;
/// Hasher used on the chain. /// Hasher used on the chain.
+39
View File
@@ -192,12 +192,51 @@ pub trait Chain: Send + Sync + 'static {
fn max_extrinsic_weight() -> Weight; fn max_extrinsic_weight() -> Weight;
} }
/// A trait that provides the type of the underlying chain.
pub trait UnderlyingChainProvider {
/// Underlying chain type.
type Chain: Chain;
}
impl<T> Chain for T
where
T: Send + Sync + 'static + UnderlyingChainProvider,
{
type BlockNumber = <T::Chain as Chain>::BlockNumber;
type Hash = <T::Chain as Chain>::Hash;
type Hasher = <T::Chain as Chain>::Hasher;
type Header = <T::Chain as Chain>::Header;
type AccountId = <T::Chain as Chain>::AccountId;
type Balance = <T::Chain as Chain>::Balance;
type Index = <T::Chain as Chain>::Index;
type Signature = <T::Chain as Chain>::Signature;
fn max_extrinsic_size() -> u32 {
<T::Chain as Chain>::max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
<T::Chain as Chain>::max_extrinsic_weight()
}
}
/// Minimal parachain representation that may be used from no_std environment. /// Minimal parachain representation that may be used from no_std environment.
pub trait Parachain: Chain { pub trait Parachain: Chain {
/// Parachain identifier. /// Parachain identifier.
const PARACHAIN_ID: u32; const PARACHAIN_ID: u32;
} }
impl<T> Parachain for T
where
T: Chain + UnderlyingChainProvider,
<T as UnderlyingChainProvider>::Chain: Parachain,
{
const PARACHAIN_ID: u32 = <<T as UnderlyingChainProvider>::Chain as Parachain>::PARACHAIN_ID;
}
/// Underlying chain type.
pub type UnderlyingChainOf<C> = <C as UnderlyingChainProvider>::Chain;
/// Block number used by the chain. /// Block number used by the chain.
pub type BlockNumberOf<C> = <C as Chain>::BlockNumber; pub type BlockNumberOf<C> = <C as Chain>::BlockNumber;
+2 -1
View File
@@ -32,7 +32,8 @@ use sp_std::{convert::TryFrom, fmt::Debug, vec, vec::Vec};
pub use chain::{ pub use chain::{
AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, EncodedOrDecodedCall, HashOf, AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, EncodedOrDecodedCall, HashOf,
HasherOf, HeaderOf, IndexOf, Parachain, SignatureOf, TransactionEraOf, HasherOf, HeaderOf, IndexOf, Parachain, SignatureOf, TransactionEraOf, UnderlyingChainOf,
UnderlyingChainProvider,
}; };
pub use frame_support::storage::storage_prefix as storage_value_final_key; pub use frame_support::storage::storage_prefix as storage_value_final_key;
use num_traits::{CheckedSub, One}; use num_traits::{CheckedSub, One};
@@ -40,8 +40,6 @@ impl SubstrateParachainsPipeline for RialtoParachainsToMillau {
type TargetChain = Millau; type TargetChain = Millau;
type SubmitParachainHeadsCallBuilder = RialtoParachainsToMillauSubmitParachainHeadsCallBuilder; type SubmitParachainHeadsCallBuilder = RialtoParachainsToMillauSubmitParachainHeadsCallBuilder;
const SOURCE_PARACHAIN_PARA_ID: u32 = bp_rialto_parachain::RIALTO_PARACHAIN_ID;
} }
/// `submit_parachain_heads` call builder for Rialto-to-Millau parachains sync pipeline. /// `submit_parachain_heads` call builder for Rialto-to-Millau parachains sync pipeline.
@@ -39,8 +39,6 @@ impl SubstrateParachainsPipeline for BridgeHubRococoToBridgeHubWococo {
type TargetChain = relay_bridge_hub_wococo_client::BridgeHubWococo; type TargetChain = relay_bridge_hub_wococo_client::BridgeHubWococo;
type SubmitParachainHeadsCallBuilder = BridgeHubRococoToBridgeHubWococoCallBuilder; type SubmitParachainHeadsCallBuilder = BridgeHubRococoToBridgeHubWococoCallBuilder;
const SOURCE_PARACHAIN_PARA_ID: u32 = bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID;
} }
pub struct BridgeHubRococoToBridgeHubWococoCallBuilder; pub struct BridgeHubRococoToBridgeHubWococoCallBuilder;
@@ -39,8 +39,6 @@ impl SubstrateParachainsPipeline for WestendParachainsToMillau {
type TargetChain = Millau; type TargetChain = Millau;
type SubmitParachainHeadsCallBuilder = WestendParachainsToMillauSubmitParachainHeadsCallBuilder; type SubmitParachainHeadsCallBuilder = WestendParachainsToMillauSubmitParachainHeadsCallBuilder;
const SOURCE_PARACHAIN_PARA_ID: u32 = bp_westend::WESTMINT_PARACHAIN_ID;
} }
/// `submit_parachain_heads` call builder for Rialto-to-Millau parachains sync pipeline. /// `submit_parachain_heads` call builder for Rialto-to-Millau parachains sync pipeline.
@@ -39,8 +39,6 @@ impl SubstrateParachainsPipeline for BridgeHubWococoToBridgeHubRococo {
type TargetChain = relay_bridge_hub_rococo_client::BridgeHubRococo; type TargetChain = relay_bridge_hub_rococo_client::BridgeHubRococo;
type SubmitParachainHeadsCallBuilder = BridgeHubWococoToBridgeHubRococoCallBuilder; type SubmitParachainHeadsCallBuilder = BridgeHubWococoToBridgeHubRococoCallBuilder;
const SOURCE_PARACHAIN_PARA_ID: u32 = bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID;
} }
pub struct BridgeHubWococoToBridgeHubRococoCallBuilder; pub struct BridgeHubWococoToBridgeHubRococoCallBuilder;
@@ -17,7 +17,9 @@
use crate::cli::CliChain; use crate::cli::CliChain;
use pallet_bridge_parachains::{RelayBlockHash, RelayBlockHasher, RelayBlockNumber}; use pallet_bridge_parachains::{RelayBlockHash, RelayBlockHasher, RelayBlockNumber};
use parachains_relay::ParachainsPipeline; use parachains_relay::ParachainsPipeline;
use relay_substrate_client::{AccountKeyPairOf, Chain, ChainWithTransactions, RelayChain}; use relay_substrate_client::{
AccountKeyPairOf, Chain, ChainWithTransactions, Parachain, RelayChain,
};
use strum::{EnumString, EnumVariantNames}; use strum::{EnumString, EnumVariantNames};
use substrate_relay_helper::{ use substrate_relay_helper::{
finality::SubstrateFinalitySyncPipeline, messages_lane::SubstrateMessageLane, finality::SubstrateFinalitySyncPipeline, messages_lane::SubstrateMessageLane,
@@ -76,7 +78,10 @@ pub trait RelayToRelayHeadersCliBridge: CliBridgeBase {
/// Bridge representation that can be used from the CLI for relaying headers /// Bridge representation that can be used from the CLI for relaying headers
/// from a parachain to a relay chain. /// from a parachain to a relay chain.
pub trait ParachainToRelayHeadersCliBridge: CliBridgeBase { pub trait ParachainToRelayHeadersCliBridge: CliBridgeBase
where
Self::Source: Parachain,
{
// The `CliBridgeBase` type represents the parachain in this situation. // The `CliBridgeBase` type represents the parachain in this situation.
// We need to add an extra type for the relay chain. // We need to add an extra type for the relay chain.
type SourceRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher> type SourceRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher>
@@ -62,6 +62,7 @@ use bp_messages::LaneId;
use bp_runtime::{BalanceOf, BlockNumberOf}; use bp_runtime::{BalanceOf, BlockNumberOf};
use relay_substrate_client::{ use relay_substrate_client::{
AccountIdOf, AccountKeyPairOf, Chain, ChainWithBalances, ChainWithTransactions, Client, AccountIdOf, AccountKeyPairOf, Chain, ChainWithBalances, ChainWithTransactions, Client,
Parachain,
}; };
use relay_utils::metrics::MetricsParams; use relay_utils::metrics::MetricsParams;
use sp_core::Pair; use sp_core::Pair;
@@ -25,7 +25,9 @@ use crate::cli::{
use bp_polkadot_core::parachains::ParaHash; use bp_polkadot_core::parachains::ParaHash;
use bp_runtime::BlockNumberOf; use bp_runtime::BlockNumberOf;
use pallet_bridge_parachains::{RelayBlockHash, RelayBlockHasher, RelayBlockNumber}; use pallet_bridge_parachains::{RelayBlockHash, RelayBlockHasher, RelayBlockNumber};
use relay_substrate_client::{AccountIdOf, AccountKeyPairOf, Chain, ChainWithTransactions, Client}; use relay_substrate_client::{
AccountIdOf, AccountKeyPairOf, Chain, ChainWithTransactions, Client, Parachain,
};
use sp_core::Pair; use sp_core::Pair;
use substrate_relay_helper::{ use substrate_relay_helper::{
finality::SubstrateFinalitySyncPipeline, finality::SubstrateFinalitySyncPipeline,
@@ -42,7 +44,10 @@ use substrate_relay_helper::{
pub struct ParachainToParachainBridge< pub struct ParachainToParachainBridge<
L2R: MessagesCliBridge + ParachainToRelayHeadersCliBridge, L2R: MessagesCliBridge + ParachainToRelayHeadersCliBridge,
R2L: MessagesCliBridge + ParachainToRelayHeadersCliBridge, R2L: MessagesCliBridge + ParachainToRelayHeadersCliBridge,
> { > where
<L2R as CliBridgeBase>::Source: Parachain,
<R2L as CliBridgeBase>::Source: Parachain,
{
/// Parameters that are shared by all bridge types. /// Parameters that are shared by all bridge types.
pub common: pub common:
Full2WayBridgeCommonParams<<R2L as CliBridgeBase>::Target, <L2R as CliBridgeBase>::Target>, Full2WayBridgeCommonParams<<R2L as CliBridgeBase>::Target, <L2R as CliBridgeBase>::Target>,
@@ -118,9 +123,9 @@ macro_rules! declare_parachain_to_parachain_bridge_schema {
impl [<$left_parachain $right_parachain HeadersAndMessages>] { impl [<$left_parachain $right_parachain HeadersAndMessages>] {
async fn into_bridge< async fn into_bridge<
Left: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Left>>, Left: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Left>> + Parachain,
LeftRelay: CliChain, LeftRelay: CliChain,
Right: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Right>>, Right: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Right>> + Parachain,
RightRelay: CliChain, RightRelay: CliChain,
L2R: CliBridgeBase<Source = Left, Target = Right> L2R: CliBridgeBase<Source = Left, Target = Right>
+ MessagesCliBridge + MessagesCliBridge
@@ -172,10 +177,14 @@ macro_rules! declare_parachain_to_parachain_bridge_schema {
#[async_trait] #[async_trait]
impl< impl<
Left: Chain<Hash = ParaHash> + ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Left>>, Left: Chain<Hash = ParaHash>
+ ChainWithTransactions
+ CliChain<KeyPair = AccountKeyPairOf<Left>>
+ Parachain,
Right: Chain<Hash = ParaHash> Right: Chain<Hash = ParaHash>
+ ChainWithTransactions + ChainWithTransactions
+ CliChain<KeyPair = AccountKeyPairOf<Right>>, + CliChain<KeyPair = AccountKeyPairOf<Right>>
+ Parachain,
LeftRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher> LeftRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher>
+ CliChain, + CliChain,
RightRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher> RightRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher>
@@ -28,7 +28,9 @@ use crate::cli::{
use bp_polkadot_core::parachains::ParaHash; use bp_polkadot_core::parachains::ParaHash;
use bp_runtime::BlockNumberOf; use bp_runtime::BlockNumberOf;
use pallet_bridge_parachains::{RelayBlockHash, RelayBlockHasher, RelayBlockNumber}; use pallet_bridge_parachains::{RelayBlockHash, RelayBlockHasher, RelayBlockNumber};
use relay_substrate_client::{AccountIdOf, AccountKeyPairOf, Chain, ChainWithTransactions, Client}; use relay_substrate_client::{
AccountIdOf, AccountKeyPairOf, Chain, ChainWithTransactions, Client, Parachain,
};
use sp_core::Pair; use sp_core::Pair;
use substrate_relay_helper::{ use substrate_relay_helper::{
finality::SubstrateFinalitySyncPipeline, finality::SubstrateFinalitySyncPipeline,
@@ -45,7 +47,9 @@ use substrate_relay_helper::{
pub struct RelayToParachainBridge< pub struct RelayToParachainBridge<
L2R: MessagesCliBridge + RelayToRelayHeadersCliBridge, L2R: MessagesCliBridge + RelayToRelayHeadersCliBridge,
R2L: MessagesCliBridge + ParachainToRelayHeadersCliBridge, R2L: MessagesCliBridge + ParachainToRelayHeadersCliBridge,
> { > where
<R2L as CliBridgeBase>::Source: Parachain,
{
/// Parameters that are shared by all bridge types. /// Parameters that are shared by all bridge types.
pub common: pub common:
Full2WayBridgeCommonParams<<R2L as CliBridgeBase>::Target, <L2R as CliBridgeBase>::Target>, Full2WayBridgeCommonParams<<R2L as CliBridgeBase>::Target, <L2R as CliBridgeBase>::Target>,
@@ -112,7 +116,7 @@ macro_rules! declare_relay_to_parachain_bridge_schema {
impl [<$left_chain $right_parachain HeadersAndMessages>] { impl [<$left_chain $right_parachain HeadersAndMessages>] {
async fn into_bridge< async fn into_bridge<
Left: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Left>>, Left: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Left>>,
Right: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Right>>, Right: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Right>> + Parachain,
RightRelay: CliChain, RightRelay: CliChain,
L2R: CliBridgeBase<Source = Left, Target = Right> + MessagesCliBridge + RelayToRelayHeadersCliBridge, L2R: CliBridgeBase<Source = Left, Target = Right> + MessagesCliBridge + RelayToRelayHeadersCliBridge,
R2L: CliBridgeBase<Source = Right, Target = Left> R2L: CliBridgeBase<Source = Right, Target = Left>
@@ -165,7 +169,8 @@ impl<
Left: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Left>>, Left: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Left>>,
Right: Chain<Hash = ParaHash> Right: Chain<Hash = ParaHash>
+ ChainWithTransactions + ChainWithTransactions
+ CliChain<KeyPair = AccountKeyPairOf<Right>>, + CliChain<KeyPair = AccountKeyPairOf<Right>>
+ Parachain,
RightRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher> RightRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher>
+ CliChain, + CliChain,
L2R: CliBridgeBase<Source = Left, Target = Right> L2R: CliBridgeBase<Source = Left, Target = Right>
@@ -26,6 +26,7 @@ use bp_polkadot_core::parachains::ParaId;
use parachains_relay::parachains_loop::{ use parachains_relay::parachains_loop::{
AvailableHeader, ParachainSyncParams, SourceClient, TargetClient, AvailableHeader, ParachainSyncParams, SourceClient, TargetClient,
}; };
use relay_substrate_client::{Parachain, ParachainBase};
use relay_utils::metrics::{GlobalMetrics, StandaloneMetric}; use relay_utils::metrics::{GlobalMetrics, StandaloneMetric};
use std::sync::Arc; use std::sync::Arc;
use structopt::StructOpt; use structopt::StructOpt;
@@ -38,7 +39,11 @@ use substrate_relay_helper::{
TransactionParams, TransactionParams,
}; };
use crate::cli::{bridge::ParachainToRelayHeadersCliBridge, chain_schema::*, PrometheusParams}; use crate::cli::{
bridge::{CliBridgeBase, ParachainToRelayHeadersCliBridge},
chain_schema::*,
PrometheusParams,
};
/// Start parachain heads relayer process. /// Start parachain heads relayer process.
#[derive(StructOpt)] #[derive(StructOpt)]
@@ -74,6 +79,7 @@ where
SourceClient<ParachainsPipelineAdapter<Self::ParachainFinality>>, SourceClient<ParachainsPipelineAdapter<Self::ParachainFinality>>,
ParachainsTarget<Self::ParachainFinality>: ParachainsTarget<Self::ParachainFinality>:
TargetClient<ParachainsPipelineAdapter<Self::ParachainFinality>>, TargetClient<ParachainsPipelineAdapter<Self::ParachainFinality>>,
<Self as CliBridgeBase>::Source: Parachain,
{ {
async fn relay_headers(data: RelayParachains) -> anyhow::Result<()> { async fn relay_headers(data: RelayParachains) -> anyhow::Result<()> {
let source_client = data.source.into_client::<Self::SourceRelay>().await?; let source_client = data.source.into_client::<Self::SourceRelay>().await?;
@@ -100,7 +106,7 @@ where
target_client, target_client,
ParachainSyncParams { ParachainSyncParams {
parachains: vec![ parachains: vec![
ParaId(<Self::ParachainFinality as SubstrateParachainsPipeline>::SOURCE_PARACHAIN_PARA_ID) ParaId(<Self::ParachainFinality as SubstrateParachainsPipeline>::SourceParachain::PARACHAIN_ID)
], ],
stall_timeout: std::time::Duration::from_secs(60), stall_timeout: std::time::Duration::from_secs(60),
strategy: parachains_relay::parachains_loop::ParachainSyncStrategy::Any, strategy: parachains_relay::parachains_loop::ParachainSyncStrategy::Any,
@@ -16,11 +16,11 @@
//! Types used to connect to the BridgeHub-Rococo-Substrate parachain. //! Types used to connect to the BridgeHub-Rococo-Substrate parachain.
use bp_messages::{MessageNonce, Weight}; use bp_messages::MessageNonce;
use codec::Encode; use codec::Encode;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainBase, ChainWithBalances, ChainWithMessages, ChainWithTransactions, Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, Error as SubstrateError,
Error as SubstrateError, SignParam, UnsignedTransaction, SignParam, UnderlyingChainProvider, UnsignedTransaction,
}; };
use sp_core::{storage::StorageKey, Pair}; use sp_core::{storage::StorageKey, Pair};
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
@@ -34,24 +34,8 @@ pub use runtime_wrapper as runtime;
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct BridgeHubRococo; pub struct BridgeHubRococo;
impl ChainBase for BridgeHubRococo { impl UnderlyingChainProvider for BridgeHubRococo {
type BlockNumber = bp_bridge_hub_rococo::BlockNumber; type Chain = bp_bridge_hub_rococo::BridgeHubRococo;
type Hash = bp_bridge_hub_rococo::Hash;
type Hasher = bp_bridge_hub_rococo::Hashing;
type Header = bp_bridge_hub_rococo::Header;
type AccountId = bp_bridge_hub_rococo::AccountId;
type Balance = bp_bridge_hub_rococo::Balance;
type Index = bp_bridge_hub_rococo::Nonce;
type Signature = bp_bridge_hub_rococo::Signature;
fn max_extrinsic_size() -> u32 {
bp_bridge_hub_rococo::BridgeHubRococo::max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
bp_bridge_hub_rococo::BridgeHubRococo::max_extrinsic_weight()
}
} }
impl Chain for BridgeHubRococo { impl Chain for BridgeHubRococo {
@@ -16,11 +16,11 @@
//! Types used to connect to the BridgeHub-Wococo-Substrate parachain. //! Types used to connect to the BridgeHub-Wococo-Substrate parachain.
use bp_messages::{MessageNonce, Weight}; use bp_messages::MessageNonce;
use codec::Encode; use codec::Encode;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainBase, ChainWithBalances, ChainWithMessages, ChainWithTransactions, Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, Error as SubstrateError,
Error as SubstrateError, SignParam, UnsignedTransaction, SignParam, UnderlyingChainProvider, UnsignedTransaction,
}; };
use sp_core::{storage::StorageKey, Pair}; use sp_core::{storage::StorageKey, Pair};
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
@@ -34,24 +34,8 @@ pub use runtime_wrapper as runtime;
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct BridgeHubWococo; pub struct BridgeHubWococo;
impl ChainBase for BridgeHubWococo { impl UnderlyingChainProvider for BridgeHubWococo {
type BlockNumber = bp_bridge_hub_wococo::BlockNumber; type Chain = bp_bridge_hub_wococo::BridgeHubWococo;
type Hash = bp_bridge_hub_wococo::Hash;
type Hasher = bp_bridge_hub_wococo::Hashing;
type Header = bp_bridge_hub_wococo::Header;
type AccountId = bp_bridge_hub_wococo::AccountId;
type Balance = bp_bridge_hub_wococo::Balance;
type Index = bp_bridge_hub_wococo::Nonce;
type Signature = bp_bridge_hub_wococo::Signature;
fn max_extrinsic_size() -> u32 {
bp_bridge_hub_wococo::BridgeHubWococo::max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
bp_bridge_hub_wococo::BridgeHubWococo::max_extrinsic_weight()
}
} }
impl Chain for BridgeHubWococo { impl Chain for BridgeHubWococo {
+3 -20
View File
@@ -17,8 +17,7 @@
//! Types used to connect to the Kusama chain. //! Types used to connect to the Kusama chain.
use bp_kusama::AccountInfoStorageMapKeyProvider; use bp_kusama::AccountInfoStorageMapKeyProvider;
use frame_support::weights::Weight; use relay_substrate_client::{Chain, ChainWithBalances, ChainWithGrandpa, UnderlyingChainProvider};
use relay_substrate_client::{Chain, ChainBase, ChainWithBalances, ChainWithGrandpa};
use sp_core::storage::StorageKey; use sp_core::storage::StorageKey;
use std::time::Duration; use std::time::Duration;
@@ -29,24 +28,8 @@ pub type HeaderId = relay_utils::HeaderId<bp_kusama::Hash, bp_kusama::BlockNumbe
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct Kusama; pub struct Kusama;
impl ChainBase for Kusama { impl UnderlyingChainProvider for Kusama {
type BlockNumber = bp_kusama::BlockNumber; type Chain = bp_kusama::Kusama;
type Hash = bp_kusama::Hash;
type Hasher = bp_kusama::Hasher;
type Header = bp_kusama::Header;
type AccountId = bp_kusama::AccountId;
type Balance = bp_kusama::Balance;
type Index = bp_kusama::Nonce;
type Signature = bp_kusama::Signature;
fn max_extrinsic_size() -> u32 {
bp_kusama::Kusama::max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
bp_kusama::Kusama::max_extrinsic_weight()
}
} }
impl Chain for Kusama { impl Chain for Kusama {
+5 -21
View File
@@ -18,10 +18,10 @@
use bp_messages::MessageNonce; use bp_messages::MessageNonce;
use codec::{Compact, Decode, Encode}; use codec::{Compact, Decode, Encode};
use frame_support::weights::Weight;
use relay_substrate_client::{ use relay_substrate_client::{
BalanceOf, Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, BalanceOf, Chain, ChainWithBalances, ChainWithGrandpa, ChainWithMessages,
ChainWithTransactions, Error as SubstrateError, IndexOf, SignParam, UnsignedTransaction, ChainWithTransactions, Error as SubstrateError, IndexOf, SignParam, UnderlyingChainProvider,
UnsignedTransaction,
}; };
use sp_core::{storage::StorageKey, Pair}; use sp_core::{storage::StorageKey, Pair};
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
@@ -34,24 +34,8 @@ pub type HeaderId = relay_utils::HeaderId<millau_runtime::Hash, millau_runtime::
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Millau; pub struct Millau;
impl ChainBase for Millau { impl UnderlyingChainProvider for Millau {
type BlockNumber = millau_runtime::BlockNumber; type Chain = bp_millau::Millau;
type Hash = millau_runtime::Hash;
type Hasher = millau_runtime::Hashing;
type Header = millau_runtime::Header;
type AccountId = millau_runtime::AccountId;
type Balance = millau_runtime::Balance;
type Index = millau_runtime::Index;
type Signature = millau_runtime::Signature;
fn max_extrinsic_size() -> u32 {
bp_millau::Millau::max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
bp_millau::Millau::max_extrinsic_weight()
}
} }
impl ChainWithGrandpa for Millau { impl ChainWithGrandpa for Millau {
+3 -20
View File
@@ -17,8 +17,7 @@
//! Types used to connect to the Polkadot chain. //! Types used to connect to the Polkadot chain.
use bp_polkadot::AccountInfoStorageMapKeyProvider; use bp_polkadot::AccountInfoStorageMapKeyProvider;
use frame_support::weights::Weight; use relay_substrate_client::{Chain, ChainWithBalances, ChainWithGrandpa, UnderlyingChainProvider};
use relay_substrate_client::{Chain, ChainBase, ChainWithBalances, ChainWithGrandpa};
use sp_core::storage::StorageKey; use sp_core::storage::StorageKey;
use std::time::Duration; use std::time::Duration;
@@ -29,24 +28,8 @@ pub type HeaderId = relay_utils::HeaderId<bp_polkadot::Hash, bp_polkadot::BlockN
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct Polkadot; pub struct Polkadot;
impl ChainBase for Polkadot { impl UnderlyingChainProvider for Polkadot {
type BlockNumber = bp_polkadot::BlockNumber; type Chain = bp_polkadot::Polkadot;
type Hash = bp_polkadot::Hash;
type Hasher = bp_polkadot::Hasher;
type Header = bp_polkadot::Header;
type AccountId = bp_polkadot::AccountId;
type Balance = bp_polkadot::Balance;
type Index = bp_polkadot::Nonce;
type Signature = bp_polkadot::Signature;
fn max_extrinsic_size() -> u32 {
bp_polkadot::Polkadot::max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
bp_polkadot::Polkadot::max_extrinsic_weight()
}
} }
impl Chain for Polkadot { impl Chain for Polkadot {
@@ -18,10 +18,9 @@
use bp_messages::MessageNonce; use bp_messages::MessageNonce;
use codec::Encode; use codec::Encode;
use frame_support::weights::Weight;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainBase, ChainWithBalances, ChainWithMessages, ChainWithTransactions, Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, Error as SubstrateError,
Error as SubstrateError, SignParam, UnsignedTransaction, SignParam, UnderlyingChainProvider, UnsignedTransaction,
}; };
use sp_core::{storage::StorageKey, Pair}; use sp_core::{storage::StorageKey, Pair};
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
@@ -35,24 +34,8 @@ pub type HeaderId =
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct RialtoParachain; pub struct RialtoParachain;
impl ChainBase for RialtoParachain { impl UnderlyingChainProvider for RialtoParachain {
type BlockNumber = rialto_parachain_runtime::BlockNumber; type Chain = bp_rialto_parachain::RialtoParachain;
type Hash = rialto_parachain_runtime::Hash;
type Hasher = rialto_parachain_runtime::Hashing;
type Header = rialto_parachain_runtime::Header;
type AccountId = rialto_parachain_runtime::AccountId;
type Balance = rialto_parachain_runtime::Balance;
type Index = rialto_parachain_runtime::Index;
type Signature = rialto_parachain_runtime::Signature;
fn max_extrinsic_size() -> u32 {
bp_rialto_parachain::RialtoParachain::max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
bp_rialto_parachain::RialtoParachain::max_extrinsic_weight()
}
} }
impl Chain for RialtoParachain { impl Chain for RialtoParachain {
+4 -21
View File
@@ -18,11 +18,10 @@
use bp_messages::MessageNonce; use bp_messages::MessageNonce;
use codec::{Compact, Decode, Encode}; use codec::{Compact, Decode, Encode};
use frame_support::weights::Weight;
use relay_substrate_client::{ use relay_substrate_client::{
BalanceOf, Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, BalanceOf, Chain, ChainWithBalances, ChainWithGrandpa, ChainWithMessages,
ChainWithTransactions, Error as SubstrateError, IndexOf, RelayChain, SignParam, ChainWithTransactions, Error as SubstrateError, IndexOf, RelayChain, SignParam,
UnsignedTransaction, UnderlyingChainProvider, UnsignedTransaction,
}; };
use sp_core::{storage::StorageKey, Pair}; use sp_core::{storage::StorageKey, Pair};
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
@@ -35,24 +34,8 @@ pub type HeaderId = relay_utils::HeaderId<rialto_runtime::Hash, rialto_runtime::
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Rialto; pub struct Rialto;
impl ChainBase for Rialto { impl UnderlyingChainProvider for Rialto {
type BlockNumber = rialto_runtime::BlockNumber; type Chain = bp_rialto::Rialto;
type Hash = rialto_runtime::Hash;
type Hasher = rialto_runtime::Hashing;
type Header = rialto_runtime::Header;
type AccountId = rialto_runtime::AccountId;
type Balance = rialto_runtime::Balance;
type Index = rialto_runtime::Index;
type Signature = rialto_runtime::Signature;
fn max_extrinsic_size() -> u32 {
bp_rialto::Rialto::max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
bp_rialto::Rialto::max_extrinsic_weight()
}
} }
impl Chain for Rialto { impl Chain for Rialto {
+5 -20
View File
@@ -16,8 +16,9 @@
//! Types used to connect to the Rococo-Substrate chain. //! Types used to connect to the Rococo-Substrate chain.
use frame_support::weights::Weight; use relay_substrate_client::{
use relay_substrate_client::{Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, RelayChain}; Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
};
use sp_core::storage::StorageKey; use sp_core::storage::StorageKey;
use std::time::Duration; use std::time::Duration;
@@ -31,24 +32,8 @@ pub type SyncHeader = relay_substrate_client::SyncHeader<bp_rococo::Header>;
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct Rococo; pub struct Rococo;
impl ChainBase for Rococo { impl UnderlyingChainProvider for Rococo {
type BlockNumber = bp_rococo::BlockNumber; type Chain = bp_rococo::Rococo;
type Hash = bp_rococo::Hash;
type Hasher = bp_rococo::Hashing;
type Header = bp_rococo::Header;
type AccountId = bp_rococo::AccountId;
type Balance = bp_rococo::Balance;
type Index = bp_rococo::Nonce;
type Signature = bp_rococo::Signature;
fn max_extrinsic_size() -> u32 {
bp_rococo::Rococo::max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
bp_rococo::Rococo::max_extrinsic_weight()
}
} }
impl Chain for Rococo { impl Chain for Rococo {
+7 -1
View File
@@ -16,7 +16,8 @@
use bp_messages::MessageNonce; use bp_messages::MessageNonce;
use bp_runtime::{ use bp_runtime::{
Chain as ChainBase, EncodedOrDecodedCall, HashOf, TransactionEra, TransactionEraOf, Chain as ChainBase, EncodedOrDecodedCall, HashOf, Parachain as ParachainBase, TransactionEra,
TransactionEraOf, UnderlyingChainProvider,
}; };
use codec::{Codec, Encode}; use codec::{Codec, Encode};
use jsonrpsee::core::{DeserializeOwned, Serialize}; use jsonrpsee::core::{DeserializeOwned, Serialize};
@@ -72,6 +73,11 @@ pub trait RelayChain: Chain {
const PARACHAINS_FINALITY_PALLET_NAME: &'static str; const PARACHAINS_FINALITY_PALLET_NAME: &'static str;
} }
/// Substrate-based parachain from minimal relay-client point of view.
pub trait Parachain: Chain + ParachainBase {}
impl<T> Parachain for T where T: UnderlyingChainProvider + Chain + ParachainBase {}
/// Substrate-based chain that is using direct GRANDPA finality from minimal relay-client point of /// Substrate-based chain that is using direct GRANDPA finality from minimal relay-client point of
/// view. /// view.
/// ///
+4 -3
View File
@@ -34,8 +34,8 @@ use std::time::Duration;
pub use crate::{ pub use crate::{
chain::{ chain::{
AccountKeyPairOf, BlockWithJustification, CallOf, Chain, ChainWithBalances, AccountKeyPairOf, BlockWithJustification, CallOf, Chain, ChainWithBalances,
ChainWithGrandpa, ChainWithMessages, ChainWithTransactions, RelayChain, SignParam, ChainWithGrandpa, ChainWithMessages, ChainWithTransactions, Parachain, RelayChain,
TransactionStatusOf, UnsignedTransaction, SignParam, TransactionStatusOf, UnsignedTransaction,
}, },
client::{ChainRuntimeVersion, Client, OpaqueGrandpaAuthoritiesSet, Subscription}, client::{ChainRuntimeVersion, Client, OpaqueGrandpaAuthoritiesSet, Subscription},
error::{Error, Result}, error::{Error, Result},
@@ -45,7 +45,8 @@ pub use crate::{
}; };
pub use bp_runtime::{ pub use bp_runtime::{
AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain as ChainBase, HashOf, HeaderIdOf, AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain as ChainBase, HashOf, HeaderIdOf,
HeaderOf, IndexOf, SignatureOf, TransactionEra, TransactionEraOf, HeaderOf, IndexOf, Parachain as ParachainBase, SignatureOf, TransactionEra, TransactionEraOf,
UnderlyingChainProvider,
}; };
/// Substrate-over-websocket connection params. /// Substrate-over-websocket connection params.
+7 -40
View File
@@ -16,8 +16,9 @@
//! Types used to connect to the Westend chain. //! Types used to connect to the Westend chain.
use frame_support::weights::Weight; use relay_substrate_client::{
use relay_substrate_client::{Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, RelayChain}; Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
};
use sp_core::storage::StorageKey; use sp_core::storage::StorageKey;
use std::time::Duration; use std::time::Duration;
@@ -31,24 +32,8 @@ pub type SyncHeader = relay_substrate_client::SyncHeader<bp_westend::Header>;
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct Westend; pub struct Westend;
impl ChainBase for Westend { impl UnderlyingChainProvider for Westend {
type BlockNumber = bp_westend::BlockNumber; type Chain = bp_westend::Westend;
type Hash = bp_westend::Hash;
type Hasher = bp_westend::Hasher;
type Header = bp_westend::Header;
type AccountId = bp_westend::AccountId;
type Balance = bp_westend::Balance;
type Index = bp_westend::Nonce;
type Signature = bp_westend::Signature;
fn max_extrinsic_size() -> u32 {
bp_westend::Westend::max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
bp_westend::Westend::max_extrinsic_weight()
}
} }
impl Chain for Westend { impl Chain for Westend {
@@ -83,26 +68,8 @@ impl ChainWithBalances for Westend {
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct Westmint; pub struct Westmint;
// Westmint seems to use the same configuration as all Polkadot-like chains, so we'll use Westend impl UnderlyingChainProvider for Westmint {
// primitives here. type Chain = bp_westend::Westmint;
impl ChainBase for Westmint {
type BlockNumber = bp_westend::BlockNumber;
type Hash = bp_westend::Hash;
type Hasher = bp_westend::Hasher;
type Header = bp_westend::Header;
type AccountId = bp_westend::AccountId;
type Balance = bp_westend::Balance;
type Index = bp_westend::Nonce;
type Signature = bp_westend::Signature;
fn max_extrinsic_size() -> u32 {
bp_westend::Westend::max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
bp_westend::Westend::max_extrinsic_weight()
}
} }
// Westmint seems to use the same configuration as all Polkadot-like chains, so we'll use Westend // Westmint seems to use the same configuration as all Polkadot-like chains, so we'll use Westend
+5 -20
View File
@@ -16,8 +16,9 @@
//! Types used to connect to the Wococo-Substrate chain. //! Types used to connect to the Wococo-Substrate chain.
use frame_support::weights::Weight; use relay_substrate_client::{
use relay_substrate_client::{Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, RelayChain}; Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
};
use sp_core::storage::StorageKey; use sp_core::storage::StorageKey;
use std::time::Duration; use std::time::Duration;
@@ -31,24 +32,8 @@ pub type SyncHeader = relay_substrate_client::SyncHeader<bp_wococo::Header>;
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct Wococo; pub struct Wococo;
impl ChainBase for Wococo { impl UnderlyingChainProvider for Wococo {
type BlockNumber = bp_wococo::BlockNumber; type Chain = bp_wococo::Wococo;
type Hash = bp_wococo::Hash;
type Hasher = bp_wococo::Hashing;
type Header = bp_wococo::Header;
type AccountId = bp_wococo::AccountId;
type Balance = bp_wococo::Balance;
type Index = bp_wococo::Nonce;
type Signature = bp_wococo::Signature;
fn max_extrinsic_size() -> u32 {
bp_wococo::Wococo::max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
bp_wococo::Wococo::max_extrinsic_weight()
}
} }
impl Chain for Wococo { impl Chain for Wococo {
@@ -39,6 +39,7 @@ use pallet_bridge_parachains::{RelayBlockHash, RelayBlockHasher, RelayBlockNumbe
use parachains_relay::parachains_loop::{AvailableHeader, ParachainSyncParams, TargetClient}; use parachains_relay::parachains_loop::{AvailableHeader, ParachainSyncParams, TargetClient};
use relay_substrate_client::{ use relay_substrate_client::{
AccountIdOf, AccountKeyPairOf, BlockNumberOf, Chain, Client, Error as SubstrateError, HashOf, AccountIdOf, AccountKeyPairOf, BlockNumberOf, Chain, Client, Error as SubstrateError, HashOf,
ParachainBase,
}; };
use relay_utils::{ use relay_utils::{
metrics::MetricsParams, relay_loop::Client as RelayClient, FailedClient, HeaderId, metrics::MetricsParams, relay_loop::Client as RelayClient, FailedClient, HeaderId,
@@ -278,7 +279,7 @@ async fn background_task<P: SubstrateParachainsPipeline>(
parachains_source.clone(), parachains_source.clone(),
parachains_target.clone(), parachains_target.clone(),
ParachainSyncParams { ParachainSyncParams {
parachains: vec![P::SOURCE_PARACHAIN_PARA_ID.into()], parachains: vec![P::SourceParachain::PARACHAIN_ID.into()],
stall_timeout: std::time::Duration::from_secs(60), stall_timeout: std::time::Duration::from_secs(60),
strategy: parachains_relay::parachains_loop::ParachainSyncStrategy::Any, strategy: parachains_relay::parachains_loop::ParachainSyncStrategy::Any,
}, },
@@ -386,7 +387,10 @@ where
source.client().best_finalized_header().await.map_err(map_source_err)?; source.client().best_finalized_header().await.map_err(map_source_err)?;
let best_finalized_relay_block_id = best_finalized_relay_header.id(); let best_finalized_relay_block_id = best_finalized_relay_header.id();
let para_header_at_source = source let para_header_at_source = source
.on_chain_para_head_id(best_finalized_relay_block_id, P::SOURCE_PARACHAIN_PARA_ID.into()) .on_chain_para_head_id(
best_finalized_relay_block_id,
P::SourceParachain::PARACHAIN_ID.into(),
)
.await .await
.map_err(map_source_err)?; .map_err(map_source_err)?;
@@ -401,7 +405,7 @@ where
.map_err(map_target_err)?; .map_err(map_target_err)?;
let para_header_at_relay_header_at_target = source let para_header_at_relay_header_at_target = source
.on_chain_para_head_id(relay_header_at_target, P::SOURCE_PARACHAIN_PARA_ID.into()) .on_chain_para_head_id(relay_header_at_target, P::SourceParachain::PARACHAIN_ID.into())
.await .await
.map_err(map_source_err)?; .map_err(map_source_err)?;
@@ -24,7 +24,9 @@ use pallet_bridge_parachains::{
RelayBlockHasher, RelayBlockNumber, RelayBlockHasher, RelayBlockNumber,
}; };
use parachains_relay::ParachainsPipeline; use parachains_relay::ParachainsPipeline;
use relay_substrate_client::{CallOf, Chain, ChainWithTransactions, HeaderIdOf, RelayChain}; use relay_substrate_client::{
CallOf, Chain, ChainWithTransactions, HeaderIdOf, Parachain, RelayChain,
};
use std::{fmt::Debug, marker::PhantomData}; use std::{fmt::Debug, marker::PhantomData};
pub mod source; pub mod source;
@@ -37,7 +39,7 @@ pub mod target;
#[async_trait] #[async_trait]
pub trait SubstrateParachainsPipeline: 'static + Clone + Debug + Send + Sync { pub trait SubstrateParachainsPipeline: 'static + Clone + Debug + Send + Sync {
/// Headers of this parachain are submitted to the `Self::TargetChain`. /// Headers of this parachain are submitted to the `Self::TargetChain`.
type SourceParachain: Chain; type SourceParachain: Parachain;
/// Relay chain that is storing headers of `Self::SourceParachain`. /// Relay chain that is storing headers of `Self::SourceParachain`.
type SourceRelayChain: RelayChain; type SourceRelayChain: RelayChain;
/// Target chain where `Self::SourceParachain` headers are submitted. /// Target chain where `Self::SourceParachain` headers are submitted.
@@ -45,9 +47,6 @@ pub trait SubstrateParachainsPipeline: 'static + Clone + Debug + Send + Sync {
/// How submit parachains heads call is built? /// How submit parachains heads call is built?
type SubmitParachainHeadsCallBuilder: SubmitParachainHeadsCallBuilder<Self>; type SubmitParachainHeadsCallBuilder: SubmitParachainHeadsCallBuilder<Self>;
/// Id of the `Self::SourceParachain`, used for registration in `Self::SourceRelayChain`.
const SOURCE_PARACHAIN_PARA_ID: u32;
} }
/// Adapter that allows all `SubstrateParachainsPipeline` to act as `ParachainsPipeline`. /// Adapter that allows all `SubstrateParachainsPipeline` to act as `ParachainsPipeline`.
@@ -29,7 +29,7 @@ use parachains_relay::{
parachains_loop_metrics::ParachainsLoopMetrics, parachains_loop_metrics::ParachainsLoopMetrics,
}; };
use relay_substrate_client::{ use relay_substrate_client::{
Chain, Client, Error as SubstrateError, HeaderIdOf, HeaderOf, RelayChain, Chain, Client, Error as SubstrateError, HeaderIdOf, HeaderOf, ParachainBase, RelayChain,
}; };
use relay_utils::relay_loop::Client as RelayClient; use relay_utils::relay_loop::Client as RelayClient;
@@ -107,11 +107,11 @@ where
para_id: ParaId, para_id: ParaId,
) -> Result<AvailableHeader<ParaHash>, Self::Error> { ) -> Result<AvailableHeader<ParaHash>, Self::Error> {
// we don't need to support many parachains now // we don't need to support many parachains now
if para_id.0 != P::SOURCE_PARACHAIN_PARA_ID { if para_id.0 != P::SourceParachain::PARACHAIN_ID {
return Err(SubstrateError::Custom(format!( return Err(SubstrateError::Custom(format!(
"Parachain id {} is not matching expected {}", "Parachain id {} is not matching expected {}",
para_id.0, para_id.0,
P::SOURCE_PARACHAIN_PARA_ID, P::SourceParachain::PARACHAIN_ID,
))) )))
} }
@@ -144,7 +144,7 @@ where
at_block: HeaderIdOf<P::SourceRelayChain>, at_block: HeaderIdOf<P::SourceRelayChain>,
parachains: &[ParaId], parachains: &[ParaId],
) -> Result<(ParaHeadsProof, Vec<ParaHash>), Self::Error> { ) -> Result<(ParaHeadsProof, Vec<ParaHash>), Self::Error> {
let parachain = ParaId(P::SOURCE_PARACHAIN_PARA_ID); let parachain = ParaId(P::SourceParachain::PARACHAIN_ID);
if parachains != [parachain] { if parachains != [parachain] {
return Err(SubstrateError::Custom(format!( return Err(SubstrateError::Custom(format!(
"Trying to prove unexpected parachains {parachains:?}. Expected {parachain:?}", "Trying to prove unexpected parachains {parachains:?}. Expected {parachain:?}",