difftreelog
fix remove known xcm locations -- unneeded due to limited opened hrmp channels
in: master
5 files changed
pallets/configuration/src/benchmarking.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! Benchmarking setup for pallet-configuration1819use super::*;20use frame_benchmarking::benchmarks;21use frame_system::{EventRecord, RawOrigin};22use frame_support::{assert_ok, BoundedVec, traits::Currency};23use xcm::latest::MultiLocation;2425fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {26 let events = frame_system::Pallet::<T>::events();27 let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();28 // compare to the last event record29 let EventRecord { event, .. } = &events[events.len() - 1];30 assert_eq!(event, &system_event);31}3233benchmarks! {34 where_clause { where T: Config }3536 set_weight_to_fee_coefficient_override {37 let coeff: u64 = 999;38 }: {39 assert_ok!(40 <Pallet<T>>::set_weight_to_fee_coefficient_override(RawOrigin::Root.into(), Some(coeff))41 );42 }4344 set_min_gas_price_override {45 let coeff: u64 = 999;46 }: {47 assert_ok!(48 <Pallet<T>>::set_min_gas_price_override(RawOrigin::Root.into(), Some(coeff))49 );50 }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 }5960 set_app_promotion_configuration_override {61 let configuration: AppPromotionConfiguration<T::BlockNumber> = Default::default();62 }: {63 assert_ok!(64 <Pallet<T>>::set_app_promotion_configuration_override(RawOrigin::Root.into(), configuration)65 );66 }6768 set_collator_selection_desired_collators {69 let max: u32 = 999;70 }: {71 assert_ok!(72 <Pallet<T>>::set_collator_selection_desired_collators(RawOrigin::Root.into(), Some(max.clone()))73 );74 }75 verify {76 assert_last_event::<T>(Event::NewDesiredCollators{desired_collators: Some(max)}.into());77 }7879 set_collator_selection_license_bond {80 let bond_cost: Option<BalanceOf<T>> = Some(T::Currency::minimum_balance() * 10u32.into());81 }: {82 assert_ok!(83 <Pallet<T>>::set_collator_selection_license_bond(RawOrigin::Root.into(), bond_cost.clone())84 );85 }86 verify {87 assert_last_event::<T>(Event::NewCollatorLicenseBond{bond_cost}.into());88 }8990 set_collator_selection_kick_threshold {91 let threshold: Option<T::BlockNumber> = Some(900u32.into());92 }: {93 assert_ok!(94 <Pallet<T>>::set_collator_selection_kick_threshold(RawOrigin::Root.into(), threshold.clone())95 );96 }97 verify {98 assert_last_event::<T>(Event::NewCollatorKickThreshold{length_in_blocks: threshold}.into());99 }100}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! Benchmarking setup for pallet-configuration1819use super::*;20use frame_benchmarking::benchmarks;21use frame_system::{EventRecord, RawOrigin};22use frame_support::{assert_ok, traits::Currency};2324fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {25 let events = frame_system::Pallet::<T>::events();26 let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();27 // compare to the last event record28 let EventRecord { event, .. } = &events[events.len() - 1];29 assert_eq!(event, &system_event);30}3132benchmarks! {33 where_clause { where T: Config }3435 set_weight_to_fee_coefficient_override {36 let coeff: u64 = 999;37 }: {38 assert_ok!(39 <Pallet<T>>::set_weight_to_fee_coefficient_override(RawOrigin::Root.into(), Some(coeff))40 );41 }4243 set_min_gas_price_override {44 let coeff: u64 = 999;45 }: {46 assert_ok!(47 <Pallet<T>>::set_min_gas_price_override(RawOrigin::Root.into(), Some(coeff))48 );49 }5051 set_app_promotion_configuration_override {52 let configuration: AppPromotionConfiguration<T::BlockNumber> = Default::default();53 }: {54 assert_ok!(55 <Pallet<T>>::set_app_promotion_configuration_override(RawOrigin::Root.into(), configuration)56 );57 }5859 set_collator_selection_desired_collators {60 let max: u32 = 999;61 }: {62 assert_ok!(63 <Pallet<T>>::set_collator_selection_desired_collators(RawOrigin::Root.into(), Some(max.clone()))64 );65 }66 verify {67 assert_last_event::<T>(Event::NewDesiredCollators{desired_collators: Some(max)}.into());68 }6970 set_collator_selection_license_bond {71 let bond_cost: Option<BalanceOf<T>> = Some(T::Currency::minimum_balance() * 10u32.into());72 }: {73 assert_ok!(74 <Pallet<T>>::set_collator_selection_license_bond(RawOrigin::Root.into(), bond_cost.clone())75 );76 }77 verify {78 assert_last_event::<T>(Event::NewCollatorLicenseBond{bond_cost}.into());79 }8081 set_collator_selection_kick_threshold {82 let threshold: Option<T::BlockNumber> = Some(900u32.into());83 }: {84 assert_ok!(85 <Pallet<T>>::set_collator_selection_kick_threshold(RawOrigin::Root.into(), threshold.clone())86 );87 }88 verify {89 assert_last_event::<T>(Event::NewCollatorKickThreshold{length_in_blocks: threshold}.into());90 }91}pallets/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(())
}
runtime/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>);
runtime/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>,
+);
runtime/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>,
+);