mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +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
@@ -215,7 +215,7 @@ pub type AmbassadorSalaryInstance = pallet_salary::Instance2;
|
||||
parameter_types! {
|
||||
// The interior location on AssetHub for the paying account. This is the Ambassador Salary
|
||||
// pallet instance (which sits at index 74). This sovereign account will need funding.
|
||||
pub AmbassadorSalaryLocation: InteriorMultiLocation = PalletInstance(74).into();
|
||||
pub AmbassadorSalaryLocation: InteriorLocation = PalletInstance(74).into();
|
||||
}
|
||||
|
||||
/// [`PayOverXcm`] setup to pay the Ambassador salary on the AssetHub in WND.
|
||||
|
||||
@@ -43,7 +43,7 @@ use parachains_common::{
|
||||
westend::{account, currency::GRAND},
|
||||
};
|
||||
use polkadot_runtime_common::impls::{
|
||||
LocatableAssetConverter, VersionedLocatableAsset, VersionedMultiLocationConverter,
|
||||
LocatableAssetConverter, VersionedLocatableAsset, VersionedLocationConverter,
|
||||
};
|
||||
use sp_arithmetic::Permill;
|
||||
use sp_core::{ConstU128, ConstU32};
|
||||
@@ -202,7 +202,7 @@ pub type FellowshipSalaryInstance = pallet_salary::Instance1;
|
||||
parameter_types! {
|
||||
// The interior location on AssetHub for the paying account. This is the Fellowship Salary
|
||||
// pallet instance (which sits at index 64). This sovereign account will need funding.
|
||||
pub Interior: InteriorMultiLocation = PalletInstance(64).into();
|
||||
pub Interior: InteriorLocation = PalletInstance(64).into();
|
||||
}
|
||||
|
||||
const USDT_UNITS: u128 = 1_000_000;
|
||||
@@ -250,7 +250,7 @@ parameter_types! {
|
||||
pub const MaxBalance: Balance = Balance::max_value();
|
||||
// The asset's interior location for the paying account. This is the Fellowship Treasury
|
||||
// pallet instance (which sits at index 65).
|
||||
pub FellowshipTreasuryInteriorLocation: InteriorMultiLocation = PalletInstance(65).into();
|
||||
pub FellowshipTreasuryInteriorLocation: InteriorLocation = PalletInstance(65).into();
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
@@ -269,10 +269,10 @@ pub type FellowshipTreasuryPaymaster = PayOverXcm<
|
||||
crate::xcm_config::XcmRouter,
|
||||
crate::PolkadotXcm,
|
||||
ConstU32<{ 6 * HOURS }>,
|
||||
VersionedMultiLocation,
|
||||
VersionedLocation,
|
||||
VersionedLocatableAsset,
|
||||
LocatableAssetConverter,
|
||||
VersionedMultiLocationConverter,
|
||||
VersionedLocationConverter,
|
||||
>;
|
||||
|
||||
pub type FellowshipTreasuryInstance = pallet_treasury::Instance1;
|
||||
@@ -327,7 +327,7 @@ impl pallet_treasury::Config<FellowshipTreasuryInstance> for Runtime {
|
||||
>,
|
||||
>;
|
||||
type AssetKind = VersionedLocatableAsset;
|
||||
type Beneficiary = VersionedMultiLocation;
|
||||
type Beneficiary = VersionedLocation;
|
||||
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
type Paymaster = FellowshipTreasuryPaymaster;
|
||||
|
||||
@@ -427,7 +427,7 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}
|
||||
|
||||
parameter_types! {
|
||||
/// The asset ID for the asset that we use to pay for message delivery fees.
|
||||
pub FeeAssetId: AssetId = Concrete(xcm_config::WndLocation::get());
|
||||
pub FeeAssetId: AssetId = AssetId(xcm_config::WndLocation::get());
|
||||
/// The base fee for the message delivery fees.
|
||||
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
||||
}
|
||||
@@ -974,28 +974,28 @@ impl_runtime_apis! {
|
||||
|
||||
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
|
||||
impl pallet_xcm::benchmarking::Config for Runtime {
|
||||
fn reachable_dest() -> Option<MultiLocation> {
|
||||
fn reachable_dest() -> Option<Location> {
|
||||
Some(Parent.into())
|
||||
}
|
||||
|
||||
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
||||
fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||
// Relay/native token can be teleported between Collectives and Relay.
|
||||
Some((
|
||||
MultiAsset {
|
||||
Asset {
|
||||
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
||||
id: Concrete(Parent.into())
|
||||
id: AssetId(Parent.into())
|
||||
}.into(),
|
||||
Parent.into(),
|
||||
))
|
||||
}
|
||||
|
||||
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
||||
fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||
// Reserve transfers are disabled on Collectives.
|
||||
None
|
||||
}
|
||||
|
||||
fn set_up_complex_asset_transfer(
|
||||
) -> Option<(MultiAssets, u32, MultiLocation, Box<dyn FnOnce()>)> {
|
||||
) -> Option<(Assets, u32, Location, Box<dyn FnOnce()>)> {
|
||||
// Collectives only supports teleports to system parachain.
|
||||
// Relay/native token can be teleported between Collectives and Relay.
|
||||
let native_location = Parent.into();
|
||||
|
||||
@@ -19,7 +19,7 @@ use super::{
|
||||
TransactionByteFee, WeightToFee, WestendTreasuryAccount, XcmpQueue,
|
||||
};
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
parameter_types,
|
||||
traits::{ConstU32, Contains, Equals, Everything, Nothing},
|
||||
weights::Weight,
|
||||
};
|
||||
@@ -51,17 +51,17 @@ use xcm_builder::{
|
||||
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
||||
|
||||
parameter_types! {
|
||||
pub const WndLocation: MultiLocation = MultiLocation::parent();
|
||||
pub const WndLocation: Location = Location::parent();
|
||||
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Westend);
|
||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||
pub UniversalLocation: InteriorMultiLocation =
|
||||
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into()));
|
||||
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(westend_runtime_constants::TREASURY_PALLET_ID)).into();
|
||||
pub UniversalLocation: InteriorLocation =
|
||||
[GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())].into();
|
||||
pub RelayTreasuryLocation: Location = (Parent, PalletInstance(westend_runtime_constants::TREASURY_PALLET_ID)).into();
|
||||
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
||||
pub const GovernanceLocation: MultiLocation = MultiLocation::parent();
|
||||
pub const GovernanceLocation: Location = Location::parent();
|
||||
pub const FellowshipAdminBodyId: BodyId = BodyId::Index(xcm_constants::body::FELLOWSHIP_ADMIN_INDEX);
|
||||
pub AssetHub: Location = (Parent, Parachain(1000)).into();
|
||||
pub const TreasurerBodyId: BodyId = BodyId::Index(xcm_constants::body::TREASURER_INDEX);
|
||||
pub AssetHub: MultiLocation = (Parent, Parachain(1000)).into();
|
||||
pub AssetHubUsdtId: AssetId = (PalletInstance(50), GeneralIndex(1984)).into();
|
||||
pub UsdtAssetHub: LocatableAssetId = LocatableAssetId {
|
||||
location: AssetHub::get(),
|
||||
@@ -73,7 +73,7 @@ parameter_types! {
|
||||
};
|
||||
}
|
||||
|
||||
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
|
||||
/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
|
||||
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
||||
/// `Transact` in order to determine the dispatch Origin.
|
||||
pub type LocationToAccountId = (
|
||||
@@ -92,7 +92,7 @@ pub type CurrencyTransactor = CurrencyAdapter<
|
||||
Balances,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
IsConcrete<WndLocation>,
|
||||
// Convert an XCM MultiLocation into a local account id:
|
||||
// Convert an XCM Location into a local account id:
|
||||
LocationToAccountId,
|
||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||
AccountId,
|
||||
@@ -136,11 +136,11 @@ parameter_types! {
|
||||
pub const FellowsBodyId: BodyId = BodyId::Technical;
|
||||
}
|
||||
|
||||
match_types! {
|
||||
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 1, interior: Here } |
|
||||
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
|
||||
};
|
||||
pub struct ParentOrParentsPlurality;
|
||||
impl Contains<Location> for ParentOrParentsPlurality {
|
||||
fn contains(location: &Location) -> bool {
|
||||
matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
|
||||
}
|
||||
}
|
||||
|
||||
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
||||
@@ -292,7 +292,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type Aliasers = Nothing;
|
||||
}
|
||||
|
||||
/// Converts a local signed origin into an XCM multilocation.
|
||||
/// Converts a local signed origin into an XCM location.
|
||||
/// Forms the basis for local origins sending/executing XCMs.
|
||||
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
|
||||
|
||||
@@ -310,10 +310,10 @@ pub type XcmRouter = WithUniqueTopic<(
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
|
||||
pub ReachableDest: Option<Location> = Some(Parent.into());
|
||||
}
|
||||
|
||||
/// 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>;
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
|
||||
Reference in New Issue
Block a user