diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 06bb829b042b..5a8495ca7998 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -25,6 +25,7 @@ use frame_support::{ traits::{Contains, Everything, Nothing}, weights::Weight, }; +use frame_system::EnsureRoot; use runtime_common::{paras_registrar, xcm_sender, ToAuthor}; use sp_core::ConstU32; use xcm::latest::prelude::*; @@ -398,6 +399,7 @@ impl pallet_xcm::Config for Runtime { type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; } #[test] diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index d853b27132c7..585197a475fb 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -26,6 +26,7 @@ use frame_support::{ traits::{Contains, Everything, Nothing}, weights::Weight, }; +use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use polkadot_runtime_constants::{system_parachain::*, xcm::body::FELLOWSHIP_ADMIN_INDEX}; use runtime_common::{paras_registrar, xcm_sender, ToAuthor}; @@ -425,4 +426,5 @@ impl pallet_xcm::Config for Runtime { type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; } diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 229df3a5df95..73408566b408 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -25,6 +25,7 @@ use frame_support::{ traits::{Contains, Everything, Nothing}, weights::Weight, }; +use frame_system::EnsureRoot; use runtime_common::{paras_registrar, xcm_sender, ToAuthor}; use sp_core::ConstU32; use xcm::latest::prelude::*; @@ -364,4 +365,5 @@ impl pallet_xcm::Config for Runtime { type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; } diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index bfe9c6ad1ad8..e346f54a1575 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -19,6 +19,7 @@ use frame_support::{ traits::{Everything, Nothing}, weights::Weight, }; +use frame_system::EnsureRoot; use xcm::latest::prelude::*; use xcm_builder::{ AllowUnpaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, SignedAccountId32AsNative, @@ -146,4 +147,5 @@ impl pallet_xcm::Config for crate::Runtime { type WeightInfo = pallet_xcm::TestWeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; } diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index ef38ca5d2970..411291c3e7f8 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -24,6 +24,7 @@ use frame_support::{ parameter_types, traits::{Contains, Everything, Nothing}, }; +use frame_system::EnsureRoot; use runtime_common::{paras_registrar, xcm_sender, ToAuthor}; use sp_core::ConstU32; use xcm::latest::prelude::*; @@ -279,4 +280,5 @@ impl pallet_xcm::Config for Runtime { type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; } diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 47a9d7d75d0a..f84c94a063e8 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -231,6 +231,9 @@ pub mod pallet { /// `pallet_xcm::CurrentXcmVersion`. type AdvertisedXcmVersion: Get; + /// The origin that is allowed to call privileged operations on the XCM pallet + type AdminOrigin: EnsureOrigin<::RuntimeOrigin>; + /// The assets which we consider a given origin is trusted if they claim to have placed a /// lock. type TrustedLockers: ContainsPair; @@ -915,7 +918,7 @@ pub mod pallet { location: Box, xcm_version: XcmVersion, ) -> DispatchResult { - ensure_root(origin)?; + T::AdminOrigin::ensure_origin(origin)?; let location = *location; SupportedVersion::::insert( XCM_VERSION, @@ -937,7 +940,7 @@ pub mod pallet { origin: OriginFor, maybe_xcm_version: Option, ) -> DispatchResult { - ensure_root(origin)?; + T::AdminOrigin::ensure_origin(origin)?; SafeXcmVersion::::set(maybe_xcm_version); Ok(()) } @@ -952,7 +955,7 @@ pub mod pallet { origin: OriginFor, location: Box, ) -> DispatchResult { - ensure_root(origin)?; + T::AdminOrigin::ensure_origin(origin)?; let location: MultiLocation = (*location).try_into().map_err(|()| Error::::BadLocation)?; Self::request_version_notify(location).map_err(|e| { @@ -976,7 +979,7 @@ pub mod pallet { origin: OriginFor, location: Box, ) -> DispatchResult { - ensure_root(origin)?; + T::AdminOrigin::ensure_origin(origin)?; let location: MultiLocation = (*location).try_into().map_err(|()| Error::::BadLocation)?; Self::unrequest_version_notify(location).map_err(|e| { diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 1e23af66b2fc..9544538ef280 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -20,6 +20,7 @@ use frame_support::{ traits::{ConstU32, Everything, Nothing}, weights::Weight, }; +use frame_system::EnsureRoot; use polkadot_parachain::primitives::Id as ParaId; use polkadot_runtime_parachains::origin; use sp_core::H256; @@ -344,6 +345,7 @@ impl pallet_xcm::Config for Test { type WeightInfo = TestWeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; } impl origin::Config for Test {} diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 450ef181869d..9c0086e34c90 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -19,6 +19,7 @@ use frame_support::{ traits::{ConstU32, Everything, Nothing}, weights::Weight, }; +use frame_system::EnsureRoot; use parity_scale_codec::Encode; use primitive_types::H256; use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; @@ -235,6 +236,7 @@ impl pallet_xcm::Config for Runtime { type WeightInfo = pallet_xcm::TestWeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; } impl origin::Config for Runtime {} diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 344ccfb9dbcc..4cd4094b3328 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -22,6 +22,8 @@ use frame_support::{ traits::{EnsureOrigin, EnsureOriginWithArg, Everything, EverythingBut, Nothing}, weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, }; + +use frame_system::EnsureRoot; use sp_core::{ConstU32, H256}; use sp_runtime::{ testing::Header, @@ -424,6 +426,7 @@ impl pallet_xcm::Config for Runtime { type WeightInfo = pallet_xcm::TestWeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index b44200378a8b..5db399717fc1 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -21,6 +21,8 @@ use frame_support::{ traits::{AsEnsureOriginWithArg, Everything, Nothing}, weights::Weight, }; + +use frame_system::EnsureRoot; use sp_core::{ConstU32, H256}; use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; @@ -221,6 +223,7 @@ impl pallet_xcm::Config for Runtime { type WeightInfo = pallet_xcm::TestWeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; } parameter_types! { diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index 66e9673394af..8480713347c0 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -22,6 +22,8 @@ use frame_support::{ traits::{Everything, Nothing}, weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, }; + +use frame_system::EnsureRoot; use sp_core::{ConstU32, H256}; use sp_runtime::{ testing::Header, @@ -339,6 +341,7 @@ impl pallet_xcm::Config for Runtime { type WeightInfo = pallet_xcm::TestWeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 3d49a71cc98a..962c22297a8e 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -21,6 +21,8 @@ use frame_support::{ traits::{Everything, Nothing}, weights::Weight, }; + +use frame_system::EnsureRoot; use sp_core::{ConstU32, H256}; use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; @@ -185,6 +187,7 @@ impl pallet_xcm::Config for Runtime { type WeightInfo = pallet_xcm::TestWeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; } parameter_types! {