difftreelog
fix remove known xcm locations -- unneeded due to limited opened hrmp channels
in: master
5 files changed
pallets/configuration/src/benchmarking.rsdiffbeforeafterboth19use 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;242325fn 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 }5152 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 }595060 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();pallets/configuration/src/lib.rsdiffbeforeafterboth43 use super::*;43 use super::*;44 use frame_support::{44 use frame_support::{45 traits::{Get, ReservableCurrency, Currency},45 traits::{Get, ReservableCurrency, Currency},46 pallet_prelude::{StorageValue, ValueQuery, DispatchResult, IsType, OptionQuery},46 pallet_prelude::{StorageValue, ValueQuery, DispatchResult, IsType}, log,47 BoundedVec, log,48 };47 };49 use frame_system::{pallet_prelude::OriginFor, ensure_root, Config as SystemConfig};48 use frame_system::{pallet_prelude::OriginFor, ensure_root, Config as SystemConfig};50 use xcm::latest::MultiLocation;514952 pub use crate::weights::WeightInfo;50 pub use crate::weights::WeightInfo;53 pub type BalanceOf<T> =51 pub type BalanceOf<T> =114 pub type MinGasPriceOverride<T: Config> =112 pub type MinGasPriceOverride<T: Config> =115 StorageValue<Value = u64, QueryKind = ValueQuery, OnEmpty = T::DefaultMinGasPrice>;113 StorageValue<Value = u64, QueryKind = ValueQuery, OnEmpty = T::DefaultMinGasPrice>;116117 #[pallet::storage]118 pub type XcmAllowedLocationsOverride<T: Config> = StorageValue<119 Value = BoundedVec<xcm::v3::MultiLocation, T::MaxXcmAllowedLocations>,120 QueryKind = OptionQuery,121 >;122114123 #[pallet::storage]115 #[pallet::storage]124 pub type AppPromomotionConfigurationOverride<T: Config> =116 pub type AppPromomotionConfigurationOverride<T: Config> =177 Ok(())169 Ok(())178 }170 }179180 #[pallet::call_index(2)]181 #[pallet::weight(T::WeightInfo::set_xcm_allowed_locations())]182 pub fn set_xcm_allowed_locations(183 origin: OriginFor<T>,184 locations: Option<BoundedVec<MultiLocation, T::MaxXcmAllowedLocations>>,185 ) -> DispatchResult {186 ensure_root(origin)?;187 <XcmAllowedLocationsOverride<T>>::set(locations);188 Ok(())189 }190171191 #[pallet::call_index(3)]172 #[pallet::call_index(3)]192 #[pallet::weight(T::WeightInfo::set_app_promotion_configuration_override())]173 #[pallet::weight(T::WeightInfo::set_app_promotion_configuration_override())]runtime/common/config/xcm/mod.rsdiffbeforeafterboth148 }148 }149}149}150151// Allow xcm exchange only with locations in list152pub struct DenyExchangeWithUnknownLocation<T>(PhantomData<T>);153impl<T: Get<Vec<MultiLocation>>> TryPass for DenyExchangeWithUnknownLocation<T> {154 fn try_pass<Call>(origin: &MultiLocation, message: &mut [Instruction<Call>]) -> Result<(), ()> {155 let allowed_locations = T::get();156157 // Check if deposit or transfer belongs to allowed parachains158 let mut allowed = allowed_locations.contains(origin);159160 message.iter().for_each(|inst| match inst {161 DepositReserveAsset { dest: dst, .. }162 | TransferReserveAsset { dest: dst, .. }163 | InitiateReserveWithdraw { reserve: dst, .. } => {164 allowed |= allowed_locations.contains(&dst);165 }166 // ? There are more instructions worth checking167 _ => {}168 });169170 if allowed {171 return Ok(());172 }173174 log::warn!(175 target: "xcm::barrier",176 "Unexpected deposit or transfer location"177 );178 // Deny179 Err(())180 }181}182150183pub type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;151pub type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;184152runtime/quartz/src/xcm_barrier.rsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617use frame_support::{17use frame_support::{18 match_types, parameter_types,18 match_types,19 traits::{Get, Everything},19 traits::Everything,20};20};21use sp_std::{vec, vec::Vec};22use xcm::latest::{Junction::*, Junctions::*, MultiLocation};21use xcm::latest::{Junctions::*, MultiLocation};23use xcm_builder::{22use xcm_builder::{24 AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,23 AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,25 AllowTopLevelPaidExecutionFrom,24 AllowTopLevelPaidExecutionFrom,26};25};272628use crate::{27use crate::PolkadotXcm;29 Runtime, ParachainInfo, PolkadotXcm,30 runtime_common::{31 config::xcm::{DenyThenTry, DenyExchangeWithUnknownLocation},32 xcm::OverridableAllowedLocations,33 },34};352836match_types! {29match_types! {37 pub type ParentOrSiblings: impl Contains<MultiLocation> = {30 pub type ParentOrSiblings: impl Contains<MultiLocation> = {40 };33 };41}34}4243parameter_types! {44 pub QuartzDefaultAllowedLocations: Vec<MultiLocation> = vec![45 // Self location46 MultiLocation {47 parents: 0,48 interior: Here,49 },50 // Parent location51 MultiLocation {52 parents: 1,53 interior: Here,54 },55 // Statemint/Statemint location56 MultiLocation {57 parents: 1,58 interior: X1(Parachain(1000)),59 },60 // Karura/Acala location61 MultiLocation {62 parents: 1,63 interior: X1(Parachain(2000)),64 },65 // Moonriver location66 MultiLocation {67 parents: 1,68 interior: X1(Parachain(2023)),69 },70 // Self parachain address71 MultiLocation {72 parents: 1,73 interior: X1(Parachain(ParachainInfo::get().into())),74 },75 ];76}773578pub type Barrier = DenyThenTry<36pub type Barrier = (79 DenyExchangeWithUnknownLocation<80 OverridableAllowedLocations<Runtime, QuartzDefaultAllowedLocations>,81 >,82 (83 TakeWeightCredit,37 TakeWeightCredit,84 AllowTopLevelPaidExecutionFrom<Everything>,38 AllowTopLevelPaidExecutionFrom<Everything>,85 // Expected responses are OK.39 // Expected responses are OK.86 AllowKnownQueryResponses<PolkadotXcm>,40 AllowKnownQueryResponses<PolkadotXcm>,87 // Subscriptions for version tracking are OK.41 // Subscriptions for version tracking are OK.88 AllowSubscriptionsFrom<ParentOrSiblings>,42 AllowSubscriptionsFrom<ParentOrSiblings>,89 ),43);90>;9144runtime/unique/src/xcm_barrier.rsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617use frame_support::{17use frame_support::{18 match_types, parameter_types,18 match_types,19 traits::{Get, Everything},19 traits::Everything,20};20};21use sp_std::{vec, vec::Vec};22use xcm::latest::{Junction::*, Junctions::*, MultiLocation};21use xcm::latest::{Junctions::*, MultiLocation};23use xcm_builder::{22use xcm_builder::{24 AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,23 AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,25 AllowTopLevelPaidExecutionFrom,24 AllowTopLevelPaidExecutionFrom,26};25};272628use crate::{27use crate::PolkadotXcm;29 Runtime, ParachainInfo, PolkadotXcm,30 runtime_common::{31 config::xcm::{DenyThenTry, DenyExchangeWithUnknownLocation},32 xcm::OverridableAllowedLocations,33 },34};352836match_types! {29match_types! {37 pub type ParentOrSiblings: impl Contains<MultiLocation> = {30 pub type ParentOrSiblings: impl Contains<MultiLocation> = {40 };33 };41}34}4243parameter_types! {44 pub UniqueDefaultAllowedLocations: Vec<MultiLocation> = vec![45 // Self location46 MultiLocation {47 parents: 0,48 interior: Here,49 },50 // Parent location51 MultiLocation {52 parents: 1,53 interior: Here,54 },55 // Statemint/Statemint location56 MultiLocation {57 parents: 1,58 interior: X1(Parachain(1000)),59 },60 // Karura/Acala location61 MultiLocation {62 parents: 1,63 interior: X1(Parachain(2000)),64 },65 // Moonbeam location66 MultiLocation {67 parents: 1,68 interior: X1(Parachain(2004)),69 },70 // Self parachain address71 MultiLocation {72 parents: 1,73 interior: X1(Parachain(ParachainInfo::get().into())),74 },75 ];76}773578pub type Barrier = DenyThenTry<36pub type Barrier = (79 DenyExchangeWithUnknownLocation<80 OverridableAllowedLocations<Runtime, UniqueDefaultAllowedLocations>,81 >,82 (83 TakeWeightCredit,37 TakeWeightCredit,84 AllowTopLevelPaidExecutionFrom<Everything>,38 AllowTopLevelPaidExecutionFrom<Everything>,85 // Expected responses are OK.39 // Expected responses are OK.86 AllowKnownQueryResponses<PolkadotXcm>,40 AllowKnownQueryResponses<PolkadotXcm>,87 // Subscriptions for version tracking are OK.41 // Subscriptions for version tracking are OK.88 AllowSubscriptionsFrom<ParentOrSiblings>,42 AllowSubscriptionsFrom<ParentOrSiblings>,89 ),43);90>;9144