git.delta.rocks / unique-network / refs/commits / 752d713492c3

difftreelog

fix remove known xcm locations -- unneeded due to limited opened hrmp channels

Daniel Shiposha2023-03-22parent: #d0b6ad7.patch.diff
in: master

5 files changed

modifiedpallets/configuration/src/benchmarking.rsdiffbeforeafterboth
19use super::*;19use super::*;
20use frame_benchmarking::benchmarks;20use frame_benchmarking::benchmarks;
21use frame_system::{EventRecord, RawOrigin};21use frame_system::{EventRecord, RawOrigin};
22use frame_support::{assert_ok, BoundedVec, traits::Currency};22use frame_support::{assert_ok, traits::Currency};
23use xcm::latest::MultiLocation;
2423
25fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {24fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
26 let events = frame_system::Pallet::<T>::events();25 let events = frame_system::Pallet::<T>::events();
49 );48 );
50 }49 }
51
52 set_xcm_allowed_locations {
53 let locations: BoundedVec<MultiLocation, T::MaxXcmAllowedLocations> = Default::default();
54 }: {
55 assert_ok!(
56 <Pallet<T>>::set_xcm_allowed_locations(RawOrigin::Root.into(), Some(locations))
57 );
58 }
5950
60 set_app_promotion_configuration_override {51 set_app_promotion_configuration_override {
61 let configuration: AppPromotionConfiguration<T::BlockNumber> = Default::default();52 let configuration: AppPromotionConfiguration<T::BlockNumber> = Default::default();
modifiedpallets/configuration/src/lib.rsdiffbeforeafterboth
--- a/pallets/configuration/src/lib.rs
+++ b/pallets/configuration/src/lib.rs
@@ -43,11 +43,9 @@
 	use super::*;
 	use frame_support::{
 		traits::{Get, ReservableCurrency, Currency},
-		pallet_prelude::{StorageValue, ValueQuery, DispatchResult, IsType, OptionQuery},
-		BoundedVec, log,
+		pallet_prelude::{StorageValue, ValueQuery, DispatchResult, IsType}, log,
 	};
 	use frame_system::{pallet_prelude::OriginFor, ensure_root, Config as SystemConfig};
-	use xcm::latest::MultiLocation;
 
 	pub use crate::weights::WeightInfo;
 	pub type BalanceOf<T> =
@@ -115,12 +113,6 @@
 		StorageValue<Value = u64, QueryKind = ValueQuery, OnEmpty = T::DefaultMinGasPrice>;
 
 	#[pallet::storage]
-	pub type XcmAllowedLocationsOverride<T: Config> = StorageValue<
-		Value = BoundedVec<xcm::v3::MultiLocation, T::MaxXcmAllowedLocations>,
-		QueryKind = OptionQuery,
-	>;
-
-	#[pallet::storage]
 	pub type AppPromomotionConfigurationOverride<T: Config> =
 		StorageValue<Value = AppPromotionConfiguration<T::BlockNumber>, QueryKind = ValueQuery>;
 
@@ -174,17 +166,6 @@
 			} else {
 				<MinGasPriceOverride<T>>::kill();
 			}
-			Ok(())
-		}
-
-		#[pallet::call_index(2)]
-		#[pallet::weight(T::WeightInfo::set_xcm_allowed_locations())]
-		pub fn set_xcm_allowed_locations(
-			origin: OriginFor<T>,
-			locations: Option<BoundedVec<MultiLocation, T::MaxXcmAllowedLocations>>,
-		) -> DispatchResult {
-			ensure_root(origin)?;
-			<XcmAllowedLocationsOverride<T>>::set(locations);
 			Ok(())
 		}
 
modifiedruntime/common/config/xcm/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/mod.rs
+++ b/runtime/common/config/xcm/mod.rs
@@ -148,38 +148,6 @@
 	}
 }
 
-// Allow xcm exchange only with locations in list
-pub struct DenyExchangeWithUnknownLocation<T>(PhantomData<T>);
-impl<T: Get<Vec<MultiLocation>>> TryPass for DenyExchangeWithUnknownLocation<T> {
-	fn try_pass<Call>(origin: &MultiLocation, message: &mut [Instruction<Call>]) -> Result<(), ()> {
-		let allowed_locations = T::get();
-
-		// Check if deposit or transfer belongs to allowed parachains
-		let mut allowed = allowed_locations.contains(origin);
-
-		message.iter().for_each(|inst| match inst {
-			DepositReserveAsset { dest: dst, .. }
-			| TransferReserveAsset { dest: dst, .. }
-			| InitiateReserveWithdraw { reserve: dst, .. } => {
-				allowed |= allowed_locations.contains(&dst);
-			}
-			// ? There are more instructions worth checking
-			_ => {}
-		});
-
-		if allowed {
-			return Ok(());
-		}
-
-		log::warn!(
-			target: "xcm::barrier",
-			"Unexpected deposit or transfer location"
-		);
-		// Deny
-		Err(())
-	}
-}
-
 pub type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
 
 pub struct XcmExecutorConfig<T>(PhantomData<T>);
modifiedruntime/quartz/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/quartz/src/xcm_barrier.rs
+++ b/runtime/quartz/src/xcm_barrier.rs
@@ -15,23 +15,16 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::{
-	match_types, parameter_types,
-	traits::{Get, Everything},
+	match_types,
+	traits::Everything,
 };
