## Motivation
`pallet-xcm` is the main user-facing interface for XCM functionality,
including assets manipulation functions like `teleportAssets()` and
`reserve_transfer_assets()` calls.
While `teleportAsset()` works both ways, `reserve_transfer_assets()`
works only for sending reserve-based assets to a remote destination and
beneficiary when the reserve is the _local chain_.
## Solution
This PR enhances `pallet_xcm::(limited_)reserve_withdraw_assets` to
support transfers when reserves are other chains.
This will allow complete, **bi-directional** reserve-based asset
transfers user stories using `pallet-xcm`.
Enables following scenarios:
- transferring assets with local reserve (was previously supported iff
asset used as fee also had local reserve - now it works in all cases),
- transferring assets with reserve on destination,
- transferring assets with reserve on remote/third-party chain (iff
assets and fees have same remote reserve),
- transferring assets with reserve different than the reserve of the
asset to be used as fees - meaning can be used to transfer random asset
with local/dest reserve while using DOT for fees on all involved chains,
even if DOT local/dest reserve doesn't match asset reserve,
- transferring assets with any type of local/dest reserve while using
fees which can be teleported between involved chains.
All of the above is done by pallet inner logic without the user having
to specify which scenario/reserves/teleports/etc. The correct scenario
and corresponding XCM programs are identified, and respectively, built
automatically based on runtime configuration of trusted teleporters and
trusted reserves.
#### Current limitations:
- while `fees` and "non-fee" `assets` CAN have different reserves (or
fees CAN be teleported), the remaining "non-fee" `assets` CANNOT, among
themselves, have different reserve locations (this is also implicitly
enforced by `MAX_ASSETS_FOR_TRANSFER=2`, but this can be safely
increased in the future).
- `fees` and "non-fee" `assets` CANNOT have **different remote**
reserves (this could also be supported in the future, but adds even more
complexity while possibly not being worth it - we'll see what the future
holds).
Fixes https://github.com/paritytech/polkadot-sdk/issues/1584
Fixes https://github.com/paritytech/polkadot-sdk/issues/2055
---------
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
Co-authored-by: Branislav Kontur <bkontur@gmail.com>
We are introducing a new set of `XcmController` traits (final name yet
to be determined).
These traits are implemented by `pallet-xcm` and allows other pallets,
such as `pallet_contracts`, to rely on these traits instead of tight
coupling them to `pallet-xcm`.
Using only the existing Xcm traits would mean duplicating the logic from
`pallet-xcm` in these other pallets, which we aim to avoid. Our
objective is to ensure that when these APIs are called from
`pallet-contracts`, they produce the exact same outcomes as if called
directly from `pallet-xcm`.
The other benefits is that we can also expose return values to
`pallet-contracts` instead of just calling `pallet-xcm` dispatchable and
getting a `DispatchResult` back.
See traits integration in this PR
https://github.com/paritytech/polkadot-sdk/pull/1248, where the traits
are used as follow to define and implement `pallet-contracts` Config.
```rs
// Contracts config:
pub trait Config: frame_system::Config {
// ...
/// A type that exposes XCM APIs, allowing contracts to interact with other parachains, and
/// execute XCM programs.
type Xcm: xcm_executor::traits::Controller<
OriginFor<Self>,
<Self as frame_system::Config>::RuntimeCall,
BlockNumberFor<Self>,
>;
}
// implementation
impl pallet_contracts::Config for Runtime {
// ...
type Xcm = pallet_xcm::Pallet<Self>;
}
```
---------
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: command-bot <>
Adds a config file that allows to run `zepter` without any arguments in
the workspace to address all issues.
A secondary workflow for the CI is provided as `zepter run check`. Both
the formatting and linting are now in one check for efficiancy.
The latest version also detects some more things that `featalign` was
already showing.
Error message [in the
CI](https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/3916205)
now looks like this:
```pre
...
crate 'test-parachains' (/Users/vados/Documents/work/polkadot-sdk/polkadot/parachain/test-parachains/Cargo.toml)
feature 'std'
must propagate to:
parity-scale-codec
Found 55 issues (run with --fix to fix).
Error: Command 'lint propagate-feature' failed with exit code 1
Polkadot-SDK uses the Zepter CLI to detect abnormalities in the feature configuration.
It looks like one more more checks failed; please check the console output. You can try to automatically address them by running `zepter`.
Otherwise please ask directly in the Merge Request, GitHub Discussions or on Matrix Chat, thank you.
For more information, see:
- https://github.com/paritytech/polkadot-sdk/issues/1831
- https://github.com/ggwpez/zepter
```
TODO:
- [x] Check that CI fails correctly
---------
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Combination of paritytech/polkadot#7005, its addon PR
paritytech/polkadot#7585 and its companion paritytech/cumulus#2433.
This PR introduces a new XcmFeesToAccount struct which implements the
`FeeManager` trait, and assigns this struct as the `FeeManager` in the
XCM config for all runtimes.
The struct simply deposits all fees handled by the XCM executor to a
specified account. In all runtimes, the specified account is configured
as the treasury account.
XCM __delivery__ fees are now being introduced (unless the root origin
is sending a message to a system parachain on behalf of the originating
chain).
# Note for reviewers
Most file changes are tests that had to be modified to account for the
new fees.
Main changes are in:
- cumulus/pallets/xcmp-queue/src/lib.rs <- To make it track the delivery
fees exponential factor
- polkadot/xcm/xcm-builder/src/fee_handling.rs <- Added. Has the
FeeManager implementation
- All runtime xcm_config files <- To add the FeeManager to the XCM
configuration
# Important note
After this change, instructions that create and send a new XCM (Query*,
Report*, ExportMessage, InitiateReserveWithdraw, InitiateTeleport,
DepositReserveAsset, TransferReserveAsset, LockAsset and RequestUnlock)
will require the corresponding origin account in the origin register to
pay for transport delivery fees, and the onward message will fail to be
sent if the origin account does not have the required amount. This
delivery fee is on top of what we already collect as tx fees in
pallet-xcm and XCM BuyExecution fees!
Wallet UIs that want to expose the new delivery fee can do so using the
formula:
```
delivery_fee_factor * (base_fee + encoded_msg_len * per_byte_fee)
```
where the delivery fee factor can be obtained from the corresponding
pallet based on which transport you are using (UMP, HRMP or bridges),
the base fee is a constant, the encoded message length from the message
itself and the per byte fee is the same as the configured per byte fee
for txs (i.e. `TransactionByteFee`).
---------
Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Co-authored-by: Giles Cope <gilescope@gmail.com>
Co-authored-by: command-bot <>
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
* Rename squatted crates
This commit adds the staging- prefix to squatted crates so we can go forward and publish them to crates.io.
Using the staging- prefix is a temp fix until we decide on replacement names.
https://forum.parity.io/t/renaming-squated-crates-in-substrate-polkadot-cumulus/1964/6
* Fix test after crate renames
* Update Lockfile
* Move XCM query functionality to trait
* Fix tests
* Add PayOverXcm implementation
* fix the PayOverXcm trait to compile
* moved doc comment out of trait implmeentation and to the trait
* PayOverXCM documentation
* Change documentation a bit
* Added empty benchmark methods implementation and changed docs
* update PayOverXCM to convert AccountIds to MultiLocations
* Implement benchmarking method
* Change v3 to latest
* Descend origin to an asset sender (#6970)
* descend origin to an asset sender
* sender as tuple of dest and sender
* Add more variants to the QueryResponseStatus enum
* Change Beneficiary to Into<[u8; 32]>
* update PayOverXcm to return concrete errors and use AccountId as sender
* use polkadot-primitives for AccountId
* fix dependency to use polkadot-core-primitives
* force Unpaid instruction to the top of the instructions list
* modify report_outcome to accept interior argument
* use new_query directly for building final xcm query, instead of report_outcome
* fix usage of new_query to use the XcmQueryHandler
* fix usage of new_query to use the XcmQueryHandler
* tiny method calling fix
* xcm query handler (#7198)
* drop redundant query status
* rename ReportQueryStatus to OuterQueryStatus
* revert rename of QueryResponseStatus
* update mapping
* Update xcm/xcm-builder/src/pay.rs
Co-authored-by: Gavin Wood <gavin@parity.io>
* Updates
* Docs
* Fix benchmarking stuff
* Destination can be determined based on asset_kind
* Tweaking API to minimise clones
* Some repotting and docs
---------
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>
Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>
Co-authored-by: Anthony Alaribe <anthony.alaribe@parity.io>
Co-authored-by: Gavin Wood <gavin@parity.io>
* Tools for unique topic references
* Formatting
* Naming
* Repot into routing.rs.
* More things done
* Universal Exporter supports topic-as-reference
* Some tests for the topic routing
* More tests
* Paid bridge tests
* Add message ID to sending events
* Formatting
* fix and integrate into test nets
* Move DenyThenTry and friend from Cumulus
* Append SetTopic rather than prepend
* Docs
* Docs
* Work with new ProcessMessage ID API
* Formatting
* Fix build
* Fixes
* Formatting
* Update xcm/xcm-builder/src/barriers.rs
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
* Update xcm/xcm-builder/src/routing.rs
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
* Docs
* Rename message_hash
* Formatting
* ".git/.scripts/commands/fmt/fmt.sh"
* Rename
* Another Rename
* ".git/.scripts/commands/fmt/fmt.sh"
* ".git/.scripts/commands/fmt/fmt.sh"
* Update xcm/xcm-builder/src/routing.rs
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
---------
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
Co-authored-by: command-bot <>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
* Happy New Year!
* Remove year entierly
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
* Remove years from copyright notice in the entire repo
---------
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
* Change ParaId->Sibling for `SiblingParachainConvertsVia`
* [XCM] Multiple `FungiblesAdapter`s support + `WeightTrader::buy_weight` more accurate error
* Added test for `ConvertedConcreteId` with `AsPrefixedGeneralIndex`
* Solution 3. - new MatchedConvertedConcreteId with matching capabilities
* Review fixes
* Renamed `AssetNotFound` -> `AssetNotHandled`
---------
Co-authored-by: parity-processbot <>
* rust 1.64 enables workspace properties
* add edition, repository and authors.
* of course, update the version in one place.
Co-authored-by: Andronik <write@reusable.software>
* Add clippy config and remove .cargo from gitignore
* first fixes
* Clippyfied
* Add clippy CI job
* comment out rusty-cachier
* minor
* fix ci
* remove DAG from check-dependent-project
* add DAG to clippy
Co-authored-by: alvicsam <alvicsam@gmail.com>
* westend: update transaction version
* polkadot: update transaction version
* kusama: update transaction version
* Bump spec_version to 9330
* bump versions to 0.9.33
* BlockId removal: &Hash to Hash
It changes &Block::Hash argument to Block::Hash.
This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292)
* missing file corrected
* update lockfile for {"substrate"}
Co-authored-by: parity-processbot <>
* Bump crate versions
* Bump spec_version to 9280 for kusama
* Bump spec_version to 9280 for polkadot
* Bump spec_version to 9280 for rococo
* Bump spec_version to 9280 for westend
* update Cargo.lock
Co-authored-by: parity-processbot <>