Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions runtime/polkadot/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ pub mod xcm {
}
}

/// System Parachains.
pub mod system_parachain {
/// Statemint parachain ID.
pub const STATEMINT_ID: u32 = 1000;
/// Collectives parachain ID.
pub const COLLECTIVES_ID: u32 = 1001;
}

#[cfg(test)]
mod tests {
use super::{
Expand Down
26 changes: 18 additions & 8 deletions runtime/polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ use frame_support::{
traits::{Contains, Everything, Nothing},
weights::Weight,
};
use polkadot_runtime_constants::xcm::body::FELLOWSHIP_ADMIN_INDEX;
use pallet_xcm::XcmPassthrough;
use polkadot_runtime_constants::{system_parachain::*, xcm::body::FELLOWSHIP_ADMIN_INDEX};
use runtime_common::{paras_registrar, xcm_sender, ToAuthor};
use sp_core::ConstU32;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, BackingToPlurality, ChildParachainAsNative,
ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds,
IsConcrete, MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative,
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, BackingToPlurality,
ChildParachainAsNative, ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter,
FixedWeightBounds, IsConcrete, MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
WithComputedOrigin,
};
Expand Down Expand Up @@ -94,6 +95,8 @@ type LocalOriginConverter = (
// If the origin kind is `Native` and the XCM origin is the `AccountId32` location, then it can
// be expressed using the `Signed` origin variant.
SignedAccountId32AsNative<ThisNetwork, RuntimeOrigin>,
// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.
XcmPassthrough<RuntimeOrigin>,
);

parameter_types! {
Expand All @@ -113,8 +116,8 @@ pub type XcmRouter = (

parameter_types! {
pub const Dot: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) });
pub const DotForStatemint: (MultiAssetFilter, MultiLocation) = (Dot::get(), Parachain(1000).into_location());
pub const CollectivesLocation: MultiLocation = Parachain(1001).into_location();
pub const DotForStatemint: (MultiAssetFilter, MultiLocation) = (Dot::get(), Parachain(STATEMINT_ID).into_location());
pub const CollectivesLocation: MultiLocation = Parachain(COLLECTIVES_ID).into_location();
pub const DotForCollectives: (MultiAssetFilter, MultiLocation) = (Dot::get(), CollectivesLocation::get());
pub const MaxAssetsIntoHolding: u32 = 64;
}
Expand All @@ -127,6 +130,10 @@ match_types! {
pub type OnlyParachains: impl Contains<MultiLocation> = {
MultiLocation { parents: 0, interior: X1(Parachain(_)) }
};
pub type CollectivesOrFellows: impl Contains<MultiLocation> = {
MultiLocation { parents: 0, interior: X1(Parachain(COLLECTIVES_ID)) } |
MultiLocation { parents: 0, interior: X2(Parachain(COLLECTIVES_ID), Plurality { id: BodyId::Technical, .. }) }
};
}

/// The barriers one of which must be passed for an XCM message to be executed.
Expand All @@ -141,6 +148,8 @@ pub type Barrier = (
AllowTopLevelPaidExecutionFrom<Everything>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<OnlyParachains>,
// Collectives and Fellows plurality get free execution.
AllowExplicitUnpaidExecutionFrom<CollectivesOrFellows>,
),
UniversalLocation,
ConstU32<8>,
Expand Down Expand Up @@ -304,7 +313,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
) |
RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets {
..
}) => true,
}) |
RuntimeCall::Whitelist(pallet_whitelist::Call::whitelist_call { .. }) => true,
_ => false,
}
}
Expand Down