diff --git a/Cargo.lock b/Cargo.lock index 14d6b177ef..3fa4042205 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1755,6 +1755,8 @@ dependencies = [ "bp-polkadot-core", "bp-relayers", "bp-runtime", + "bp-xcm-bridge-hub", + "bp-xcm-bridge-hub-router", "bridge-hub-common", "bridge-hub-test-utils", "bridge-runtime-common", @@ -1899,6 +1901,8 @@ dependencies = [ "bp-polkadot-core", "bp-relayers", "bp-runtime", + "bp-xcm-bridge-hub", + "bp-xcm-bridge-hub-router", "bridge-hub-common", "bridge-hub-test-utils", "bridge-runtime-common", diff --git a/Cargo.toml b/Cargo.toml index 8f44675da1..3c91060a80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ bp-polkadot-bulletin = { version = "0.15.0", default-features = false } bp-polkadot-core = { version = "0.18.0", default-features = false } bp-relayers = { version = "0.18.0", default-features = false } bp-runtime = { version = "0.18.0", default-features = false } +bp-xcm-bridge-hub = { version = "0.4.0", default-features = false } bp-xcm-bridge-hub-router = { version = "0.14.1", default-features = false } bridge-hub-common = { version = "0.10.0", default-features = false } bridge-hub-kusama-emulated-chain = { path = "integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama" } diff --git a/system-parachains/asset-hubs/asset-hub-kusama/primitives/src/lib.rs b/system-parachains/asset-hubs/asset-hub-kusama/primitives/src/lib.rs index 78e00d3134..f2f0b89052 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/primitives/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/primitives/src/lib.rs @@ -46,30 +46,9 @@ frame_support::parameter_types! { /// Some sane weight to execute `xcm::Transact(pallet-xcm-bridge-hub-router::Call::report_bridge_status)`. pub const XcmBridgeHubRouterTransactCallMaxWeight: Weight = Weight::from_parts(200_000_000, 6144); - /// Message that is sent to the sibling Kusama Asset Hub when the with-Polkadot bridge becomes congested. - pub CongestedMessage: Xcm<()> = build_congestion_message(true).into(); - /// Message that is sent to the sibling Kusama Asset Hub when the with-Polkadot bridge becomes uncongested. - pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into(); - /// Should match the `AssetDeposit` of the `ForeignAssets` pallet on Asset Hub. pub const CreateForeignAssetDeposit: u128 = system_para_deposit(1, 190); } -fn build_congestion_message(is_congested: bool) -> sp_std::vec::Vec> { - sp_std::vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind: OriginKind::Xcm, - require_weight_at_most: XcmBridgeHubRouterTransactCallMaxWeight::get(), - call: Call::ToPolkadotXcmRouter(XcmBridgeHubRouterCall::report_bridge_status { - bridge_id: Default::default(), - is_congested, - }) - .encode() - .into(), - } - ] -} - /// Identifier of AssetHubKusama in the Kusama relay chain. pub const ASSET_HUB_KUSAMA_PARACHAIN_ID: u32 = 1000; diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/primitives/src/lib.rs b/system-parachains/asset-hubs/asset-hub-polkadot/primitives/src/lib.rs index 49e171e33b..8a8916a86f 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/primitives/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/primitives/src/lib.rs @@ -46,30 +46,9 @@ frame_support::parameter_types! { /// Some sane weight to execute `xcm::Transact(pallet-xcm-bridge-hub-router::Call::report_bridge_status)`. pub const XcmBridgeHubRouterTransactCallMaxWeight: Weight = Weight::from_parts(200_000_000, 6144); - /// Message that is sent to the sibling Kusama Asset Hub when the with-Polkadot bridge becomes congested. - pub CongestedMessage: Xcm<()> = build_congestion_message(true).into(); - /// Message that is sent to the sibling Kusama Asset Hub when the with-Polkadot bridge becomes uncongested. - pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into(); - /// Should match the `AssetDeposit` of the `ForeignAssets` pallet on Asset Hub. pub const CreateForeignAssetDeposit: u128 = system_para_deposit(1, 190); } -fn build_congestion_message(is_congested: bool) -> sp_std::vec::Vec> { - sp_std::vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind: OriginKind::Xcm, - require_weight_at_most: XcmBridgeHubRouterTransactCallMaxWeight::get(), - call: Call::ToKusamaXcmRouter(XcmBridgeHubRouterCall::report_bridge_status { - bridge_id: Default::default(), - is_congested, - }) - .encode() - .into(), - } - ] -} - /// Identifier of AssetHubPolkadot in the Polkadot relay chain. pub const ASSET_HUB_POLKADOT_PARACHAIN_ID: u32 = 1000; diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs index d399b81ba6..c0898617be 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs @@ -860,7 +860,6 @@ impl pallet_xcm_bridge_hub_router::Config for Runtime type ByteFee = xcm_config::bridging::XcmBridgeHubRouterByteFee; type FeeAsset = xcm_config::bridging::XcmBridgeHubRouterFeeAssetId; - // TODO: @bkontur - change to `report_bridge_status` when patched - FAIL-CI type LocalXcmChannelManager = cumulus_pallet_xcmp_queue::bridging::InAndOutXcmpChannelStatusProvider; } diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml b/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml index c2b201ff7f..e61468c8de 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml @@ -96,6 +96,8 @@ bp-relayers = { workspace = true } bp-runtime = { workspace = true } bp-kusama = { workspace = true } bp-polkadot = { workspace = true } +bp-xcm-bridge-hub = { workspace = true } +bp-xcm-bridge-hub-router = { workspace = true } bridge-hub-common = { workspace = true } bridge-runtime-common = { workspace = true } pallet-bridge-grandpa = { workspace = true } @@ -129,6 +131,8 @@ std = [ "bp-polkadot/std", "bp-relayers/std", "bp-runtime/std", + "bp-xcm-bridge-hub-router/std", + "bp-xcm-bridge-hub/std", "bridge-hub-common/std", "bridge-runtime-common/std", "codec/std", diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_polkadot_config.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_polkadot_config.rs index c1fca39d40..583053c990 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_polkadot_config.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_polkadot_config.rs @@ -29,7 +29,10 @@ use bp_messages::{ use bp_parachains::SingleParaStoredHeaderDataBuilder; use bp_runtime::Chain; use bridge_hub_common::xcm_version::XcmVersionOfDestAndRemoteBridge; -use frame_support::{parameter_types, traits::PalletInfoAccess}; +use frame_support::{ + parameter_types, + traits::{ConstU128, PalletInfoAccess}, +}; use frame_system::{EnsureNever, EnsureRoot}; use kusama_runtime_constants as constants; use pallet_bridge_messages::LaneIdOf; @@ -140,8 +143,6 @@ parameter_types! { pub PriorityBoostPerParachainHeader: u64 = 920_224_664_224_664; // see the `FEE_BOOST_PER_MESSAGE` constant to get the meaning of this value pub PriorityBoostPerMessage: u64 = 182_044_444_444_444; - // TODO: What's the correct value? - FAIL-CI - pub storage BridgeDeposit: Balance = constants::currency::UNITS; } /// Proof of messages, coming from Polkadot. @@ -246,19 +247,156 @@ impl pallet_xcm_bridge_hub::Config for Runtime type BridgeOriginAccountIdConverter = (ParentIsPreset, SiblingParachainConvertsVia); - type BridgeDeposit = BridgeDeposit; + // We do not allow creating bridges here (see `T::OpenBridgeOrigin` above), so there is no need + // to set a deposit. + type BridgeDeposit = ConstU128<0>; type Currency = Balances; type RuntimeHoldReason = RuntimeHoldReason; // Do not require deposit from system parachains or relay chain type AllowWithoutBridgeDeposit = RelayOrOtherSystemParachains; - // TODO: @acatangiu (bridges-v2) - add `LocalXcmChannelManager` impl - https://github.com/paritytech/parity-bridges-common/issues/3047 - // @acatangiu - type LocalXcmChannelManager = (); + type LocalXcmChannelManager = XcmpQueueChannelManager; type BlobDispatcher = FromPolkadotMessageBlobDispatcher; } +/// Implementation `bp_xcm_bridge_hub::LocalXcmChannelManager`. +pub struct XcmpQueueChannelManager; +impl bp_xcm_bridge_hub::LocalXcmChannelManager for XcmpQueueChannelManager { + type Error = (); + + fn is_congested(with: &Location) -> bool { + // This is used to check the inbound queue/messages to determine if they can be dispatched + // and sent to the sibling parachain. Therefore, checking `OutXcmp` is sufficient. + use bp_xcm_bridge_hub_router::XcmChannelStatusProvider; + cumulus_pallet_xcmp_queue::bridging::OutXcmpChannelStatusProvider::::is_congested( + with, + ) + } + + fn suspend_bridge( + _local_origin: &Location, + _: pallet_xcm_bridge_hub::BridgeId, + ) -> Result<(), Self::Error> { + // IMPORTANT NOTE: + // + // Unfortunately, `https://github.com/paritytech/polkadot-sdk/pull/6231` reworked congestion is not yet released. + // + // And unfortunately, we don't have access to `XcmpQueue::send_signal(para, + // ChannelSignal::Suspend)` here (which would require patch release), we can add this + // hacky workaround/tmp/implementation that should trigger `ChannelSignal::Suspend`, e.g.: + /* + use crate::{MessageQueue, XcmpQueue}; + use bridge_hub_common::message_queue::AggregateMessageOrigin; + use codec::{Decode, Encode, MaxEncodedLen}; + use frame_support::traits::EnqueueMessage; + use frame_support::pallet_prelude::OptionQuery; + use pallet_message_queue::OnQueueChanged; + use scale_info::TypeInfo; + + // get sibling para id + let local_origin_para_id: crate::ParaId = match local_origin.unpack() { + (1, [Parachain(id)]) => (*id).into(), + _ => return Err(()) + }; + + // read `suspend_threshold` from `XcmpQueue` storage + #[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, TypeInfo, MaxEncodedLen)] + struct QueueConfigData { + suspend_threshold: u32, + drop_threshold: u32, + resume_threshold: u32, + } + #[frame_support::storage_alias] + type QueueConfig = StorageValue; + let suspend_threshold = match QueueConfig::get() { + Some(qc) => qc.suspend_threshold, + None => return Err(()) + }; + + // Now, this should trigger `XcmpQueue::send_signal(para, ChannelSignal::Suspend)` + let mut qf = MessageQueue::footprint(AggregateMessageOrigin::Sibling(local_origin_para_id)); + qf.ready_pages = suspend_threshold; + XcmpQueue::on_queue_changed(local_origin_para_id.into(), qf); + */ + + // IMPORTANT NOTE2: + // + // In the current setup, this code is likely triggered only for the hard-coded AHK<>AHP + // lane, as we do not support any other bridge lanes on BridgeHubs. It is triggered only + // when `pallet_bridge_messages::OutboundMessages` reaches 8,192 undelivered messages. The + // potential risk of keeping `Ok(())` or `Err(())` here is that + // `pallet_bridge_messages::OutboundMessages` may continue to grow: + // + // ``` + // #[pallet::storage] + // pub type OutboundMessages, I: 'static = ()> = + // StorageMap<_, Blake2_128Concat, MessageKey, StoredMessagePayload>; + // ``` + + // TODO: decide: + // 1. wait for patch-release stable2409-3 2024-12-12 + // 2. go with `Ok(())` / `Err(())` + // 3. go with `XcmpQueue::send_signal` temporary workaround till patch release + + Ok(()) + } + + fn resume_bridge( + _local_origin: &Location, + _: pallet_xcm_bridge_hub::BridgeId, + ) -> Result<(), Self::Error> { + // IMPORTANT NOTE: + // + // Unfortunately, `https://github.com/paritytech/polkadot-sdk/pull/6231` reworked congestion is not yet released. + // + // And unfortunately, we don't have access to `XcmpQueue::send_signal(para, + // ChannelSignal::Resume)` here (which would require patch release), we can add this hacky + // workaround/tmp/implementation that should trigger `ChannelSignal::Resume`, e.g.: + /* + use crate::{MessageQueue, XcmpQueue}; + use bridge_hub_common::message_queue::AggregateMessageOrigin; + use codec::{Decode, Encode, MaxEncodedLen}; + use frame_support::traits::EnqueueMessage; + use frame_support::pallet_prelude::OptionQuery; + use pallet_message_queue::OnQueueChanged; + use scale_info::TypeInfo; + + // get sibling para id + let local_origin_para_id: crate::ParaId = match local_origin.unpack() { + (1, [Parachain(id)]) => (*id).into(), + _ => return Err(()) + }; + + // read `resume_threshold` from `XcmpQueue` storage + #[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, TypeInfo, MaxEncodedLen)] + struct QueueConfigData { + suspend_threshold: u32, + drop_threshold: u32, + resume_threshold: u32, + } + #[frame_support::storage_alias] + type QueueConfig = StorageValue; + let resume_threshold = match QueueConfig::get() { + Some(qc) => qc.resume_threshold, + None => return Err(()) + }; + + // Now, this should trigger `XcmpQueue::send_signal(para, ChannelSignal::Resume)` + let mut qf = MessageQueue::footprint(AggregateMessageOrigin::Sibling(local_origin_para_id)); + qf.ready_pages = resume_threshold; + XcmpQueue::on_queue_changed(local_origin_para_id.into(), qf); + */ + + // TODO: decide: + // 1. wait for patch-release stable2409-3 2024-12-12 + // 2. go with `Ok(())` / `Err(())` + // 3. go with `XcmpQueue::send_signal` temporary workaround till patch release + + Ok(()) + } +} + #[cfg(feature = "runtime-benchmarks")] pub(crate) fn open_bridge_for_benchmarks( with: pallet_xcm_bridge_hub::LaneIdOf, diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs index 1d7d3389e8..dc009ec2c2 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -1128,21 +1128,9 @@ impl_runtime_apis! { BenchmarkError::Stop("XcmVersion was not stored!") })?; - let sibling_parachain_id = Parachain(8765); + let sibling_system_parachain_id = Parachain(1000); let remote_parachain_id = Parachain(5678); - let sibling_parachain_location = Location::new(1, [sibling_parachain_id]); - - // fund SA - use frame_support::traits::fungible::Mutate; - use xcm_executor::traits::ConvertLocation; - frame_support::assert_ok!( - Balances::mint_into( - &xcm_config::LocationToAccountId::convert_location(&sibling_parachain_location).expect("valid AccountId"), - bridge_to_polkadot_config::BridgeDeposit::get() - .saturating_add(ExistentialDeposit::get()) - .saturating_add(UNITS * 5) - ) - ); + let sibling_parachain_location = Location::new(1, [sibling_system_parachain_id]); // open bridge let bridge_destination_universal_location: InteriorLocation = [GlobalConsensus(NetworkId::Polkadot), remote_parachain_id].into(); diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/Cargo.toml b/system-parachains/bridge-hubs/bridge-hub-polkadot/Cargo.toml index a5d12b7637..75598dc389 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/Cargo.toml +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/Cargo.toml @@ -96,6 +96,8 @@ bp-relayers = { workspace = true } bp-runtime = { workspace = true } bp-kusama = { workspace = true } bp-polkadot = { workspace = true } +bp-xcm-bridge-hub = { workspace = true } +bp-xcm-bridge-hub-router = { workspace = true } bridge-hub-common = { workspace = true } bridge-runtime-common = { workspace = true } pallet-bridge-grandpa = { workspace = true } @@ -143,6 +145,8 @@ std = [ "bp-polkadot/std", "bp-relayers/std", "bp-runtime/std", + "bp-xcm-bridge-hub-router/std", + "bp-xcm-bridge-hub/std", "bridge-hub-common/std", "bridge-runtime-common/std", "codec/std", diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/bridge_to_kusama_config.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/bridge_to_kusama_config.rs index 7d21d4acfe..869972e9b1 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/bridge_to_kusama_config.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/bridge_to_kusama_config.rs @@ -30,7 +30,10 @@ use bp_messages::{ use bp_parachains::SingleParaStoredHeaderDataBuilder; use bp_runtime::Chain; use bridge_hub_common::xcm_version::XcmVersionOfDestAndRemoteBridge; -use frame_support::{parameter_types, traits::PalletInfoAccess}; +use frame_support::{ + parameter_types, + traits::{ConstU128, PalletInfoAccess}, +}; use frame_system::{EnsureNever, EnsureRoot}; use pallet_bridge_messages::LaneIdOf; use pallet_bridge_relayers::extension::{ @@ -141,8 +144,6 @@ parameter_types! { pub PriorityBoostPerParachainHeader: u64 = 9_182_241_758_241; // see the `FEE_BOOST_PER_MESSAGE` constant to get the meaning of this value pub PriorityBoostPerMessage: u64 = 1_820_444_444_444; - // TODO: @acatangiu, is there any specs about the deposit cost? - pub storage BridgeDeposit: Balance = 10 * constants::currency::UNITS; } /// Proof of messages, coming from Kusama. @@ -247,17 +248,155 @@ impl pallet_xcm_bridge_hub::Config for Runtime { type BridgeOriginAccountIdConverter = (ParentIsPreset, SiblingParachainConvertsVia); - type BridgeDeposit = BridgeDeposit; + // We do not allow creating bridges here (see `T::OpenBridgeOrigin` above), so there is no need + // to set a deposit. + type BridgeDeposit = ConstU128<0>; type Currency = Balances; type RuntimeHoldReason = RuntimeHoldReason; type AllowWithoutBridgeDeposit = RelayOrOtherSystemParachains; - // TODO: @acatangiu (bridges-v2) - add `LocalXcmChannelManager` impl - https://github.com/paritytech/parity-bridges-common/issues/3047 - type LocalXcmChannelManager = (); + type LocalXcmChannelManager = XcmpQueueChannelManager; type BlobDispatcher = FromKusamaMessageBlobDispatcher; } +/// Implementation `bp_xcm_bridge_hub::LocalXcmChannelManager`. +pub struct XcmpQueueChannelManager; +impl bp_xcm_bridge_hub::LocalXcmChannelManager for XcmpQueueChannelManager { + type Error = (); + + fn is_congested(with: &Location) -> bool { + // This is used to check the inbound queue/messages to determine if they can be dispatched + // and sent to the sibling parachain. Therefore, checking `OutXcmp` is sufficient. + use bp_xcm_bridge_hub_router::XcmChannelStatusProvider; + cumulus_pallet_xcmp_queue::bridging::OutXcmpChannelStatusProvider::::is_congested( + with, + ) + } + + fn suspend_bridge( + _local_origin: &Location, + _: pallet_xcm_bridge_hub::BridgeId, + ) -> Result<(), Self::Error> { + // IMPORTANT NOTE: + // + // Unfortunately, `https://github.com/paritytech/polkadot-sdk/pull/6231` reworked congestion is not yet released. + // + // And unfortunately, we don't have access to `XcmpQueue::send_signal(para, + // ChannelSignal::Suspend)` here (which would require patch release), we can add this + // hacky workaround/tmp/implementation that should trigger `ChannelSignal::Suspend`, e.g.: + /* + use crate::{MessageQueue, XcmpQueue}; + use bridge_hub_common::message_queue::AggregateMessageOrigin; + use codec::{Decode, Encode, MaxEncodedLen}; + use frame_support::traits::EnqueueMessage; + use frame_support::pallet_prelude::OptionQuery; + use pallet_message_queue::OnQueueChanged; + use scale_info::TypeInfo; + + // get sibling para id + let local_origin_para_id: crate::ParaId = match _local_origin.unpack() { + (1, [Parachain(id)]) => (*id).into(), + _ => return Err(()) + }; + + // read `suspend_threshold` from `XcmpQueue` storage + #[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, TypeInfo, MaxEncodedLen)] + struct QueueConfigData { + suspend_threshold: u32, + drop_threshold: u32, + resume_threshold: u32, + } + #[frame_support::storage_alias] + type QueueConfig = StorageValue; + let suspend_threshold = match QueueConfig::get() { + Some(qc) => qc.suspend_threshold, + None => return Err(()) + }; + + // Now, this should trigger `XcmpQueue::send_signal(para, ChannelSignal::Suspend)` + let mut qf = MessageQueue::footprint(AggregateMessageOrigin::Sibling(local_origin_para_id)); + qf.ready_pages = suspend_threshold; + XcmpQueue::on_queue_changed(local_origin_para_id.into(), qf); + */ + + // IMPORTANT NOTE2: + // + // In the current setup, this code is likely triggered only for the hard-coded AHK<>AHP + // lane, as we do not support any other bridge lanes on BridgeHubs. It is triggered only + // when `pallet_bridge_messages::OutboundMessages` reaches 8,192 undelivered messages. The + // potential risk of keeping `Ok(())` or `Err(())` here is that + // `pallet_bridge_messages::OutboundMessages` may continue to grow: + // + // ``` + // #[pallet::storage] + // pub type OutboundMessages, I: 'static = ()> = + // StorageMap<_, Blake2_128Concat, MessageKey, StoredMessagePayload>; + // ``` + + // TODO: decide: + // 1. wait for patch-release stable2409-3 2024-12-12 + // 2. go with `Ok(())` / `Err(())` + // 3. go with `XcmpQueue::send_signal` temporary workaround till patch release + + Ok(()) + } + + fn resume_bridge( + _local_origin: &Location, + _: pallet_xcm_bridge_hub::BridgeId, + ) -> Result<(), Self::Error> { + // IMPORTANT NOTE: + // + // Unfortunately, `https://github.com/paritytech/polkadot-sdk/pull/6231` reworked congestion is not yet released. + // + // And unfortunately, we don't have access to `XcmpQueue::send_signal(para, + // ChannelSignal::Resume)` here (which would require patch release), we can add this hacky + // workaround/tmp/implementation that should trigger `ChannelSignal::Resume`, e.g.: + /* + use crate::{MessageQueue, XcmpQueue}; + use bridge_hub_common::message_queue::AggregateMessageOrigin; + use codec::{Decode, Encode, MaxEncodedLen}; + use frame_support::traits::EnqueueMessage; + use frame_support::pallet_prelude::OptionQuery; + use pallet_message_queue::OnQueueChanged; + use scale_info::TypeInfo; + + // get sibling para id + let local_origin_para_id: crate::ParaId = match _local_origin.unpack() { + (1, [Parachain(id)]) => (*id).into(), + _ => return Err(()) + }; + + // read `resume_threshold` from `XcmpQueue` storage + #[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, TypeInfo, MaxEncodedLen)] + struct QueueConfigData { + suspend_threshold: u32, + drop_threshold: u32, + resume_threshold: u32, + } + #[frame_support::storage_alias] + type QueueConfig = StorageValue; + let resume_threshold = match QueueConfig::get() { + Some(qc) => qc.resume_threshold, + None => return Err(()) + }; + + // Now, this should trigger `XcmpQueue::send_signal(para, ChannelSignal::Resume)` + let mut qf = MessageQueue::footprint(AggregateMessageOrigin::Sibling(local_origin_para_id)); + qf.ready_pages = resume_threshold; + XcmpQueue::on_queue_changed(local_origin_para_id.into(), qf); + */ + + // TODO: decide: + // 1. wait for patch-release stable2409-3 2024-12-12 + // 2. go with `Ok(())` / `Err(())` + // 3. go with `XcmpQueue::send_signal` temporary workaround till patch release + + Ok(()) + } +} + #[cfg(feature = "runtime-benchmarks")] pub(crate) fn open_bridge_for_benchmarks( with: pallet_xcm_bridge_hub::LaneIdOf, diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 2aecae8639..8579c12c1f 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -1146,21 +1146,9 @@ impl_runtime_apis! { BenchmarkError::Stop("XcmVersion was not stored!") })?; - let sibling_parachain_id = Parachain(5678); + let sibling_system_parachain_id = Parachain(1000); let remote_parachain_id = Parachain(8765); - let sibling_parachain_location = Location::new(1, [sibling_parachain_id]); - - // fund SA - use frame_support::traits::fungible::Mutate; - use xcm_executor::traits::ConvertLocation; - frame_support::assert_ok!( - Balances::mint_into( - &xcm_config::LocationToAccountId::convert_location(&sibling_parachain_location).expect("valid AccountId"), - bridge_to_kusama_config::BridgeDeposit::get() - .saturating_add(ExistentialDeposit::get()) - .saturating_add(UNITS * 5) - ) - ); + let sibling_parachain_location = Location::new(1, [sibling_system_parachain_id]); // open bridge let bridge_destination_universal_location: InteriorLocation = [GlobalConsensus(NetworkId::Kusama), remote_parachain_id].into();