bp_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//! Primitives of the Polkadot chain.
18
19#![warn(missing_docs)]
20#![cfg_attr(not(feature = "std"), no_std)]
21
22pub use bp_polkadot_core::*;
23
24use bp_header_chain::ChainWithGrandpa;
25use bp_runtime::{
26	decl_bridge_finality_runtime_apis, extensions::PrevalidateAttests, Chain, ChainId,
27};
28use frame_support::{sp_runtime::StateVersion, weights::Weight};
29
30/// Polkadot Chain
31pub struct Polkadot;
32
33impl Chain for Polkadot {
34	const ID: ChainId = *b"pdot";
35
36	type BlockNumber = BlockNumber;
37	type Hash = Hash;
38	type Hasher = Hasher;
39	type Header = Header;
40
41	type AccountId = AccountId;
42	type Balance = Balance;
43	type Nonce = Nonce;
44	type Signature = Signature;
45
46	const STATE_VERSION: StateVersion = StateVersion::V0;
47
48	fn max_extrinsic_size() -> u32 {
49		max_extrinsic_size()
50	}
51
52	fn max_extrinsic_weight() -> Weight {
53		max_extrinsic_weight()
54	}
55}
56
57impl ChainWithGrandpa for Polkadot {
58	const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = WITH_POLKADOT_GRANDPA_PALLET_NAME;
59	const MAX_AUTHORITIES_COUNT: u32 = MAX_AUTHORITIES_COUNT;
60	const REASONABLE_HEADERS_IN_JUSTIFICATION_ANCESTRY: u32 =
61		REASONABLE_HEADERS_IN_JUSTIFICATION_ANCESTRY;
62	const MAX_MANDATORY_HEADER_SIZE: u32 = MAX_MANDATORY_HEADER_SIZE;
63	const AVERAGE_HEADER_SIZE: u32 = AVERAGE_HEADER_SIZE;
64}
65
66/// The TransactionExtension used by Polkadot.
67pub type TransactionExtension = SuffixedCommonTransactionExtension<PrevalidateAttests>;
68
69/// Name of the parachains pallet in the Polkadot runtime.
70pub const PARAS_PALLET_NAME: &str = "Paras";
71
72/// Name of the With-Polkadot GRANDPA pallet instance that is deployed at bridged chains.
73pub const WITH_POLKADOT_GRANDPA_PALLET_NAME: &str = "BridgePolkadotGrandpa";
74/// Name of the With-Polkadot parachains pallet instance that is deployed at bridged chains.
75pub const WITH_POLKADOT_BRIDGE_PARACHAINS_PALLET_NAME: &str = "BridgePolkadotParachains";
76
77/// Maximal size of encoded `bp_parachains::ParaStoredHeaderData` structure among all Polkadot
78/// parachains.
79///
80/// It includes the block number and state root, so it shall be near 40 bytes, but let's have some
81/// reserve.
82pub const MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE: u32 = 128;
83
84decl_bridge_finality_runtime_apis!(polkadot, grandpa);