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
125 }125 }
126}126}
127
128pub struct DenyTransact;
129impl TryPass for DenyTransact {
130 fn try_pass<Call>(
131 _origin: &MultiLocation,
132 message: &mut [Instruction<Call>],
133 ) -> Result<(), ()> {
134 let transact_inst = message
135 .iter()
136 .find(|inst| matches![inst, Instruction::Transact { .. }]);
137
138 if transact_inst.is_some() {
139 log::warn!(
140 target: "xcm::barrier",
141 "transact XCM rejected"
142 );
143
144 Err(())
145 } else {
146 Ok(())
147 }
148 }
149}
150127
151/// Deny executing the XCM if it matches any of the Deny filter regardless of anything else.128/// Deny executing the XCM if it matches any of the Deny filter regardless of anything else.
152/// If it passes the Deny, and matches one of the Allow cases then it is let through.129/// If it passes the Deny, and matches one of the Allow cases then it is let through.
235 type UniversalAliases = Nothing;212 type UniversalAliases = Nothing;
236 type CallDispatcher = RuntimeCall;213 type CallDispatcher = RuntimeCall;
214
215 // Deny all XCM Transacts.
237 type SafeCallFilter = Nothing; // ? Only non-recursive calls may go here, but do we need this?216 type SafeCallFilter = Nothing;
238}217}
239218
240#[cfg(feature = "runtime-benchmarks")]219#[cfg(feature = "runtime-benchmarks")]
modifiedruntime/opal/src/xcm_barrier.rsdiffbeforeafterboth
20use xcm_builder::{AllowTopLevelPaidExecutionFrom, TakeWeightCredit};20use xcm_builder::{AllowTopLevelPaidExecutionFrom, TakeWeightCredit};
21use xcm_executor::traits::ShouldExecute;21use xcm_executor::traits::ShouldExecute;
22
23use crate::runtime_common::config::xcm::{DenyThenTry, DenyTransact};
2422
25/// Execution barrier that just takes `max_weight` from `weight_credit`.23/// Execution barrier that just takes `max_weight` from `weight_credit`.
26///24///
39 }37 }
40}38}
4139
42pub type Barrier = DenyThenTry<40pub type Barrier = (
43 DenyTransact,
44 (
45 TakeWeightCredit,41 TakeWeightCredit,
46 AllowTopLevelPaidExecutionFrom<Everything>,42 AllowTopLevelPaidExecutionFrom<Everything>,
47 AllowAllDebug,43 AllowAllDebug,
48 ),44);
49>;
5045
modifiedruntime/quartz/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, QuartzDefaultAllowedLocations>,80 OverridableAllowedLocations<Runtime, QuartzDefaultAllowedLocations>,
83 >,81 >,
84 ),
85 (82 (
86 TakeWeightCredit,83 TakeWeightCredit,
87 AllowTopLevelPaidExecutionFrom<Everything>,84 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>,