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