Skip to content

Commit

Permalink
parachains relay now only works with single parachain
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik committed Feb 28, 2023
1 parent 3621a9f commit ef652f0
Show file tree
Hide file tree
Showing 5 changed files with 341 additions and 574 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions relays/client-substrate/src/test_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,51 @@ impl ChainWithBalances for TestChain {
unreachable!()
}
}

/// Primitives-level parachain that may be used in tests.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TestParachainBase;

impl bp_runtime::Chain for TestParachainBase {
type BlockNumber = u32;
type Hash = sp_core::H256;
type Hasher = sp_runtime::traits::BlakeTwo256;
type Header = sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>;

type AccountId = u32;
type Balance = u32;
type Index = u32;
type Signature = sp_runtime::testing::TestSignature;

fn max_extrinsic_size() -> u32 {
unreachable!()
}

fn max_extrinsic_weight() -> Weight {
unreachable!()
}
}

impl bp_runtime::Parachain for TestParachainBase {
const PARACHAIN_ID: u32 = 1000;
}

/// Parachain that may be used in tests.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TestParachain;

impl bp_runtime::UnderlyingChainProvider for TestParachain {
type Chain = TestParachainBase;
}

impl Chain for TestParachain {
const NAME: &'static str = "TestParachain";
const TOKEN_ID: Option<&'static str> = None;
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = "TestParachainMethod";
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_millis(0);

type SignedBlock = sp_runtime::generic::SignedBlock<
sp_runtime::generic::Block<Self::Header, sp_runtime::OpaqueExtrinsic>,
>;
type Call = ();
}
1 change: 0 additions & 1 deletion relays/parachains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ relay-utils = { path = "../utils" }

# Bridge dependencies

bp-parachains = { path = "../../primitives/parachains" }
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
relay-substrate-client = { path = "../client-substrate" }

Expand Down
6 changes: 4 additions & 2 deletions relays/parachains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@

use std::fmt::Debug;

use relay_substrate_client::Chain;
use relay_substrate_client::{Chain, Parachain};

pub mod parachains_loop;
pub mod parachains_loop_metrics;

/// Finality proofs synchronization pipeline.
pub trait ParachainsPipeline: 'static + Clone + Debug + Send + Sync {
/// Relay chain which is storing parachain heads in its `paras` module.
type SourceChain: Chain;
type SourceRelayChain: Chain;
/// Parachain which headers we are syncing here.
type SourceParachain: Parachain;
/// Target chain (either relay or para) which wants to know about new parachain heads.
type TargetChain: Chain;
}
Loading

0 comments on commit ef652f0

Please sign in to comment.