bp_bridge_hub_polkadot/
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 BridgeHubPolkadot runtime setup
18//! (AccountId, Headers, 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::dispatch::DispatchClass;
29use sp_runtime::{RuntimeDebug, StateVersion};
30
31/// BridgeHubPolkadot parachain.
32#[derive(RuntimeDebug)]
33pub struct BridgeHubPolkadot;
34
35impl Chain for BridgeHubPolkadot {
36	const ID: ChainId = *b"bhpd";
37
38	type BlockNumber = BlockNumber;
39	type Hash = Hash;
40	type Hasher = Hasher;
41	type Header = Header;
42
43	type AccountId = AccountId;
44	type Balance = Balance;
45	type Nonce = Nonce;
46	type Signature = Signature;
47
48	const STATE_VERSION: StateVersion = StateVersion::V1;
49
50	fn max_extrinsic_size() -> u32 {
51		*BlockLength::get().max.get(DispatchClass::Normal)
52	}
53
54	fn max_extrinsic_weight() -> Weight {
55		BlockWeights::get()
56			.get(DispatchClass::Normal)
57			.max_extrinsic
58			.unwrap_or(Weight::MAX)
59	}
60}
61
62impl Parachain for BridgeHubPolkadot {
63	const PARACHAIN_ID: u32 = BRIDGE_HUB_POLKADOT_PARACHAIN_ID;
64	const MAX_HEADER_SIZE: u32 = MAX_BRIDGE_HUB_HEADER_SIZE;
65}
66
67impl ChainWithMessages for BridgeHubPolkadot {
68	const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
69		WITH_BRIDGE_HUB_POLKADOT_MESSAGES_PALLET_NAME;
70
71	const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
72		MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
73	const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
74		MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
75}
76
77/// Identifier of BridgeHubPolkadot in the Polkadot relay chain.
78pub const BRIDGE_HUB_POLKADOT_PARACHAIN_ID: u32 = 1002;
79
80/// Name of the With-BridgeHubPolkadot messages pallet instance that is deployed at bridged chains.
81pub const WITH_BRIDGE_HUB_POLKADOT_MESSAGES_PALLET_NAME: &str = "BridgePolkadotMessages";
82
83/// Name of the With-BridgeHubPolkadot bridge-relayers pallet instance that is deployed at bridged
84/// chains.
85pub const WITH_BRIDGE_HUB_POLKADOT_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
86
87decl_bridge_finality_runtime_apis!(bridge_hub_polkadot);
88decl_bridge_messages_runtime_apis!(bridge_hub_polkadot, LegacyLaneId);