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
@@ -740,6 +740,13 @@ impl_runtime_apis! {
// Reserve transfers are disabled
None
}
fn get_asset() -> Asset {
Asset {
id: AssetId(Location::parent()),
fun: Fungible(ExistentialDeposit::get()),
}
}
}
parameter_types! {
@@ -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: 2024-01-12, 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-j8vvqcjr-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("coretime-rococo-dev")`, DB CACHE: 1024
// Executed Command:
// ./target/production/polkadot-parachain
// target/production/polkadot-parachain
// benchmark
// pallet
// --chain=coretime-rococo-dev
// --wasm-execution=compiled
// --pallet=pallet_xcm
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --extrinsic=*
// --steps=50
// --repeat=20
// --json
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
// --pallet=pallet_xcm
// --chain=coretime-rococo-dev
// --header=./cumulus/file_header.txt
// --output=./cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/
@@ -64,8 +62,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `74`
// Estimated: `3539`
// Minimum execution time: 22_669_000 picoseconds.
Weight::from_parts(23_227_000, 0)
// Minimum execution time: 35_051_000 picoseconds.
Weight::from_parts(35_200_000, 0)
.saturating_add(Weight::from_parts(0, 3539))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
@@ -86,8 +84,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `106`
// Estimated: `3571`
// Minimum execution time: 64_486_000 picoseconds.
Weight::from_parts(65_247_000, 0)
// Minimum execution time: 56_235_000 picoseconds.
Weight::from_parts(58_178_000, 0)
.saturating_add(Weight::from_parts(0, 3571))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
@@ -128,8 +126,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_020_000 picoseconds.
Weight::from_parts(7_300_000, 0)
// Minimum execution time: 6_226_000 picoseconds.
Weight::from_parts(6_403_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -139,8 +137,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_022_000 picoseconds.
Weight::from_parts(2_141_000, 0)
// Minimum execution time: 2_020_000 picoseconds.
Weight::from_parts(2_100_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -164,8 +162,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `74`
// Estimated: `3539`
// Minimum execution time: 26_893_000 picoseconds.
Weight::from_parts(27_497_000, 0)
// Minimum execution time: 24_387_000 picoseconds.
Weight::from_parts(24_814_000, 0)
.saturating_add(Weight::from_parts(0, 3539))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(5))
@@ -188,8 +186,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `292`
// Estimated: `3757`
// Minimum execution time: 29_673_000 picoseconds.
Weight::from_parts(30_693_000, 0)
// Minimum execution time: 27_039_000 picoseconds.
Weight::from_parts(27_693_000, 0)
.saturating_add(Weight::from_parts(0, 3757))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
@@ -200,45 +198,45 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_990_000 picoseconds.
Weight::from_parts(2_105_000, 0)
// Minimum execution time: 1_920_000 picoseconds.
Weight::from_parts(2_082_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PolkadotXcm::SupportedVersion` (r:4 w:2)
/// Storage: `PolkadotXcm::SupportedVersion` (r:5 w:2)
/// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn migrate_supported_version() -> Weight {
// Proof Size summary in bytes:
// Measured: `95`
// Estimated: `10985`
// Minimum execution time: 14_819_000 picoseconds.
Weight::from_parts(15_180_000, 0)
.saturating_add(Weight::from_parts(0, 10985))
.saturating_add(T::DbWeight::get().reads(4))
// Measured: `89`
// Estimated: `13454`
// Minimum execution time: 17_141_000 picoseconds.
Weight::from_parts(17_500_000, 0)
.saturating_add(Weight::from_parts(0, 13454))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PolkadotXcm::VersionNotifiers` (r:4 w:2)
/// Storage: `PolkadotXcm::VersionNotifiers` (r:5 w:2)
/// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn migrate_version_notifiers() -> Weight {
// Proof Size summary in bytes:
// Measured: `99`
// Estimated: `10989`
// Minimum execution time: 14_935_000 picoseconds.
Weight::from_parts(15_335_000, 0)
.saturating_add(Weight::from_parts(0, 10989))
.saturating_add(T::DbWeight::get().reads(4))
// Measured: `93`
// Estimated: `13458`
// Minimum execution time: 17_074_000 picoseconds.
Weight::from_parts(17_431_000, 0)
.saturating_add(Weight::from_parts(0, 13458))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:0)
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:0)
/// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn already_notified_target() -> Weight {
// Proof Size summary in bytes:
// Measured: `106`
// Estimated: `13471`
// Minimum execution time: 16_278_000 picoseconds.
Weight::from_parts(16_553_000, 0)
.saturating_add(Weight::from_parts(0, 13471))
.saturating_add(T::DbWeight::get().reads(5))
// Estimated: `15946`
// Minimum execution time: 19_139_000 picoseconds.
Weight::from_parts(19_474_000, 0)
.saturating_add(Weight::from_parts(0, 15946))
.saturating_add(T::DbWeight::get().reads(6))
}
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1)
/// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
@@ -256,36 +254,36 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `142`
// Estimated: `6082`
// Minimum execution time: 26_360_000 picoseconds.
Weight::from_parts(26_868_000, 0)
// Minimum execution time: 24_346_000 picoseconds.
Weight::from_parts(25_318_000, 0)
.saturating_add(Weight::from_parts(0, 6082))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:3 w:0)
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:0)
/// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn notify_target_migration_fail() -> Weight {
// Proof Size summary in bytes:
// Measured: `136`
// Estimated: `8551`
// Minimum execution time: 8_615_000 picoseconds.
Weight::from_parts(8_903_000, 0)
.saturating_add(Weight::from_parts(0, 8551))
.saturating_add(T::DbWeight::get().reads(3))
// Estimated: `11026`
// Minimum execution time: 11_777_000 picoseconds.
Weight::from_parts(12_051_000, 0)
.saturating_add(Weight::from_parts(0, 11026))
.saturating_add(T::DbWeight::get().reads(4))
}
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:2)
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:2)
/// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn migrate_version_notify_targets() -> Weight {
// Proof Size summary in bytes:
// Measured: `106`
// Estimated: `10996`
// Minimum execution time: 15_284_000 picoseconds.
Weight::from_parts(15_504_000, 0)
.saturating_add(Weight::from_parts(0, 10996))
.saturating_add(T::DbWeight::get().reads(4))
// Measured: `100`
// Estimated: `13465`
// Minimum execution time: 17_538_000 picoseconds.
Weight::from_parts(17_832_000, 0)
.saturating_add(Weight::from_parts(0, 13465))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:2)
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:2)
/// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0)
/// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
@@ -299,12 +297,12 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
/// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn migrate_and_notify_old_targets() -> Weight {
// Proof Size summary in bytes:
// Measured: `148`
// Estimated: `11038`
// Minimum execution time: 32_675_000 picoseconds.
Weight::from_parts(33_816_000, 0)
.saturating_add(Weight::from_parts(0, 11038))
.saturating_add(T::DbWeight::get().reads(9))
// Measured: `142`
// Estimated: `13507`
// Minimum execution time: 33_623_000 picoseconds.
Weight::from_parts(34_186_000, 0)
.saturating_add(Weight::from_parts(0, 13507))
.saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `PolkadotXcm::QueryCounter` (r:1 w:1)
@@ -315,8 +313,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `32`
// Estimated: `1517`
// Minimum execution time: 4_058_000 picoseconds.
Weight::from_parts(4_170_000, 0)
// Minimum execution time: 3_363_000 picoseconds.
Weight::from_parts(3_511_000, 0)
.saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
@@ -327,10 +325,22 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `7669`
// Estimated: `11134`
// Minimum execution time: 25_375_000 picoseconds.
Weight::from_parts(26_026_000, 0)
// Minimum execution time: 23_969_000 picoseconds.
Weight::from_parts(24_347_000, 0)
.saturating_add(Weight::from_parts(0, 11134))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PolkadotXcm::AssetTraps` (r:1 w:1)
/// Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn claim_assets() -> Weight {
// Proof Size summary in bytes:
// Measured: `90`
// Estimated: `3555`
// Minimum execution time: 34_071_000 picoseconds.
Weight::from_parts(35_031_000, 0)
.saturating_add(Weight::from_parts(0, 3555))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}