mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 18:05:41 +00:00
XCMv4 (#1230)
# Note for reviewer
Most changes are just syntax changes necessary for the new version.
Most important files should be the ones under the `xcm` folder.
# Description
Added XCMv4.
## Removed `Multi` prefix
The following types have been renamed:
- MultiLocation -> Location
- MultiAsset -> Asset
- MultiAssets -> Assets
- InteriorMultiLocation -> InteriorLocation
- MultiAssetFilter -> AssetFilter
- VersionedMultiAsset -> VersionedAsset
- WildMultiAsset -> WildAsset
- VersionedMultiLocation -> VersionedLocation
In order to fix a name conflict, the `Assets` in `xcm-executor` were
renamed to `HoldingAssets`, as they represent assets in holding.
## Removed `Abstract` asset id
It was not being used anywhere and this simplifies the code.
Now assets are just constructed as follows:
```rust
let asset: Asset = (AssetId(Location::new(1, Here)), 100u128).into();
```
No need for specifying `Concrete` anymore.
## Outcome is now a named fields struct
Instead of
```rust
pub enum Outcome {
Complete(Weight),
Incomplete(Weight, Error),
Error(Error),
}
```
we now have
```rust
pub enum Outcome {
Complete { used: Weight },
Incomplete { used: Weight, error: Error },
Error { error: Error },
}
```
## Added Reanchorable trait
Now both locations and assets implement this trait, making it easier to
reanchor both.
## New syntax for building locations and junctions
Now junctions are built using the following methods:
```rust
let location = Location {
parents: 1,
interior: [Parachain(1000), PalletInstance(50), GeneralIndex(1984)].into()
};
```
or
```rust
let location = Location::new(1, [Parachain(1000), PalletInstance(50), GeneralIndex(1984)]);
```
And they are matched like so:
```rust
match location.unpack() {
(1, [Parachain(id)]) => ...
(0, Here) => ...,
(1, [_]) => ...,
}
```
This syntax is mandatory in v4, and has been also implemented for v2 and
v3 for easier migration.
This was needed to make all sizes smaller.
# TODO
- [x] Scaffold v4
- [x] Port github.com/paritytech/polkadot/pull/7236
- [x] Remove `Multi` prefix
- [x] Remove `Abstract` asset id
---------
Co-authored-by: command-bot <>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
This commit is contained in:
committed by
GitHub
parent
ec7bfae00a
commit
8428f678fe
@@ -22,7 +22,7 @@ use primitives::Balance;
|
||||
use rococo_runtime_constants::currency::*;
|
||||
use runtime_common::identity_migrator::{OnReapIdentity, WeightInfo};
|
||||
use sp_std::{marker::PhantomData, prelude::*};
|
||||
use xcm::{latest::prelude::*, VersionedMultiLocation, VersionedXcm};
|
||||
use xcm::{latest::prelude::*, VersionedLocation, VersionedXcm};
|
||||
use xcm_executor::traits::TransactAsset;
|
||||
|
||||
/// A type containing the encoding of the People Chain pallets in its runtime. Used to construct any
|
||||
@@ -95,9 +95,9 @@ where
|
||||
let total_to_send = Self::calculate_remote_deposit(fields, subs);
|
||||
|
||||
// define asset / destination from relay perspective
|
||||
let roc = MultiAsset { id: Concrete(Here.into_location()), fun: Fungible(total_to_send) };
|
||||
let roc = Asset { id: AssetId(Here.into_location()), fun: Fungible(total_to_send) };
|
||||
// People Chain: ParaId 1004
|
||||
let destination: MultiLocation = MultiLocation::new(0, Parachain(1004));
|
||||
let destination: Location = Location::new(0, Parachain(1004));
|
||||
|
||||
// Do `check_out` accounting since the XCM Executor's `InitiateTeleport` doesn't support
|
||||
// unpaid teleports.
|
||||
@@ -138,11 +138,9 @@ where
|
||||
);
|
||||
|
||||
// reanchor
|
||||
let roc_reanchored: MultiAssets = vec![MultiAsset {
|
||||
id: Concrete(MultiLocation::new(1, Here)),
|
||||
fun: Fungible(total_to_send),
|
||||
}]
|
||||
.into();
|
||||
let roc_reanchored: Assets =
|
||||
vec![Asset { id: AssetId(Location::new(1, Here)), fun: Fungible(total_to_send) }]
|
||||
.into();
|
||||
|
||||
let poke = PeopleRuntimePallets::<AccountId>::IdentityMigrator(PokeDeposit(who.clone()));
|
||||
let remote_weight_limit = MigratorWeights::<Runtime>::poke_deposit().saturating_mul(2);
|
||||
@@ -172,8 +170,8 @@ where
|
||||
// send
|
||||
let _ = <pallet_xcm::Pallet<Runtime>>::send(
|
||||
RawOrigin::Root.into(),
|
||||
Box::new(VersionedMultiLocation::V3(destination)),
|
||||
Box::new(VersionedXcm::V3(program)),
|
||||
Box::new(VersionedLocation::V4(destination)),
|
||||
Box::new(VersionedXcm::V4(program)),
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ use rococo_runtime_constants::system_parachain::BROKER_ID;
|
||||
use runtime_common::{
|
||||
assigned_slots, auctions, claims, crowdloan, identity_migrator, impl_runtime_weights,
|
||||
impls::{
|
||||
LocatableAssetConverter, ToAuthor, VersionedLocatableAsset, VersionedMultiLocationConverter,
|
||||
LocatableAssetConverter, ToAuthor, VersionedLocatableAsset, VersionedLocationConverter,
|
||||
},
|
||||
paras_registrar, paras_sudo_wrapper, prod_or_fast, slots,
|
||||
traits::Leaser,
|
||||
@@ -99,10 +99,7 @@ use sp_staking::SessionIndex;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use sp_version::NativeVersion;
|
||||
use sp_version::RuntimeVersion;
|
||||
use xcm::{
|
||||
latest::{InteriorMultiLocation, Junction, Junction::PalletInstance},
|
||||
VersionedMultiLocation,
|
||||
};
|
||||
use xcm::{latest::prelude::*, VersionedLocation};
|
||||
use xcm_builder::PayOverXcm;
|
||||
|
||||
pub use frame_system::Call as SystemCall;
|
||||
@@ -461,7 +458,7 @@ parameter_types! {
|
||||
pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
|
||||
// The asset's interior location for the paying account. This is the Treasury
|
||||
// pallet instance (which sits at index 18).
|
||||
pub TreasuryInteriorLocation: InteriorMultiLocation = PalletInstance(18).into();
|
||||
pub TreasuryInteriorLocation: InteriorLocation = PalletInstance(18).into();
|
||||
|
||||
pub const TipCountdown: BlockNumber = 1 * DAYS;
|
||||
pub const TipFindersFee: Percent = Percent::from_percent(20);
|
||||
@@ -492,7 +489,7 @@ impl pallet_treasury::Config for Runtime {
|
||||
type SpendFunds = Bounties;
|
||||
type SpendOrigin = TreasurySpender;
|
||||
type AssetKind = VersionedLocatableAsset;
|
||||
type Beneficiary = VersionedMultiLocation;
|
||||
type Beneficiary = VersionedLocation;
|
||||
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
|
||||
type Paymaster = PayOverXcm<
|
||||
TreasuryInteriorLocation,
|
||||
@@ -502,7 +499,7 @@ impl pallet_treasury::Config for Runtime {
|
||||
Self::Beneficiary,
|
||||
Self::AssetKind,
|
||||
LocatableAssetConverter,
|
||||
VersionedMultiLocationConverter,
|
||||
VersionedLocationConverter,
|
||||
>;
|
||||
type BalanceConverter = AssetRate;
|
||||
type PayoutPeriod = PayoutSpendPeriod;
|
||||
@@ -538,7 +535,7 @@ impl pallet_bounties::Config for Runtime {
|
||||
|
||||
parameter_types! {
|
||||
pub const MaxActiveChildBountyCount: u32 = 100;
|
||||
pub const ChildBountyValueMinimum: Balance = BountyValueMinimum::get() / 10;
|
||||
pub ChildBountyValueMinimum: Balance = BountyValueMinimum::get() / 10;
|
||||
}
|
||||
|
||||
impl pallet_child_bounties::Config for Runtime {
|
||||
@@ -1209,7 +1206,7 @@ impl pallet_nis::Config for Runtime {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const BeefySetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
|
||||
pub BeefySetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
|
||||
}
|
||||
|
||||
impl pallet_beefy::Config for Runtime {
|
||||
@@ -2270,7 +2267,7 @@ sp_api::impl_runtime_apis! {
|
||||
};
|
||||
|
||||
parameter_types! {
|
||||
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
|
||||
pub ExistentialDepositAsset: Option<Asset> = Some((
|
||||
TokenLocation::get(),
|
||||
ExistentialDeposit::get()
|
||||
).into());
|
||||
@@ -2280,34 +2277,34 @@ sp_api::impl_runtime_apis! {
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
impl frame_benchmarking::baseline::Config for Runtime {}
|
||||
impl pallet_xcm::benchmarking::Config for Runtime {
|
||||
fn reachable_dest() -> Option<MultiLocation> {
|
||||
fn reachable_dest() -> Option<Location> {
|
||||
Some(crate::xcm_config::AssetHub::get())
|
||||
}
|
||||
|
||||
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
||||
fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||
// Relay/native token can be teleported to/from AH.
|
||||
Some((
|
||||
MultiAsset {
|
||||
Asset {
|
||||
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
||||
id: Concrete(Here.into())
|
||||
id: AssetId(Here.into())
|
||||
},
|
||||
crate::xcm_config::AssetHub::get(),
|
||||
))
|
||||
}
|
||||
|
||||
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
||||
fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||
// Relay can reserve transfer native token to some random parachain.
|
||||
Some((
|
||||
MultiAsset {
|
||||
Asset {
|
||||
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
||||
id: Concrete(Here.into())
|
||||
id: AssetId(Here.into())
|
||||
},
|
||||
Parachain(43211234).into(),
|
||||
))
|
||||
}
|
||||
|
||||
fn set_up_complex_asset_transfer(
|
||||
) -> Option<(MultiAssets, u32, MultiLocation, Box<dyn FnOnce()>)> {
|
||||
) -> Option<(Assets, u32, Location, Box<dyn FnOnce()>)> {
|
||||
// Relay supports only native token, either reserve transfer it to non-system parachains,
|
||||
// or teleport it to system parachain. Use the teleport case for benchmarking as it's
|
||||
// slightly heavier.
|
||||
@@ -2325,29 +2322,29 @@ sp_api::impl_runtime_apis! {
|
||||
type AccountIdConverter = LocationConverter;
|
||||
type DeliveryHelper = runtime_common::xcm_sender::ToParachainDeliveryHelper<
|
||||
XcmConfig,
|
||||
ExistentialDepositMultiAsset,
|
||||
ExistentialDepositAsset,
|
||||
xcm_config::PriceForChildParachainDelivery,
|
||||
ToParachain,
|
||||
(),
|
||||
>;
|
||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
||||
fn valid_destination() -> Result<Location, BenchmarkError> {
|
||||
Ok(AssetHub::get())
|
||||
}
|
||||
fn worst_case_holding(_depositable_count: u32) -> MultiAssets {
|
||||
fn worst_case_holding(_depositable_count: u32) -> Assets {
|
||||
// Rococo only knows about ROC
|
||||
vec![MultiAsset{
|
||||
id: Concrete(TokenLocation::get()),
|
||||
vec![Asset{
|
||||
id: AssetId(TokenLocation::get()),
|
||||
fun: Fungible(1_000_000 * UNITS),
|
||||
}].into()
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
|
||||
pub TrustedTeleporter: Option<(Location, Asset)> = Some((
|
||||
AssetHub::get(),
|
||||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) },
|
||||
Asset { fun: Fungible(1 * UNITS), id: AssetId(TokenLocation::get()) },
|
||||
));
|
||||
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None;
|
||||
pub TrustedReserve: Option<(Location, Asset)> = None;
|
||||
}
|
||||
|
||||
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
|
||||
@@ -2357,9 +2354,9 @@ sp_api::impl_runtime_apis! {
|
||||
type TrustedTeleporter = TrustedTeleporter;
|
||||
type TrustedReserve = TrustedReserve;
|
||||
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
id: Concrete(TokenLocation::get()),
|
||||
fn get_asset() -> Asset {
|
||||
Asset {
|
||||
id: AssetId(TokenLocation::get()),
|
||||
fun: Fungible(1 * UNITS),
|
||||
}
|
||||
}
|
||||
@@ -2373,43 +2370,43 @@ sp_api::impl_runtime_apis! {
|
||||
(0u64, Response::Version(Default::default()))
|
||||
}
|
||||
|
||||
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> {
|
||||
fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
|
||||
// Rococo doesn't support asset exchanges
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn universal_alias() -> Result<(MultiLocation, Junction), BenchmarkError> {
|
||||
fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
|
||||
// The XCM executor of Rococo doesn't have a configured `UniversalAliases`
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> {
|
||||
fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
|
||||
Ok((AssetHub::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
||||
}
|
||||
|
||||
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
fn subscribe_origin() -> Result<Location, BenchmarkError> {
|
||||
Ok(AssetHub::get())
|
||||
}
|
||||
|
||||
fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> {
|
||||
fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
|
||||
let origin = AssetHub::get();
|
||||
let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into();
|
||||
let ticket = MultiLocation { parents: 0, interior: Here };
|
||||
let assets: Assets = (AssetId(TokenLocation::get()), 1_000 * UNITS).into();
|
||||
let ticket = Location { parents: 0, interior: Here };
|
||||
Ok((origin, ticket, assets))
|
||||
}
|
||||
|
||||
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> {
|
||||
fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
|
||||
// Rococo doesn't support asset locking
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn export_message_origin_and_destination(
|
||||
) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError> {
|
||||
) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
|
||||
// Rococo doesn't support exporting messages
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError> {
|
||||
fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
|
||||
// The XCM executor of Rococo doesn't have a configured `Aliasers`
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
@@ -33,25 +33,25 @@ pub enum AssetTypes {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
impl From<&MultiAsset> for AssetTypes {
|
||||
fn from(asset: &MultiAsset) -> Self {
|
||||
impl From<&Asset> for AssetTypes {
|
||||
fn from(asset: &Asset) -> Self {
|
||||
match asset {
|
||||
MultiAsset { id: Concrete(MultiLocation { parents: 0, interior: Here }), .. } =>
|
||||
Asset { id: AssetId(Location { parents: 0, interior: Here }), .. } =>
|
||||
AssetTypes::Balances,
|
||||
_ => AssetTypes::Unknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait WeighMultiAssets {
|
||||
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight;
|
||||
trait WeighAssets {
|
||||
fn weigh_assets(&self, balances_weight: Weight) -> Weight;
|
||||
}
|
||||
|
||||
// Rococo only knows about one asset, the balances pallet.
|
||||
const MAX_ASSETS: u64 = 1;
|
||||
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight {
|
||||
impl WeighAssets for AssetFilter {
|
||||
fn weigh_assets(&self, balances_weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) => assets
|
||||
.inner()
|
||||
@@ -72,11 +72,11 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
}
|
||||
}
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight {
|
||||
impl WeighAssets for Assets {
|
||||
fn weigh_assets(&self, balances_weight: Weight) -> Weight {
|
||||
self.inner()
|
||||
.into_iter()
|
||||
.map(|m| <AssetTypes as From<&MultiAsset>>::from(m))
|
||||
.map(|m| <AssetTypes as From<&Asset>>::from(m))
|
||||
.map(|t| match t {
|
||||
AssetTypes::Balances => balances_weight,
|
||||
AssetTypes::Unknown => Weight::MAX,
|
||||
@@ -87,32 +87,28 @@ impl WeighMultiAssets for MultiAssets {
|
||||
|
||||
pub struct RococoXcmWeight<RuntimeCall>(core::marker::PhantomData<RuntimeCall>);
|
||||
impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for RococoXcmWeight<RuntimeCall> {
|
||||
fn withdraw_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::withdraw_asset())
|
||||
fn withdraw_asset(assets: &Assets) -> Weight {
|
||||
assets.weigh_assets(XcmBalancesWeight::<Runtime>::withdraw_asset())
|
||||
}
|
||||
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::reserve_asset_deposited())
|
||||
fn reserve_asset_deposited(assets: &Assets) -> Weight {
|
||||
assets.weigh_assets(XcmBalancesWeight::<Runtime>::reserve_asset_deposited())
|
||||
}
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::receive_teleported_asset())
|
||||
fn receive_teleported_asset(assets: &Assets) -> Weight {
|
||||
assets.weigh_assets(XcmBalancesWeight::<Runtime>::receive_teleported_asset())
|
||||
}
|
||||
fn query_response(
|
||||
_query_id: &u64,
|
||||
_response: &Response,
|
||||
_max_weight: &Weight,
|
||||
_querier: &Option<MultiLocation>,
|
||||
_querier: &Option<Location>,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::query_response()
|
||||
}
|
||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::transfer_asset())
|
||||
fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight {
|
||||
assets.weigh_assets(XcmBalancesWeight::<Runtime>::transfer_asset())
|
||||
}
|
||||
fn transfer_reserve_asset(
|
||||
assets: &MultiAssets,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::transfer_reserve_asset())
|
||||
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||
assets.weigh_assets(XcmBalancesWeight::<Runtime>::transfer_reserve_asset())
|
||||
}
|
||||
fn transact(
|
||||
_origin_kind: &OriginKind,
|
||||
@@ -140,45 +136,37 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for RococoXcmWeight<RuntimeCall> {
|
||||
fn clear_origin() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_origin()
|
||||
}
|
||||
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
|
||||
fn descend_origin(_who: &InteriorLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::descend_origin()
|
||||
}
|
||||
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_error()
|
||||
}
|
||||
|
||||
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::deposit_asset())
|
||||
fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight {
|
||||
assets.weigh_assets(XcmBalancesWeight::<Runtime>::deposit_asset())
|
||||
}
|
||||
fn deposit_reserve_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::deposit_reserve_asset())
|
||||
fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||
assets.weigh_assets(XcmBalancesWeight::<Runtime>::deposit_reserve_asset())
|
||||
}
|
||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight {
|
||||
fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight {
|
||||
// Rococo does not currently support exchange asset operations
|
||||
Weight::MAX
|
||||
}
|
||||
fn initiate_reserve_withdraw(
|
||||
assets: &MultiAssetFilter,
|
||||
_reserve: &MultiLocation,
|
||||
assets: &AssetFilter,
|
||||
_reserve: &Location,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::initiate_reserve_withdraw())
|
||||
assets.weigh_assets(XcmBalancesWeight::<Runtime>::initiate_reserve_withdraw())
|
||||
}
|
||||
fn initiate_teleport(
|
||||
assets: &MultiAssetFilter,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::initiate_teleport())
|
||||
fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||
assets.weigh_assets(XcmBalancesWeight::<Runtime>::initiate_teleport())
|
||||
}
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_holding()
|
||||
}
|
||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
|
||||
fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight {
|
||||
XcmGeneric::<Runtime>::buy_execution()
|
||||
}
|
||||
fn refund_surplus() -> Weight {
|
||||
@@ -193,7 +181,7 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for RococoXcmWeight<RuntimeCall> {
|
||||
fn clear_error() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_error()
|
||||
}
|
||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
|
||||
fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight {
|
||||
XcmGeneric::<Runtime>::claim_asset()
|
||||
}
|
||||
fn trap(_code: &u64) -> Weight {
|
||||
@@ -205,13 +193,13 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for RococoXcmWeight<RuntimeCall> {
|
||||
fn unsubscribe_version() -> Weight {
|
||||
XcmGeneric::<Runtime>::unsubscribe_version()
|
||||
}
|
||||
fn burn_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
|
||||
fn burn_asset(assets: &Assets) -> Weight {
|
||||
assets.weigh_assets(XcmGeneric::<Runtime>::burn_asset())
|
||||
}
|
||||
fn expect_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
|
||||
fn expect_asset(assets: &Assets) -> Weight {
|
||||
assets.weigh_assets(XcmGeneric::<Runtime>::expect_asset())
|
||||
}
|
||||
fn expect_origin(_origin: &Option<MultiLocation>) -> Weight {
|
||||
fn expect_origin(_origin: &Option<Location>) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_origin()
|
||||
}
|
||||
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
||||
@@ -246,19 +234,19 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for RococoXcmWeight<RuntimeCall> {
|
||||
// Rococo relay should not support export message operations
|
||||
Weight::MAX
|
||||
}
|
||||
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
fn lock_asset(_: &Asset, _: &Location) -> Weight {
|
||||
// Rococo does not currently support asset locking operations
|
||||
Weight::MAX
|
||||
}
|
||||
fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
fn unlock_asset(_: &Asset, _: &Location) -> Weight {
|
||||
// Rococo does not currently support asset locking operations
|
||||
Weight::MAX
|
||||
}
|
||||
fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
fn note_unlockable(_: &Asset, _: &Location) -> Weight {
|
||||
// Rococo does not currently support asset locking operations
|
||||
Weight::MAX
|
||||
}
|
||||
fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
fn request_unlock(_: &Asset, _: &Location) -> Weight {
|
||||
// Rococo does not currently support asset locking operations
|
||||
Weight::MAX
|
||||
}
|
||||
@@ -271,19 +259,19 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for RococoXcmWeight<RuntimeCall> {
|
||||
fn clear_topic() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_topic()
|
||||
}
|
||||
fn alias_origin(_: &MultiLocation) -> Weight {
|
||||
fn alias_origin(_: &Location) -> Weight {
|
||||
// XCM Executor does not currently support alias origin operations
|
||||
Weight::MAX
|
||||
}
|
||||
fn unpaid_execution(_: &WeightLimit, _: &Option<MultiLocation>) -> Weight {
|
||||
fn unpaid_execution(_: &WeightLimit, _: &Option<Location>) -> Weight {
|
||||
XcmGeneric::<Runtime>::unpaid_execution()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_counted_has_a_sane_weight_upper_limit() {
|
||||
let assets = MultiAssetFilter::Wild(AllCounted(4294967295));
|
||||
let assets = AssetFilter::Wild(AllCounted(4294967295));
|
||||
let weight = Weight::from_parts(1000, 1000);
|
||||
|
||||
assert_eq!(assets.weigh_multi_assets(weight), weight * MAX_ASSETS);
|
||||
assert_eq!(assets.weigh_assets(weight), weight * MAX_ASSETS);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ use super::{
|
||||
use crate::governance::StakingAdmin;
|
||||
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
traits::{Equals, Everything, Nothing},
|
||||
parameter_types,
|
||||
traits::{Contains, Equals, Everything, Nothing},
|
||||
weights::Weight,
|
||||
};
|
||||
use frame_system::EnsureRoot;
|
||||
@@ -50,10 +50,10 @@ use xcm_builder::{
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
parameter_types! {
|
||||
pub const RootLocation: MultiLocation = MultiLocation::here();
|
||||
pub const TokenLocation: MultiLocation = Here.into_location();
|
||||
pub TokenLocation: Location = Here.into_location();
|
||||
pub RootLocation: Location = Location::here();
|
||||
pub const ThisNetwork: NetworkId = NetworkId::Rococo;
|
||||
pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into();
|
||||
pub UniversalLocation: InteriorLocation = ThisNetwork::get().into();
|
||||
pub CheckAccount: AccountId = XcmPallet::check_account();
|
||||
pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local);
|
||||
pub TreasuryAccount: AccountId = Treasury::account_id();
|
||||
@@ -69,7 +69,7 @@ pub type LocationConverter = (
|
||||
);
|
||||
|
||||
/// Our asset transactor. This is what allows us to interest with the runtime facilities from the
|
||||
/// point of view of XCM-only concepts like `MultiLocation` and `MultiAsset`.
|
||||
/// point of view of XCM-only concepts like `Location` and `Asset`.
|
||||
///
|
||||
/// Ours is only aware of the Balances pallet, which is mapped to `RocLocation`.
|
||||
#[allow(deprecated)]
|
||||
@@ -78,7 +78,7 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter<
|
||||
Balances,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
IsConcrete<TokenLocation>,
|
||||
// We can convert the MultiLocations with our converter above:
|
||||
// We can convert the Locations with our converter above:
|
||||
LocationConverter,
|
||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||
AccountId,
|
||||
@@ -100,7 +100,7 @@ parameter_types! {
|
||||
/// The amount of weight an XCM operation takes. This is a safe overestimate.
|
||||
pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
|
||||
/// The asset ID for the asset that we use to pay for message delivery fees.
|
||||
pub FeeAssetId: AssetId = Concrete(TokenLocation::get());
|
||||
pub FeeAssetId: AssetId = AssetId(TokenLocation::get());
|
||||
/// The base fee for the message delivery fees.
|
||||
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
||||
}
|
||||
@@ -116,25 +116,25 @@ pub type XcmRouter = WithUniqueTopic<
|
||||
>;
|
||||
|
||||
parameter_types! {
|
||||
pub const Roc: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) });
|
||||
pub const AssetHub: MultiLocation = Parachain(ASSET_HUB_ID).into_location();
|
||||
pub const Contracts: MultiLocation = Parachain(CONTRACTS_ID).into_location();
|
||||
pub const Encointer: MultiLocation = Parachain(ENCOINTER_ID).into_location();
|
||||
pub const BridgeHub: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location();
|
||||
pub const People: MultiLocation = Parachain(PEOPLE_ID).into_location();
|
||||
pub const Broker: MultiLocation = Parachain(BROKER_ID).into_location();
|
||||
pub const Tick: MultiLocation = Parachain(100).into_location();
|
||||
pub const Trick: MultiLocation = Parachain(110).into_location();
|
||||
pub const Track: MultiLocation = Parachain(120).into_location();
|
||||
pub const RocForTick: (MultiAssetFilter, MultiLocation) = (Roc::get(), Tick::get());
|
||||
pub const RocForTrick: (MultiAssetFilter, MultiLocation) = (Roc::get(), Trick::get());
|
||||
pub const RocForTrack: (MultiAssetFilter, MultiLocation) = (Roc::get(), Track::get());
|
||||
pub const RocForAssetHub: (MultiAssetFilter, MultiLocation) = (Roc::get(), AssetHub::get());
|
||||
pub const RocForContracts: (MultiAssetFilter, MultiLocation) = (Roc::get(), Contracts::get());
|
||||
pub const RocForEncointer: (MultiAssetFilter, MultiLocation) = (Roc::get(), Encointer::get());
|
||||
pub const RocForBridgeHub: (MultiAssetFilter, MultiLocation) = (Roc::get(), BridgeHub::get());
|
||||
pub const RocForPeople: (MultiAssetFilter, MultiLocation) = (Roc::get(), People::get());
|
||||
pub const RocForBroker: (MultiAssetFilter, MultiLocation) = (Roc::get(), Broker::get());
|
||||
pub Roc: AssetFilter = Wild(AllOf { fun: WildFungible, id: AssetId(TokenLocation::get()) });
|
||||
pub AssetHub: Location = Parachain(ASSET_HUB_ID).into_location();
|
||||
pub Contracts: Location = Parachain(CONTRACTS_ID).into_location();
|
||||
pub Encointer: Location = Parachain(ENCOINTER_ID).into_location();
|
||||
pub BridgeHub: Location = Parachain(BRIDGE_HUB_ID).into_location();
|
||||
pub People: Location = Parachain(PEOPLE_ID).into_location();
|
||||
pub Broker: Location = Parachain(BROKER_ID).into_location();
|
||||
pub Tick: Location = Parachain(100).into_location();
|
||||
pub Trick: Location = Parachain(110).into_location();
|
||||
pub Track: Location = Parachain(120).into_location();
|
||||
pub RocForTick: (AssetFilter, Location) = (Roc::get(), Tick::get());
|
||||
pub RocForTrick: (AssetFilter, Location) = (Roc::get(), Trick::get());
|
||||
pub RocForTrack: (AssetFilter, Location) = (Roc::get(), Track::get());
|
||||
pub RocForAssetHub: (AssetFilter, Location) = (Roc::get(), AssetHub::get());
|
||||
pub RocForContracts: (AssetFilter, Location) = (Roc::get(), Contracts::get());
|
||||
pub RocForEncointer: (AssetFilter, Location) = (Roc::get(), Encointer::get());
|
||||
pub RocForBridgeHub: (AssetFilter, Location) = (Roc::get(), BridgeHub::get());
|
||||
pub RocForPeople: (AssetFilter, Location) = (Roc::get(), People::get());
|
||||
pub RocForBroker: (AssetFilter, Location) = (Roc::get(), Broker::get());
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
}
|
||||
@@ -150,13 +150,18 @@ pub type TrustedTeleporters = (
|
||||
xcm_builder::Case<RocForBroker>,
|
||||
);
|
||||
|
||||
match_types! {
|
||||
pub type OnlyParachains: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 0, interior: X1(Parachain(_)) }
|
||||
};
|
||||
pub type LocalPlurality: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 0, interior: X1(Plurality { .. }) }
|
||||
};
|
||||
pub struct OnlyParachains;
|
||||
impl Contains<Location> for OnlyParachains {
|
||||
fn contains(loc: &Location) -> bool {
|
||||
matches!(loc.unpack(), (0, [Parachain(_)]))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct LocalPlurality;
|
||||
impl Contains<Location> for LocalPlurality {
|
||||
fn contains(loc: &Location) -> bool {
|
||||
matches!(loc.unpack(), (0, [Plurality { .. }]))
|
||||
}
|
||||
}
|
||||
|
||||
/// The barriers one of which must be passed for an XCM message to be executed.
|
||||
@@ -227,26 +232,26 @@ parameter_types! {
|
||||
pub const FellowsBodyId: BodyId = BodyId::Technical;
|
||||
}
|
||||
|
||||
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior
|
||||
/// Type to convert an `Origin` type value into a `Location` value which represents an interior
|
||||
/// location of this chain.
|
||||
pub type LocalOriginToLocation = (
|
||||
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
|
||||
SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>,
|
||||
);
|
||||
|
||||
/// Type to convert the `StakingAdmin` origin to a Plurality `MultiLocation` value.
|
||||
/// Type to convert the `StakingAdmin` origin to a Plurality `Location` value.
|
||||
pub type StakingAdminToPlurality =
|
||||
OriginToPluralityVoice<RuntimeOrigin, StakingAdmin, StakingAdminBodyId>;
|
||||
|
||||
/// Type to convert the Fellows origin to a Plurality `MultiLocation` value.
|
||||
/// Type to convert the Fellows origin to a Plurality `Location` value.
|
||||
pub type FellowsToPlurality = OriginToPluralityVoice<RuntimeOrigin, Fellows, FellowsBodyId>;
|
||||
|
||||
/// Type to convert a pallet `Origin` type value into a `MultiLocation` value which represents an
|
||||
/// Type to convert a pallet `Origin` type value into a `Location` value which represents an
|
||||
/// interior location of this chain for a destination chain.
|
||||
pub type LocalPalletOriginToLocation = (
|
||||
// StakingAdmin origin to be used in XCM as a corresponding Plurality `MultiLocation` value.
|
||||
// StakingAdmin origin to be used in XCM as a corresponding Plurality `Location` value.
|
||||
StakingAdminToPlurality,
|
||||
// Fellows origin to be used in XCM as a corresponding Plurality `MultiLocation` value.
|
||||
// Fellows origin to be used in XCM as a corresponding Plurality `Location` value.
|
||||
FellowsToPlurality,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user