Fix ParentOrSiblings (#2428)

We were not filtering for sibling parachains, but for sibling anything

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: command-bot <>
This commit is contained in:
Francisco Aguirre
2023-12-12 17:36:24 +01:00
committed by GitHub
parent 575b8f8d15
commit 313b2c4b6e
6 changed files with 29 additions and 30 deletions
@@ -139,6 +139,21 @@ impl<AssetLocation: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation>
}
}
/// Filter to check if a given location is the parent Relay Chain or a sibling parachain.
///
/// This type should only be used within the context of a parachain, since it does not verify that
/// the parent is indeed a Relay Chain.
pub struct ParentRelayOrSiblingParachains;
impl Contains<MultiLocation> for ParentRelayOrSiblingParachains {
fn contains(location: &MultiLocation) -> bool {
matches!(
location,
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(Parachain(_)) }
)
}
}
#[cfg(test)]
mod tests {
use frame_support::{parameter_types, traits::Contains};
@@ -33,7 +33,7 @@ use parachains_common::{
impls::ToStakingPot,
xcm_config::{
AllSiblingSystemParachains, AssetFeeAsExistentialDepositMultiplier,
ConcreteAssetFromSystem, RelayOrOtherSystemParachains,
ConcreteAssetFromSystem, ParentRelayOrSiblingParachains, RelayOrOtherSystemParachains,
},
TREASURY_PALLET_ID,
};
@@ -238,10 +238,6 @@ match_types! {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
};
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(_) }
};
}
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
@@ -486,7 +482,7 @@ pub type Barrier = TrailingSetTopicAsId<
Equals<bridging::SiblingBridgeHub>,
)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
),
UniversalLocation,
ConstU32<8>,
@@ -34,7 +34,8 @@ use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{
AllSiblingSystemParachains, ConcreteAssetFromSystem, RelayOrOtherSystemParachains,
AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
RelayOrOtherSystemParachains,
},
TREASURY_PALLET_ID,
};
@@ -126,10 +127,6 @@ match_types! {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
};
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(_) }
};
}
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
@@ -212,7 +209,7 @@ pub type Barrier = TrailingSetTopicAsId<
Equals<RelayTreasuryLocation>,
)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
),
UniversalLocation,
ConstU32<8>,
@@ -29,7 +29,8 @@ use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{
AllSiblingSystemParachains, ConcreteAssetFromSystem, RelayOrOtherSystemParachains,
AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
RelayOrOtherSystemParachains,
},
TREASURY_PALLET_ID,
};
@@ -115,10 +116,6 @@ match_types! {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
};
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(_) }
};
}
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
@@ -201,7 +198,7 @@ pub type Barrier = TrailingSetTopicAsId<
Equals<RelayTreasuryLocation>,
)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
),
UniversalLocation,
ConstU32<8>,
@@ -28,7 +28,8 @@ use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{
AllSiblingSystemParachains, ConcreteAssetFromSystem, RelayOrOtherSystemParachains,
AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
RelayOrOtherSystemParachains,
},
};
use polkadot_parachain_primitives::primitives::Sibling;
@@ -137,10 +138,6 @@ match_types! {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
};
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(_) }
};
}
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
@@ -242,7 +239,7 @@ pub type Barrier = TrailingSetTopicAsId<
// Parent and its pluralities (i.e. governance bodies) get free execution.
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
),
UniversalLocation,
ConstU32<8>,
@@ -28,7 +28,8 @@ use frame_system::EnsureRoot;
use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
use parachains_common::{
xcm_config::{
AllSiblingSystemParachains, ConcreteAssetFromSystem, RelayOrOtherSystemParachains,
AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
RelayOrOtherSystemParachains,
},
TREASURY_PALLET_ID,
};
@@ -124,10 +125,6 @@ match_types! {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
};
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(_) }
};
}
pub type Barrier = TrailingSetTopicAsId<
@@ -150,7 +147,7 @@ pub type Barrier = TrailingSetTopicAsId<
Equals<RelayTreasuryLocation>,
)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
),
UniversalLocation,
ConstU32<8>,