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