Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Nov 21, 2024
1 parent 35d0417 commit 51f9056
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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::{ConstU128, 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;
Expand Down Expand Up @@ -244,7 +247,8 @@ impl pallet_xcm_bridge_hub::Config<XcmOverBridgeHubPolkadotInstance> for Runtime
type BridgeOriginAccountIdConverter =
(ParentIsPreset<AccountId>, SiblingParachainConvertsVia<Sibling, AccountId>);

// We do not allow creating bridges here (see `T::OpenBridgeOrigin` above), so there is no need to set a deposit.
// 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;
Expand All @@ -262,18 +266,25 @@ 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.
// 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::<Runtime>::is_congested(with)
cumulus_pallet_xcmp_queue::bridging::OutXcmpChannelStatusProvider::<Runtime>::is_congested(
with,
)
}

fn suspend_bridge(_local_origin: &Location, _: pallet_xcm_bridge_hub::BridgeId) -> Result<(), Self::Error> {
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.:
// 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;
Expand Down Expand Up @@ -311,9 +322,11 @@ impl bp_xcm_bridge_hub::LocalXcmChannelManager for XcmpQueueChannelManager {

// 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:
// 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]
Expand All @@ -329,13 +342,17 @@ impl bp_xcm_bridge_hub::LocalXcmChannelManager for XcmpQueueChannelManager {
Ok(())
}

fn resume_bridge(_local_origin: &Location, _: pallet_xcm_bridge_hub::BridgeId) -> Result<(), Self::Error> {
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.:
// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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::{ConstU128, PalletInfoAccess}};
use frame_support::{
parameter_types,
traits::{ConstU128, PalletInfoAccess},
};
use frame_system::{EnsureNever, EnsureRoot};
use pallet_bridge_messages::LaneIdOf;
use pallet_bridge_relayers::extension::{
Expand Down Expand Up @@ -245,7 +248,8 @@ impl pallet_xcm_bridge_hub::Config<XcmOverBridgeHubKusamaInstance> for Runtime {
type BridgeOriginAccountIdConverter =
(ParentIsPreset<AccountId>, SiblingParachainConvertsVia<Sibling, AccountId>);

// We do not allow creating bridges here (see `T::OpenBridgeOrigin` above), so there is no need to set a deposit.
// 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;
Expand All @@ -262,18 +266,25 @@ 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.
// 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::<Runtime>::is_congested(with)
cumulus_pallet_xcmp_queue::bridging::OutXcmpChannelStatusProvider::<Runtime>::is_congested(
with,
)
}

fn suspend_bridge(_local_origin: &Location, _: pallet_xcm_bridge_hub::BridgeId) -> Result<(), Self::Error> {
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.:
// 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;
Expand Down Expand Up @@ -311,9 +322,11 @@ impl bp_xcm_bridge_hub::LocalXcmChannelManager for XcmpQueueChannelManager {

// 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:
// 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]
Expand All @@ -329,13 +342,17 @@ impl bp_xcm_bridge_hub::LocalXcmChannelManager for XcmpQueueChannelManager {
Ok(())
}

fn resume_bridge(_local_origin: &Location, _: pallet_xcm_bridge_hub::BridgeId) -> Result<(), Self::Error> {
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.:
// 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;
Expand Down

0 comments on commit 51f9056

Please sign in to comment.