diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs index d124d9dd5d6e..b406ec306b19 100644 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -69,7 +69,7 @@ use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, - EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, + EnsureXcmOrigin, FixedWeightBounds, IsConcrete, NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, @@ -372,7 +372,7 @@ impl Config for XcmConfig { type OriginConverter = XcmOriginToTransactDispatchOrigin; type IsReserve = NativeAsset; type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of UNIT - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = UsingComponents, RelayLocation, AccountId, Balances, ()>; @@ -406,7 +406,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 0d1f9960156f..1ea3717051bd 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -32,8 +32,8 @@ use xcm_builder::{ AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, - LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, - TakeWeightCredit, UsingComponents, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + UsingComponents, }; use xcm_executor::XcmExecutor; @@ -142,7 +142,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; // The weight trader piggybacks on the existing transaction-fee conversion logic. @@ -192,7 +192,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 501e5e5620e5..02066df1fb32 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -31,8 +31,8 @@ use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, - IsConcrete, LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, + TakeWeightCredit, UsingComponents, }; use xcm_executor::XcmExecutor; @@ -134,7 +134,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; // The weight trader piggybacks on the existing transaction-fee conversion logic. @@ -184,7 +184,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Nothing; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 00e3b643ff59..8e71ca8daffe 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -31,7 +31,7 @@ use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, - CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, LocationInverter, + CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, UsingComponents, }; use xcm_executor::XcmExecutor; @@ -128,7 +128,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = @@ -172,7 +172,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 07508efc2ff0..1353b0507d1b 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -521,6 +521,7 @@ parameter_types! { pub const BaseXcmWeight: frame_support::weights::Weight = 1_000; pub const AnyNetwork: Option = None; pub const MaxInstructions: u32 = 100; + pub const UniversalLocation: xcm::latest::InteriorMultiLocation = xcm::latest::Junctions::Here; } pub type LocalOriginToLocation = xcm_builder::SignedToAccountId32; @@ -530,7 +531,7 @@ impl pallet_xcm::Config for Runtime { // is `XcmExecutor`, which will be used in unit tests located in xcm-executor. type Event = Event; type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; - type LocationInverter = xcm_config::InvertNothing; + type UniversalLocation = UniversalLocation; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type Weigher = xcm_builder::FixedWeightBounds; type XcmRouter = xcm_config::DoNothingRouter; diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index cd0ac5137bd0..284a1d3dc21b 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -22,7 +22,7 @@ use frame_support::{ use xcm::latest::prelude::*; use xcm_builder::{AllowUnpaidExecutionFrom, FixedWeightBounds, SignedToAccountId32}; use xcm_executor::{ - traits::{TransactAsset, UniversalLocation, WeightTrader}, + traits::{TransactAsset, WeightTrader}, Assets, }; @@ -30,6 +30,7 @@ parameter_types! { pub const OurNetwork: NetworkId = NetworkId::Polkadot; pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 16; + pub const UniversalLocation: xcm::latest::InteriorMultiLocation = xcm::latest::Junctions::Here; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location @@ -79,17 +80,6 @@ impl WeightTrader for DummyWeightTrader { } } -pub struct InvertNothing; -impl UniversalLocation for InvertNothing { - fn invert_location(_: &MultiLocation) -> sp_std::result::Result { - Ok(Here.into()) - } - - fn universal_location() -> InteriorMultiLocation { - Here - } -} - pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type Call = super::Call; @@ -98,7 +88,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = pallet_xcm::XcmPassthrough; type IsReserve = (); type IsTeleporter = (); - type LocationInverter = InvertNothing; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = DummyWeightTrader; diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 4952c2d007d9..ecf1a8be21bb 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -30,7 +30,7 @@ use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, - CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, LocationInverter, + CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, }; @@ -107,7 +107,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = WeightInfoBounds, Call, MaxInstructions>; type Trader = @@ -144,7 +144,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = WeightInfoBounds, Call, MaxInstructions>; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index bf962f65668c..f20fe23146a8 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -138,7 +138,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = (); type IsReserve = TrustedReserves; type IsTeleporter = TrustedTeleporters; - type LocationInverter = xcm_builder::LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = AllowUnpaidExecutionFrom; type Weigher = xcm_builder::FixedWeightBounds; type Trader = xcm_builder::FixedRateOfFungible; diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 5f45cb56df00..ec34975e3a0d 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -110,7 +110,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = AlwaysSignedByDefault; type IsReserve = AllAssetLocationsPass; type IsTeleporter = (); - type LocationInverter = xcm_builder::LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = AllowUnpaidExecutionFrom; type Weigher = xcm_builder::FixedWeightBounds; type Trader = xcm_builder::FixedRateOfFungible; diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 5a388982c788..30254ff4e769 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -54,8 +54,7 @@ pub use pallet::*; use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, BlockNumberProvider, Hash}; use xcm_executor::{ traits::{ - ClaimAssets, DropAssets, MatchesFungible, OnResponse, UniversalLocation, - VersionChangeNotifier, WeightBounds, + ClaimAssets, DropAssets, MatchesFungible, OnResponse, VersionChangeNotifier, WeightBounds, }, Assets, }; @@ -69,7 +68,7 @@ pub mod pallet { }; use frame_system::Config as SysConfig; use sp_core::H256; - use xcm_executor::traits::{MatchesFungible, UniversalLocation, WeightBounds}; + use xcm_executor::traits::{MatchesFungible, WeightBounds}; parameter_types! { /// An implementation of `Get` which just returns the latest XCM version which we can @@ -125,8 +124,8 @@ pub mod pallet { /// Means of measuring the weight consumed by an XCM message locally. type Weigher: WeightBounds<::Call>; - /// Means of inverting a location. - type LocationInverter: UniversalLocation; + /// This chain's Universal Location. + type UniversalLocation: Get; /// The outer `Origin` type. type Origin: From + From<::Origin>; @@ -983,12 +982,12 @@ impl Pallet { let value = (origin_location, assets.into_inner()); ensure!(T::XcmReserveTransferFilter::contains(&value), Error::::Filtered); let (origin_location, assets) = value; - let ancestry = T::LocationInverter::universal_location().into(); + let context = T::UniversalLocation::get(); let fees = assets .get(fee_asset_item as usize) .ok_or(Error::::Empty)? .clone() - .reanchored(&dest, &ancestry) + .reanchored(&dest, context) .map_err(|_| Error::::CannotReanchor)?; let max_assets = assets.len() as u32; let assets: MultiAssets = assets.into(); @@ -1041,12 +1040,12 @@ impl Pallet { let value = (origin_location, assets.into_inner()); ensure!(T::XcmTeleportFilter::contains(&value), Error::::Filtered); let (origin_location, assets) = value; - let ancestry = T::LocationInverter::universal_location().into(); + let context = T::UniversalLocation::get(); let fees = assets .get(fee_asset_item as usize) .ok_or(Error::::Empty)? .clone() - .reanchored(&dest, &ancestry) + .reanchored(&dest, context) .map_err(|_| Error::::CannotReanchor)?; let max_assets = assets.len() as u32; let assets: MultiAssets = assets.into(); @@ -1333,7 +1332,8 @@ impl Pallet { timeout: T::BlockNumber, ) -> Result { let responder = responder.into(); - let destination = T::LocationInverter::invert_location(&responder) + let destination = T::UniversalLocation::get() + .invert_target(&responder) .map_err(|()| XcmError::MultiLocationNotInvertible)?; let query_id = Self::new_query(responder, timeout, Here); let response_info = QueryResponseInfo { destination, query_id, max_weight: 0 }; @@ -1371,7 +1371,8 @@ impl Pallet { timeout: T::BlockNumber, ) -> Result<(), XcmError> { let responder = responder.into(); - let destination = T::LocationInverter::invert_location(&responder) + let destination = T::UniversalLocation::get() + .invert_target(&responder) .map_err(|()| XcmError::MultiLocationNotInvertible)?; let notify: ::Call = notify.into(); let max_weight = notify.get_dispatch_info().weight; diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 2b72a87f92e4..2a6018ac35f1 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -30,8 +30,8 @@ use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, Case, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, - FixedWeightBounds, IsConcrete, LocationInverter, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + FixedWeightBounds, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, TakeWeightCredit, }; use xcm_executor::XcmExecutor; @@ -285,7 +285,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = Case; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -318,7 +318,7 @@ impl pallet_xcm::Config for Test { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/src/v3/junctions.rs b/xcm/src/v3/junctions.rs index d958478ac50d..5deb952d1506 100644 --- a/xcm/src/v3/junctions.rs +++ b/xcm/src/v3/junctions.rs @@ -135,6 +135,19 @@ impl Junctions { self.for_each_mut(Junction::remove_network_id); } + /// Treating `self` as the universal context, return the location of the local consensus system + /// from the point of view of the given `location`. + pub fn invert_target(mut self, location: &MultiLocation) -> Result { + let mut junctions = Self::Here; + for _ in 0..location.parent_count() { + junctions = junctions + .pushed_with(self.take_first().unwrap_or(Junction::OnlyChild)) + .map_err(|_| ())?; + } + let parents = location.interior().len() as u8; + Ok(MultiLocation::new(parents, junctions)) + } + /// Execute a function `f` on every junction. We use this since we cannot implement a mutable /// `Iterator` without unsafe code. pub fn for_each_mut(&mut self, mut x: impl FnMut(&mut Junction)) { @@ -570,6 +583,22 @@ xcm_procedural::impl_conversion_functions_for_junctions_v3!(); mod tests { use super::{super::prelude::*, *}; + #[test] + fn inverting_works() { + let context: InteriorMultiLocation = (Parachain(1000), PalletInstance(42)).into(); + let target = (Parent, PalletInstance(69)).into(); + let expected = (Parent, PalletInstance(42)).into(); + let inverted = context.invert_target(&target).unwrap(); + assert_eq!(inverted, expected); + + let context: InteriorMultiLocation = + (Parachain(1000), PalletInstance(42), GeneralIndex(1)).into(); + let target = (Parent, Parent, PalletInstance(69), GeneralIndex(2)).into(); + let expected = (Parent, Parent, PalletInstance(42), GeneralIndex(1)).into(); + let inverted = context.invert_target(&target).unwrap(); + assert_eq!(inverted, expected); + } + #[test] fn relative_to_works() { use Junctions::*; diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index c93ac0902789..d5064faab8d3 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -23,7 +23,7 @@ //! - `MultiAssetFilter`: A combination of `Wild` and `MultiAssets` designed for efficiently filtering an XCM holding //! account. -use super::MultiLocation; +use super::{InteriorMultiLocation, MultiLocation}; use crate::v2::{ AssetId as OldAssetId, AssetInstance as OldAssetInstance, Fungibility as OldFungibility, MultiAsset as OldMultiAsset, MultiAssetFilter as OldMultiAssetFilter, @@ -347,7 +347,11 @@ impl AssetId { /// Mutate the asset to represent the same value from the perspective of a new `target` /// location. The local chain's location is provided in `context`. - pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + pub fn reanchor( + &mut self, + target: &MultiLocation, + context: InteriorMultiLocation, + ) -> Result<(), ()> { if let AssetId::Concrete(ref mut l) = self { l.reanchor(target, context)?; } @@ -412,7 +416,11 @@ impl MultiAsset { /// Mutate the location of the asset identifier if concrete, giving it the same location /// relative to a `target` context. The local context is provided as `context`. - pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + pub fn reanchor( + &mut self, + target: &MultiLocation, + context: InteriorMultiLocation, + ) -> Result<(), ()> { self.id.reanchor(target, context) } @@ -421,7 +429,7 @@ impl MultiAsset { pub fn reanchored( mut self, target: &MultiLocation, - context: &MultiLocation, + context: InteriorMultiLocation, ) -> Result { self.id.reanchor(target, context)?; Ok(self) @@ -620,8 +628,12 @@ impl MultiAssets { /// Mutate the location of the asset identifier if concrete, giving it the same location /// relative to a `target` context. The local context is provided as `context`. - pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { - self.0.iter_mut().try_for_each(|i| i.reanchor(target, context)) + pub fn reanchor( + &mut self, + target: &MultiLocation, + context: InteriorMultiLocation, + ) -> Result<(), ()> { + self.0.iter_mut().try_for_each(|i| i.reanchor(target, context.clone())) } /// Return a reference to an item at a specific index or `None` if it doesn't exist. @@ -700,7 +712,11 @@ impl WildMultiAsset { /// Mutate the asset to represent the same value from the perspective of a new `target` /// location. The local chain's location is provided in `context`. - pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + pub fn reanchor( + &mut self, + target: &MultiLocation, + context: InteriorMultiLocation, + ) -> Result<(), ()> { use WildMultiAsset::*; match self { AllOf { ref mut id, .. } | AllOfCounted { ref mut id, .. } => @@ -785,7 +801,11 @@ impl MultiAssetFilter { /// Mutate the location of the asset identifier if concrete, giving it the same location /// relative to a `target` context. The local context is provided as `context`. - pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + pub fn reanchor( + &mut self, + target: &MultiLocation, + context: InteriorMultiLocation, + ) -> Result<(), ()> { match self { MultiAssetFilter::Definite(ref mut assets) => assets.reanchor(target, context), MultiAssetFilter::Wild(ref mut wild) => wild.reanchor(target, context), diff --git a/xcm/src/v3/multilocation.rs b/xcm/src/v3/multilocation.rs index f5d9256aacc3..28e2cf84cca6 100644 --- a/xcm/src/v3/multilocation.rs +++ b/xcm/src/v3/multilocation.rs @@ -388,11 +388,15 @@ impl MultiLocation { /// The context of `self` is provided as `context`. /// /// Does not modify `self` in case of overflow. - pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + pub fn reanchor( + &mut self, + target: &MultiLocation, + context: InteriorMultiLocation, + ) -> Result<(), ()> { // TODO: https://github.com/paritytech/polkadot/issues/4489 Optimize this. // 1. Use our `context` to figure out how the `target` would address us. - let inverted_target = context.inverted(target)?; + let inverted_target = context.invert_target(target)?; // 2. Prepend `inverted_target` to `self` to get self's location from the perspective of // `target`. @@ -412,7 +416,7 @@ impl MultiLocation { pub fn reanchored( mut self, target: &MultiLocation, - context: &MultiLocation, + context: InteriorMultiLocation, ) -> Result { match self.reanchor(target, context) { Ok(()) => Ok(self), @@ -420,20 +424,6 @@ impl MultiLocation { } } - /// Treating `self` as a context, determine how it would be referenced by a `target` location. - pub fn inverted(&self, target: &MultiLocation) -> Result { - use Junction::OnlyChild; - let mut context = self.clone(); - let mut junctions = Junctions::Here; - for _ in 0..target.parent_count() { - junctions = junctions - .pushed_front_with(context.interior.take_last().unwrap_or(OnlyChild)) - .map_err(|_| ())?; - } - let parents = target.interior().len() as u8; - Ok(MultiLocation::new(parents, junctions)) - } - /// Remove any unneeded parents/junctions in `self` based on the given context it will be /// interpreted in. pub fn simplify(&mut self, context: &Junctions) { @@ -520,21 +510,6 @@ mod tests { assert_eq!(x, MultiLocation { parents: 0, interior: OnlyChild.into() }); } - #[test] - fn inverted_works() { - let context: MultiLocation = (Parachain(1000), PalletInstance(42)).into(); - let target = (Parent, PalletInstance(69)).into(); - let expected = (Parent, PalletInstance(42)).into(); - let inverted = context.inverted(&target).unwrap(); - assert_eq!(inverted, expected); - - let context: MultiLocation = (Parachain(1000), PalletInstance(42), GeneralIndex(1)).into(); - let target = (Parent, Parent, PalletInstance(69), GeneralIndex(2)).into(); - let expected = (Parent, Parent, PalletInstance(42), GeneralIndex(1)).into(); - let inverted = context.inverted(&target).unwrap(); - assert_eq!(inverted, expected); - } - #[test] fn simplify_basic_works() { let mut location: MultiLocation = @@ -589,7 +564,7 @@ mod tests { let context = Parachain(2000).into(); let target = (Parent, Parachain(1000)).into(); let expected = GeneralIndex(42).into(); - id.reanchor(&target, &context).unwrap(); + id.reanchor(&target, context).unwrap(); assert_eq!(id, expected); } diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index e69dfbfbc6af..eb160fa12ecd 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -29,7 +29,7 @@ pub mod test_utils; mod location_conversion; pub use location_conversion::{ Account32Hash, AccountId32Aliases, AccountKey20Aliases, ChildParachainConvertsVia, - LocationInverter, ParentIsPreset, SiblingParachainConvertsVia, + ParentIsPreset, SiblingParachainConvertsVia, }; mod origin_conversion; diff --git a/xcm/xcm-builder/src/location_conversion.rs b/xcm/xcm-builder/src/location_conversion.rs index 1afc855df2a2..9384bdf2732a 100644 --- a/xcm/xcm-builder/src/location_conversion.rs +++ b/xcm/xcm-builder/src/location_conversion.rs @@ -20,7 +20,7 @@ use sp_io::hashing::blake2_256; use sp_runtime::traits::{AccountIdConversion, TrailingZeroInput}; use sp_std::{borrow::Borrow, marker::PhantomData}; use xcm::latest::prelude::*; -use xcm_executor::traits::{Convert, UniversalLocation}; +use xcm_executor::traits::Convert; pub struct Account32Hash(PhantomData<(Network, AccountId)>); impl>, AccountId: From<[u8; 32]> + Into<[u8; 32]> + Clone> @@ -147,45 +147,6 @@ impl>, AccountId: From<[u8; 20]> + Into<[u8; 20]> } } -/// Simple location inverter; give it this location's context and it'll figure out the inverted -/// location. -/// -/// # Example -/// ## Network Topology -/// ```txt -/// v Source -/// Relay -> Para 1 -> Account20 -/// -> Para 2 -> Account32 -/// ^ Target -/// ``` -/// ```rust -/// # use frame_support::parameter_types; -/// # use xcm::latest::prelude::*; -/// # use xcm_builder::LocationInverter; -/// # use xcm_executor::traits::UniversalLocation; -/// # fn main() { -/// parameter_types!{ -/// pub UniversalLocation: InteriorMultiLocation = X2( -/// Parachain(1), -/// AccountKey20 { network: None, key: Default::default() }, -/// ); -/// } -/// -/// let input = MultiLocation::new(2, X2(Parachain(2), AccountId32 { network: None, id: Default::default() })); -/// let inverted = LocationInverter::::invert_location(&input); -/// assert_eq!(inverted, Ok(MultiLocation::new( -/// 2, -/// X2(Parachain(1), AccountKey20 { network: None, key: Default::default() }), -/// ))); -/// # } -/// ``` -pub struct LocationInverter(PhantomData); -impl> UniversalLocation for LocationInverter { - fn universal_location() -> InteriorMultiLocation { - Location::get() - } -} - #[cfg(test)] mod tests { use super::*; @@ -220,7 +181,7 @@ mod tests { } let input = MultiLocation::new(3, X2(Parachain(2), account32())); - let inverted = LocationInverter::::invert_location(&input).unwrap(); + let inverted = UniversalLocation::get().invert_target(&input).unwrap(); assert_eq!(inverted, MultiLocation::new(2, X3(Parachain(1), account20(), account20()))); } @@ -235,7 +196,7 @@ mod tests { } let input = MultiLocation::grandparent(); - let inverted = LocationInverter::::invert_location(&input).unwrap(); + let inverted = UniversalLocation::get().invert_target(&input).unwrap(); assert_eq!(inverted, X2(account20(), account20()).into()); } @@ -250,7 +211,7 @@ mod tests { } let input = MultiLocation::grandparent(); - let inverted = LocationInverter::::invert_location(&input).unwrap(); + let inverted = UniversalLocation::get().invert_target(&input).unwrap(); assert_eq!(inverted, X2(PalletInstance(5), OnlyChild).into()); } @@ -261,7 +222,7 @@ mod tests { } let input = MultiLocation { parents: 99, interior: X1(Parachain(88)) }; - let inverted = LocationInverter::::invert_location(&input); + let inverted = UniversalLocation::get().invert_target(&input); assert_eq!(inverted, Err(())); } } diff --git a/xcm/xcm-builder/src/test_utils.rs b/xcm/xcm-builder/src/test_utils.rs index f75edc47661c..b56e39f4266a 100644 --- a/xcm/xcm-builder/src/test_utils.rs +++ b/xcm/xcm-builder/src/test_utils.rs @@ -25,7 +25,7 @@ use sp_std::vec::Vec; pub use xcm::latest::prelude::*; use xcm_executor::traits::{ClaimAssets, DropAssets, VersionChangeNotifier}; pub use xcm_executor::{ - traits::{ConvertOrigin, OnResponse, TransactAsset, UniversalLocation}, + traits::{ConvertOrigin, OnResponse, TransactAsset}, Assets, Config, }; diff --git a/xcm/xcm-builder/src/tests/mock.rs b/xcm/xcm-builder/src/tests/mock.rs index e1f2fbcbaa87..dc5b427e9674 100644 --- a/xcm/xcm-builder/src/tests/mock.rs +++ b/xcm/xcm-builder/src/tests/mock.rs @@ -17,7 +17,7 @@ use crate::{barriers::AllowSubscriptionsFrom, test_utils::*}; pub use crate::{ AllowKnownQueryResponses, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, - FixedRateOfFungible, FixedWeightBounds, LocationInverter, TakeWeightCredit, + FixedRateOfFungible, FixedWeightBounds, TakeWeightCredit, }; use frame_support::traits::ContainsPair; pub use frame_support::{ @@ -41,7 +41,7 @@ pub use xcm::prelude::*; pub use xcm_executor::{ traits::{ AssetExchange, AssetLock, ConvertOrigin, Enact, ExportXcm, FeeManager, FeeReason, - LockError, OnResponse, TransactAsset, UniversalLocation, + LockError, OnResponse, TransactAsset, }, Assets, Config, }; @@ -593,7 +593,7 @@ impl Config for TestConfig { type OriginConverter = TestOriginConverter; type IsReserve = TestIsReserve; type IsTeleporter = TestIsTeleporter; - type LocationInverter = LocationInverter; + type UniversalLocation = ExecutorUniversalLocation; type Barrier = TestBarrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; diff --git a/xcm/xcm-builder/src/universal_exports.rs b/xcm/xcm-builder/src/universal_exports.rs index 1e0869801812..5db871135db8 100644 --- a/xcm/xcm-builder/src/universal_exports.rs +++ b/xcm/xcm-builder/src/universal_exports.rs @@ -55,9 +55,11 @@ fn ensure_is_remote( /// that the message sending cannot be abused in any way. /// /// This is only useful when the local chain has bridging capabilities. -pub struct LocalUnpaidExporter(PhantomData<(Exporter, Ancestry)>); -impl> SendXcm - for LocalUnpaidExporter +pub struct LocalUnpaidExporter( + PhantomData<(Exporter, UniversalLocation)>, +); +impl> SendXcm + for LocalUnpaidExporter { type Ticket = Exporter::Ticket; @@ -66,7 +68,7 @@ impl> SendXcm xcm: &mut Option>, ) -> SendResult { let d = dest.take().ok_or(MissingArgument)?; - let devolved = match ensure_is_remote(Ancestry::get(), d) { + let devolved = match ensure_is_remote(UniversalLocation::get(), d) { Ok(x) => x, Err(d) => { *dest = Some(d); @@ -144,11 +146,11 @@ impl)>>> ExporterFor /// /// This is only useful if we have special dispensation by the remote bridges to have the /// `ExportMessage` instruction executed without payment. -pub struct UnpaidRemoteExporter( - PhantomData<(Bridges, Router, Ancestry)>, +pub struct UnpaidRemoteExporter( + PhantomData<(Bridges, Router, UniversalLocation)>, ); -impl> SendXcm - for UnpaidRemoteExporter +impl> SendXcm + for UnpaidRemoteExporter { type Ticket = Router::Ticket; @@ -157,7 +159,7 @@ impl xcm: &mut Option>, ) -> SendResult { let d = dest.as_ref().ok_or(MissingArgument)?.clone(); - let devolved = ensure_is_remote(Ancestry::get(), d).map_err(|_| NotApplicable)?; + let devolved = ensure_is_remote(UniversalLocation::get(), d).map_err(|_| NotApplicable)?; let (remote_network, remote_location, local_network, local_location) = devolved; // Prepend the desired message with instructions which effectively rewrite the origin. @@ -203,11 +205,11 @@ impl /// /// The `ExportMessage` instruction on the bridge is paid for from the local chain's sovereign /// account on the bridge. The amount paid is determined through the `ExporterFor` trait. -pub struct SovereignPaidRemoteExporter( - PhantomData<(Bridges, Router, Ancestry)>, +pub struct SovereignPaidRemoteExporter( + PhantomData<(Bridges, Router, UniversalLocation)>, ); -impl> SendXcm - for SovereignPaidRemoteExporter +impl> SendXcm + for SovereignPaidRemoteExporter { type Ticket = Router::Ticket; @@ -216,7 +218,7 @@ impl xcm: &mut Option>, ) -> SendResult { let d = dest.as_ref().ok_or(MissingArgument)?.clone(); - let devolved = ensure_is_remote(Ancestry::get(), d).map_err(|_| NotApplicable)?; + let devolved = ensure_is_remote(UniversalLocation::get(), d).map_err(|_| NotApplicable)?; let (remote_network, remote_location, local_network, local_location) = devolved; // Prepend the desired message with instructions which effectively rewrite the origin. @@ -234,14 +236,14 @@ impl .ok_or(NotApplicable)?; let local_from_bridge = - MultiLocation::from(Ancestry::get()).inverted(&bridge).map_err(|_| Unroutable)?; + UniversalLocation::get().invert_target(&bridge).map_err(|_| Unroutable)?; let export_instruction = ExportMessage { network: remote_network, destination: remote_location, xcm: exported }; let message = Xcm(if let Some(ref payment) = maybe_payment { let fees = payment .clone() - .reanchored(&bridge, &Ancestry::get().into()) + .reanchored(&bridge, UniversalLocation::get()) .map_err(|_| Unroutable)?; vec![ WithdrawAsset(fees.clone().into()), diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 424a0e28017c..4104e91b8776 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -33,8 +33,8 @@ use xcm_builder::{ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds, - IsChildSystemParachain, IsConcrete, LocationInverter, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + IsChildSystemParachain, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, TakeWeightCredit, }; pub type AccountId = AccountId32; @@ -178,7 +178,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -199,7 +199,7 @@ pub type LocalOriginToLocation = SignedToAccountId32; + type UniversalLocation = UniversalLocation; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmRouter = TestSendXcm; // Anyone can execute XCM messages locally... diff --git a/xcm/xcm-executor/src/assets.rs b/xcm/xcm-executor/src/assets.rs index ac8b41233bf4..0f09fde03806 100644 --- a/xcm/xcm-executor/src/assets.rs +++ b/xcm/xcm-executor/src/assets.rs @@ -23,7 +23,7 @@ use sp_std::{ use xcm::latest::{ AssetId, AssetInstance, Fungibility::{Fungible, NonFungible}, - MultiAsset, MultiAssetFilter, MultiAssets, MultiLocation, + InteriorMultiLocation, MultiAsset, MultiAssetFilter, MultiAssets, MultiLocation, WildFungibility::{Fungible as WildFungible, NonFungible as WildNonFungible}, WildMultiAsset::{All, AllCounted, AllOf, AllOfCounted}, }; @@ -216,7 +216,7 @@ impl Assets { pub fn reanchor( &mut self, target: &MultiLocation, - context: &MultiLocation, + context: InteriorMultiLocation, mut maybe_failed_bin: Option<&mut Self>, ) { let mut fungible = Default::default(); diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index 23cc7e885764..1184f77c6712 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -16,8 +16,7 @@ use crate::traits::{ AssetExchange, AssetLock, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, FeeManager, - OnResponse, ShouldExecute, TransactAsset, UniversalLocation, VersionChangeNotifier, - WeightBounds, WeightTrader, + OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, }; use frame_support::{ dispatch::{Dispatchable, Parameter}, @@ -46,8 +45,8 @@ pub trait Config { /// Combinations of (Asset, Location) pairs which we trust as teleporters. type IsTeleporter: ContainsPair; - /// Means of inverting a location. - type LocationInverter: UniversalLocation; + /// This chain's Universal Location. + type UniversalLocation: Get; /// Whether we should execute the given XCM at all. type Barrier: ShouldExecute; diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 9b765041e251..61fa76be551f 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -31,7 +31,7 @@ use xcm::latest::prelude::*; pub mod traits; use traits::{ validate_export, AssetExchange, AssetLock, ClaimAssets, ConvertOrigin, DropAssets, Enact, - ExportXcm, FeeManager, FeeReason, OnResponse, ShouldExecute, TransactAsset, UniversalLocation, + ExportXcm, FeeManager, FeeReason, OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, }; @@ -472,9 +472,9 @@ impl XcmExecutor { for asset in assets.inner() { Config::AssetTransactor::beam_asset(asset, origin, &dest, &self.context)?; } - let reanchor_context = Config::LocationInverter::universal_location().into(); + let reanchor_context = Config::UniversalLocation::get(); assets - .reanchor(&dest, &reanchor_context) + .reanchor(&dest, reanchor_context) .map_err(|()| XcmError::MultiLocationFull)?; let mut message = vec![ReserveAssetDeposited(assets), ClearOrigin]; message.extend(xcm.0.into_iter()); @@ -755,7 +755,7 @@ impl XcmExecutor { Ok(()) }, UniversalOrigin(new_global) => { - let universal_location = Config::LocationInverter::universal_location(); + let universal_location = Config::UniversalLocation::get(); ensure!(universal_location.first() != Some(&new_global), XcmError::InvalidLocation); let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); let origin_xform = (origin, new_global); @@ -784,7 +784,7 @@ impl XcmExecutor { let lock_ticket = Config::AssetLocker::prepare_lock(unlocker.clone(), asset, origin.clone())?; let owner = - origin.reanchored(&unlocker, &context).map_err(|_| XcmError::ReanchorFailed)?; + origin.reanchored(&unlocker, context).map_err(|_| XcmError::ReanchorFailed)?; let msg = Xcm::<()>(vec![NoteUnlockable { asset: remote_asset, owner }]); let (ticket, price) = validate_send::(unlocker, msg)?; self.take_fee(price, FeeReason::LockAsset)?; @@ -876,7 +876,7 @@ impl XcmExecutor { Ok(match local_querier { None => None, Some(q) => Some( - q.reanchored(&destination, &Config::LocationInverter::universal_location().into()) + q.reanchored(&destination, Config::UniversalLocation::get()) .map_err(|_| XcmError::ReanchorFailed)?, ), }) @@ -907,10 +907,10 @@ impl XcmExecutor { fn try_reanchor( asset: MultiAsset, destination: &MultiLocation, - ) -> Result<(MultiAsset, MultiLocation), XcmError> { - let reanchor_context = Config::LocationInverter::universal_location().into(); + ) -> Result<(MultiAsset, InteriorMultiLocation), XcmError> { + let reanchor_context = Config::UniversalLocation::get(); let asset = asset - .reanchored(&destination, &reanchor_context) + .reanchored(&destination, reanchor_context.clone()) .map_err(|()| XcmError::ReanchorFailed)?; Ok((asset, reanchor_context)) } @@ -921,8 +921,8 @@ impl XcmExecutor { dest: &MultiLocation, maybe_failed_bin: Option<&mut Assets>, ) -> MultiAssets { - let reanchor_context = Config::LocationInverter::universal_location().into(); - assets.reanchor(dest, &reanchor_context, maybe_failed_bin); + let reanchor_context = Config::UniversalLocation::get(); + assets.reanchor(dest, reanchor_context, maybe_failed_bin); assets.into_assets_iter().collect::>().into() } } diff --git a/xcm/xcm-executor/src/traits/conversion.rs b/xcm/xcm-executor/src/traits/conversion.rs index b14aedc37b64..acb91c1b9ef9 100644 --- a/xcm/xcm-executor/src/traits/conversion.rs +++ b/xcm/xcm-executor/src/traits/conversion.rs @@ -203,26 +203,3 @@ impl ConvertOrigin for Tuple { Err(origin) } } - -/// Means of wotking with a relative location. -pub trait UniversalLocation { - /// Return the location of the local consensus system from the point of view of the location - /// `l`. - /// - /// Given a target `location`, the result provides the location which represents the local - /// consensus system from the targets perspective. - fn invert_location(location: &MultiLocation) -> Result { - let mut context = Self::universal_location(); - let mut junctions = Here; - for _ in 0..location.parent_count() { - junctions = junctions - .pushed_with(context.take_first().unwrap_or(OnlyChild)) - .map_err(|_| ())?; - } - let parents = location.interior().len() as u8; - Ok(MultiLocation::new(parents, junctions)) - } - - /// Return the location of the local consensus system within the known Universe. - fn universal_location() -> InteriorMultiLocation; -} diff --git a/xcm/xcm-executor/src/traits/mod.rs b/xcm/xcm-executor/src/traits/mod.rs index 4ad216effde6..ead19f79eea5 100644 --- a/xcm/xcm-executor/src/traits/mod.rs +++ b/xcm/xcm-executor/src/traits/mod.rs @@ -17,9 +17,7 @@ //! Various traits used in configuring the executor. mod conversion; -pub use conversion::{ - Convert, ConvertOrigin, Decoded, Encoded, Identity, JustTry, UniversalLocation, -}; +pub use conversion::{Convert, ConvertOrigin, Decoded, Encoded, Identity, JustTry}; mod drop_assets; pub use drop_assets::{ClaimAssets, DropAssets}; mod asset_lock; @@ -51,7 +49,7 @@ pub mod prelude { export_xcm, validate_export, AssetExchange, AssetLock, ClaimAssets, Convert, ConvertOrigin, Decoded, DropAssets, Enact, Encoded, Error, ExportXcm, FeeManager, FeeReason, Identity, JustTry, LockError, MatchesFungible, MatchesFungibles, MatchesNonFungible, - MatchesNonFungibles, OnResponse, ShouldExecute, TransactAsset, UniversalLocation, - VersionChangeNotifier, WeightBounds, WeightTrader, + MatchesNonFungibles, OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, + WeightBounds, WeightTrader, }; } diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 36c63ec014e0..4147ac3a408a 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -39,9 +39,8 @@ use xcm::{latest::prelude::*, VersionedXcm}; use xcm_builder::{ Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, - IsConcrete, LocationInverter, NativeAsset, NonFungiblesAdapter, ParentIsPreset, - SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, + IsConcrete, NativeAsset, NonFungiblesAdapter, ParentIsPreset, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, }; use xcm_executor::{ traits::{Convert, JustTry}, @@ -222,7 +221,7 @@ impl Config for XcmConfig { type OriginConverter = XcmOriginToCallOrigin; type IsReserve = (NativeAsset, TrustedReserves); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -395,7 +394,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index 53b06a32648e..b7a7a13f0bf6 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -31,8 +31,8 @@ use xcm_builder::{ Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, - FixedWeightBounds, IsConcrete, LocationInverter, NonFungiblesAdapter, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, + FixedWeightBounds, IsConcrete, NonFungiblesAdapter, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, }; use xcm_executor::{traits::JustTry, Config, XcmExecutor}; @@ -165,7 +165,7 @@ impl Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = (); - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -195,7 +195,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index 620563067469..58ad7a95136c 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -38,9 +38,9 @@ use polkadot_parachain::primitives::{ use xcm::{latest::prelude::*, VersionedXcm}; use xcm_builder::{ AccountId32Aliases, AllowUnpaidExecutionFrom, CurrencyAdapter as XcmCurrencyAdapter, - EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, IsConcrete, LocationInverter, - NativeAsset, ParentIsPreset, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, + EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, IsConcrete, NativeAsset, + ParentIsPreset, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, }; use xcm_executor::{Config, XcmExecutor}; @@ -140,7 +140,7 @@ impl Config for XcmConfig { type OriginConverter = XcmOriginToCallOrigin; type IsReserve = NativeAsset; type IsTeleporter = (); - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -314,7 +314,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 1e77d3ec9f69..4a0267214a8a 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -31,7 +31,7 @@ use xcm_builder::{ AccountId32Aliases, AllowUnpaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds, IsConcrete, - LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, }; use xcm_executor::{Config, XcmExecutor}; @@ -97,7 +97,7 @@ parameter_types! { pub const TokenLocation: MultiLocation = Here.into_location(); pub const ThisNetwork: NetworkId = NetworkId::ByGenesis([0; 32]); pub const AnyNetwork: Option = None; - pub const Ancestry: InteriorMultiLocation = Here; + pub const UniversalLocation: InteriorMultiLocation = Here; pub const UnitWeightCost: Weight = 1_000; } @@ -132,7 +132,7 @@ impl Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = (); - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -162,7 +162,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;