Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

XCM v1 #2815

Merged
merged 87 commits into from
Aug 6, 2021
Merged

XCM v1 #2815

merged 87 commits into from
Aug 6, 2021

Conversation

gavofyork
Copy link
Member

@gavofyork gavofyork commented Apr 4, 2021

A number of changes and renames to the XCM framework, with the centrepiece being a safer, more ergonomic MultiAsset where matching is a lot less verbose/tedious and the underlying code is simpler. Additionally, Assets has been largely rewritten, optimising a number of operations and removing a lot of superfluous code.

This fixes a number of issues with the existing MultiAsset:

  • No type safety over where masks should be allowed
  • Unspecified/incorrect behaviour where multiple wildcards are used in asset arithmetic
  • Overly complicated matching and construction code needed

It replaces the large, unwieldy and overly general MultiAsset with:

  • MultiAsset: A single asset type, either a single non-fungible instance or a non-zero amount of a fungible.
  • MultiAssets: A vec of MultiAsset, sorted, with no duplicate non-fungibles or repetitions of the same fungible.
  • WildMultiAsset: A wildcard which describes classes of assets; either All assets or all of a particular identified class of fungibles or non-fungibles.
  • MultiAssetFilter: A means of filtering a collection of assets. Takes the form of either a WildMultiAsset value or a MultiAssets value. Unlike with the old Vec<MultiAsset> paradigm, the two cannot be combined - it's either one wildcard or a list of definite assets.

A number of conversions are provided to allow ease of use:

  • u128::into() and AssetInstance::into() will convert into a Fungibility, as will anything which itself will convert into an AssetInstance.
  • Junction::into(), MultiLocation::into() and Vec::<u8>::into() will convert into a AssetId.
  • (), [u8; 4], [u8; 8], [u8; 16], [u8; 32] and Vec<u8> will convert into an AssetInstance. A u128 will NOT convert and must be stated explicitly with Index(u128), since otherwise this collides with the u128::into() of Fungibility.
  • (AssetId, Fungibility)::into() will convert into a MultiAsset or MultiAssets; AssetId and Fungibility can both be optionally substituted with a type that converts into them, allowing for e.g. (Junction, u128)::into().
  • Vec<MultiAsset>::into() will convert into MultiAssets and MultiAssetFilter
  • MultiAsset::into() and MultiAssets::into() will convert into MultiAssetFilter
  • (AssetId, WildFungibility)::into() will convert into a WildMultiAsset and MultiAssetFilter; AssetId can be optionally substituted with a type that converts into it.

Compatibility

The v0 API remains in place and unchanged with one minor exception (AssetInstance::Index moving from a struct item to a tuple item). XCM messages may be converted between v0::Xcm API and v1::Xcm API with .try_into(). VersionedXcm supports both.

Automatic backwards compatibility is provided for incoming messages, so runtimes using this code will be able to interpret and execute v0::Xcm messages sent from older runtimes.

Messages sent as part of executing an XCM operation (e.g. DepositReserveAsset sending the ReserveAssetDeposited message) will be authored under the v1::Xcm API. A new trait WrapVersion is provided to determine which version they will eventually be encoded with prior to sending based on the destination. Chains concerned about destination chains being unable to interpret v1 messages should implement this trait to ensure that such destintions have messages first translated to v0::Xcm for encoding. A ForceV0 implementation is given which does a blanket v0 translation for all destinations, however it is not recommended for general use since v0 does not support all v1 features and messsages using them will fail to be encoded and sent.

Compatibility v0 -> v1 (receiving messages from a legacy chain)

  • BuyExecution::fees is required to be a single, definite (non-wild) asset. fees: vec![MultiAsset::All], a typical pattern in the past, has no equivalent in v1. This is due to an internal change in xcm_executer and cannot easily be worked around. If the v0 chain has vec![MultiAsset::All] hardcoded for the fees parameter, it will need to be upgraded to specify fees explicitly and with only a single, definite asset. Avoid bad pattern of wildcard fees #3578 fixes this usage in pallet_xcm and all chains should be upgrades to use it ASAP.
  • Vec<MultiAsset> may contain at most one wildcard, and if it does, it must be the only element.
  • MultiAsset::AllFungible and MultiAsset::AllNonFungible have no equivalent in v1 and messages using them will result in failure.

