referrerpolicy=no-referrer-when-downgrade

bp_bridge_hub_westend/
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 BridgeHubWestend runtime setup
17//! (AccountId, Headers, Hashes...)
18
19#![cfg_attr(not(feature = "std"), no_std)]
20
21pub use bp_bridge_hub_cumulus::*;
22use bp_messages::*;
23use bp_runtime::{
24	decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain,
25};
26use codec::{Decode, Encode};
27use frame_support::dispatch::DispatchClass;
28use sp_runtime::{RuntimeDebug, StateVersion};
29
30/// BridgeHubWestend parachain.
31#[derive(RuntimeDebug)]
32pub struct BridgeHubWestend;
33
34impl Chain for BridgeHubWestend {
35	const ID: ChainId = *b"bhwd";
36
37	type BlockNumber = BlockNumber;
38	type Hash = Hash;
39	type Hasher = Hasher;
40	type Header = Header;
41
42	type AccountId = AccountId;
43	type Balance = Balance;
44	type Nonce = Nonce;
45	type Signature = Signature;
46
47	const STATE_VERSION: StateVersion = StateVersion::V1;
48
49	fn max_extrinsic_size() -> u32 {
50		*BlockLength::get().max.get(DispatchClass::Normal)
51	}
52
53	fn max_extrinsic_weight() -> Weight {
54		BlockWeightsForAsyncBacking::get()
55			.get(DispatchClass::Normal)
56			.max_extrinsic
57			.unwrap_or(Weight::MAX)
58	}
59}
60
61impl Parachain for BridgeHubWestend {
62	const PARACHAIN_ID: u32 = BRIDGE_HUB_WESTEND_PARACHAIN_ID;
63	const MAX_HEADER_SIZE: u32 = MAX_BRIDGE_HUB_HEADER_SIZE;
64}
65
66impl ChainWithMessages for BridgeHubWestend {
67	const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
68		WITH_BRIDGE_HUB_WESTEND_MESSAGES_PALLET_NAME;
69
70	const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
71		MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
72	const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
73		MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
74}
75
76/// Identifier of BridgeHubWestend in the Westend relay chain.
77pub const BRIDGE_HUB_WESTEND_PARACHAIN_ID: u32 = 1002;
78
79/// Name of the With-BridgeHubWestend messages pallet instance that is deployed at bridged chains.
80pub const WITH_BRIDGE_HUB_WESTEND_MESSAGES_PALLET_NAME: &str = "BridgeWestendMessages";
81
82/// Name of the With-BridgeHubWestend bridge-relayers pallet instance that is deployed at bridged
83/// chains.
84pub const WITH_BRIDGE_HUB_WESTEND_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
85
86/// Pallet index of `BridgeRococoMessages: pallet_bridge_messages::<Instance1>`.
87pub const WITH_BRIDGE_WESTEND_TO_ROCOCO_MESSAGES_PALLET_INDEX: u8 = 44;
88
89decl_bridge_finality_runtime_apis!(bridge_hub_westend);
90decl_bridge_messages_runtime_apis!(bridge_hub_westend, LegacyLaneId);
91
92frame_support::parameter_types! {
93	/// The XCM fee that is paid for executing XCM program (with `ExportMessage` instruction) at the Westend
94	/// BridgeHub.
95	/// (initially was calculated by test `BridgeHubWestend::can_calculate_weight_for_paid_export_message_with_reserve_transfer` + `33%`)
96	pub const BridgeHubWestendBaseXcmFeeInWnds: u128 = 22_962_450_000;
97
98	/// Transaction fee that is paid at the Westend BridgeHub for delivering single inbound message.
99	/// (initially was calculated by test `BridgeHubWestend::can_calculate_fee_for_standalone_message_delivery_transaction` + `33%`)
100	pub const BridgeHubWestendBaseDeliveryFeeInWnds: u128 = 89_305_927_116;
101
102	/// Transaction fee that is paid at the Westend BridgeHub for delivering single outbound message confirmation.
103	/// (initially was calculated by test `BridgeHubWestend::can_calculate_fee_for_standalone_message_confirmation_transaction` + `33%`)
104	pub const BridgeHubWestendBaseConfirmationFeeInWnds: u128 = 17_034_677_116;
105}
106
107/// Wrapper over `BridgeHubWestend`'s `RuntimeCall` that can be used without a runtime.
108#[derive(Decode, Encode)]
109pub enum RuntimeCall {
110	/// Points to the `pallet_xcm_bridge_hub` pallet instance for `BridgeHubRococo`.
111	#[codec(index = 45)]
112	XcmOverBridgeHubRococo(bp_xcm_bridge_hub::XcmBridgeHubCall),
113}