Skip to content

Commit 28cf5c9

Browse files
authored
Kusama <> Polkadot relay prototype (#1982)
* moved bridge declarations to dedicated folder * Kusama <> Polkadot bridges declaration * support for Kusama <> Polkadot bridge in CLI * update dictionary
1 parent b195223 commit 28cf5c9

File tree

68 files changed

+1674
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1674
-161
lines changed

.config/lingua.dic

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ BridgeStorage
1919
BridgeHub
2020
BridgeHubRococo
2121
BridgeHubWococo
22+
BridgeHubKusama
23+
BridgeHubPolkadot
2224
CLI/MS
2325
Chain1
2426
Chain2

Cargo.lock

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ members = [
1818
"modules/shift-session-manager",
1919
"primitives/beefy",
2020
"primitives/chain-bridge-hub-cumulus",
21+
"primitives/chain-bridge-hub-kusama",
22+
"primitives/chain-bridge-hub-polkadot",
2123
"primitives/chain-bridge-hub-rococo",
2224
"primitives/chain-bridge-hub-wococo",
2325
"primitives/chain-kusama",
@@ -36,6 +38,8 @@ members = [
3638
"primitives/runtime",
3739
"primitives/test-utils",
3840
"relays/bin-substrate",
41+
"relays/client-bridge-hub-kusama",
42+
"relays/client-bridge-hub-polkadot",
3943
"relays/client-bridge-hub-rococo",
4044
"relays/client-bridge-hub-wococo",
4145
"relays/client-kusama",
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "bp-bridge-hub-kusama"
3+
description = "Primitives of BridgeHubRococo parachain runtime."
4+
version = "0.1.0"
5+
authors = ["Parity Technologies <[email protected]>"]
6+
edition = "2021"
7+
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
8+
9+
[dependencies]
10+
# Bridge Dependencies
11+
12+
bp-bridge-hub-cumulus = { path = "../chain-bridge-hub-cumulus", default-features = false }
13+
bp-runtime = { path = "../../primitives/runtime", default-features = false }
14+
bp-messages = { path = "../../primitives/messages", default-features = false }
15+
16+
# Substrate Based Dependencies
17+
18+
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
19+
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
20+
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
21+
22+
[features]
23+
default = ["std"]
24+
std = [
25+
"bp-bridge-hub-cumulus/std",
26+
"bp-messages/std",
27+
"bp-runtime/std",
28+
"frame-support/std",
29+
"sp-api/std",
30+
"sp-std/std",
31+
]
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Copyright 2022 Parity Technologies (UK) Ltd.
2+
// This file is part of Parity Bridges Common.
3+
4+
// Parity Bridges Common is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// Parity Bridges Common is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
16+
17+
//! Module with configuration which reflects BridgeHubKusama runtime setup (AccountId, Headers,
18+
//! Hashes...)
19+
20+
#![cfg_attr(not(feature = "std"), no_std)]
21+
22+
pub use bp_bridge_hub_cumulus::*;
23+
use bp_messages::*;
24+
use bp_runtime::{
25+
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, Parachain,
26+
};
27+
use frame_support::{
28+
dispatch::DispatchClass,
29+
sp_runtime::{MultiAddress, MultiSigner},
30+
RuntimeDebug,
31+
};
32+
use sp_std::prelude::*;
33+
34+
/// BridgeHubKusama parachain.
35+
#[derive(RuntimeDebug)]
36+
pub struct BridgeHubKusama;
37+
38+
impl Chain for BridgeHubKusama {
39+
type BlockNumber = BlockNumber;
40+
type Hash = Hash;
41+
type Hasher = Hasher;
42+
type Header = Header;
43+
44+
type AccountId = AccountId;
45+
type Balance = Balance;
46+
type Index = Index;
47+
type Signature = Signature;
48+
49+
fn max_extrinsic_size() -> u32 {
50+
*BlockLength::get().max.get(DispatchClass::Normal)
51+
}
52+
53+
fn max_extrinsic_weight() -> Weight {
54+
BlockWeights::get()
55+
.get(DispatchClass::Normal)
56+
.max_extrinsic
57+
.unwrap_or(Weight::MAX)
58+
}
59+
}
60+
61+
impl Parachain for BridgeHubKusama {
62+
const PARACHAIN_ID: u32 = BRIDGE_HUB_KUSAMA_PARACHAIN_ID;
63+
}
64+
65+
/// Public key of the chain account that may be used to verify signatures.
66+
pub type AccountSigner = MultiSigner;
67+
68+
/// The address format for describing accounts.
69+
pub type Address = MultiAddress<AccountId, ()>;
70+
71+
/// Identifier of BridgeHubKusama in the Kusama relay chain.
72+
pub const BRIDGE_HUB_KUSAMA_PARACHAIN_ID: u32 = 1002;
73+
74+
/// Name of the With-BridgeHubKusama messages pallet instance that is deployed at bridged chains.
75+
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
76+
pub const WITH_BRIDGE_HUB_KUSAMA_MESSAGES_PALLET_NAME: &str = "BridgeKusamaMessages";
77+
78+
/// Name of the With-BridgeHubKusama bridge-relayers pallet instance that is deployed at bridged
79+
/// chains.
80+
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
81+
pub const WITH_BRIDGE_HUB_KUSAMA_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
82+
83+
decl_bridge_finality_runtime_apis!(bridge_hub_kusama);
84+
decl_bridge_messages_runtime_apis!(bridge_hub_kusama);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[package]
2+
name = "bp-bridge-hub-polkadot"
3+
description = "Primitives of BridgeHubWococo parachain runtime."
4+
version = "0.1.0"
5+
authors = ["Parity Technologies <[email protected]>"]
6+
edition = "2021"
7+
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
8+
9+
[dependencies]
10+
11+
# Bridge Dependencies
12+
13+
bp-bridge-hub-cumulus = { path = "../chain-bridge-hub-cumulus", default-features = false }
14+
bp-runtime = { path = "../../primitives/runtime", default-features = false }
15+
bp-messages = { path = "../../primitives/messages", default-features = false }
16+
17+
# Substrate Based Dependencies
18+
19+
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
20+
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
21+
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
22+
23+
[features]
24+
default = ["std"]
25+
std = [
26+
"bp-bridge-hub-cumulus/std",
27+
"bp-runtime/std",
28+
"bp-messages/std",
29+
"frame-support/std",
30+
"sp-api/std",
31+
"sp-std/std",
32+
]
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
2+
// This file is part of Parity Bridges Common.
3+
4+
// Parity Bridges Common is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// Parity Bridges Common is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
16+
17+
//! Module with configuration which reflects BridgeHubPolkadot runtime setup
18+
//! (AccountId, Headers, Hashes...)
19+
20+
#![cfg_attr(not(feature = "std"), no_std)]
21+
22+
pub use bp_bridge_hub_cumulus::*;
23+
use bp_messages::*;
24+
use bp_runtime::{
25+
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, Parachain,
26+
};
27+
use frame_support::{dispatch::DispatchClass, RuntimeDebug};
28+
use sp_std::prelude::*;
29+
30+
/// BridgeHubPolkadot parachain.
31+
#[derive(RuntimeDebug)]
32+
pub struct BridgeHubPolkadot;
33+
34+
impl Chain for BridgeHubPolkadot {
35+
type BlockNumber = BlockNumber;
36+
type Hash = Hash;
37+
type Hasher = Hasher;
38+
type Header = Header;
39+
40+
type AccountId = AccountId;
41+
type Balance = Balance;
42+
type Index = Index;
43+
type Signature = Signature;
44+
45+
fn max_extrinsic_size() -> u32 {
46+
*BlockLength::get().max.get(DispatchClass::Normal)
47+
}
48+
49+
fn max_extrinsic_weight() -> Weight {
50+
BlockWeights::get()
51+
.get(DispatchClass::Normal)
52+
.max_extrinsic
53+
.unwrap_or(Weight::MAX)
54+
}
55+
}
56+
57+
impl Parachain for BridgeHubPolkadot {
58+
const PARACHAIN_ID: u32 = BRIDGE_HUB_POLKADOT_PARACHAIN_ID;
59+
}
60+
61+
/// Identifier of BridgeHubPolkadot in the Polkadot relay chain.
62+
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
63+
pub const BRIDGE_HUB_POLKADOT_PARACHAIN_ID: u32 = 1002;
64+
65+
/// Name of the With-BridgeHubPolkadot messages pallet instance that is deployed at bridged chains.
66+
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
67+
pub const WITH_BRIDGE_HUB_POLKADOT_MESSAGES_PALLET_NAME: &str = "BridgePolkadotMessages";
68+
69+
/// Name of the With-BridgeHubPolkadot bridge-relayers pallet instance that is deployed at bridged
70+
/// chains.
71+
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
72+
pub const WITH_BRIDGE_HUB_POLKADOT_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
73+
74+
decl_bridge_finality_runtime_apis!(bridge_hub_polkadot);
75+
decl_bridge_messages_runtime_apis!(bridge_hub_polkadot);

primitives/chain-kusama/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ impl ChainWithGrandpa for Kusama {
5656
const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = AVERAGE_HEADER_SIZE_IN_JUSTIFICATION;
5757
}
5858

59+
/// Name of the parachains pallet in the Kusama runtime.
60+
pub const PARAS_PALLET_NAME: &str = "Paras";
61+
5962
/// Name of the With-Kusama GRANDPA pallet instance that is deployed at bridged chains.
6063
pub const WITH_KUSAMA_GRANDPA_PALLET_NAME: &str = "BridgeKusamaGrandpa";
6164

primitives/chain-polkadot/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ impl ChainWithGrandpa for Polkadot {
5656
const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = AVERAGE_HEADER_SIZE_IN_JUSTIFICATION;
5757
}
5858

59+
/// Name of the parachains pallet in the Polkadot runtime.
60+
pub const PARAS_PALLET_NAME: &str = "Paras";
61+
5962
/// Name of the With-Polkadot GRANDPA pallet instance that is deployed at bridged chains.
6063
pub const WITH_POLKADOT_GRANDPA_PALLET_NAME: &str = "BridgePolkadotGrandpa";
6164

0 commit comments

Comments
 (0)