Compatibility v1 -> v0 (sending messages to a legacy chain)

  • BuyExecution::orders has no equivalent in v0 and messages where it is not empty will fail translation.

Migrating from v0::Xcm API

  • Replace xcm::v0 for xcm::v1.
  • For ease of use you may want to use the prelude declaration: use xcm::v1::prelude::*;.
  • xcm::latest may be used in order to track the latest XCM version. This is not generally recommended outside of the Polkadot codebase.

MultiAsset & MultiLocation

  • MultiLocation::Null becomes MultiLocation::Here

  • Vec<MultiAsset> as a pattern is deprecated in favour of MultiAssets (which does not support wildcards) or MultiAssetFilter (which does).

  • MultiAsset::ConcreteFungible { id: MultiLocation::Null, amount: 100 } becomes MultiAsset { id: Concrete(Here), fun: Fungible(100) } or just (Here, 100).into().

  • MultiAsset::ConcreteNonFungible { id: MultiLocation::X1(Junction::Parent), instance: AssetInstance::Blob(vec![0]) } becomes MultiAsset { id: Concrete(X1(Parent)), fun: NonFungible(Blob(vec![0])) } or just (Parent, vec![0]).into().

  • vec![MultiAsset::All] becomes Wild(All) or All.into() (both of type MultiAssetFilter).

  • vec![MultiAsset::None] becomes Definite(vec![]) (of type MultiAssetFilter) or just vec![].into() (of type MultiAssets or MultiAssetFilter).

  • vec![MultiAsset::AllConcreteFungible { id: Null }] becomes Wild(AllOf(fun: WildFungible, id: Here)) or just (Here, WildFungible).into()

  • MultiAsset::AllFungibles and MultiAsset::AllNonFungibles have been removed and can no longer be used.

  • A MultiAsset must strictly identify an asset: there is no MultiAsset value equivalent to the old MultiAsset::None. Fungible assets may not have a zero amount. To allow for an asset value which could include "no asset", use MultiAssets (if more than one asset type is allowable) or Option<MultiAsset> (otherwise).

XCM

Within XCM, the once ubiquitous Vec<MultiAsset> has now been changed to be one of:

  • MultiAssets in the Xcm items, since these describe definite (lists of) assets rather than filters and thus cannot be wild.
  • MultiAsset in the Order::BuyExecution item, since it describes fees and we choose not to support fee payment in multiple asset types.
  • MultiAssetFilter in all other Order items, since these select/filter assets from the Holding Register.

DepositAsset and DepositReserveAsset now both have an additional max_assets field, which states the maximum number of unique assets/asset instances which may be deposited from the Holding Register. This is trivial to provide in the case of a definite set of assets, but requires some knowledge of the expected value of the contents of Holding if wildcards are used.

There are some additional renames to Xcm:

  • ReserveAssetDeposit becomes ReserveAssetDeposited
  • TeleportAsset becomes ReceiveTeleportedAsset
  • TransferAsset::dest becomes TransferAsset::beneficiary

And to Order:

  • Null becomes Noop
  • DepositAsset::dest becomes DepositAsset::beneficiary
  • TransferAsset::dest becomes TransferAsset::beneficiary

Other changes

  • FixedRateOfConcreteFungible has been deprecated - use FixedRateOfFungible instead.
  • pallet_xcm::Config now has a new type field LocationInverter; this should be equivalent to the field of the same name in xcm_executor::Config.
  • AssetInstance::Index ( index: N } becomes AssetInstance::Index(N) (NOTE: This is also the case in v0)

TODO:

  • Implement all the same functionality as OldMultiAsset.
  • Convert all constructor and matching code over in:
  • Optimize:
    • Optimize subsume_assets
    • Optimize checked_sub
  • Remove OldMultiAsset

