Skip to main content

bp_bridge_hub_kusama/
lib.rs

1// Copyright (C) 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#![warn(missing_docs)]
21#![cfg_attr(not(feature = "std"), no_std)]
22
23pub use bp_bridge_hub_cumulus::*;
24use bp_messages::*;
25use bp_runtime::{
26	decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain,
27};
28use frame_support::{
29	dispatch::DispatchClass,
30	sp_runtime::{MultiAddress, MultiSigner},
31};
32use sp_runtime::{RuntimeDebug, StateVersion};
33
34/// BridgeHubKusama parachain.
35#[derive(RuntimeDebug)]
36pub struct BridgeHubKusama;
37
38impl Chain for BridgeHubKusama {
39	const ID: ChainId = *b"bhks";
40
41	type BlockNumber = BlockNumber;
42	type Hash = Hash;
43	type Hasher = Hasher;
44	type Header = Header;
45
46	type AccountId = AccountId;
47	type Balance = Balance;
48	type Nonce = Nonce;
49	type Signature = Signature;
50
51	const STATE_VERSION: StateVersion = StateVersion::V1;
52
53	fn max_extrinsic_size() -> u32 {
54		*BlockLength::get().max.get(DispatchClass::Normal)
55	}
56
57	fn max_extrinsic_weight() -> Weight {
58		BlockWeights::get()
59			.get(DispatchClass::Normal)
60			.max_extrinsic
61			.unwrap_or(Weight::MAX)
62	}
63}
64
65impl Parachain for BridgeHubKusama {
66	const PARACHAIN_ID: u32 = BRIDGE_HUB_KUSAMA_PARACHAIN_ID;
67	const MAX_HEADER_SIZE: u32 = MAX_BRIDGE_HUB_HEADER_SIZE;
68}
69
70impl ChainWithMessages for BridgeHubKusama {
71	const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
72		WITH_BRIDGE_HUB_KUSAMA_MESSAGES_PALLET_NAME;
73	const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
74		MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
75	const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
76		MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
77}
78
79/// Public key of the chain account that may be used to verify signatures.
80pub type AccountSigner = MultiSigner;
81
82/// The address format for describing accounts.
83pub type Address = MultiAddress<AccountId, ()>;
84
85/// Identifier of BridgeHubKusama in the Kusama relay chain.
86pub const BRIDGE_HUB_KUSAMA_PARACHAIN_ID: u32 = 1002;
87
88/// Name of the With-BridgeHubKusama messages pallet instance that is deployed at bridged chains.
89pub const WITH_BRIDGE_HUB_KUSAMA_MESSAGES_PALLET_NAME: &str = "BridgeKusamaMessages";
90
91/// Name of the With-BridgeHubKusama bridge-relayers pallet instance that is deployed at bridged
92/// chains.
93pub const WITH_BRIDGE_HUB_KUSAMA_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
94
95decl_bridge_finality_runtime_apis!(bridge_hub_kusama);
96decl_bridge_messages_runtime_apis!(bridge_hub_kusama, LegacyLaneId);