Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Vstam1/xcm admin origin #6928

Merged
merged 5 commits into from
Mar 23, 2023
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
2 changes: 2 additions & 0 deletions runtime/kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -398,6 +399,7 @@ impl pallet_xcm::Config for Runtime {
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;
type AdminOrigin = EnsureRoot<AccountId>;
}

#[test]
Expand Down
2 changes: 2 additions & 0 deletions runtime/polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -425,4 +426,5 @@ impl pallet_xcm::Config for Runtime {
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;
type AdminOrigin = EnsureRoot<AccountId>;
}
2 changes: 2 additions & 0 deletions runtime/rococo/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -364,4 +365,5 @@ impl pallet_xcm::Config for Runtime {
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;
type AdminOrigin = EnsureRoot<AccountId>;
}
2 changes: 2 additions & 0 deletions runtime/test-runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<crate::AccountId>;
}
2 changes: 2 additions & 0 deletions runtime/westend/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -279,4 +280,5 @@ impl pallet_xcm::Config for Runtime {
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;
type AdminOrigin = EnsureRoot<AccountId>;
}
11 changes: 7 additions & 4 deletions xcm/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ pub mod pallet {
/// `pallet_xcm::CurrentXcmVersion`.
type AdvertisedXcmVersion: Get<XcmVersion>;

/// The origin that is allowed to call privileged operations on the XCM pallet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The origin that is allowed to call privileged operations on the XCM pallet
/// The origin that is allowed to call privileged operations on the XCM pallet.

type AdminOrigin: EnsureOrigin<<Self as SysConfig>::RuntimeOrigin>;

/// The assets which we consider a given origin is trusted if they claim to have placed a
/// lock.
type TrustedLockers: ContainsPair<MultiLocation, MultiAsset>;
Expand Down Expand Up @@ -915,7 +918,7 @@ pub mod pallet {
location: Box<MultiLocation>,
xcm_version: XcmVersion,
) -> DispatchResult {
ensure_root(origin)?;
T::AdminOrigin::ensure_origin(origin)?;
let location = *location;
SupportedVersion::<T>::insert(
XCM_VERSION,
Expand All @@ -937,7 +940,7 @@ pub mod pallet {
origin: OriginFor<T>,
maybe_xcm_version: Option<XcmVersion>,
) -> DispatchResult {
ensure_root(origin)?;
T::AdminOrigin::ensure_origin(origin)?;
SafeXcmVersion::<T>::set(maybe_xcm_version);
Ok(())
}
Expand All @@ -952,7 +955,7 @@ pub mod pallet {
origin: OriginFor<T>,
location: Box<VersionedMultiLocation>,
) -> DispatchResult {
ensure_root(origin)?;
T::AdminOrigin::ensure_origin(origin)?;
let location: MultiLocation =
(*location).try_into().map_err(|()| Error::<T>::BadLocation)?;
Self::request_version_notify(location).map_err(|e| {
Expand All @@ -976,7 +979,7 @@ pub mod pallet {
origin: OriginFor<T>,
location: Box<VersionedMultiLocation>,
) -> DispatchResult {
ensure_root(origin)?;
T::AdminOrigin::ensure_origin(origin)?;
let location: MultiLocation =
(*location).try_into().map_err(|()| Error::<T>::BadLocation)?;
Self::unrequest_version_notify(location).map_err(|e| {
Expand Down
2 changes: 2 additions & 0 deletions xcm/pallet-xcm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -344,6 +345,7 @@ impl pallet_xcm::Config for Test {
type WeightInfo = TestWeightInfo;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;
type AdminOrigin = EnsureRoot<AccountId>;
}

impl origin::Config for Test {}
Expand Down
2 changes: 2 additions & 0 deletions xcm/xcm-builder/tests/mock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<AccountId>;
}

impl origin::Config for Runtime {}
Expand Down
3 changes: 3 additions & 0 deletions xcm/xcm-simulator/example/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<AccountId>;
}

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
Expand Down
3 changes: 3 additions & 0 deletions xcm/xcm-simulator/example/src/relay_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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<AccountId>;
}

parameter_types! {
Expand Down
3 changes: 3 additions & 0 deletions xcm/xcm-simulator/fuzzer/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<AccountId>;
}

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
Expand Down
3 changes: 3 additions & 0 deletions xcm/xcm-simulator/fuzzer/src/relay_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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<AccountId>;
}

parameter_types! {
Expand Down