@github-actions github-actions bot added the A0-please_review Pull request needs code review. label Apr 4, 2021
@gavofyork gavofyork added A3-in_progress Pull request is in progress. No review needed at this stage. and removed A0-please_review Pull request needs code review. labels Apr 4, 2021
This was referenced Apr 7, 2021
Copy link
Contributor

@apopiak apopiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for the MultiAsset/WildMultiAsset/MultiAssetFilter distinction

xcm/src/v0/multiasset.rs Outdated Show resolved Hide resolved
@gavofyork gavofyork added A0-please_review Pull request needs code review. B7-runtimenoteworthy C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Aug 2, 2021
@gavofyork gavofyork merged commit 8f0a57a into master Aug 6, 2021
@gavofyork gavofyork deleted the gav-multiasset-2 branch August 6, 2021 16:25
Comment on lines +408 to +411
/// Consume `self` and return the inner vec.
pub fn drain(self) -> Vec<MultiAsset> {
self.0
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

late nitpick: I would expect an iterator from drain based the Substrate function of the same name
this looks more like into_inner to me

@@ -153,21 +154,28 @@ pub mod pallet {
origin: OriginFor<T>,
dest: MultiLocation,
beneficiary: MultiLocation,
assets: Vec<MultiAsset>,
assets: MultiAssets,
fee_asset_item: u32,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a transaction_version breaking change. Maybe need some additional label so frontend developers can be aware about this?

Copy link
Member

@shawntabrizi shawntabrizi Aug 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. We also have CI which would flag this automatically when the release comes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think polkadot.js would need updates to include new types and type changes introduced in this PR. cc @jacogr

@apopiak apopiak mentioned this pull request Aug 16, 2021
@mattsse mattsse mentioned this pull request Aug 18, 2021
4 tasks
@s3krit s3krit added this to the v0.9.10 milestone Aug 30, 2021
@chevdor chevdor mentioned this pull request Sep 1, 2021
gavofyork added a commit that referenced this pull request Sep 1, 2021
* MultiAsset TWO

* Draft next MultiAsset API.

* XCM core builds

* XCM Executor builds

* XCM Builder builds

* API changes making their way throughout

* Some TODOs

* Further build fixes

* Basic compile builds

* First test fixed

* All executor tests fixed

* Typo

* Optimize subsume_assets and add test

* Optimize checked_sub

* XCM Builder first test fixed

* Fix builder tests

* Fix doc test

* fix some doc tests

* spelling

* named fields for AllOf

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Reformat

* Move to XCM version 1

* Spelling

* warnings

* Replace some more v0->v1s

* warnings

* format

* Add max_assets param

* building

* test fixes

* tests

* another test

* final test

* tests

* Rename Null -> Here

* Introduce

* More ergonomics

* More ergonomics

* test fix

* test fixes

* docs

* BuyExecution includes

* Fix XCM extrinsics

* fmt

* Make Vec<MultiAsset>/MultiAssets conversions safe

* More MultiAssets conversion safety

* spelling

* fix doc test

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* fmt

* Add v0, remove VersionedMultiAsset

* Remove VersionedMultiLocation

* Update xcm/src/v1/order.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Update xcm/src/v1/mod.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* XCM v0 backwards compatibility

* Full compatibility

* fmt

* Update xcm/pallet-xcm/src/lib.rs

* Update xcm/src/v0/order.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Tweaks to versioning system

* Fixes

* fmt

* Update xcm/xcm-executor/src/assets.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update xcm/xcm-executor/src/assets.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Grumbles

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* fmt

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Fixes

* Formatting

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Amar Singh <asinghchrony@protonmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
gavofyork pushed a commit that referenced this pull request Sep 1, 2021
* MultiAsset TWO

* Draft next MultiAsset API.

* XCM core builds

* XCM Executor builds

* XCM Builder builds

* API changes making their way throughout

* Some TODOs

* Further build fixes

* Basic compile builds

* First test fixed

* All executor tests fixed

* Typo

* Optimize subsume_assets and add test

* Optimize checked_sub

* XCM Builder first test fixed

* Fix builder tests

* Fix doc test

* fix some doc tests

* spelling

* named fields for AllOf

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Reformat

* Move to XCM version 1

* Spelling

* warnings

* Replace some more v0->v1s

* warnings

* format

* Add max_assets param

* building

* test fixes

* tests

* another test

* final test

* tests

* Rename Null -> Here

* Introduce

* More ergonomics

* More ergonomics

* test fix

* test fixes

* docs

* BuyExecution includes

* Fix XCM extrinsics

* fmt

* Make Vec<MultiAsset>/MultiAssets conversions safe

* More MultiAssets conversion safety

* spelling

* fix doc test

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* fmt

* Add v0, remove VersionedMultiAsset

* Remove VersionedMultiLocation

* Update xcm/src/v1/order.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Update xcm/src/v1/mod.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* XCM v0 backwards compatibility

* Full compatibility

* fmt

* Update xcm/pallet-xcm/src/lib.rs

* Update xcm/src/v0/order.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Tweaks to versioning system

* Fixes

* fmt

* Update xcm/xcm-executor/src/assets.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update xcm/xcm-executor/src/assets.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Grumbles

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* fmt

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Fixes

* Formatting

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Amar Singh <asinghchrony@protonmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
chevdor pushed a commit that referenced this pull request Sep 13, 2021
* MultiAsset TWO

* Draft next MultiAsset API.

* XCM core builds

* XCM Executor builds

* XCM Builder builds

* API changes making their way throughout

* Some TODOs

* Further build fixes

* Basic compile builds

* First test fixed

* All executor tests fixed

* Typo

* Optimize subsume_assets and add test

* Optimize checked_sub

* XCM Builder first test fixed

* Fix builder tests

* Fix doc test

* fix some doc tests

* spelling

* named fields for AllOf

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Reformat

* Move to XCM version 1

* Spelling

* warnings

* Replace some more v0->v1s

* warnings

* format

* Add max_assets param

* building

* test fixes

* tests

* another test

* final test

* tests

* Rename Null -> Here

* Introduce

* More ergonomics

* More ergonomics

* test fix

* test fixes

* docs

* BuyExecution includes

* Fix XCM extrinsics

* fmt

* Make Vec<MultiAsset>/MultiAssets conversions safe

* More MultiAssets conversion safety

* spelling

* fix doc test

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* fmt

* Add v0, remove VersionedMultiAsset

* Remove VersionedMultiLocation

* Update xcm/src/v1/order.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Update xcm/src/v1/mod.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* XCM v0 backwards compatibility

* Full compatibility

* fmt

* Update xcm/pallet-xcm/src/lib.rs

* Update xcm/src/v0/order.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Tweaks to versioning system

* Fixes

* fmt

* Update xcm/xcm-executor/src/assets.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update xcm/xcm-executor/src/assets.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Grumbles

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* fmt

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Fixes

* Formatting

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Amar Singh <asinghchrony@protonmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
chevdor pushed a commit that referenced this pull request Sep 13, 2021
* MultiAsset TWO

* Draft next MultiAsset API.

* XCM core builds

* XCM Executor builds

* XCM Builder builds

* API changes making their way throughout

* Some TODOs

* Further build fixes

* Basic compile builds

* First test fixed

* All executor tests fixed

* Typo

* Optimize subsume_assets and add test

* Optimize checked_sub

* XCM Builder first test fixed

* Fix builder tests

* Fix doc test

* fix some doc tests

* spelling

* named fields for AllOf

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Reformat

* Move to XCM version 1

* Spelling

* warnings

* Replace some more v0->v1s

* warnings

* format

* Add max_assets param

* building

* test fixes

* tests

* another test

* final test

* tests

* Rename Null -> Here

* Introduce

* More ergonomics

* More ergonomics

* test fix

* test fixes

* docs

* BuyExecution includes

* Fix XCM extrinsics

* fmt

* Make Vec<MultiAsset>/MultiAssets conversions safe

* More MultiAssets conversion safety

* spelling

* fix doc test

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* fmt

* Add v0, remove VersionedMultiAsset

* Remove VersionedMultiLocation

* Update xcm/src/v1/order.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Update xcm/src/v1/mod.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* XCM v0 backwards compatibility

* Full compatibility

* fmt

* Update xcm/pallet-xcm/src/lib.rs

* Update xcm/src/v0/order.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Tweaks to versioning system

* Fixes

* fmt

* Update xcm/xcm-executor/src/assets.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update xcm/xcm-executor/src/assets.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Grumbles

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* fmt

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Fixes

* Formatting

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Amar Singh <asinghchrony@protonmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
s3krit pushed a commit that referenced this pull request Sep 15, 2021
* Companion for substrate/pull/9442 (#3594)

* Fix compact build

* Fix again

* fix staking miner

* fmt

* update Substrate

Co-authored-by: parity-processbot <>

* More standard staking miner deposits (#3621)

* XCM v1 (#2815)

* MultiAsset TWO

* Draft next MultiAsset API.

* XCM core builds

* XCM Executor builds

* XCM Builder builds

* API changes making their way throughout

* Some TODOs

* Further build fixes

* Basic compile builds

* First test fixed

* All executor tests fixed

* Typo

* Optimize subsume_assets and add test

* Optimize checked_sub

* XCM Builder first test fixed

* Fix builder tests

* Fix doc test

* fix some doc tests

* spelling

* named fields for AllOf

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Reformat

* Move to XCM version 1

* Spelling

* warnings

* Replace some more v0->v1s

* warnings

* format

* Add max_assets param

* building

* test fixes

* tests

* another test

* final test

* tests

* Rename Null -> Here

* Introduce

* More ergonomics

* More ergonomics

* test fix

* test fixes

* docs

* BuyExecution includes

* Fix XCM extrinsics

* fmt

* Make Vec<MultiAsset>/MultiAssets conversions safe

* More MultiAssets conversion safety

* spelling

* fix doc test

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* fmt

* Add v0, remove VersionedMultiAsset

* Remove VersionedMultiLocation

* Update xcm/src/v1/order.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Update xcm/src/v1/mod.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* XCM v0 backwards compatibility

* Full compatibility

* fmt

* Update xcm/pallet-xcm/src/lib.rs

* Update xcm/src/v0/order.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Tweaks to versioning system

* Fixes

* fmt

* Update xcm/xcm-executor/src/assets.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update xcm/xcm-executor/src/assets.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Grumbles

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* fmt

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Fixes

* Formatting

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Amar Singh <asinghchrony@protonmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* XCM v1 (#2815)

* MultiAsset TWO

* Draft next MultiAsset API.

* XCM core builds

* XCM Executor builds

* XCM Builder builds

* API changes making their way throughout

* Some TODOs

* Further build fixes

* Basic compile builds

* First test fixed

* All executor tests fixed

* Typo

* Optimize subsume_assets and add test

* Optimize checked_sub

* XCM Builder first test fixed

* Fix builder tests

* Fix doc test

* fix some doc tests

* spelling

* named fields for AllOf

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Reformat

* Move to XCM version 1

* Spelling

* warnings

* Replace some more v0->v1s

* warnings

* format

* Add max_assets param

* building

* test fixes

* tests

* another test

* final test

* tests

* Rename Null -> Here

* Introduce

* More ergonomics

* More ergonomics

* test fix

* test fixes

* docs

* BuyExecution includes

* Fix XCM extrinsics

* fmt

* Make Vec<MultiAsset>/MultiAssets conversions safe

* More MultiAssets conversion safety

* spelling

* fix doc test

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* fmt

* Add v0, remove VersionedMultiAsset

* Remove VersionedMultiLocation

* Update xcm/src/v1/order.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Update xcm/src/v1/mod.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* XCM v0 backwards compatibility

* Full compatibility

* fmt

* Update xcm/pallet-xcm/src/lib.rs

* Update xcm/src/v0/order.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Tweaks to versioning system

* Fixes

* fmt

* Update xcm/xcm-executor/src/assets.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update xcm/xcm-executor/src/assets.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Grumbles

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* fmt

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update xcm/src/v1/multiasset.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Fixes

* Formatting

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Amar Singh <asinghchrony@protonmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Companion to #9514 (Remove Filter and use Contains instead) (#3591)

* Remove Filter and use Contains instead

* Fixes

* Remove patch

* Formatting

* update Substrate

Co-authored-by: parity-processbot <>

* Fix Backwards Compatability with v0 Response (#3597)

* fix junction + response

* Update xcm/src/v1/mod.rs

* better comment

* Minor fix to encoding for XCM v1 (#3602)

* Ensure MultiLocation always has a canonical representation (#3404)

* MultiAsset TWO

* Ensure MultiLocation always has a canonical representation

* Remove v1 module

* Draft next MultiAsset API.

* Implement custom encoding/decoding scheme for MultiLocation

* Properly implement IntoIterator for Junctions

* Implement TryFrom<MultiLocation> for Junctions

* Fix spelling mistakes

* Fix tests in xcm-executor

* XCM core builds

* XCM Executor builds

* XCM Builder builds

* Fix xcm-builder tests and compilation

* Make pallet-xcm compile

* Use MultiLocation::default()

* Make polkadot-runtime-common compile

* Make rococo-runtime compile

* Change return type of parent_count to u8

* Change MAX_MULTILOCATION_LENGTH to 255

* Make kusama-runtime compile

* Fix logic in pallet-xcm

* Use MultiLocation::empty()

* Fix logic in location_conversion

* Fix logic in origin_conversion.rs

* Make westend-runtime compile

* Rename prefixes and suffixes variables

* Rename non_parent to interior

* Rename non_parent to interior

* Add test for encode/decode roundtrip and fix decode algorithm

* API changes making their way throughout

* Some TODOs

* Further build fixes

* Rename non_parent/junctions to interior

* Basic compile builds

* First test fixed

* All executor tests fixed

* Typo

* Optimize subsume_assets and add test

* Optimize checked_sub

* XCM Builder first test fixed

* Fix builder tests

* Fix doc test

* Make xcm-simulator compile

* Make xcm-simulator-example compile

* Make spellcheck happy

* cargo fmt

* fix some doc tests

* spelling

* named fields for AllOf

* Fix subtle bug where Null is treated as an identifier

* Add FIXME comment awaiting for const generics eval stabilization

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update xcm/src/v0/multiasset.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Reformat

* Move to XCM version 1

* Spelling

* warnings

* Replace some more v0->v1s

* warnings

* format

* Add max_assets param

* building

* test fixes

* tests

* another test

* final test

* Update rustdocs and add debug_assert where sensible

* Revert debug_assert in const fn len()

* tests

* Rename Null -> Here

* Introduce

* More ergonomics

* More ergonomics

* test fix

* test fixes

* docs

* BuyExecution includes

* Fix XCM extrinsics

* fmt

* Make Vec<MultiAsset>/MultiAssets conversions safe

* More MultiAssets conversion safety

* spelling

* fix doc test

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* fmt

* Add v0, remove VersionedMultiAsset

* Remove VersionedMultiLocation

* Update xcm/src/v1/order.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Update xcm/src/v1/mod.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* XCM v0 backwards compatibility

* Full compatibility

* fmt

* Update xcm/pallet-xcm/src/lib.rs

* Update xcm/src/v0/order.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Tweaks to versioning system

* Fixes

* fmt

* Fix pallet-xcm tests

* fix

* Substitute with_parent with with_parents_const

* Rename argument name from a to m

* Rename split_last to split_last_interior

* Allow adding multiple parents in MultiLocation

* Rename pop_parent to dec_parent

* Ensure relay chain XCM sender receives a MultiLocation without any parents

* Block only when MultiLocation destination length is 8

* Cargo fmt

* Remove reverse iterators, implement DoubleEndedIterator and add tests

* Fix iter_rev lifetime requirements

* Cargo fmt

* Add an into() method for Junctions for conciseness in const context

* Ensure parent count is 0 while executing who in RelayedFrom

* Appease spellchecker

* Use and_then instead of repeated map_err

* Remove custom codec indices for v1 Junctions

* Add convenience 'contains_parents_only' method to MultiLocation

* Fix merge conflict

* Use more convenience methods

* Remove with_parachain_interior

* Prefer matching against tuple instead of using match guards

* Match against tuple instead of using more match guards

* Update encode/decode test for MultiLocation

* Minor tweaks

* Fixes

* Fixes

* Fixes

* Fix MultiLocation

* Add deprecation note for iter_rev and into_iter_rev

* Update some rustdocs

* cargo fmt

* Fix xcm-executor unit tests

* Fix compilation and unit tests in xcm-builder

* cargo fmt

* Fix tests in xcm-simulator-example

* Publicize MultiLocation fields

* Match on the MultiLocation struct directly in xcm-builder

* Do not dereference undereferenceable types

* Add convenience MultiLocation conversions for tuples

* Use clearer import paths

* Remove unused dependency

* fix junction + response

* Import from latest opaque xcm module

* Update xcm/src/v1/mod.rs

* better comment

* Fix ownership transfer

* Fix merge

* Fix merge

* cargo fmt

* Fix merge

* Fix merge

* Fix integration test

* More readable Parent syntax

* cleanup

* cleanup

* cleanup

* cleanup

* cleanup

* cleanup

* cleanup

* cleanup

* cargo fmt

* Fixes

* Fix doc test

Co-authored-by: Gav Wood <gavin@parity.io>
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Amar Singh <asinghchrony@protonmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Make RelayedFrom typesafe (#3617)

* Corrent type

* Fix build

* Fixes

* Fixes

* Formatting

* Remove BuyExecution::orders (#3640)

* Remove BuyExecution::orders

* Fixes

* Fixes

* Fixes

* Formatting

* XCM: Introduce versioning to dispatchables' params (#3693)

* Introduce versioning to dispatchables' params

* Fixes

* Formatting

* Bump

* Bump deps

* Fixes

* Fixes

* check runtime version in staking miner (#3628)

* check runtime version in staking miner

* fmt

* add short alias for things

* fix fee

* print length as well

* fix build

* review comments

* add integration tests to xcm-builder (#3537)

* add integration tests to xcm-builder

* add an integration test for reserve_transfer_assets

* add query holding and teleport tests

* formatting

* add to barrier doc comments and fix doc tests warnings

* use more realistic barrier for integration tests

* improve imports

* adjust base xcm weight and existential deposit to be in line with Kusama

* remove AnyNetwork

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* add more comments and remove unnecessary code

* move mock into separate file

* reduce imports

* update cargo.lock

* remove reserve transfer test from xcm builder integration tests

* reword barrier doc comment

* elaborate on QueryHolding test scenario

* add an integration test for reserve based transfers from parachain to parachain

* add teleport tests

* fix failing teleport filter tests

* Update xcm/xcm-builder/src/integration_tests.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update xcm/xcm-builder/src/integration_tests.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update xcm/xcm-builder/src/integration_tests.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Move integration tests to tests/ directory

* Fix merge

* Replace All wildcard with a concrete seed amount

* Rename SEED_AMOUNT to REGISTER_AMOUNT

* Fix compilation error

* Check for teleport destination first before checking out assets

* Fix unit test

* Do not run tests in integration mock

* Add a permissive assets filter for teleportation

* Remove check for teleport location in InitiateTeleport XCM

* Remove defunct test

* Apply suggestions from code review

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Reword comment

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* Impl WeightTrader for tuple (#3601)

* Impl WeightTrader for tuple.

* fmt

* Renaming.

* add tracing for buy_weight

* Add comment clarifying the default behavior of a WeightTrader tuple

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* fix compilation (#3657)

* Use proc macros to generate conversion functions for MultiLocation (#3635)

* Use proc macros to generate conversion functions for MultiLocation

* Add compile test and missing conversion cases

* Add common derives for Parent and Ancestor

* Generate conversion functions for MultiLocation v0 via proc macro

* Add type conversion test and fix a bug

* cargo fmt

* Do not hardcode 8 as the number of max parents

* Use map instead of for loops when generating code fragments

* Spelling

* cargo fmt

* More mapping, less for-looping

* Improve MultiLocation conversion functions in xcm-procedural (#3690)

* Use fully-qualified paths to reference core traits in proc macro

* Ensure a canonicalized v0 MultiLocation first before attempting to convert to v1

* Fix failing test

* XCM v1 version notification stub (#3766)

* Initial draft

* v1 subscriptions

* Fixes

* Fixes

* Formatting

* Fixes

* Formatting

* chore: update substrate to branch polkadot-v0.9.10

* chore: update beefy to branch polkadot-v0.9.10

* Provide dummy dispute coordinator by default. (#3661)

* Provide dummy dispute coordinator by default.

* cargo fmt

* Fill up requests slots via `launch_parallel_requests` (#3681)

in case waiting for the next response takes too long.

* Fix missing overseer feature

* Update beefy deps

* xcm executor version bump

* Remove request multiplexer (#3624)

* WIP: Get rid of request multiplexer.

* WIP

* Receiver for handling of incoming requests.

* Get rid of useless `Fault` abstraction.

The things the type system let us do are not worth getting abstracted in
its own type. Instead error handling is going to be merely a pattern.

* Make most things compile again.

* Port availability distribution away from request multiplexer.

* Formatting.

* Port dispute distribution over.

* Fixup statement distribution.

* Handle request directly in collator protocol.

+ Only allow fatal errors at top level.

* Use direct request channel for availability recovery.

* Finally get rid of request multiplexer

Fixes #2842 and paves the way for more back pressure possibilities.

* Fix overseer and statement distribution tests.

* Fix collator protocol and network bridge tests.

* Fix tests in availability recovery.

* Fix availability distribution tests.

* Fix dispute distribution tests.

* Add missing dependency

* Typos.

* Review remarks.

* More remarks.

* Add words to the dictionnary

* sp-io update

* Don't drop UMP queue items if weight exhausted (#3784)

* Requeue UMP queue items if weight exhausted

* Reduce complexity and remove Deque

* Formatting

* Formatting

* Avoid needless storage writes

* Test

* Formatting

* Docs and cleanup

* fmt

* Remove now irrelevant comment.

* Simplify `take_processed` by using `mem::take`

* Clean up & fmt: use `upward_message` directly.

* Grumbles

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Sergei Shulepov <sergei@parity.io>

* Update beefy deps

* Update Substrate and Beefy

* fix for #3537

* Update substrate

* Fix spelling

* Do not expire HRMP open channel requests (#3543)

* Do not expire HRMP open channel requests

* Fix the build and update the docs

* Implement canceling requests and do not remove them automatically

* Fix a borked merge

* Fix fmt

* Please spellchecker

* Apply suggestions from code review

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Use `mutate_exists` for maintaining request counts

* Apply `rustfmt`

* Move newly introduced entrypoint to end to preserve ordering

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* UMP: Support Overweight messages (#3575)

* Introduce new config: ump_max_individual_weight

* Implement overweight msg stashing

* Test

* Add migration module.

Also introduces a test for migration

* Integrate ExecuteOverweightOrigin to runtimes

* Fix more stuff

* Add `yeet` into dictionary

* Use suggested `Error` variant names

* typo

* Use 20ms as the maximum individual message weight

* Update the test value

* rustfmt

* Clean up

* Remove deprecated field from host config

* Remove missed _hrmp_open_request_ttl

* Apply typo fix suggestion

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Rename `migration::migrate_to_latest`

* Restore `_hrmp_open_request_ttl` in `v0::HostConfiguration`

* Apply suggestion for a rustdoc

* Apply the suggestion

* Test v0 config with the raw production data fetched from Kusama

* Update runtime/parachains/src/ump.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Expose migration functions

* Fix spellcheck

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* Remove migration done by runtime version 9090 (#3731)

* remove 9090 migrations

* remove unused

* fmt

* revert removal of polkadot migration

* remove migration for polkadot

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Gavin Wood <gavin@parity.io>
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Amar Singh <asinghchrony@protonmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: Shaun Wang <spxwang@gmail.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Robert Klotzner <eskimor@users.noreply.github.com>
Co-authored-by: Sergei Shulepov <sergei@parity.io>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants