1#![cfg_attr(not(feature = "std"), no_std)]
20
21pub use bp_bridge_hub_cumulus::{
22 BlockLength, BlockWeights, Hasher, Nonce, SignedBlock, AVERAGE_BLOCK_INTERVAL,
23 MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
24};
25use bp_messages::{ChainWithMessages, MessageNonce};
26
27use bp_runtime::{
28 decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain,
29};
30use frame_support::{dispatch::DispatchClass, weights::Weight};
31pub use moonbeam_core_primitives::{AccountId, Balance, BlockNumber, Hash, Header, Signature};
32use sp_runtime::StateVersion;
33use xcm::latest::prelude::{Junction, Location, NetworkId};
34
35pub type LaneId = bp_messages::HashedLaneId;
37
38pub struct Moonbeam;
40
41impl Chain for Moonbeam {
42 const ID: ChainId = *b"mnbm";
43
44 type BlockNumber = BlockNumber;
45 type Hash = Hash;
46 type Hasher = Hasher;
47 type Header = Header;
48
49 type AccountId = AccountId;
50 type Balance = Balance;
51 type Nonce = Nonce;
52 type Signature = Signature;
53
54 const STATE_VERSION: StateVersion = StateVersion::V1;
55
56 fn max_extrinsic_size() -> u32 {
57 *BlockLength::get().max.get(DispatchClass::Normal)
58 }
59
60 fn max_extrinsic_weight() -> Weight {
61 BlockWeights::get()
62 .get(DispatchClass::Normal)
63 .max_extrinsic
64 .unwrap_or(Weight::MAX)
65 }
66}
67
68impl Parachain for Moonbeam {
69 const PARACHAIN_ID: u32 = PARACHAIN_ID;
70 const MAX_HEADER_SIZE: u32 = 4_096;
71}
72
73impl ChainWithMessages for Moonbeam {
74 const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
75 WITH_MOONBEAM_POLKADOT_MESSAGES_PALLET_NAME;
76
77 const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
78 MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
79 const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
80 MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
81}
82
83pub const PARACHAIN_ID: u32 = 2004;
85
86pub const WITH_MOONBEAM_POLKADOT_MESSAGES_PALLET_NAME: &str = "BridgePolkadotMessages";
88
89decl_bridge_finality_runtime_apis!(moonbeam_polkadot);
90decl_bridge_messages_runtime_apis!(moonbeam_polkadot, LaneId);
91
92frame_support::parameter_types! {
93 pub GlobalConsensusLocation: Location = Location::new(
94 2,
95 [
96 Junction::GlobalConsensus(NetworkId::Polkadot),
97 Junction::Parachain(Moonbeam::PARACHAIN_ID)
98 ]
99 );
100}
101
102pub mod bp_kusama {
105 use super::{decl_bridge_finality_runtime_apis, Chain, ChainId, StateVersion, Weight};
106 use bp_header_chain::ChainWithGrandpa;
107 pub use bp_polkadot_core::*;
108
109 pub struct Kusama;
111
112 impl Chain for Kusama {
113 const ID: ChainId = *b"ksma";
114
115 type BlockNumber = BlockNumber;
116 type Hash = Hash;
117 type Hasher = Hasher;
118 type Header = Header;
119
120 type AccountId = AccountId;
121 type Balance = Balance;
122 type Nonce = Nonce;
123 type Signature = Signature;
124
125 const STATE_VERSION: StateVersion = StateVersion::V1;
126
127 fn max_extrinsic_size() -> u32 {
128 max_extrinsic_size()
129 }
130
131 fn max_extrinsic_weight() -> Weight {
132 max_extrinsic_weight()
133 }
134 }
135
136 impl ChainWithGrandpa for Kusama {
137 const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = WITH_KUSAMA_GRANDPA_PALLET_NAME;
138 const MAX_AUTHORITIES_COUNT: u32 = MAX_AUTHORITIES_COUNT;
139 const REASONABLE_HEADERS_IN_JUSTIFICATION_ANCESTRY: u32 =
140 REASONABLE_HEADERS_IN_JUSTIFICATION_ANCESTRY;
141 const MAX_MANDATORY_HEADER_SIZE: u32 = MAX_MANDATORY_HEADER_SIZE;
142 const AVERAGE_HEADER_SIZE: u32 = AVERAGE_HEADER_SIZE;
143 }
144
145 pub const PARAS_PALLET_NAME: &str = "Paras";
147 pub const WITH_KUSAMA_GRANDPA_PALLET_NAME: &str = "BridgeKusamaGrandpa";
149 pub const WITH_KUSAMA_BRIDGE_PARACHAINS_PALLET_NAME: &str = "BridgeKusamaParachains";
151
152 pub const MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE: u32 = 128;
158
159 decl_bridge_finality_runtime_apis!(kusama, grandpa);
160}