mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
pallet-xcm: add new flexible transfer_assets() call/extrinsic (#2388)
# Motivation (+testing)
### Enable easy `ForeignAssets` transfers using `pallet-xcm`
We had just previously added capabilities to teleport fees during
reserve-based transfers, but what about reserve-transferring fees when
needing to teleport some non-fee asset?
This PR aligns everything under either explicit reserve-transfer,
explicit teleport, or this new flexible `transfer_assets()` which can
mix and match as needed with fewer artificial constraints imposed to the
user.
This will enable, for example, a (non-system) parachain to teleport
their `ForeignAssets` assets to AssetHub while using DOT to pay fees.
(the assets are teleported - as foreign assets should from their owner
chain - while DOT used for fees can only be reserve-based transferred
between said parachain and AssetHub).
Added `xcm-emulator` tests for this scenario ^.
# Description
Reverts `(limited_)reserve_transfer_assets` to only allow reserve-based
transfers for all `assets` including fees.
Similarly `(limited_)teleport_assets` only allows teleports for all
`assets` including fees.
For complex combinations of asset transfers where assets and fees may
have different reserves or different reserve/teleport trust
configurations, users can use the newly added `transfer_assets()`
extrinsic which is more flexible in allowing more complex scenarios.
`assets` (excluding `fees`) must have same reserve location or otherwise
be teleportable to `dest`.
No limitations imposed on `fees`.
- for local reserve: transfer assets to sovereign account of destination
chain and forward a notification XCM to `dest` to mint and deposit
reserve-based assets to `beneficiary`.
- for destination reserve: burn local assets and forward a notification
to `dest` chain to withdraw the reserve assets from this chain's
sovereign account and deposit them to `beneficiary`.
- for remote reserve: burn local assets, forward XCM to reserve chain to
move reserves from this chain's SA to `dest` chain's SA, and forward
another XCM to `dest` to mint and deposit reserve-based assets to
`beneficiary`.
- for teleports: burn local assets and forward XCM to `dest` chain to
mint/teleport assets and deposit them to `beneficiary`.
## Review notes
Only around 500 lines are prod code (see `pallet_xcm/src/lib.rs`), the
rest of the PR is new tests and improving existing tests.
---------
Co-authored-by: command-bot <>
This commit is contained in:
@@ -969,6 +969,18 @@ impl_runtime_apis! {
|
||||
// Reserve transfers are disabled on Collectives.
|
||||
None
|
||||
}
|
||||
|
||||
fn set_up_complex_asset_transfer(
|
||||
) -> Option<(MultiAssets, u32, MultiLocation, 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();
|
||||
let dest = Parent.into();
|
||||
pallet_xcm::benchmarking::helpers::native_teleport_as_asset_transfer::<Runtime>(
|
||||
native_location,
|
||||
dest
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
let whitelist: Vec<TrackedStorageKey> = vec![
|
||||
|
||||
+79
-38
@@ -17,9 +17,9 @@
|
||||
//! Autogenerated weights for `pallet_xcm`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2023-11-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! DATE: 2023-12-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `runner-yprdrvc7-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! HOSTNAME: `runner-r43aesjn-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("collectives-westend-dev")`, DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
@@ -64,22 +64,37 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `145`
|
||||
// Estimated: `3610`
|
||||
// Minimum execution time: 25_746_000 picoseconds.
|
||||
Weight::from_parts(26_349_000, 0)
|
||||
// Minimum execution time: 24_540_000 picoseconds.
|
||||
Weight::from_parts(25_439_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 3610))
|
||||
.saturating_add(T::DbWeight::get().reads(6))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
/// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
|
||||
/// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0)
|
||||
/// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0)
|
||||
/// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1)
|
||||
/// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0)
|
||||
/// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0)
|
||||
/// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1)
|
||||
/// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
fn teleport_assets() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `69`
|
||||
// Estimated: `1489`
|
||||
// Minimum execution time: 22_660_000 picoseconds.
|
||||
Weight::from_parts(23_173_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1489))
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
// Measured: `214`
|
||||
// Estimated: `3679`
|
||||
// Minimum execution time: 86_614_000 picoseconds.
|
||||
Weight::from_parts(88_884_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 3679))
|
||||
.saturating_add(T::DbWeight::get().reads(8))
|
||||
.saturating_add(T::DbWeight::get().writes(3))
|
||||
}
|
||||
/// Storage: `Benchmark::Override` (r:0 w:0)
|
||||
/// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
@@ -91,6 +106,32 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
Weight::from_parts(18_446_744_073_709_551_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 0))
|
||||
}
|
||||
/// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
|
||||
/// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0)
|
||||
/// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0)
|
||||
/// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1)
|
||||
/// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0)
|
||||
/// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0)
|
||||
/// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1)
|
||||
/// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
fn transfer_assets() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `214`
|
||||
// Estimated: `3679`
|
||||
// Minimum execution time: 87_915_000 picoseconds.
|
||||
Weight::from_parts(90_219_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 3679))
|
||||
.saturating_add(T::DbWeight::get().reads(8))
|
||||
.saturating_add(T::DbWeight::get().writes(3))
|
||||
}
|
||||
/// Storage: `Benchmark::Override` (r:0 w:0)
|
||||
/// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
fn execute() -> Weight {
|
||||
@@ -107,8 +148,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 7_321_000 picoseconds.
|
||||
Weight::from_parts(7_542_000, 0)
|
||||
// Minimum execution time: 6_872_000 picoseconds.
|
||||
Weight::from_parts(7_110_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 0))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
@@ -118,8 +159,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 2_232_000 picoseconds.
|
||||
Weight::from_parts(2_395_000, 0)
|
||||
// Minimum execution time: 2_009_000 picoseconds.
|
||||
Weight::from_parts(2_163_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 0))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
@@ -145,8 +186,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `145`
|
||||
// Estimated: `3610`
|
||||
// Minimum execution time: 29_006_000 picoseconds.
|
||||
Weight::from_parts(29_777_000, 0)
|
||||
// Minimum execution time: 28_858_000 picoseconds.
|
||||
Weight::from_parts(29_355_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 3610))
|
||||
.saturating_add(T::DbWeight::get().reads(8))
|
||||
.saturating_add(T::DbWeight::get().writes(5))
|
||||
@@ -171,8 +212,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `363`
|
||||
// Estimated: `3828`
|
||||
// Minimum execution time: 31_245_000 picoseconds.
|
||||
Weight::from_parts(32_125_000, 0)
|
||||
// Minimum execution time: 30_598_000 picoseconds.
|
||||
Weight::from_parts(31_168_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 3828))
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
@@ -183,8 +224,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 2_255_000 picoseconds.
|
||||
Weight::from_parts(2_399_000, 0)
|
||||
// Minimum execution time: 2_090_000 picoseconds.
|
||||
Weight::from_parts(2_253_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 0))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
@@ -194,8 +235,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `162`
|
||||
// Estimated: `11052`
|
||||
// Minimum execution time: 16_521_000 picoseconds.
|
||||
Weight::from_parts(17_001_000, 0)
|
||||
// Minimum execution time: 16_133_000 picoseconds.
|
||||
Weight::from_parts(16_433_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 11052))
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
@@ -206,8 +247,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `166`
|
||||
// Estimated: `11056`
|
||||
// Minimum execution time: 16_486_000 picoseconds.
|
||||
Weight::from_parts(16_729_000, 0)
|
||||
// Minimum execution time: 16_012_000 picoseconds.
|
||||
Weight::from_parts(16_449_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 11056))
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
@@ -218,8 +259,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `173`
|
||||
// Estimated: `13538`
|
||||
// Minimum execution time: 18_037_000 picoseconds.
|
||||
Weight::from_parts(18_310_000, 0)
|
||||
// Minimum execution time: 17_922_000 picoseconds.
|
||||
Weight::from_parts(18_426_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 13538))
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
}
|
||||
@@ -241,8 +282,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `212`
|
||||
// Estimated: `6152`
|
||||
// Minimum execution time: 27_901_000 picoseconds.
|
||||
Weight::from_parts(28_566_000, 0)
|
||||
// Minimum execution time: 27_280_000 picoseconds.
|
||||
Weight::from_parts(28_026_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 6152))
|
||||
.saturating_add(T::DbWeight::get().reads(8))
|
||||
.saturating_add(T::DbWeight::get().writes(3))
|
||||
@@ -253,8 +294,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `206`
|
||||
// Estimated: `8621`
|
||||
// Minimum execution time: 9_299_000 picoseconds.
|
||||
Weight::from_parts(9_547_000, 0)
|
||||
// Minimum execution time: 9_387_000 picoseconds.
|
||||
Weight::from_parts(9_644_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 8621))
|
||||
.saturating_add(T::DbWeight::get().reads(3))
|
||||
}
|
||||
@@ -264,8 +305,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `173`
|
||||
// Estimated: `11063`
|
||||
// Minimum execution time: 16_768_000 picoseconds.
|
||||
Weight::from_parts(17_215_000, 0)
|
||||
// Minimum execution time: 16_649_000 picoseconds.
|
||||
Weight::from_parts(17_025_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 11063))
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
@@ -288,8 +329,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `215`
|
||||
// Estimated: `11105`
|
||||
// Minimum execution time: 35_134_000 picoseconds.
|
||||
Weight::from_parts(35_883_000, 0)
|
||||
// Minimum execution time: 34_355_000 picoseconds.
|
||||
Weight::from_parts(35_295_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 11105))
|
||||
.saturating_add(T::DbWeight::get().reads(10))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
@@ -302,8 +343,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `103`
|
||||
// Estimated: `1588`
|
||||
// Minimum execution time: 4_562_000 picoseconds.
|
||||
Weight::from_parts(4_802_000, 0)
|
||||
// Minimum execution time: 4_527_000 picoseconds.
|
||||
Weight::from_parts(4_699_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1588))
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
@@ -314,8 +355,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `7740`
|
||||
// Estimated: `11205`
|
||||
// Minimum execution time: 26_865_000 picoseconds.
|
||||
Weight::from_parts(27_400_000, 0)
|
||||
// Minimum execution time: 27_011_000 picoseconds.
|
||||
Weight::from_parts(27_398_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 11205))
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
|
||||
Reference in New Issue
Block a user