From 752d713492c38012f09d78b5527fae2d93f81526 Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Wed, 22 Mar 2023 12:49:53 +0000 Subject: [PATCH] fix: remove known xcm locations -- unneeded due to limited opened hrmp channels --- --- a/pallets/configuration/src/benchmarking.rs +++ b/pallets/configuration/src/benchmarking.rs @@ -19,8 +19,7 @@ use super::*; use frame_benchmarking::benchmarks; use frame_system::{EventRecord, RawOrigin}; -use frame_support::{assert_ok, BoundedVec, traits::Currency}; -use xcm::latest::MultiLocation; +use frame_support::{assert_ok, traits::Currency}; fn assert_last_event(generic_event: ::RuntimeEvent) { let events = frame_system::Pallet::::events(); @@ -46,14 +45,6 @@ }: { assert_ok!( >::set_min_gas_price_override(RawOrigin::Root.into(), Some(coeff)) - ); - } - - set_xcm_allowed_locations { - let locations: BoundedVec = Default::default(); - }: { - assert_ok!( - >::set_xcm_allowed_locations(RawOrigin::Root.into(), Some(locations)) ); } --- 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 = @@ -115,12 +113,6 @@ StorageValue; #[pallet::storage] - pub type XcmAllowedLocationsOverride = StorageValue< - Value = BoundedVec, - QueryKind = OptionQuery, - >; - - #[pallet::storage] pub type AppPromomotionConfigurationOverride = StorageValue, QueryKind = ValueQuery>; @@ -174,17 +166,6 @@ } else { >::kill(); } - Ok(()) - } - - #[pallet::call_index(2)] - #[pallet::weight(T::WeightInfo::set_xcm_allowed_locations())] - pub fn set_xcm_allowed_locations( - origin: OriginFor, - locations: Option>, - ) -> DispatchResult { - ensure_root(origin)?; - >::set(locations); Ok(()) } --- 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(PhantomData); -impl>> TryPass for DenyExchangeWithUnknownLocation { - fn try_pass(origin: &MultiLocation, message: &mut [Instruction]) -> 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; pub struct XcmExecutorConfig(PhantomData); --- 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 . 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 = { @@ -40,51 +33,11 @@ }; } -parameter_types! { - pub QuartzDefaultAllowedLocations: Vec = 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, - >, - ( - TakeWeightCredit, - AllowTopLevelPaidExecutionFrom, - // Expected responses are OK. - AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, - ), ->; +pub type Barrier = ( + TakeWeightCredit, + AllowTopLevelPaidExecutionFrom, + // Expected responses are OK. + AllowKnownQueryResponses, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, +); --- 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 . 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 = { @@ -40,51 +33,11 @@ }; } -parameter_types! { - pub UniqueDefaultAllowedLocations: Vec = 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, - >, - ( - TakeWeightCredit, - AllowTopLevelPaidExecutionFrom, - // Expected responses are OK. - AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, - ), ->; +pub type Barrier = ( + TakeWeightCredit, + AllowTopLevelPaidExecutionFrom, + // Expected responses are OK. + AllowKnownQueryResponses, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, +); -- gitstuff