git.delta.rocks / unique-network / refs/commits / aee14e966771

difftreelog

fix remove unneeded barrier, add safecallfilter

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

4 files changed

modifiedruntime/common/config/xcm/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/mod.rs
+++ b/runtime/common/config/xcm/mod.rs
@@ -125,29 +125,6 @@
 	}
 }
 
-pub struct DenyTransact;
-impl TryPass for DenyTransact {
-	fn try_pass<Call>(
-		_origin: &MultiLocation,
-		message: &mut [Instruction<Call>],
-	) -> Result<(), ()> {
-		let transact_inst = message
-			.iter()
-			.find(|inst| matches![inst, Instruction::Transact { .. }]);
-
-		if transact_inst.is_some() {
-			log::warn!(
-				target: "xcm::barrier",
-				"transact XCM rejected"
-			);
-
-			Err(())
-		} else {
-			Ok(())
-		}
-	}
-}
-
 /// Deny executing the XCM if it matches any of the Deny filter regardless of anything else.
 /// If it passes the Deny, and matches one of the Allow cases then it is let through.
 pub struct DenyThenTry<Deny, Allow>(PhantomData<Deny>, PhantomData<Allow>)
@@ -234,7 +211,9 @@
 	type MessageExporter = ();
 	type UniversalAliases = Nothing;
 	type CallDispatcher = RuntimeCall;
-	type SafeCallFilter = Nothing; // ? Only non-recursive calls may go here, but do we need this?
+
+	// Deny all XCM Transacts.
+	type SafeCallFilter = Nothing;
 }
 
 #[cfg(feature = "runtime-benchmarks")]
modifiedruntime/opal/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/opal/src/xcm_barrier.rs
+++ b/runtime/opal/src/xcm_barrier.rs
@@ -20,8 +20,6 @@
 use xcm_builder::{AllowTopLevelPaidExecutionFrom, TakeWeightCredit};
 use xcm_executor::traits::ShouldExecute;
 
-use crate::runtime_common::config::xcm::{DenyThenTry, DenyTransact};
-
 /// Execution barrier that just takes `max_weight` from `weight_credit`.
 ///
 /// Useful to allow XCM execution by local chain users via extrinsics.
@@ -39,11 +37,8 @@
 	}
 }
 
-pub type Barrier = DenyThenTry<
-	DenyTransact,
-	(
-		TakeWeightCredit,
-		AllowTopLevelPaidExecutionFrom<Everything>,
-		AllowAllDebug,
-	),
->;
+pub type Barrier = (
+	TakeWeightCredit,
+	AllowTopLevelPaidExecutionFrom<Everything>,
+	AllowAllDebug,
+);
modifiedruntime/quartz/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/quartz/src/xcm_barrier.rs
+++ b/runtime/quartz/src/xcm_barrier.rs
@@ -28,7 +28,7 @@
 use crate::{
 	Runtime, ParachainInfo, PolkadotXcm,
 	runtime_common::{
-		config::xcm::{DenyThenTry, DenyTransact, DenyExchangeWithUnknownLocation},
+		config::xcm::{DenyThenTry, DenyExchangeWithUnknownLocation},
 		xcm::OverridableAllowedLocations,
 	},
 };
@@ -76,12 +76,9 @@
 }
 
 pub type Barrier = DenyThenTry<
-	(
-		DenyTransact,
-		DenyExchangeWithUnknownLocation<
-			OverridableAllowedLocations<Runtime, QuartzDefaultAllowedLocations>,
-		>,
-	),
+	DenyExchangeWithUnknownLocation<
+		OverridableAllowedLocations<Runtime, QuartzDefaultAllowedLocations>,
+	>,
 	(
 		TakeWeightCredit,
 		AllowTopLevelPaidExecutionFrom<Everything>,
modifiedruntime/unique/src/xcm_barrier.rsdiffbeforeafterboth
28use crate::{28use crate::{
29 Runtime, ParachainInfo, PolkadotXcm,29 Runtime, ParachainInfo, PolkadotXcm,
30 runtime_common::{30 runtime_common::{
31 config::xcm::{DenyThenTry, DenyTransact, DenyExchangeWithUnknownLocation},31 config::xcm::{DenyThenTry, DenyExchangeWithUnknownLocation},
32 xcm::OverridableAllowedLocations,32 xcm::OverridableAllowedLocations,
33 },33 },
34};34};
76}76}
7777
78pub type Barrier = DenyThenTry<78pub type Barrier = DenyThenTry<
79 (
80 DenyTransact,
81 DenyExchangeWithUnknownLocation<79 DenyExchangeWithUnknownLocation<
82 OverridableAllowedLocations<Runtime, UniqueDefaultAllowedLocations>,80 OverridableAllowedLocations<Runtime, UniqueDefaultAllowedLocations>,
83 >,81 >,
84 ),
85 (82 (
86 TakeWeightCredit,83 TakeWeightCredit,
87 AllowTopLevelPaidExecutionFrom<Everything>,84 AllowTopLevelPaidExecutionFrom<Everything>,