# 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:
Francisco Aguirre
2024-01-16 19:18:04 +01:00
committed by GitHub
parent ec7bfae00a
commit 8428f678fe
255 changed files with 12425 additions and 6726 deletions
@@ -26,10 +26,7 @@ pub mod pallet {
use frame_benchmarking::BenchmarkError;
use frame_support::{dispatch::GetDispatchInfo, pallet_prelude::Encode};
use sp_runtime::traits::Dispatchable;
use xcm::latest::{
InteriorMultiLocation, Junction, MultiAsset, MultiAssets, MultiLocation, NetworkId,
Response,
};
use xcm::latest::{Asset, Assets, InteriorLocation, Junction, Location, NetworkId, Response};
#[pallet::config]
pub trait Config<I: 'static = ()>: frame_system::Config + crate::Config {
@@ -53,44 +50,44 @@ pub mod pallet {
/// from, whereas the second element represents the assets that are being exchanged to.
///
/// If set to `Err`, benchmarks which rely on an `exchange_asset` will be skipped.
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError>;
fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError>;
/// A `(MultiLocation, Junction)` that is one of the `UniversalAliases` configured by the
/// A `(Location, Junction)` that is one of the `UniversalAliases` configured by the
/// XCM executor.
///
/// If set to `Err`, benchmarks which rely on a universal alias will be skipped.
fn universal_alias() -> Result<(MultiLocation, Junction), BenchmarkError>;
fn universal_alias() -> Result<(Location, Junction), BenchmarkError>;
/// The `MultiLocation` and `RuntimeCall` used for successful transaction XCMs.
/// The `Location` and `RuntimeCall` used for successful transaction XCMs.
///
/// If set to `Err`, benchmarks which rely on a `transact_origin_and_runtime_call` will be
/// skipped.
fn transact_origin_and_runtime_call(
) -> Result<(MultiLocation, <Self as crate::generic::Config<I>>::RuntimeCall), BenchmarkError>;
) -> Result<(Location, <Self as crate::generic::Config<I>>::RuntimeCall), BenchmarkError>;
/// A valid `MultiLocation` we can successfully subscribe to.
/// A valid `Location` we can successfully subscribe to.
///
/// If set to `Err`, benchmarks which rely on a `subscribe_origin` will be skipped.
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError>;
fn subscribe_origin() -> Result<Location, BenchmarkError>;
/// Return an origin, ticket, and assets that can be trapped and claimed.
fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError>;
fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError>;
/// Return an unlocker, owner and assets that can be locked and unlocked.
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError>;
fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError>;
/// A `(MultiLocation, NetworkId, InteriorMultiLocation)` we can successfully export message
/// A `(Location, NetworkId, InteriorLocation)` we can successfully export message
/// to.
///
/// If set to `Err`, benchmarks which rely on `export_message` will be skipped.
fn export_message_origin_and_destination(
) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError>;
) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError>;
/// A `(MultiLocation, MultiLocation)` that is one of the `Aliasers` configured by the XCM
/// A `(Location, Location)` that is one of the `Aliasers` configured by the XCM
/// executor.
///
/// If set to `Err`, benchmarks which rely on a universal alias will be skipped.
fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError>;
fn alias_origin() -> Result<(Location, Location), BenchmarkError>;
/// Returns a valid pallet info for `ExpectPallet` or `QueryPallet` benchmark.
///