Skip to content

Commit 859179f

Browse files
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 #3495 --------- Co-authored-by: command-bot <> Co-authored-by: Adrian Catangiu <adrian@parity.io>
1 parent 0fa7f6f commit 859179f

29 files changed

Lines changed: 1549 additions & 1088 deletions

File tree

cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,13 @@ impl_runtime_apis! {
14751475
});
14761476
Some((assets, fee_index as u32, dest, verify))
14771477
}
1478+
1479+
fn get_asset() -> Asset {
1480+
Asset {
1481+
id: AssetId(Location::parent()),
1482+
fun: Fungible(ExistentialDeposit::get()),
1483+
}
1484+
}
14781485
}
14791486

14801487
impl XcmBridgeHubRouterConfig<ToWestendXcmRouterInstance> for Runtime {

cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs

Lines changed: 79 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
//! Autogenerated weights for `pallet_xcm`
1818
//!
19-
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
20-
//! DATE: 2023-12-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
19+
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
20+
//! DATE: 2024-02-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
2121
//! WORST CASE MAP SIZE: `1000000`
22-
//! HOSTNAME: `runner-r43aesjn-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
22+
//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
2323
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-rococo-dev")`, DB CACHE: 1024
2424
2525
// Executed Command:
@@ -64,8 +64,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
6464
// Proof Size summary in bytes:
6565
// Measured: `145`
6666
// Estimated: `3610`
67-
// Minimum execution time: 25_003_000 picoseconds.
68-
Weight::from_parts(25_800_000, 0)
67+
// Minimum execution time: 22_136_000 picoseconds.
68+
Weight::from_parts(22_518_000, 0)
6969
.saturating_add(Weight::from_parts(0, 3610))
7070
.saturating_add(T::DbWeight::get().reads(6))
7171
.saturating_add(T::DbWeight::get().writes(2))
@@ -90,8 +90,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
9090
// Proof Size summary in bytes:
9191
// Measured: `145`
9292
// Estimated: `3610`
93-
// Minimum execution time: 88_832_000 picoseconds.
94-
Weight::from_parts(90_491_000, 0)
93+
// Minimum execution time: 92_277_000 picoseconds.
94+
Weight::from_parts(94_843_000, 0)
9595
.saturating_add(Weight::from_parts(0, 3610))
9696
.saturating_add(T::DbWeight::get().reads(8))
9797
.saturating_add(T::DbWeight::get().writes(3))
@@ -118,8 +118,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
118118
// Proof Size summary in bytes:
119119
// Measured: `400`
120120
// Estimated: `6196`
121-
// Minimum execution time: 138_911_000 picoseconds.
122-
Weight::from_parts(142_483_000, 0)
121+
// Minimum execution time: 120_110_000 picoseconds.
122+
Weight::from_parts(122_968_000, 0)
123123
.saturating_add(Weight::from_parts(0, 6196))
124124
.saturating_add(T::DbWeight::get().reads(9))
125125
.saturating_add(T::DbWeight::get().writes(5))
@@ -148,8 +148,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
148148
// Proof Size summary in bytes:
149149
// Measured: `496`
150150
// Estimated: `6208`
151-
// Minimum execution time: 146_932_000 picoseconds.
152-
Weight::from_parts(153_200_000, 0)
151+
// Minimum execution time: 143_116_000 picoseconds.
152+
Weight::from_parts(147_355_000, 0)
153153
.saturating_add(Weight::from_parts(0, 6208))
154154
.saturating_add(T::DbWeight::get().reads(12))
155155
.saturating_add(T::DbWeight::get().writes(7))
@@ -170,8 +170,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
170170
// Proof Size summary in bytes:
171171
// Measured: `0`
172172
// Estimated: `0`
173-
// Minimum execution time: 7_081_000 picoseconds.
174-
Weight::from_parts(7_397_000, 0)
173+
// Minimum execution time: 6_517_000 picoseconds.
174+
Weight::from_parts(6_756_000, 0)
175175
.saturating_add(Weight::from_parts(0, 0))
176176
.saturating_add(T::DbWeight::get().writes(1))
177177
}
@@ -181,8 +181,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
181181
// Proof Size summary in bytes:
182182
// Measured: `0`
183183
// Estimated: `0`
184-
// Minimum execution time: 2_007_000 picoseconds.
185-
Weight::from_parts(2_183_000, 0)
184+
// Minimum execution time: 1_894_000 picoseconds.
185+
Weight::from_parts(2_024_000, 0)
186186
.saturating_add(Weight::from_parts(0, 0))
187187
.saturating_add(T::DbWeight::get().writes(1))
188188
}
@@ -208,8 +208,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
208208
// Proof Size summary in bytes:
209209
// Measured: `145`
210210
// Estimated: `3610`
211-
// Minimum execution time: 28_790_000 picoseconds.
212-
Weight::from_parts(29_767_000, 0)
211+
// Minimum execution time: 27_314_000 picoseconds.
212+
Weight::from_parts(28_787_000, 0)
213213
.saturating_add(Weight::from_parts(0, 3610))
214214
.saturating_add(T::DbWeight::get().reads(8))
215215
.saturating_add(T::DbWeight::get().writes(5))
@@ -234,8 +234,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
234234
// Proof Size summary in bytes:
235235
// Measured: `363`
236236
// Estimated: `3828`
237-
// Minimum execution time: 30_951_000 picoseconds.
238-
Weight::from_parts(31_804_000, 0)
237+
// Minimum execution time: 29_840_000 picoseconds.
238+
Weight::from_parts(30_589_000, 0)
239239
.saturating_add(Weight::from_parts(0, 3828))
240240
.saturating_add(T::DbWeight::get().reads(7))
241241
.saturating_add(T::DbWeight::get().writes(4))
@@ -246,45 +246,45 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
246246
// Proof Size summary in bytes:
247247
// Measured: `0`
248248
// Estimated: `0`
249-
// Minimum execution time: 2_164_000 picoseconds.
250-
Weight::from_parts(2_311_000, 0)
249+
// Minimum execution time: 1_893_000 picoseconds.
250+
Weight::from_parts(2_017_000, 0)
251251
.saturating_add(Weight::from_parts(0, 0))
252252
.saturating_add(T::DbWeight::get().writes(1))
253253
}
254-
/// Storage: `PolkadotXcm::SupportedVersion` (r:4 w:2)
254+
/// Storage: `PolkadotXcm::SupportedVersion` (r:5 w:2)
255255
/// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
256256
fn migrate_supported_version() -> Weight {
257257
// Proof Size summary in bytes:
258-
// Measured: `162`
259-
// Estimated: `11052`
260-
// Minimum execution time: 16_906_000 picoseconds.
261-
Weight::from_parts(17_612_000, 0)
262-
.saturating_add(Weight::from_parts(0, 11052))
263-
.saturating_add(T::DbWeight::get().reads(4))
258+
// Measured: `159`
259+
// Estimated: `13524`
260+
// Minimum execution time: 19_211_000 picoseconds.
261+
Weight::from_parts(19_552_000, 0)
262+
.saturating_add(Weight::from_parts(0, 13524))
263+
.saturating_add(T::DbWeight::get().reads(5))
264264
.saturating_add(T::DbWeight::get().writes(2))
265265
}
266-
/// Storage: `PolkadotXcm::VersionNotifiers` (r:4 w:2)
266+
/// Storage: `PolkadotXcm::VersionNotifiers` (r:5 w:2)
267267
/// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`)
268268
fn migrate_version_notifiers() -> Weight {
269269
// Proof Size summary in bytes:
270-
// Measured: `166`
271-
// Estimated: `11056`
272-
// Minimum execution time: 17_443_000 picoseconds.
273-
Weight::from_parts(18_032_000, 0)
274-
.saturating_add(Weight::from_parts(0, 11056))
275-
.saturating_add(T::DbWeight::get().reads(4))
270+
// Measured: `163`
271+
// Estimated: `13528`
272+
// Minimum execution time: 19_177_000 picoseconds.
273+
Weight::from_parts(19_704_000, 0)
274+
.saturating_add(Weight::from_parts(0, 13528))
275+
.saturating_add(T::DbWeight::get().reads(5))
276276
.saturating_add(T::DbWeight::get().writes(2))
277277
}
278-
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:0)
278+
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:0)
279279
/// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
280280
fn already_notified_target() -> Weight {
281281
// Proof Size summary in bytes:
282282
// Measured: `173`
283-
// Estimated: `13538`
284-
// Minimum execution time: 18_992_000 picoseconds.
285-
Weight::from_parts(19_464_000, 0)
286-
.saturating_add(Weight::from_parts(0, 13538))
287-
.saturating_add(T::DbWeight::get().reads(5))
283+
// Estimated: `16013`
284+
// Minimum execution time: 20_449_000 picoseconds.
285+
Weight::from_parts(21_075_000, 0)
286+
.saturating_add(Weight::from_parts(0, 16013))
287+
.saturating_add(T::DbWeight::get().reads(6))
288288
}
289289
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1)
290290
/// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
@@ -304,36 +304,36 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
304304
// Proof Size summary in bytes:
305305
// Measured: `212`
306306
// Estimated: `6152`
307-
// Minimum execution time: 28_011_000 picoseconds.
308-
Weight::from_parts(28_716_000, 0)
307+
// Minimum execution time: 26_578_000 picoseconds.
308+
Weight::from_parts(27_545_000, 0)
309309
.saturating_add(Weight::from_parts(0, 6152))
310310
.saturating_add(T::DbWeight::get().reads(8))
311311
.saturating_add(T::DbWeight::get().writes(3))
312312
}
313-
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:3 w:0)
313+
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:0)
314314
/// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
315315
fn notify_target_migration_fail() -> Weight {
316316
// Proof Size summary in bytes:
317317
// Measured: `206`
318-
// Estimated: `8621`
319-
// Minimum execution time: 9_533_000 picoseconds.
320-
Weight::from_parts(9_856_000, 0)
321-
.saturating_add(Weight::from_parts(0, 8621))
322-
.saturating_add(T::DbWeight::get().reads(3))
318+
// Estimated: `11096`
319+
// Minimum execution time: 11_646_000 picoseconds.
320+
Weight::from_parts(11_944_000, 0)
321+
.saturating_add(Weight::from_parts(0, 11096))
322+
.saturating_add(T::DbWeight::get().reads(4))
323323
}
324-
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:2)
324+
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:2)
325325
/// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
326326
fn migrate_version_notify_targets() -> Weight {
327327
// Proof Size summary in bytes:
328-
// Measured: `173`
329-
// Estimated: `11063`
330-
// Minimum execution time: 17_628_000 picoseconds.
331-
Weight::from_parts(18_146_000, 0)
332-
.saturating_add(Weight::from_parts(0, 11063))
333-
.saturating_add(T::DbWeight::get().reads(4))
328+
// Measured: `170`
329+
// Estimated: `13535`
330+
// Minimum execution time: 19_301_000 picoseconds.
331+
Weight::from_parts(19_664_000, 0)
332+
.saturating_add(Weight::from_parts(0, 13535))
333+
.saturating_add(T::DbWeight::get().reads(5))
334334
.saturating_add(T::DbWeight::get().writes(2))
335335
}
336-
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:2)
336+
/// Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:2)
337337
/// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
338338
/// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0)
339339
/// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
@@ -349,12 +349,12 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
349349
/// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
350350
fn migrate_and_notify_old_targets() -> Weight {
351351
// Proof Size summary in bytes:
352-
// Measured: `215`
353-
// Estimated: `11105`
354-
// Minimum execution time: 34_877_000 picoseconds.
355-
Weight::from_parts(35_607_000, 0)
356-
.saturating_add(Weight::from_parts(0, 11105))
357-
.saturating_add(T::DbWeight::get().reads(10))
352+
// Measured: `212`
353+
// Estimated: `13577`
354+
// Minimum execution time: 35_715_000 picoseconds.
355+
Weight::from_parts(36_915_000, 0)
356+
.saturating_add(Weight::from_parts(0, 13577))
357+
.saturating_add(T::DbWeight::get().reads(11))
358358
.saturating_add(T::DbWeight::get().writes(4))
359359
}
360360
/// Storage: `PolkadotXcm::QueryCounter` (r:1 w:1)
@@ -365,8 +365,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
365365
// Proof Size summary in bytes:
366366
// Measured: `103`
367367
// Estimated: `1588`
368-
// Minimum execution time: 5_370_000 picoseconds.
369-
Weight::from_parts(5_616_000, 0)
368+
// Minimum execution time: 4_871_000 picoseconds.
369+
Weight::from_parts(5_066_000, 0)
370370
.saturating_add(Weight::from_parts(0, 1588))
371371
.saturating_add(T::DbWeight::get().reads(1))
372372
.saturating_add(T::DbWeight::get().writes(2))
@@ -377,10 +377,22 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
377377
// Proof Size summary in bytes:
378378
// Measured: `7740`
379379
// Estimated: `11205`
380-
// Minimum execution time: 26_820_000 picoseconds.
381-
Weight::from_parts(27_143_000, 0)
380+
// Minimum execution time: 25_150_000 picoseconds.
381+
Weight::from_parts(26_119_000, 0)
382382
.saturating_add(Weight::from_parts(0, 11205))
383383
.saturating_add(T::DbWeight::get().reads(1))
384384
.saturating_add(T::DbWeight::get().writes(1))
385385
}
386+
/// Storage: `PolkadotXcm::AssetTraps` (r:1 w:1)
387+
/// Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`)
388+
fn claim_assets() -> Weight {
389+
// Proof Size summary in bytes:
390+
// Measured: `160`
391+
// Estimated: `3625`
392+
// Minimum execution time: 38_248_000 picoseconds.
393+
Weight::from_parts(39_122_000, 0)
394+
.saturating_add(Weight::from_parts(0, 3625))
395+
.saturating_add(T::DbWeight::get().reads(1))
396+
.saturating_add(T::DbWeight::get().writes(1))
397+
}
386398
}

cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,13 @@ impl_runtime_apis! {
15111511
});
15121512
Some((assets, fee_index as u32, dest, verify))
15131513
}
1514+
1515+
fn get_asset() -> Asset {
1516+
Asset {
1517+
id: AssetId(Location::parent()),
1518+
fun: Fungible(ExistentialDeposit::get()),
1519+
}
1520+
}
15141521
}
15151522

15161523
use pallet_xcm_bridge_hub_router::benchmarking::{

0 commit comments

Comments
 (0)