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
@@ -1148,6 +1148,13 @@ impl_runtime_apis! {
dest
)
}
fn get_asset() -> Asset {
Asset {
id: AssetId(Location::parent()),
fun: Fungible(ExistentialDeposit::get()),
}
}
}
use xcm::latest::prelude::*;
@@ -16,10 +16,10 @@
//! Autogenerated weights for `pallet_xcm`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-12-05, 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-r43aesjn-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("bridge-hub-rococo-dev")`, DB CACHE: 1024
// Executed Command:
@@ -64,8 +64,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `38`
// Estimated: `3503`
// Minimum execution time: 23_683_000 picoseconds.
Weight::from_parts(24_199_000, 0)
// Minimum execution time: 18_513_000 picoseconds.
Weight::from_parts(19_156_000, 0)
.saturating_add(Weight::from_parts(0, 3503))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
@@ -90,8 +90,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `70`
// Estimated: `3593`
// Minimum execution time: 89_524_000 picoseconds.
Weight::from_parts(91_401_000, 0)
// Minimum execution time: 88_096_000 picoseconds.
Weight::from_parts(89_732_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(3))
@@ -126,8 +126,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `70`
// Estimated: `3593`
// Minimum execution time: 91_890_000 picoseconds.
Weight::from_parts(93_460_000, 0)
// Minimum execution time: 88_239_000 picoseconds.
Weight::from_parts(89_729_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(3))
@@ -148,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_152_000 picoseconds.
Weight::from_parts(7_355_000, 0)
// Minimum execution time: 5_955_000 picoseconds.
Weight::from_parts(6_266_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -159,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_081_000 picoseconds.
Weight::from_parts(2_258_000, 0)
// Minimum execution time: 1_868_000 picoseconds.
Weight::from_parts(1_961_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -186,8 +186,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `38`
// Estimated: `3503`
// Minimum execution time: 28_067_000 picoseconds.
Weight::from_parts(28_693_000, 0)
// Minimum execution time: 24_388_000 picoseconds.
Weight::from_parts(25_072_000, 0)
.saturating_add(Weight::from_parts(0, 3503))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(5))
@@ -212,8 +212,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `3720`
// Minimum execution time: 30_420_000 picoseconds.
Weight::from_parts(31_373_000, 0)
// Minimum execution time: 26_762_000 picoseconds.
Weight::from_parts(27_631_000, 0)
.saturating_add(Weight::from_parts(0, 3720))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(4))
@@ -224,45 +224,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_087_000 picoseconds.
Weight::from_parts(2_243_000, 0)
// Minimum execution time: 1_856_000 picoseconds.
Weight::from_parts(2_033_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: 15_142_000 picoseconds.
Weight::from_parts(15_598_000, 0)
.saturating_add(Weight::from_parts(0, 10985))
.saturating_add(T::DbWeight::get().reads(4))
// Measured: `89`
// Estimated: `13454`
// Minimum execution time: 17_718_000 picoseconds.
Weight::from_parts(18_208_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: 15_041_000 picoseconds.
Weight::from_parts(15_493_000, 0)
.saturating_add(Weight::from_parts(0, 10989))
.saturating_add(T::DbWeight::get().reads(4))
// Measured: `93`
// Estimated: `13458`
// Minimum execution time: 17_597_000 picoseconds.
Weight::from_parts(18_090_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_624_000 picoseconds.
Weight::from_parts(17_031_000, 0)
.saturating_add(Weight::from_parts(0, 13471))
.saturating_add(T::DbWeight::get().reads(5))
// Estimated: `15946`
// Minimum execution time: 19_533_000 picoseconds.
Weight::from_parts(20_164_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`)
@@ -282,36 +282,36 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `106`
// Estimated: `6046`
// Minimum execution time: 26_398_000 picoseconds.
Weight::from_parts(26_847_000, 0)
// Minimum execution time: 24_958_000 picoseconds.
Weight::from_parts(25_628_000, 0)
.saturating_add(Weight::from_parts(0, 6046))
.saturating_add(T::DbWeight::get().reads(8))
.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_741_000 picoseconds.
Weight::from_parts(8_954_000, 0)
.saturating_add(Weight::from_parts(0, 8551))
.saturating_add(T::DbWeight::get().reads(3))
// Estimated: `11026`
// Minimum execution time: 12_209_000 picoseconds.
Weight::from_parts(12_612_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_306_000 picoseconds.
Weight::from_parts(15_760_000, 0)
.saturating_add(Weight::from_parts(0, 10996))
.saturating_add(T::DbWeight::get().reads(4))
// Measured: `100`
// Estimated: `13465`
// Minimum execution time: 17_844_000 picoseconds.
Weight::from_parts(18_266_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: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0)
/// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
@@ -327,12 +327,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: `112`
// Estimated: `11002`
// Minimum execution time: 33_127_000 picoseconds.
Weight::from_parts(33_938_000, 0)
.saturating_add(Weight::from_parts(0, 11002))
.saturating_add(T::DbWeight::get().reads(10))
// Measured: `106`
// Estimated: `13471`
// Minimum execution time: 34_131_000 picoseconds.
Weight::from_parts(34_766_000, 0)
.saturating_add(Weight::from_parts(0, 13471))
.saturating_add(T::DbWeight::get().reads(11))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `PolkadotXcm::QueryCounter` (r:1 w:1)
@@ -343,8 +343,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_290_000 picoseconds.
Weight::from_parts(4_450_000, 0)
// Minimum execution time: 3_525_000 picoseconds.
Weight::from_parts(3_724_000, 0)
.saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
@@ -355,10 +355,22 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `7669`
// Estimated: `11134`
// Minimum execution time: 26_408_000 picoseconds.
Weight::from_parts(26_900_000, 0)
// Minimum execution time: 24_975_000 picoseconds.
Weight::from_parts(25_517_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: 33_761_000 picoseconds.
Weight::from_parts(34_674_000, 0)
.saturating_add(Weight::from_parts(0, 3555))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}