Add claim_assets extrinsic to pallet-xcm (#3403)

If an XCM execution fails or ends with leftover assets, these will be
trapped.
In order to claim them, a custom XCM has to be executed, with the
`ClaimAsset` instruction.
However, arbitrary XCM execution is not allowed everywhere yet and XCM
itself is still not easy enough to use for users out there with trapped
assets.
This new extrinsic in `pallet-xcm` will allow these users to easily
claim their assets, without concerning themselves with writing arbitrary
XCMs.

Part of fixing https://github.com/paritytech/polkadot-sdk/issues/3495

---------

Co-authored-by: command-bot <>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
This commit is contained in:
Francisco Aguirre
2024-03-01 08:31:48 +01:00
committed by GitHub
parent c0e52a9ed6
commit 650886683d
29 changed files with 1521 additions and 1063 deletions
@@ -16,26 +16,24 @@
//! Autogenerated weights for `pallet_xcm`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-11-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-02-20, 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-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("westend-dev")`, DB CACHE: 1024
// Executed Command:
// ./target/production/polkadot
// target/production/polkadot
// benchmark
// pallet
// --chain=westend-dev
// --steps=50
// --repeat=20
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --pallet=pallet_xcm
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
// --pallet=pallet_xcm
// --chain=westend-dev
// --header=./polkadot/file_header.txt
// --output=./polkadot/runtime/westend/src/weights/
@@ -50,10 +48,6 @@ use core::marker::PhantomData;
/// Weight functions for `pallet_xcm`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
fn transfer_assets() -> Weight {
// TODO: run benchmarks
Weight::zero()
}
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
@@ -64,29 +58,73 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn send() -> Weight {
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `3574`
// Minimum execution time: 28_098_000 picoseconds.
Weight::from_parts(28_887_000, 0)
.saturating_add(Weight::from_parts(0, 3574))
// Measured: `147`
// Estimated: `3612`
// Minimum execution time: 25_725_000 picoseconds.
Weight::from_parts(26_174_000, 0)
.saturating_add(Weight::from_parts(0, 3612))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn teleport_assets() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 17_609_000 picoseconds.
Weight::from_parts(18_000_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Measured: `250`
// Estimated: `6196`
// Minimum execution time: 113_140_000 picoseconds.
Weight::from_parts(116_204_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn reserve_transfer_assets() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 17_007_000 picoseconds.
Weight::from_parts(17_471_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Measured: `302`
// Estimated: `6196`
// Minimum execution time: 108_571_000 picoseconds.
Weight::from_parts(110_650_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn transfer_assets() -> Weight {
// Proof Size summary in bytes:
// Measured: `250`
// Estimated: `6196`
// Minimum execution time: 111_836_000 picoseconds.
Weight::from_parts(114_435_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Benchmark::Override` (r:0 w:0)
/// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`)
@@ -104,8 +142,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_444_000 picoseconds.
Weight::from_parts(7_671_000, 0)
// Minimum execution time: 7_160_000 picoseconds.
Weight::from_parts(7_477_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -113,8 +151,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_126_000 picoseconds.
Weight::from_parts(2_253_000, 0)
// Minimum execution time: 1_934_000 picoseconds.
Weight::from_parts(2_053_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `XcmPallet::VersionNotifiers` (r:1 w:1)
@@ -133,11 +171,11 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
/// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn force_subscribe_version_notify() -> Weight {
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `3574`
// Minimum execution time: 31_318_000 picoseconds.
Weight::from_parts(32_413_000, 0)
.saturating_add(Weight::from_parts(0, 3574))
// Measured: `147`
// Estimated: `3612`
// Minimum execution time: 31_123_000 picoseconds.
Weight::from_parts(31_798_000, 0)
.saturating_add(Weight::from_parts(0, 3612))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(5))
}
@@ -155,11 +193,11 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
/// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn force_unsubscribe_version_notify() -> Weight {
// Proof Size summary in bytes:
// Measured: `289`
// Estimated: `3754`
// Minimum execution time: 35_282_000 picoseconds.
Weight::from_parts(35_969_000, 0)
.saturating_add(Weight::from_parts(0, 3754))
// Measured: `327`
// Estimated: `3792`
// Minimum execution time: 35_175_000 picoseconds.
Weight::from_parts(36_098_000, 0)
.saturating_add(Weight::from_parts(0, 3792))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(4))
}
@@ -169,45 +207,45 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_247_000 picoseconds.
Weight::from_parts(2_381_000, 0)
// Minimum execution time: 1_974_000 picoseconds.
Weight::from_parts(2_096_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `XcmPallet::SupportedVersion` (r:4 w:2)
/// Storage: `XcmPallet::SupportedVersion` (r:5 w:2)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn migrate_supported_version() -> Weight {
// Proof Size summary in bytes:
// Measured: `26`
// Estimated: `10916`
// Minimum execution time: 14_512_000 picoseconds.
Weight::from_parts(15_042_000, 0)
.saturating_add(Weight::from_parts(0, 10916))
.saturating_add(T::DbWeight::get().reads(4))
// Measured: `22`
// Estimated: `13387`
// Minimum execution time: 16_626_000 picoseconds.
Weight::from_parts(17_170_000, 0)
.saturating_add(Weight::from_parts(0, 13387))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `XcmPallet::VersionNotifiers` (r:4 w:2)
/// Storage: `XcmPallet::VersionNotifiers` (r:5 w:2)
/// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn migrate_version_notifiers() -> Weight {
// Proof Size summary in bytes:
// Measured: `30`
// Estimated: `10920`
// Minimum execution time: 14_659_000 picoseconds.
Weight::from_parts(15_164_000, 0)
.saturating_add(Weight::from_parts(0, 10920))
.saturating_add(T::DbWeight::get().reads(4))
// Measured: `26`
// Estimated: `13391`
// Minimum execution time: 16_937_000 picoseconds.
Weight::from_parts(17_447_000, 0)
.saturating_add(Weight::from_parts(0, 13391))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `XcmPallet::VersionNotifyTargets` (r:5 w:0)
/// Storage: `XcmPallet::VersionNotifyTargets` (r:6 w:0)
/// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn already_notified_target() -> Weight {
// Proof Size summary in bytes:
// Measured: `40`
// Estimated: `13405`
// Minimum execution time: 16_261_000 picoseconds.
Weight::from_parts(16_986_000, 0)
.saturating_add(Weight::from_parts(0, 13405))
.saturating_add(T::DbWeight::get().reads(5))
// Estimated: `15880`
// Minimum execution time: 19_157_000 picoseconds.
Weight::from_parts(19_659_000, 0)
.saturating_add(Weight::from_parts(0, 15880))
.saturating_add(T::DbWeight::get().reads(6))
}
/// Storage: `XcmPallet::VersionNotifyTargets` (r:2 w:1)
/// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
@@ -221,38 +259,38 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn notify_current_targets() -> Weight {
// Proof Size summary in bytes:
// Measured: `145`
// Estimated: `6085`
// Minimum execution time: 30_539_000 picoseconds.
Weight::from_parts(31_117_000, 0)
.saturating_add(Weight::from_parts(0, 6085))
// Measured: `183`
// Estimated: `6123`
// Minimum execution time: 30_699_000 picoseconds.
Weight::from_parts(31_537_000, 0)
.saturating_add(Weight::from_parts(0, 6123))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `XcmPallet::VersionNotifyTargets` (r:3 w:0)
/// Storage: `XcmPallet::VersionNotifyTargets` (r:4 w:0)
/// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn notify_target_migration_fail() -> Weight {
// Proof Size summary in bytes:
// Measured: `69`
// Estimated: `8484`
// Minimum execution time: 9_463_000 picoseconds.
Weight::from_parts(9_728_000, 0)
.saturating_add(Weight::from_parts(0, 8484))
.saturating_add(T::DbWeight::get().reads(3))
// Estimated: `10959`
// Minimum execution time: 12_303_000 picoseconds.
Weight::from_parts(12_670_000, 0)
.saturating_add(Weight::from_parts(0, 10959))
.saturating_add(T::DbWeight::get().reads(4))
}
/// Storage: `XcmPallet::VersionNotifyTargets` (r:4 w:2)
/// Storage: `XcmPallet::VersionNotifyTargets` (r:5 w:2)
/// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn migrate_version_notify_targets() -> Weight {
// Proof Size summary in bytes:
// Measured: `37`
// Estimated: `10927`
// Minimum execution time: 15_169_000 picoseconds.
Weight::from_parts(15_694_000, 0)
.saturating_add(Weight::from_parts(0, 10927))
.saturating_add(T::DbWeight::get().reads(4))
// Measured: `33`
// Estimated: `13398`
// Minimum execution time: 17_129_000 picoseconds.
Weight::from_parts(17_668_000, 0)
.saturating_add(Weight::from_parts(0, 13398))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `XcmPallet::VersionNotifyTargets` (r:4 w:2)
/// Storage: `XcmPallet::VersionNotifyTargets` (r:5 w:2)
/// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
@@ -264,12 +302,12 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn migrate_and_notify_old_targets() -> Weight {
// Proof Size summary in bytes:
// Measured: `149`
// Estimated: `11039`
// Minimum execution time: 37_549_000 picoseconds.
Weight::from_parts(38_203_000, 0)
.saturating_add(Weight::from_parts(0, 11039))
.saturating_add(T::DbWeight::get().reads(8))
// Measured: `183`
// Estimated: `13548`
// Minimum execution time: 39_960_000 picoseconds.
Weight::from_parts(41_068_000, 0)
.saturating_add(Weight::from_parts(0, 13548))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `XcmPallet::QueryCounter` (r:1 w:1)
@@ -280,8 +318,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `1485`
// Minimum execution time: 2_947_000 picoseconds.
Weight::from_parts(3_117_000, 0)
// Minimum execution time: 2_333_000 picoseconds.
Weight::from_parts(2_504_000, 0)
.saturating_add(Weight::from_parts(0, 1485))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
@@ -292,10 +330,22 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `7576`
// Estimated: `11041`
// Minimum execution time: 24_595_000 picoseconds.
Weight::from_parts(24_907_000, 0)
// Minimum execution time: 22_932_000 picoseconds.
Weight::from_parts(23_307_000, 0)
.saturating_add(Weight::from_parts(0, 11041))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `XcmPallet::AssetTraps` (r:1 w:1)
/// Proof: `XcmPallet::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn claim_assets() -> Weight {
// Proof Size summary in bytes:
// Measured: `23`
// Estimated: `3488`
// Minimum execution time: 34_558_000 picoseconds.
Weight::from_parts(35_299_000, 0)
.saturating_add(Weight::from_parts(0, 3488))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}