Skip to content

Commit

Permalink
Add claim_assets extrinsic to pallet-xcm (paritytech#3403)
Browse files Browse the repository at this point in the history
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 paritytech#3495

---------

Co-authored-by: command-bot <>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
  • Loading branch information
2 people authored and skunert committed Mar 4, 2024
1 parent 2a6486e commit e8051ac
Show file tree
Hide file tree
Showing 29 changed files with 1,501 additions and 1,043 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,13 @@ impl_runtime_apis! {
});
Some((assets, fee_index as u32, dest, verify))
}

fn get_asset() -> Asset {
Asset {
id: AssetId(Location::parent()),
fun: Fungible(ExistentialDeposit::get()),
}
}
}

impl XcmBridgeHubRouterConfig<ToWestendXcmRouterInstance> for Runtime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("asset-hub-rococo-dev")`, DB CACHE: 1024

// Executed Command:
Expand Down Expand Up @@ -64,8 +64,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `145`
// Estimated: `3610`
// Minimum execution time: 25_003_000 picoseconds.
Weight::from_parts(25_800_000, 0)
// Minimum execution time: 22_136_000 picoseconds.
Weight::from_parts(22_518_000, 0)
.saturating_add(Weight::from_parts(0, 3610))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -90,8 +90,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `145`
// Estimated: `3610`
// Minimum execution time: 88_832_000 picoseconds.
Weight::from_parts(90_491_000, 0)
// Minimum execution time: 92_277_000 picoseconds.
Weight::from_parts(94_843_000, 0)
.saturating_add(Weight::from_parts(0, 3610))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(3))
Expand All @@ -118,8 +118,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `400`
// Estimated: `6196`
// Minimum execution time: 138_911_000 picoseconds.
Weight::from_parts(142_483_000, 0)
// Minimum execution time: 120_110_000 picoseconds.
Weight::from_parts(122_968_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(5))
Expand Down Expand Up @@ -148,8 +148,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `496`
// Estimated: `6208`
// Minimum execution time: 146_932_000 picoseconds.
Weight::from_parts(153_200_000, 0)
// Minimum execution time: 143_116_000 picoseconds.
Weight::from_parts(147_355_000, 0)
.saturating_add(Weight::from_parts(0, 6208))
.saturating_add(T::DbWeight::get().reads(12))
.saturating_add(T::DbWeight::get().writes(7))
Expand All @@ -170,8 +170,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_081_000 picoseconds.
Weight::from_parts(7_397_000, 0)
// Minimum execution time: 6_517_000 picoseconds.
Weight::from_parts(6_756_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand All @@ -181,8 +181,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_007_000 picoseconds.
Weight::from_parts(2_183_000, 0)
// Minimum execution time: 1_894_000 picoseconds.
Weight::from_parts(2_024_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand All @@ -208,8 +208,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `145`
// Estimated: `3610`
// Minimum execution time: 28_790_000 picoseconds.
Weight::from_parts(29_767_000, 0)
// Minimum execution time: 27_314_000 picoseconds.
Weight::from_parts(28_787_000, 0)
.saturating_add(Weight::from_parts(0, 3610))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(5))
Expand All @@ -234,8 +234,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `363`
// Estimated: `3828`
// Minimum execution time: 30_951_000 picoseconds.
Weight::from_parts(31_804_000, 0)
// Minimum execution time: 29_840_000 picoseconds.
Weight::from_parts(30_589_000, 0)
.saturating_add(Weight::from_parts(0, 3828))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(4))
Expand All @@ -246,45 +246,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_164_000 picoseconds.
Weight::from_parts(2_311_000, 0)
// Minimum execution time: 1_893_000 picoseconds.
Weight::from_parts(2_017_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: `162`
// Estimated: `11052`
// Minimum execution time: 16_906_000 picoseconds.
Weight::from_parts(17_612_000, 0)
.saturating_add(Weight::from_parts(0, 11052))
.saturating_add(T::DbWeight::get().reads(4))
// Measured: `159`
// Estimated: `13524`
// Minimum execution time: 19_211_000 picoseconds.
Weight::from_parts(19_552_000, 0)
.saturating_add(Weight::from_parts(0, 13524))
.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: `166`
// Estimated: `11056`
// Minimum execution time: 17_443_000 picoseconds.
Weight::from_parts(18_032_000, 0)
.saturating_add(Weight::from_parts(0, 11056))
.saturating_add(T::DbWeight::get().reads(4))
// Measured: `163`
// Estimated: `13528`
// Minimum execution time: 19_177_000 picoseconds.
Weight::from_parts(19_704_000, 0)
.saturating_add(Weight::from_parts(0, 13528))
.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: `173`
// Estimated: `13538`
// Minimum execution time: 18_992_000 picoseconds.
Weight::from_parts(19_464_000, 0)
.saturating_add(Weight::from_parts(0, 13538))
.saturating_add(T::DbWeight::get().reads(5))
// Estimated: `16013`
// Minimum execution time: 20_449_000 picoseconds.
Weight::from_parts(21_075_000, 0)
.saturating_add(Weight::from_parts(0, 16013))
.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`)
Expand All @@ -304,36 +304,36 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `212`
// Estimated: `6152`
// Minimum execution time: 28_011_000 picoseconds.
Weight::from_parts(28_716_000, 0)
// Minimum execution time: 26_578_000 picoseconds.
Weight::from_parts(27_545_000, 0)
.saturating_add(Weight::from_parts(0, 6152))
.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: `206`
// Estimated: `8621`
// Minimum execution time: 9_533_000 picoseconds.
Weight::from_parts(9_856_000, 0)
.saturating_add(Weight::from_parts(0, 8621))
.saturating_add(T::DbWeight::get().reads(3))
// Estimated: `11096`
// Minimum execution time: 11_646_000 picoseconds.
Weight::from_parts(11_944_000, 0)
.saturating_add(Weight::from_parts(0, 11096))
.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: `173`
// Estimated: `11063`
// Minimum execution time: 17_628_000 picoseconds.
Weight::from_parts(18_146_000, 0)
.saturating_add(Weight::from_parts(0, 11063))
.saturating_add(T::DbWeight::get().reads(4))
// Measured: `170`
// Estimated: `13535`
// Minimum execution time: 19_301_000 picoseconds.
Weight::from_parts(19_664_000, 0)
.saturating_add(Weight::from_parts(0, 13535))
.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`)
Expand All @@ -349,12 +349,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: `215`
// Estimated: `11105`
// Minimum execution time: 34_877_000 picoseconds.
Weight::from_parts(35_607_000, 0)
.saturating_add(Weight::from_parts(0, 11105))
.saturating_add(T::DbWeight::get().reads(10))
// Measured: `212`
// Estimated: `13577`
// Minimum execution time: 35_715_000 picoseconds.
Weight::from_parts(36_915_000, 0)
.saturating_add(Weight::from_parts(0, 13577))
.saturating_add(T::DbWeight::get().reads(11))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `PolkadotXcm::QueryCounter` (r:1 w:1)
Expand All @@ -365,8 +365,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `103`
// Estimated: `1588`
// Minimum execution time: 5_370_000 picoseconds.
Weight::from_parts(5_616_000, 0)
// Minimum execution time: 4_871_000 picoseconds.
Weight::from_parts(5_066_000, 0)
.saturating_add(Weight::from_parts(0, 1588))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -377,10 +377,22 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `7740`
// Estimated: `11205`
// Minimum execution time: 26_820_000 picoseconds.
Weight::from_parts(27_143_000, 0)
// Minimum execution time: 25_150_000 picoseconds.
Weight::from_parts(26_119_000, 0)
.saturating_add(Weight::from_parts(0, 11205))
.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: `160`
// Estimated: `3625`
// Minimum execution time: 38_248_000 picoseconds.
Weight::from_parts(39_122_000, 0)
.saturating_add(Weight::from_parts(0, 3625))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,13 @@ impl_runtime_apis! {
});
Some((assets, fee_index as u32, dest, verify))
}

fn get_asset() -> Asset {
Asset {
id: AssetId(Location::parent()),
fun: Fungible(ExistentialDeposit::get()),
}
}
}

use pallet_xcm_bridge_hub_router::benchmarking::{
Expand Down
Loading

0 comments on commit e8051ac

Please sign in to comment.