bp_asset_hub_rococo/
lib.rs1#![cfg_attr(not(feature = "std"), no_std)]
19
20extern crate alloc;
21
22use codec::{Decode, Encode};
23use scale_info::TypeInfo;
24
25pub use bp_bridge_hub_cumulus::*;
26use bp_messages::*;
27use bp_runtime::{
28 decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain,
29};
30pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall;
31use frame_support::{
32 dispatch::DispatchClass,
33 sp_runtime::{MultiAddress, MultiSigner, RuntimeDebug, StateVersion},
34};
35use testnet_parachains_constants::rococo::currency::UNITS;
36use xcm::latest::prelude::*;
37
38#[allow(clippy::large_enum_variant)]
47#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
48pub enum Call {
49 #[codec(index = 45)]
51 ToWestendXcmRouter(XcmBridgeHubRouterCall),
52}
53
54frame_support::parameter_types! {
55 pub const XcmBridgeHubRouterTransactCallMaxWeight: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(200_000_000, 6144);
57 pub const CreateForeignAssetDeposit: u128 = UNITS / 10;
59}
60
61pub fn build_congestion_message<RuntimeCall>(
64 bridge_id: sp_core::H256,
65 is_congested: bool,
66) -> alloc::vec::Vec<Instruction<RuntimeCall>> {
67 alloc::vec![
68 UnpaidExecution { weight_limit: Unlimited, check_origin: None },
69 Transact {
70 origin_kind: OriginKind::Xcm,
71 fallback_max_weight: Some(XcmBridgeHubRouterTransactCallMaxWeight::get()),
72 call: Call::ToWestendXcmRouter(XcmBridgeHubRouterCall::report_bridge_status {
73 bridge_id,
74 is_congested,
75 })
76 .encode()
77 .into(),
78 },
79 ExpectTransactStatus(MaybeErrorCode::Success),
80 ]
81}
82
83pub const ASSET_HUB_ROCOCO_PARACHAIN_ID: u32 = 1000;
85
86#[derive(RuntimeDebug)]
88
89pub struct AssetHubRococo;
90
91impl Chain for AssetHubRococo {
92 const ID: ChainId = *b"ahro";
93
94 type BlockNumber = BlockNumber;
95 type Hash = Hash;
96 type Hasher = Hasher;
97 type Header = Header;
98
99 type AccountId = AccountId;
100 type Balance = Balance;
101 type Nonce = Nonce;
102 type Signature = Signature;
103
104 const STATE_VERSION: StateVersion = StateVersion::V1;
105
106 fn max_extrinsic_size() -> u32 {
107 *BlockLength::get().max.get(DispatchClass::Normal)
108 }
109
110 fn max_extrinsic_weight() -> Weight {
111 BlockWeightsForAsyncBacking::get()
112 .get(DispatchClass::Normal)
113 .max_extrinsic
114 .unwrap_or(Weight::MAX)
115 }
116}
117
118impl Parachain for AssetHubRococo {
119 const PARACHAIN_ID: u32 = ASSET_HUB_ROCOCO_PARACHAIN_ID;
120 const MAX_HEADER_SIZE: u32 = MAX_ASSET_HUB_HEADER_SIZE;
121}
122
123impl ChainWithMessages for AssetHubRococo {
125 const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
126 WITH_ASSET_HUB_ROCOCO_MESSAGES_PALLET_NAME;
127
128 const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
129 MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
130 const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
131 MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
132}
133
134pub type AccountSigner = MultiSigner;
136
137pub type Address = MultiAddress<AccountId, ()>;
139
140pub const WITH_ASSET_HUB_ROCOCO_MESSAGES_PALLET_NAME: &str = "BridgeRococoMessages";
142
143pub const WITH_ASSET_HUB_ROCOCO_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
146
147pub const WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX: u8 = 62;
149
150decl_bridge_finality_runtime_apis!(asset_hub_rococo);
151decl_bridge_messages_runtime_apis!(asset_hub_rococo, HashedLaneId);