From ec6fd2534897ddecad8db5c9f3e38d9501ce9af9 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Fri, 4 Dec 2020 18:46:35 +0300 Subject: [PATCH] Polkadot integration (#542) * kusama primitives + client * polkadot primitives + client * lost Chain definitions * fix compilation and fmt * Update primitives/runtime/src/lib.rs Co-authored-by: Hernando Castano Co-authored-by: Hernando Castano --- bridges/primitives/kusama/Cargo.toml | 34 +++++ bridges/primitives/kusama/src/lib.rs | 150 +++++++++++++++++++ bridges/primitives/polkadot/Cargo.toml | 34 +++++ bridges/primitives/polkadot/src/lib.rs | 150 +++++++++++++++++++ bridges/primitives/runtime/src/lib.rs | 6 + bridges/relays/kusama-client/Cargo.toml | 25 ++++ bridges/relays/kusama-client/src/lib.rs | 47 ++++++ bridges/relays/polkadot-client/Cargo.toml | 25 ++++ bridges/relays/polkadot-client/src/lib.rs | 47 ++++++ bridges/relays/substrate-client/src/chain.rs | 3 +- bridges/relays/substrate/Cargo.toml | 4 + bridges/relays/substrate/src/main.rs | 3 + 12 files changed, 526 insertions(+), 2 deletions(-) create mode 100644 bridges/primitives/kusama/Cargo.toml create mode 100644 bridges/primitives/kusama/src/lib.rs create mode 100644 bridges/primitives/polkadot/Cargo.toml create mode 100644 bridges/primitives/polkadot/src/lib.rs create mode 100644 bridges/relays/kusama-client/Cargo.toml create mode 100644 bridges/relays/kusama-client/src/lib.rs create mode 100644 bridges/relays/polkadot-client/Cargo.toml create mode 100644 bridges/relays/polkadot-client/src/lib.rs diff --git a/bridges/primitives/kusama/Cargo.toml b/bridges/primitives/kusama/Cargo.toml new file mode 100644 index 0000000000000..619a1947126bb --- /dev/null +++ b/bridges/primitives/kusama/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "bp-kusama" +description = "Primitives of Kusama runtime." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] + +# Bridge Dependencies + +bp-message-lane = { path = "../message-lane", default-features = false } +bp-runtime = { path = "../runtime", default-features = false } + +# Substrate Based Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-message-lane/std", + "bp-runtime/std", + "frame-support/std", + "sp-api/std", + "sp-core/std", + "sp-runtime/std", + "sp-std/std", +] diff --git a/bridges/primitives/kusama/src/lib.rs b/bridges/primitives/kusama/src/lib.rs new file mode 100644 index 0000000000000..732db82bcd2fa --- /dev/null +++ b/bridges/primitives/kusama/src/lib.rs @@ -0,0 +1,150 @@ +// Copyright 2019-2020 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Bridges Common is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Bridges Common. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] +// RuntimeApi generated functions +#![allow(clippy::too_many_arguments)] +// Runtime-generated DecodeLimit::decode_all_with_depth_limit +#![allow(clippy::unnecessary_mut_passed)] + +use bp_message_lane::{LaneId, MessageNonce}; +use bp_runtime::Chain; +use frame_support::{weights::Weight, RuntimeDebug}; +use sp_core::Hasher as HasherT; +use sp_runtime::{ + generic, + traits::{BlakeTwo256, IdentifyAccount, Verify}, + MultiSignature, OpaqueExtrinsic as UncheckedExtrinsic, +}; +use sp_std::prelude::*; + +/// Block number type used in Kusama. +pub type BlockNumber = u32; + +/// Hash type used in Kusama. +pub type Hash = ::Out; + +/// The type of an object that can produce hashes on Kusama. +pub type Hasher = BlakeTwo256; + +/// The header type used by Kusama. +pub type Header = generic::Header; + +/// Signature type used by Kusama. +pub type Signature = MultiSignature; + +/// Public key of account on Kusama chain. +pub type AccountPublic = ::Signer; + +/// Id of account on Kusama chain. +pub type AccountId = ::AccountId; + +/// Index of a transaction on the Kusama chain. +pub type Nonce = u32; + +/// Block type of Kusama. +pub type Block = generic::Block; + +/// Kusama block signed with a Justification. +pub type SignedBlock = generic::SignedBlock; + +/// The balance of an account on Polkadot. +pub type Balance = u128; + +/// Kusama chain. +#[derive(RuntimeDebug)] +pub struct Kusama; + +impl Chain for Kusama { + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hasher = Hasher; + type Header = Header; +} + +/// Name of the `KusamaHeaderApi::best_blocks` runtime method. +pub const BEST_KUSAMA_BLOCKS_METHOD: &str = "KusamaHeaderApi_best_blocks"; +/// Name of the `KusamaHeaderApi::finalized_block` runtime method. +pub const FINALIZED_KUSAMA_BLOCK_METHOD: &str = "KusamaHeaderApi_finalized_block"; +/// Name of the `KusamaHeaderApi::is_known_block` runtime method. +pub const IS_KNOWN_KUSAMA_BLOCK_METHOD: &str = "KusamaHeaderApi_is_known_block"; +/// Name of the `KusamaHeaderApi::incomplete_headers` runtime method. +pub const INCOMPLETE_KUSAMA_HEADERS_METHOD: &str = "KusamaHeaderApi_incomplete_headers"; + +/// Maximal weight of single Kusama extrinsic. +pub const MAXIMUM_EXTRINSIC_WEIGHT: Weight = 725_000_000_000; + +// TODO: should be selected keeping in mind: finality delay on both chains + reward payout cost + messages throughput. +/// Maximal number of unconfirmed messages at inbound lane. +pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 8192; + +sp_api::decl_runtime_apis! { + /// API for querying information about Kusama headers from the Bridge Pallet instance. + /// + /// This API is implemented by runtimes that are bridging with Kusama chain, not the + /// Kusama runtime itself. + pub trait KusamaHeaderApi { + /// Returns number and hash of the best blocks known to the bridge module. + /// + /// Will return multiple headers if there are many headers at the same "best" height. + /// + /// The caller should only submit an `import_header` transaction that makes + /// (or leads to making) other header the best one. + fn best_blocks() -> Vec<(BlockNumber, Hash)>; + /// Returns number and hash of the best finalized block known to the bridge module. + fn finalized_block() -> (BlockNumber, Hash); + /// Returns numbers and hashes of headers that require finality proofs. + /// + /// An empty response means that there are no headers which currently require a + /// finality proof. + fn incomplete_headers() -> Vec<(BlockNumber, Hash)>; + /// Returns true if the header is known to the runtime. + fn is_known_block(hash: Hash) -> bool; + /// Returns true if the header is considered finalized by the runtime. + fn is_finalized_block(hash: Hash) -> bool; + } + + /// Outbound message lane API for messages that are sent to Kusama chain. + /// + /// This API is implemented by runtimes that are sending messages to Kusama chain, not the + /// Kusama runtime itself. + pub trait ToKusamaOutboundLaneApi { + /// Returns dispatch weight of all messages in given inclusive range. + /// + /// If some (or all) messages are missing from the storage, they'll also will + /// be missing from the resulting vector. The vector is ordered by the nonce. + fn messages_dispatch_weight( + lane: LaneId, + begin: MessageNonce, + end: MessageNonce, + ) -> Vec<(MessageNonce, Weight)>; + /// Returns nonce of the latest message, received by bridged chain. + fn latest_received_nonce(lane: LaneId) -> MessageNonce; + /// Returns nonce of the latest message, generated by given lane. + fn latest_generated_nonce(lane: LaneId) -> MessageNonce; + } + + /// Inbound message lane API for messages sent by Kusama chain. + /// + /// This API is implemented by runtimes that are receiving messages from Kusama chain, not the + /// Kusama runtime itself. + pub trait FromKusamaInboundLaneApi { + /// Returns nonce of the latest message, received by given lane. + fn latest_received_nonce(lane: LaneId) -> MessageNonce; + /// Nonce of latest message that has been confirmed to the bridged chain. + fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; + } +} diff --git a/bridges/primitives/polkadot/Cargo.toml b/bridges/primitives/polkadot/Cargo.toml new file mode 100644 index 0000000000000..6f79e6bd1b984 --- /dev/null +++ b/bridges/primitives/polkadot/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "bp-polkadot" +description = "Primitives of Polkadot runtime." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] + +# Bridge Dependencies + +bp-message-lane = { path = "../message-lane", default-features = false } +bp-runtime = { path = "../runtime", default-features = false } + +# Substrate Based Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-message-lane/std", + "bp-runtime/std", + "frame-support/std", + "sp-api/std", + "sp-core/std", + "sp-runtime/std", + "sp-std/std", +] diff --git a/bridges/primitives/polkadot/src/lib.rs b/bridges/primitives/polkadot/src/lib.rs new file mode 100644 index 0000000000000..d716601474679 --- /dev/null +++ b/bridges/primitives/polkadot/src/lib.rs @@ -0,0 +1,150 @@ +// Copyright 2019-2020 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Bridges Common is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Bridges Common. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] +// RuntimeApi generated functions +#![allow(clippy::too_many_arguments)] +// Runtime-generated DecodeLimit::decode_all_with_depth_limit +#![allow(clippy::unnecessary_mut_passed)] + +use bp_message_lane::{LaneId, MessageNonce}; +use bp_runtime::Chain; +use frame_support::{weights::Weight, RuntimeDebug}; +use sp_core::Hasher as HasherT; +use sp_runtime::{ + generic, + traits::{BlakeTwo256, IdentifyAccount, Verify}, + MultiSignature, OpaqueExtrinsic as UncheckedExtrinsic, +}; +use sp_std::prelude::*; + +/// Block number type used in Polkadot. +pub type BlockNumber = u32; + +/// Hash type used in Polkadot. +pub type Hash = ::Out; + +/// The type of an object that can produce hashes on Polkadot. +pub type Hasher = BlakeTwo256; + +/// The header type used by Polkadot. +pub type Header = generic::Header; + +/// Signature type used by Polkadot. +pub type Signature = MultiSignature; + +/// Public key of account on Polkadot chain. +pub type AccountPublic = ::Signer; + +/// Id of account on Polkadot chain. +pub type AccountId = ::AccountId; + +/// Index of a transaction on the Polkadot chain. +pub type Nonce = u32; + +/// Block type of Polkadot. +pub type Block = generic::Block; + +/// Polkadot block signed with a Justification. +pub type SignedBlock = generic::SignedBlock; + +/// The balance of an account on Polkadot. +pub type Balance = u128; + +/// Polkadot chain. +#[derive(RuntimeDebug)] +pub struct Polkadot; + +impl Chain for Polkadot { + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hasher = Hasher; + type Header = Header; +} + +/// Name of the `PolkadotHeaderApi::best_blocks` runtime method. +pub const BEST_POLKADOT_BLOCKS_METHOD: &str = "PolkadotHeaderApi_best_blocks"; +/// Name of the `PolkadotHeaderApi::finalized_block` runtime method. +pub const FINALIZED_POLKADOT_BLOCK_METHOD: &str = "PolkadotHeaderApi_finalized_block"; +/// Name of the `PolkadotHeaderApi::is_known_block` runtime method. +pub const IS_KNOWN_POLKADOT_BLOCK_METHOD: &str = "PolkadotHeaderApi_is_known_block"; +/// Name of the `PolkadotHeaderApi::incomplete_headers` runtime method. +pub const INCOMPLETE_POLKADOT_HEADERS_METHOD: &str = "PolkadotHeaderApi_incomplete_headers"; + +/// Maximal weight of single Polkadot extrinsic. +pub const MAXIMUM_EXTRINSIC_WEIGHT: Weight = 725_000_000_000; + +// TODO: should be selected keeping in mind: finality delay on both chains + reward payout cost + messages throughput. +/// Maximal number of unconfirmed messages at inbound lane. +pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 8192; + +sp_api::decl_runtime_apis! { + /// API for querying information about Polkadot headers from the Bridge Pallet instance. + /// + /// This API is implemented by runtimes that are bridging with Polkadot chain, not the + /// Polkadot runtime itself. + pub trait PolkadotHeaderApi { + /// Returns number and hash of the best blocks known to the bridge module. + /// + /// Will return multiple headers if there are many headers at the same "best" height. + /// + /// The caller should only submit an `import_header` transaction that makes + /// (or leads to making) other header the best one. + fn best_blocks() -> Vec<(BlockNumber, Hash)>; + /// Returns number and hash of the best finalized block known to the bridge module. + fn finalized_block() -> (BlockNumber, Hash); + /// Returns numbers and hashes of headers that require finality proofs. + /// + /// An empty response means that there are no headers which currently require a + /// finality proof. + fn incomplete_headers() -> Vec<(BlockNumber, Hash)>; + /// Returns true if the header is known to the runtime. + fn is_known_block(hash: Hash) -> bool; + /// Returns true if the header is considered finalized by the runtime. + fn is_finalized_block(hash: Hash) -> bool; + } + + /// Outbound message lane API for messages that are sent to Polkadot chain. + /// + /// This API is implemented by runtimes that are sending messages to Polkadot chain, not the + /// Polkadot runtime itself. + pub trait ToPolkadotOutboundLaneApi { + /// Returns dispatch weight of all messages in given inclusive range. + /// + /// If some (or all) messages are missing from the storage, they'll also will + /// be missing from the resulting vector. The vector is ordered by the nonce. + fn messages_dispatch_weight( + lane: LaneId, + begin: MessageNonce, + end: MessageNonce, + ) -> Vec<(MessageNonce, Weight)>; + /// Returns nonce of the latest message, received by bridged chain. + fn latest_received_nonce(lane: LaneId) -> MessageNonce; + /// Returns nonce of the latest message, generated by given lane. + fn latest_generated_nonce(lane: LaneId) -> MessageNonce; + } + + /// Inbound message lane API for messages sent by Polkadot chain. + /// + /// This API is implemented by runtimes that are receiving messages from Polkadot chain, not the + /// Polkadot runtime itself. + pub trait FromPolkadotInboundLaneApi { + /// Returns nonce of the latest message, received by given lane. + fn latest_received_nonce(lane: LaneId) -> MessageNonce; + /// Nonce of latest message that has been confirmed to the bridged chain. + fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; + } +} diff --git a/bridges/primitives/runtime/src/lib.rs b/bridges/primitives/runtime/src/lib.rs index 926761b4ba3c4..e23a8d887cec5 100644 --- a/bridges/primitives/runtime/src/lib.rs +++ b/bridges/primitives/runtime/src/lib.rs @@ -35,6 +35,12 @@ pub const RIALTO_BRIDGE_INSTANCE: InstanceId = *b"rlto"; /// Bridge-with-Millau instance id. pub const MILLAU_BRIDGE_INSTANCE: InstanceId = *b"mlau"; +/// Bridge-with-Polkadot instance id. +pub const POLKADOT_BRIDGE_INSTANCE: InstanceId = *b"pdot"; + +/// Bridge-with-Kusama instance id. +pub const KUSAMA_BRIDGE_INSTANCE: InstanceId = *b"ksma"; + /// Call-dispatch module prefix. pub const CALL_DISPATCH_MODULE_PREFIX: &[u8] = b"pallet-bridge/call-dispatch"; diff --git a/bridges/relays/kusama-client/Cargo.toml b/bridges/relays/kusama-client/Cargo.toml new file mode 100644 index 0000000000000..4ea971f0e14f8 --- /dev/null +++ b/bridges/relays/kusama-client/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "relay-kusama-client" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +codec = { package = "parity-scale-codec", version = "1.3.4" } +headers-relay = { path = "../headers-relay" } +relay-substrate-client = { path = "../substrate-client" } +relay-utils = { path = "../utils" } + +# Bridge dependencies + +bp-kusama = { path = "../../primitives/kusama" } + +# Substrate Dependencies + +frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "master" } +frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "master" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate.git", branch = "master" } +sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" } +sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "master" } +sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" } diff --git a/bridges/relays/kusama-client/src/lib.rs b/bridges/relays/kusama-client/src/lib.rs new file mode 100644 index 0000000000000..9f9507f5ca62e --- /dev/null +++ b/bridges/relays/kusama-client/src/lib.rs @@ -0,0 +1,47 @@ +// Copyright 2019-2020 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Bridges Common is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Bridges Common. If not, see . + +//! Types used to connect to the Kusama chain. + +use relay_substrate_client::{Chain, ChainBase}; +use std::time::Duration; + +/// Kusama header id. +pub type HeaderId = relay_utils::HeaderId; + +/// Kusama chain definition +#[derive(Debug, Clone, Copy)] +pub struct Kusama; + +impl ChainBase for Kusama { + type BlockNumber = bp_kusama::BlockNumber; + type Hash = bp_kusama::Hash; + type Hasher = bp_kusama::Hasher; + type Header = bp_kusama::Header; +} + +impl Chain for Kusama { + const NAME: &'static str = "Kusama"; + const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6); + + type AccountId = bp_kusama::AccountId; + type Index = bp_kusama::Nonce; + type SignedBlock = bp_kusama::SignedBlock; + type Call = (); +} + +/// Kusama header type used in headers sync. +pub type SyncHeader = relay_substrate_client::SyncHeader; diff --git a/bridges/relays/polkadot-client/Cargo.toml b/bridges/relays/polkadot-client/Cargo.toml new file mode 100644 index 0000000000000..e4b1d84eaa110 --- /dev/null +++ b/bridges/relays/polkadot-client/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "relay-polkadot-client" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +codec = { package = "parity-scale-codec", version = "1.3.4" } +headers-relay = { path = "../headers-relay" } +relay-substrate-client = { path = "../substrate-client" } +relay-utils = { path = "../utils" } + +# Bridge dependencies + +bp-polkadot = { path = "../../primitives/polkadot" } + +# Substrate Dependencies + +frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "master" } +frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "master" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate.git", branch = "master" } +sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" } +sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "master" } +sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" } diff --git a/bridges/relays/polkadot-client/src/lib.rs b/bridges/relays/polkadot-client/src/lib.rs new file mode 100644 index 0000000000000..7f85de13632c3 --- /dev/null +++ b/bridges/relays/polkadot-client/src/lib.rs @@ -0,0 +1,47 @@ +// Copyright 2019-2020 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Bridges Common is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Bridges Common. If not, see . + +//! Types used to connect to the Polkadot chain. + +use relay_substrate_client::{Chain, ChainBase}; +use std::time::Duration; + +/// Polkadot header id. +pub type HeaderId = relay_utils::HeaderId; + +/// Polkadot chain definition +#[derive(Debug, Clone, Copy)] +pub struct Polkadot; + +impl ChainBase for Polkadot { + type BlockNumber = bp_polkadot::BlockNumber; + type Hash = bp_polkadot::Hash; + type Hasher = bp_polkadot::Hasher; + type Header = bp_polkadot::Header; +} + +impl Chain for Polkadot { + const NAME: &'static str = "Polkadot"; + const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6); + + type AccountId = bp_polkadot::AccountId; + type Index = bp_polkadot::Nonce; + type SignedBlock = bp_polkadot::SignedBlock; + type Call = (); +} + +/// Polkadot header type used in headers sync. +pub type SyncHeader = relay_substrate_client::SyncHeader; diff --git a/bridges/relays/substrate-client/src/chain.rs b/bridges/relays/substrate-client/src/chain.rs index 1de2bf401f13b..37ce156a0ed2a 100644 --- a/bridges/relays/substrate-client/src/chain.rs +++ b/bridges/relays/substrate-client/src/chain.rs @@ -40,8 +40,7 @@ pub trait Chain: ChainBase { /// The user account identifier type for the runtime. type AccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord + Default; - /// Account index (aka nonce) type. This stores the number of previous transactions associated - /// with a sender account. + /// Index of a transaction used by the chain. type Index: Parameter + Member + MaybeSerialize diff --git a/bridges/relays/substrate/Cargo.toml b/bridges/relays/substrate/Cargo.toml index e35021d445195..f4ac7723298d3 100644 --- a/bridges/relays/substrate/Cargo.toml +++ b/bridges/relays/substrate/Cargo.toml @@ -18,8 +18,10 @@ structopt = "0.3" # Bridge dependencies +bp-kusama = { path = "../../primitives/kusama" } bp-message-lane = { path = "../../primitives/message-lane" } bp-millau = { path = "../../primitives/millau" } +bp-polkadot = { path = "../../primitives/polkadot" } bp-runtime = { path = "../../primitives/runtime" } bp-rialto = { path = "../../primitives/rialto" } headers-relay = { path = "../headers-relay" } @@ -27,7 +29,9 @@ messages-relay = { path = "../messages-relay" } millau-runtime = { path = "../../bin/millau/runtime" } pallet-bridge-call-dispatch = { path = "../../modules/call-dispatch" } pallet-substrate-bridge = { path = "../../modules/substrate" } +relay-kusama-client = { path = "../kusama-client" } relay-millau-client = { path = "../millau-client" } +relay-polkadot-client = { path = "../polkadot-client" } relay-rialto-client = { path = "../rialto-client" } relay-substrate-client = { path = "../substrate-client" } relay-utils = { path = "../utils" } diff --git a/bridges/relays/substrate/src/main.rs b/bridges/relays/substrate/src/main.rs index e7812219d174a..8258f985a77eb 100644 --- a/bridges/relays/substrate/src/main.rs +++ b/bridges/relays/substrate/src/main.rs @@ -21,6 +21,7 @@ use codec::Encode; use frame_support::weights::GetDispatchInfo; use pallet_bridge_call_dispatch::{CallOrigin, MessagePayload}; +use relay_kusama_client::Kusama; use relay_millau_client::{Millau, SigningParams as MillauSigningParams}; use relay_rialto_client::{Rialto, SigningParams as RialtoSigningParams}; use relay_substrate_client::{ConnectionParams, TransactionSignScheme}; @@ -28,6 +29,8 @@ use relay_utils::initialize::initialize_relay; use sp_core::{Bytes, Pair}; use sp_runtime::traits::IdentifyAccount; +/// Kusama node client. +pub type KusamaClient = relay_substrate_client::Client; /// Millau node client. pub type MillauClient = relay_substrate_client::Client; /// Rialto node client.