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

difftreelog

style fix formatting

Yaroslav Bolyukin2023-11-17parent: #c1585fd.patch.diff
in: master

4 files changed

modifiedruntime/common/config/substrate.rsdiffbeforeafterboth
--- a/runtime/common/config/substrate.rs
+++ b/runtime/common/config/substrate.rs
@@ -17,7 +17,10 @@
 use frame_support::{
 	dispatch::DispatchClass,
 	ord_parameter_types, parameter_types,
-	traits::{ConstBool, ConstU32, ConstU64, Everything, NeverEnsureOrigin, tokens::{PayFromAccount, UnityAssetBalanceConversion}},
+	traits::{
+		tokens::{PayFromAccount, UnityAssetBalanceConversion},
+		ConstBool, ConstU32, ConstU64, Everything, NeverEnsureOrigin,
+	},
 	weights::{
 		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
 		ConstantMultiplier,
@@ -39,7 +42,8 @@
 
 use crate::{
 	runtime_common::DealWithFees, Balances, Block, OriginCaller, PalletInfo, Runtime, RuntimeCall,
-	RuntimeEvent, RuntimeHoldReason, RuntimeFreezeReason, RuntimeOrigin, SS58Prefix, System, Version, Treasury,
+	RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, SS58Prefix, System,
+	Treasury, Version,
 };
 
 parameter_types! {
@@ -139,7 +143,7 @@
 	type Moment = u64;
 	type OnTimestampSet = ();
 	#[cfg(not(feature = "lookahead"))]
-	type MinimumPeriod = ConstU64<{SLOT_DURATION / 2}>;
+	type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
 	#[cfg(feature = "lookahead")]
 	type MinimumPeriod = ConstU64<0>;
 	type WeightInfo = ();
modifiedruntime/common/config/xcm/foreignassets.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/foreignassets.rs
+++ b/runtime/common/config/xcm/foreignassets.rs
@@ -132,7 +132,11 @@
 
 	fn check_out(_dest: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {}
 
-	fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: Option<&XcmContext>) -> XcmResult {
+	fn deposit_asset(
+		what: &MultiAsset,
+		who: &MultiLocation,
+		context: Option<&XcmContext>,
+	) -> XcmResult {
 		FungiblesTransactor::deposit_asset(what, who, context)
 	}
 
modifiedruntime/common/config/xcm/mod.rsdiffbeforeafterboth
before · runtime/common/config/xcm/mod.rs
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/>.1617use frame_support::{18	parameter_types,19	traits::{ConstU32, Contains, Everything, Get, Nothing, ProcessMessageError},20};21use frame_system::EnsureRoot;22use pallet_xcm::XcmPassthrough;23use polkadot_parachain_primitives::primitives::Sibling;24use sp_std::marker::PhantomData;25use staging_xcm::{26	latest::{prelude::*, MultiLocation, Weight},27	v3::Instruction,28};29use staging_xcm_builder::{30	AccountId32Aliases, EnsureXcmOrigin, FixedWeightBounds, ParentAsSuperuser, ParentIsPreset,31	RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,32	SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,33};34use staging_xcm_executor::{35	traits::{Properties, ShouldExecute},36	XcmExecutor,37};38use up_common::types::AccountId;39use cumulus_primitives_core::ParaId;40use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;4142use crate::{43	xcm_barrier::Barrier, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem,44	PolkadotXcm, RelayNetwork, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, XcmpQueue,45};4647#[cfg(feature = "foreign-assets")]48pub mod foreignassets;4950#[cfg(not(feature = "foreign-assets"))]51pub mod nativeassets;5253#[cfg(feature = "foreign-assets")]54pub use foreignassets as xcm_assets;55#[cfg(not(feature = "foreign-assets"))]56pub use nativeassets as xcm_assets;57use xcm_assets::{AssetTransactor, IsReserve, Trader};5859#[cfg(feature = "governance")]60use crate::runtime_common::config::governance;6162parameter_types! {63	pub const RelayLocation: MultiLocation = MultiLocation::parent();64	pub RelayOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();65	pub UniversalLocation: InteriorMultiLocation = (66		GlobalConsensus(crate::RelayNetwork::get()),67		Parachain(ParachainInfo::get().into()),68	).into();69	pub SelfLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));7071	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.72	pub UnitWeightCost: Weight = Weight::from_parts(1_000_000, 1000); // ?73	pub const MaxInstructions: u32 = 100;74}7576/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used77/// when determining ownership of accounts for asset transacting and when attempting to use XCM78/// `Transact` in order to determine the dispatch Origin.79pub type LocationToAccountId = (80	// The parent (Relay-chain) origin converts to the default `AccountId`.81	ParentIsPreset<AccountId>,82	// Sibling parachain origins convert to AccountId via the `ParaId::into`.83	SiblingParachainConvertsVia<Sibling, AccountId>,84	// Straight up local `AccountId32` origins just alias directly to `AccountId`.85	AccountId32Aliases<RelayNetwork, AccountId>,86);8788/// No local origins on this chain are allowed to dispatch XCM sends/executions.89pub type LocalOriginToLocation = (SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>,);9091/// The means for routing XCM messages which are not for local execution into the right message92/// queues.93pub type XcmRouter = (94	// Two routers - use UMP to communicate with the relay chain:95	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,96	// ..and XCMP to communicate with the sibling chains.97	XcmpQueue,98);99100/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,101/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can102/// biases the kind of local `Origin` it will become.103pub type XcmOriginToTransactDispatchOrigin = (104	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location105	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for106	// foreign chains who want to have a local sovereign account on this chain which they control.107	SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,108	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when109	// recognised.110	RelayChainAsNative<RelayOrigin, RuntimeOrigin>,111	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when112	// recognised.113	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,114	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a115	// transaction from the Root origin.116	ParentAsSuperuser<RuntimeOrigin>,117	// Native signed account converter; this just converts an `AccountId32` origin into a normal118	// `Origin::Signed` origin of the same 32-byte value.119	SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,120	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.121	XcmPassthrough<RuntimeOrigin>,122);123124pub trait TryPass {125	fn try_pass<Call>(126		origin: &MultiLocation,127		message: &mut [Instruction<Call>],128	) -> Result<(), ProcessMessageError>;129}130131#[impl_trait_for_tuples::impl_for_tuples(30)]132impl TryPass for Tuple {133	fn try_pass<Call>(134		origin: &MultiLocation,135		message: &mut [Instruction<Call>],136	) -> Result<(), ProcessMessageError> {137		for_tuples!( #(138			Tuple::try_pass(origin, message)?;139		)* );140141		Ok(())142	}143}144145/// Deny executing the XCM if it matches any of the Deny filter regardless of anything else.146/// If it passes the Deny, and matches one of the Allow cases then it is let through.147pub struct DenyThenTry<Deny, Allow>(PhantomData<Deny>, PhantomData<Allow>)148where149	Deny: TryPass,150	Allow: ShouldExecute;151152impl<Deny, Allow> ShouldExecute for DenyThenTry<Deny, Allow>153where154	Deny: TryPass,155	Allow: ShouldExecute,156{157	fn should_execute<Call>(158		origin: &MultiLocation,159		message: &mut [Instruction<Call>],160		max_weight: Weight,161		properties: &mut Properties,162	) -> Result<(), ProcessMessageError> {163		Deny::try_pass(origin, message)?;164		Allow::should_execute(origin, message, max_weight, properties)165	}166}167168pub type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;169170pub struct XcmCallFilter;171impl XcmCallFilter {172	fn allow_gov_and_sys_call(call: &RuntimeCall) -> bool {173		match call {174			RuntimeCall::System(..) => true,175176			#[cfg(feature = "governance")]177			RuntimeCall::Identity(..)178			| RuntimeCall::Preimage(..)179			| RuntimeCall::Democracy(..)180			| RuntimeCall::Council(..)181			| RuntimeCall::TechnicalCommittee(..)182			| RuntimeCall::CouncilMembership(..)183			| RuntimeCall::TechnicalCommitteeMembership(..)184			| RuntimeCall::FellowshipCollective(..)185			| RuntimeCall::FellowshipReferenda(..) => true,186			_ => false,187		}188	}189190	fn allow_utility_call(call: &RuntimeCall) -> bool {191		match call {192			RuntimeCall::Utility(pallet_utility::Call::batch { calls, .. }) => {193				calls.iter().all(Self::allow_gov_and_sys_call)194			}195			RuntimeCall::Utility(pallet_utility::Call::batch_all { calls, .. }) => {196				calls.iter().all(Self::allow_gov_and_sys_call)197			}198			RuntimeCall::Utility(pallet_utility::Call::as_derivative { call, .. }) => {199				Self::allow_gov_and_sys_call(call)200			}201			RuntimeCall::Utility(pallet_utility::Call::dispatch_as { call, .. }) => {202				Self::allow_gov_and_sys_call(call)203			}204			RuntimeCall::Utility(pallet_utility::Call::force_batch { calls, .. }) => {205				calls.iter().all(Self::allow_gov_and_sys_call)206			}207			_ => false,208		}209	}210}211212impl Contains<RuntimeCall> for XcmCallFilter {213	fn contains(call: &RuntimeCall) -> bool {214		Self::allow_gov_and_sys_call(call) || Self::allow_utility_call(call)215	}216}217218pub struct XcmExecutorConfig<T>(PhantomData<T>);219impl<T> staging_xcm_executor::Config for XcmExecutorConfig<T>220where221	T: pallet_configuration::Config,222{223	type RuntimeCall = RuntimeCall;224	type XcmSender = XcmRouter;225	// How to withdraw and deposit an asset.226	type AssetTransactor = AssetTransactor;227	type OriginConverter = XcmOriginToTransactDispatchOrigin;228	type IsReserve = IsReserve;229	type IsTeleporter = (); // Teleportation is disabled230	type UniversalLocation = UniversalLocation;231	type Barrier = Barrier;232	type Weigher = Weigher;233	type Trader = Trader<T>;234	type ResponseHandler = PolkadotXcm;235	type SubscriptionService = PolkadotXcm;236	type PalletInstancesInfo = AllPalletsWithSystem;237	type MaxAssetsIntoHolding = ConstU32<8>;238239	type AssetTrap = PolkadotXcm;240	type AssetClaims = PolkadotXcm;241	type AssetLocker = ();242	type AssetExchanger = ();243	type FeeManager = ();244	type MessageExporter = ();245	type UniversalAliases = Nothing;246	type CallDispatcher = RuntimeCall;247	type SafeCallFilter = XcmCallFilter;248	type Aliasers = Nothing;249}250251#[cfg(feature = "runtime-benchmarks")]252parameter_types! {253	pub ReachableDest: Option<MultiLocation> = Some(Parent.into());254}255256impl pallet_xcm::Config for Runtime {257	type RuntimeEvent = RuntimeEvent;258	type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, ()>;259	type XcmRouter = XcmRouter;260	type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;261	type XcmExecuteFilter = Everything;262	type XcmExecutor = XcmExecutor<XcmExecutorConfig<Self>>;263	type XcmTeleportFilter = Everything;264	type XcmReserveTransferFilter = Everything;265	type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;266	type RuntimeOrigin = RuntimeOrigin;267	type RuntimeCall = RuntimeCall;268	const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;269	type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;270	type UniversalLocation = UniversalLocation;271	type Currency = Balances;272	type CurrencyMatcher = ();273	type TrustedLockers = ();274	type SovereignAccountOf = LocationToAccountId;275	type MaxLockers = ConstU32<8>;276	type WeightInfo = crate::weights::xcm::SubstrateWeight<Runtime>;277	type AdminOrigin = EnsureRoot<AccountId>;278	type MaxRemoteLockConsumers = ConstU32<0>;279	type RemoteLockConsumerIdentifier = ();280	#[cfg(feature = "runtime-benchmarks")]281	type ReachableDest = ReachableDest;282}283284impl cumulus_pallet_xcm::Config for Runtime {285	type RuntimeEvent = RuntimeEvent;286	type XcmExecutor = XcmExecutor<XcmExecutorConfig<Self>>;287}288impl cumulus_pallet_xcmp_queue::Config for Runtime {289	type WeightInfo = ();290	type RuntimeEvent = RuntimeEvent;291	type XcmExecutor = XcmExecutor<XcmExecutorConfig<Self>>;292	type ChannelInfo = ParachainSystem;293	type VersionWrapper = PolkadotXcm;294	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;295296	#[cfg(feature = "governance")]297	type ControllerOrigin = governance::RootOrTechnicalCommitteeMember;298299	#[cfg(not(feature = "governance"))]300	type ControllerOrigin = frame_system::EnsureRoot<AccountId>;301302	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;303	type PriceForSiblingDelivery = NoPriceForMessageDelivery<ParaId>;304}305306impl cumulus_pallet_dmp_queue::Config for Runtime {307	type RuntimeEvent = RuntimeEvent;308	type XcmExecutor = XcmExecutor<XcmExecutorConfig<Self>>;309	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;310}
modifiedruntime/common/mod.rsdiffbeforeafterboth
--- a/runtime/common/mod.rs
+++ b/runtime/common/mod.rs
@@ -43,10 +43,7 @@
 use sp_version::NativeVersion;
 use up_common::types::{AccountId, BlockNumber};
 
-use crate::{
-	AllPalletsWithSystem, Aura, Balances, Runtime, RuntimeCall, Signature,
-	Treasury,
-};
+use crate::{AllPalletsWithSystem, Aura, Balances, Runtime, RuntimeCall, Signature, Treasury};
 
 #[macro_export]
 macro_rules! unsupported {