Skip to content

Commit

Permalink
Bridges small nits/improvements (#7383)
Browse files Browse the repository at this point in the history
This PR contains small fixes and backwards compatibility issues
identified during work on the larger PR:
#6906.

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
(cherry picked from commit ada12be)
  • Loading branch information
bkontur committed Jan 29, 2025
1 parent 008650b commit e06d981
Show file tree
Hide file tree
Showing 15 changed files with 381 additions and 345 deletions.
4 changes: 0 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions bridges/modules/xcm-bridge-hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@

use bp_messages::{LaneState, MessageNonce};
use bp_runtime::{AccountIdOf, BalanceOf, RangeInclusiveExt};
pub use bp_xcm_bridge_hub::{Bridge, BridgeId, BridgeState, LocalXcmChannelManager};
use bp_xcm_bridge_hub::{BridgeLocations, BridgeLocationsError};
use bp_xcm_bridge_hub::BridgeLocationsError;
pub use bp_xcm_bridge_hub::{
Bridge, BridgeId, BridgeLocations, BridgeState, LocalXcmChannelManager,
};
use frame_support::{traits::fungible::MutateHold, DefaultNoBound};
use frame_system::Config as SystemConfig;
use pallet_bridge_messages::{Config as BridgeMessagesConfig, LanesManagerError};
Expand Down
17 changes: 12 additions & 5 deletions cumulus/pallets/xcmp-queue/src/bridging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ impl<Runtime: crate::Config> bp_xcm_bridge_hub_router::XcmChannelStatusProvider
}
}

/// Adapter implementation for `bp_xcm_bridge_hub_router::XcmChannelStatusProvider` which checks
/// only `OutboundXcmpStatus` for defined `SiblingParaId` if is suspended.
/// Adapter implementation for `bp_xcm_bridge::ChannelStatusProvider` and/or
/// `bp_xcm_bridge_hub_router::XcmChannelStatusProvider` which checks only `OutboundXcmpStatus`
/// for defined `Location` if is suspended.
pub struct OutXcmpChannelStatusProvider<Runtime>(core::marker::PhantomData<Runtime>);
impl<Runtime: crate::Config> bp_xcm_bridge_hub_router::XcmChannelStatusProvider
for OutXcmpChannelStatusProvider<Runtime>
{
impl<Runtime: crate::Config> OutXcmpChannelStatusProvider<Runtime> {
fn is_congested(with: &Location) -> bool {
// handle congestion only for a sibling parachain locations.
let sibling_para_id: ParaId = match with.unpack() {
Expand Down Expand Up @@ -88,6 +87,14 @@ impl<Runtime: crate::Config> bp_xcm_bridge_hub_router::XcmChannelStatusProvider
}
}

impl<Runtime: crate::Config> bp_xcm_bridge_hub_router::XcmChannelStatusProvider
for OutXcmpChannelStatusProvider<Runtime>
{
fn is_congested(with: &Location) -> bool {
Self::is_congested(with)
}
}

#[cfg(feature = "runtime-benchmarks")]
pub fn suspend_channel_for_benchmarks<T: crate::Config>(target: ParaId) {
pallet::Pallet::<T>::suspend_channel(target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pallet-xcm.workspace = true
xcm-executor.workspace = true
xcm-runtime-apis.workspace = true
pallet-bridge-messages.workspace = true
pallet-xcm-bridge-hub.workspace = true
cumulus-pallet-xcmp-queue.workspace = true
emulated-integration-tests-common.workspace = true
parachains-common.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pallet-xcm.workspace = true
xcm-executor.workspace = true
xcm-runtime-apis.workspace = true
pallet-bridge-messages.workspace = true
pallet-xcm-bridge-hub.workspace = true
cumulus-pallet-xcmp-queue.workspace = true
emulated-integration-tests-common.workspace = true
parachains-common.workspace = true
Expand Down
6 changes: 2 additions & 4 deletions cumulus/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ sp-io.workspace = true
sp-keyring.workspace = true
sp-keyring.default-features = true
sp-runtime.workspace = true
sp-std.workspace = true
sp-tracing.workspace = true
sp-tracing.default-features = true
pallet-balances.workspace = true
Expand All @@ -42,13 +43,11 @@ bp-polkadot-core.workspace = true
bp-relayers.workspace = true
bp-runtime.workspace = true
bp-test-utils.workspace = true
bp-xcm-bridge-hub.workspace = true
pallet-bridge-grandpa.workspace = true
pallet-bridge-parachains.workspace = true
pallet-bridge-messages = { features = ["test-helpers"], workspace = true }
pallet-bridge-relayers.workspace = true
pallet-xcm-bridge-hub.workspace = true
bridge-runtime-common.workspace = true

[features]
default = ["std"]
Expand All @@ -61,8 +60,6 @@ std = [
"bp-relayers/std",
"bp-runtime/std",
"bp-test-utils/std",
"bp-xcm-bridge-hub/std",
"bridge-runtime-common/std",
"codec/std",
"cumulus-pallet-parachain-system/std",
"cumulus-pallet-xcmp-queue/std",
Expand All @@ -83,6 +80,7 @@ std = [
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern crate alloc;
pub use bp_test_utils::test_header;
pub use parachains_runtimes_test_utils::*;
use sp_runtime::Perbill;
pub use test_cases::helpers::{
pub use test_cases::helpers::for_pallet_xcm_bridge_hub::{
ensure_opened_bridge, open_bridge_with_extrinsic, open_bridge_with_storage,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
use crate::{
test_cases::{bridges_prelude::*, helpers, run_test},
test_data,
test_data::XcmAsPlainPayload,
};

use alloc::{boxed::Box, vec};
use bp_header_chain::ChainWithGrandpa;
use bp_messages::UnrewardedRelayersState;
use bp_relayers::{RewardsAccountOwner, RewardsAccountParams};
use bp_xcm_bridge_hub::XcmAsPlainPayload;
use frame_support::traits::{OnFinalize, OnInitialize};
use frame_system::pallet_prelude::BlockNumberFor;
use pallet_bridge_messages::{BridgedChainOf, LaneIdOf, ThisChainOf};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use crate::{
test_cases::{bridges_prelude::*, helpers, run_test},
test_data,
test_data::XcmAsPlainPayload,
};

use alloc::{boxed::Box, vec};
Expand All @@ -28,7 +29,6 @@ use bp_messages::UnrewardedRelayersState;
use bp_polkadot_core::parachains::ParaHash;
use bp_relayers::{RewardsAccountOwner, RewardsAccountParams};
use bp_runtime::{Chain, Parachain};
use bp_xcm_bridge_hub::XcmAsPlainPayload;
use frame_support::traits::{OnFinalize, OnInitialize};
use frame_system::pallet_prelude::BlockNumberFor;
use pallet_bridge_messages::{BridgedChainOf, LaneIdOf, ThisChainOf};
Expand Down
Loading

0 comments on commit e06d981

Please sign in to comment.