referrerpolicy=no-referrer-when-downgrade

bp_bridge_hub_rococo/
lib.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// SPDX-License-Identifier: Apache-2.0
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// 	http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! Module with configuration which reflects BridgeHubRococo runtime setup (AccountId, Headers,
17//! Hashes...)
18
19#![warn(missing_docs)]
20#![cfg_attr(not(feature = "std"), no_std)]
21
22pub use bp_bridge_hub_cumulus::*;
23use bp_messages::*;
24use bp_runtime::{
25	decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain,
26};
27use codec::{Decode, Encode};
28use frame_support::{
29	dispatch::DispatchClass,
30	sp_runtime::{MultiAddress, MultiSigner, RuntimeDebug, StateVersion},
31};
32
33/// BridgeHubRococo parachain.
34#[derive(RuntimeDebug)]
35pub struct BridgeHubRococo;
36
37impl Chain for BridgeHubRococo {
38	const ID: ChainId = *b"bhro";
39
40	type BlockNumber = BlockNumber;
41	type Hash = Hash;
42	type Hasher = Hasher;
43	type Header = Header;
44
45	type AccountId = AccountId;
46	type Balance = Balance;
47	type Nonce = Nonce;
48	type Signature = Signature;
49
50	const STATE_VERSION: StateVersion = StateVersion::V1;
51
52	fn max_extrinsic_size() -> u32 {
53		*BlockLength::get().max.get(DispatchClass::Normal)
54	}
55
56	fn max_extrinsic_weight() -> Weight {
57		BlockWeightsForAsyncBacking::get()
58			.get(DispatchClass::Normal)
59			.max_extrinsic
60			.unwrap_or(Weight::MAX)
61	}
62}
63
64impl Parachain for BridgeHubRococo {
65	const PARACHAIN_ID: u32 = BRIDGE_HUB_ROCOCO_PARACHAIN_ID;
66	const MAX_HEADER_SIZE: u32 = MAX_BRIDGE_HUB_HEADER_SIZE;
67}
68
69impl ChainWithMessages for BridgeHubRococo {
70	const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
71		WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME;
72
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 BridgeHubRococo in the Rococo relay chain.
86pub const BRIDGE_HUB_ROCOCO_PARACHAIN_ID: u32 = 1013;
87
88/// Name of the With-BridgeHubRococo messages pallet instance that is deployed at bridged chains.
89pub const WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME: &str = "BridgeRococoMessages";
90
91/// Name of the With-BridgeHubRococo bridge-relayers pallet instance that is deployed at bridged
92/// chains.
93pub const WITH_BRIDGE_HUB_ROCOCO_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
94
95/// Pallet index of `BridgeWestendMessages: pallet_bridge_messages::<Instance3>`.
96pub const WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX: u8 = 51;
97/// Pallet index of `BridgePolkadotBulletinMessages: pallet_bridge_messages::<Instance4>`.
98pub const WITH_BRIDGE_ROCOCO_TO_BULLETIN_MESSAGES_PALLET_INDEX: u8 = 61;
99
100decl_bridge_finality_runtime_apis!(bridge_hub_rococo);
101decl_bridge_messages_runtime_apis!(bridge_hub_rococo, LegacyLaneId);
102
103frame_support::parameter_types! {
104	/// The XCM fee that is paid for executing XCM program (with `ExportMessage` instruction) at the Rococo
105	/// BridgeHub.
106	/// (initially was calculated by test `BridgeHubRococo::can_calculate_weight_for_paid_export_message_with_reserve_transfer` + `33%`)
107	pub const BridgeHubRococoBaseXcmFeeInRocs: u128 = 72_091_666;
108
109	/// Transaction fee that is paid at the Rococo BridgeHub for delivering single inbound message.
110	/// (initially was calculated by test `BridgeHubRococo::can_calculate_fee_for_standalone_message_delivery_transaction` + `33%`)
111	pub const BridgeHubRococoBaseDeliveryFeeInRocs: u128 = 297_685_840;
112
113	/// Transaction fee that is paid at the Rococo BridgeHub for delivering single outbound message confirmation.
114	/// (initially was calculated by test `BridgeHubRococo::can_calculate_fee_for_standalone_message_confirmation_transaction` + `33%`)
115	pub const BridgeHubRococoBaseConfirmationFeeInRocs: u128 = 56_782_099;
116}
117
118/// Wrapper over `BridgeHubRococo`'s `RuntimeCall` that can be used without a runtime.
119#[derive(Decode, Encode)]
120pub enum RuntimeCall {
121	/// Points to the `pallet_xcm_bridge_hub` pallet instance for `BridgeHubWestend`.
122	#[codec(index = 52)]
123	XcmOverBridgeHubWestend(bp_xcm_bridge_hub::XcmBridgeHubCall),
124}