-use sp_std::{vec, vec::Vec};
-use xcm::latest::{Junction::*, Junctions::*, MultiLocation};
+use xcm::latest::{Junctions::*, MultiLocation};
 use xcm_builder::{
 	AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,
 	AllowTopLevelPaidExecutionFrom,
 };
 
-use crate::{
-	Runtime, ParachainInfo, PolkadotXcm,
-	runtime_common::{
-		config::xcm::{DenyThenTry, DenyExchangeWithUnknownLocation},
-		xcm::OverridableAllowedLocations,
-	},
-};
+use crate::PolkadotXcm;
 
 match_types! {
 	pub type ParentOrSiblings: impl Contains<MultiLocation> = {
@@ -40,51 +33,11 @@
 	};
 }
 
-parameter_types! {
-	pub QuartzDefaultAllowedLocations: Vec<MultiLocation> = vec![
-		// Self location
-		MultiLocation {
-			parents: 0,
-			interior: Here,
-		},
-		// Parent location
-		MultiLocation {
-			parents: 1,
-			interior: Here,
-		},
-		// Statemint/Statemint location
-		MultiLocation {
-			parents: 1,
-			interior: X1(Parachain(1000)),
-		},
-		// Karura/Acala location
-		MultiLocation {
-			parents: 1,
-			interior: X1(Parachain(2000)),
-		},
-		// Moonriver location
-		MultiLocation {
-			parents: 1,
-			interior: X1(Parachain(2023)),
-		},
-		// Self parachain address
-		MultiLocation {
-			parents: 1,
-			interior: X1(Parachain(ParachainInfo::get().into())),
-		},
-	];
-}
-
-pub type Barrier = DenyThenTry<
-	DenyExchangeWithUnknownLocation<
-		OverridableAllowedLocations<Runtime, QuartzDefaultAllowedLocations>,
-	>,
-	(
-		TakeWeightCredit,
-		AllowTopLevelPaidExecutionFrom<Everything>,
-		// Expected responses are OK.
-		AllowKnownQueryResponses<PolkadotXcm>,
-		// Subscriptions for version tracking are OK.
-		AllowSubscriptionsFrom<ParentOrSiblings>,
-	),
->;
+pub type Barrier = (
+	TakeWeightCredit,
+	AllowTopLevelPaidExecutionFrom<Everything>,
+	// Expected responses are OK.
+	AllowKnownQueryResponses<PolkadotXcm>,
+	// Subscriptions for version tracking are OK.
+	AllowSubscriptionsFrom<ParentOrSiblings>,
+);
modifiedruntime/unique/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/unique/src/xcm_barrier.rs
+++ b/runtime/unique/src/xcm_barrier.rs
@@ -15,23 +15,16 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::{
-	match_types, parameter_types,
-	traits::{Get, Everything},
+	match_types,
+	traits::Everything,
 };
-use sp_std::{vec, vec::Vec};
-use xcm::latest::{Junction::*, Junctions::*, MultiLocation};
+use xcm::latest::{Junctions::*, MultiLocation};
 use xcm_builder::{
 	AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,
 	AllowTopLevelPaidExecutionFrom,
 };
 
-use crate::{
-	Runtime, ParachainInfo, PolkadotXcm,
-	runtime_common::{
-		config::xcm::{DenyThenTry, DenyExchangeWithUnknownLocation},
-		xcm::OverridableAllowedLocations,
-	},
-};
+use crate::PolkadotXcm;
 
 match_types! {
 	pub type ParentOrSiblings: impl Contains<MultiLocation> = {
@@ -40,51 +33,11 @@
 	};
 }
 
-parameter_types! {
-	pub UniqueDefaultAllowedLocations: Vec<MultiLocation> = vec![
-		// Self location
-		MultiLocation {
-			parents: 0,
-			interior: Here,
-		},
-		// Parent location
-		MultiLocation {
-			parents: 1,
-			interior: Here,
-		},
-		// Statemint/Statemint location
-		MultiLocation {
-			parents: 1,
-			interior: X1(Parachain(1000)),
-		},
-		// Karura/Acala location
-		MultiLocation {
-			parents: 1,
-			interior: X1(Parachain(2000)),
-		},
-		// Moonbeam location
-		MultiLocation {
-			parents: 1,
-			interior: X1(Parachain(2004)),
-		},
-		// Self parachain address
-		MultiLocation {
-			parents: 1,
-			interior: X1(Parachain(ParachainInfo::get().into())),
-		},
-	];
-}
-
-pub type Barrier = DenyThenTry<
-	DenyExchangeWithUnknownLocation<
-		OverridableAllowedLocations<Runtime, UniqueDefaultAllowedLocations>,
-	>,
-	(
-		TakeWeightCredit,
-		AllowTopLevelPaidExecutionFrom<Everything>,
-		// Expected responses are OK.
-		AllowKnownQueryResponses<PolkadotXcm>,
-		// Subscriptions for version tracking are OK.
-		AllowSubscriptionsFrom<ParentOrSiblings>,
-	),
->;
+pub type Barrier = (
+	TakeWeightCredit,
+	AllowTopLevelPaidExecutionFrom<Everything>,
+	// Expected responses are OK.
+	AllowKnownQueryResponses<PolkadotXcm>,
+	// Subscriptions for version tracking are OK.
+	AllowSubscriptionsFrom<ParentOrSiblings>,
+);