Skip to content

Commit a78ffe8

Browse files
committed
[pallet_xcm] adapt paritytech/polkadot-sdk#1672 (new reserve_transfer_assets)
1 parent 3e19b99 commit a78ffe8

File tree

14 files changed

+206
-59
lines changed

14 files changed

+206
-59
lines changed

relay/kusama/src/lib.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,7 @@ mod benches {
17631763
[pallet_whitelist, Whitelist]
17641764
[pallet_asset_rate, AssetRate]
17651765
// XCM
1766-
[pallet_xcm, XcmPallet]
1766+
[pallet_xcm, PalletXcmExtrinsiscsBenchmark::<Runtime>]
17671767
[pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::<Runtime>]
17681768
[pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::<Runtime>]
17691769
);
@@ -2291,6 +2291,7 @@ sp_api::impl_runtime_apis! {
22912291
use pallet_session_benchmarking::Pallet as SessionBench;
22922292
use pallet_offences_benchmarking::Pallet as OffencesBench;
22932293
use pallet_election_provider_support_benchmarking::Pallet as ElectionProviderBench;
2294+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
22942295
use frame_system_benchmarking::Pallet as SystemBench;
22952296
use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench;
22962297
use frame_benchmarking::baseline::Pallet as Baseline;
@@ -2339,6 +2340,32 @@ sp_api::impl_runtime_apis! {
23392340
impl pallet_nomination_pools_benchmarking::Config for Runtime {}
23402341
impl runtime_parachains::disputes::slashing::benchmarking::Config for Runtime {}
23412342

2343+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
2344+
impl pallet_xcm::benchmarking::Config for Runtime {
2345+
fn reachable_dest() -> Option<MultiLocation> {
2346+
Some(crate::xcm_config::AssetHubLocation::get())
2347+
}
2348+
2349+
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
2350+
// Relay/native token can be teleported to/from AH.
2351+
Some((
2352+
MultiAsset { fun: Fungible(EXISTENTIAL_DEPOSIT), id: Concrete(Here.into()) },
2353+
crate::xcm_config::AssetHubLocation::get(),
2354+
))
2355+
}
2356+
2357+
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
2358+
// Relay can reserve transfer native token to some random parachain.
2359+
Some((
2360+
MultiAsset {
2361+
fun: Fungible(EXISTENTIAL_DEPOSIT),
2362+
id: Concrete(Here.into())
2363+
},
2364+
crate::Junction::Parachain(43211234).into(),
2365+
))
2366+
}
2367+
}
2368+
23422369
parameter_types! {
23432370
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
23442371
TokenLocation::get(),

relay/kusama/src/xcm_config.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,6 @@ parameter_types! {
374374
pub const FellowsBodyId: BodyId = BodyId::Technical;
375375
}
376376

377-
#[cfg(feature = "runtime-benchmarks")]
378-
parameter_types! {
379-
pub ReachableDest: Option<MultiLocation> = Some(Parachain(1000).into());
380-
}
381-
382377
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior
383378
/// location of this chain.
384379
pub type LocalOriginToLocation = (
@@ -438,8 +433,6 @@ impl pallet_xcm::Config for Runtime {
438433
type MaxRemoteLockConsumers = ConstU32<0>;
439434
type RemoteLockConsumerIdentifier = ();
440435
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
441-
#[cfg(feature = "runtime-benchmarks")]
442-
type ReachableDest = ReachableDest;
443436
type AdminOrigin = EnsureRoot<AccountId>;
444437
}
445438

relay/polkadot/src/lib.rs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ mod benches {
17791779
[pallet_whitelist, Whitelist]
17801780
[pallet_asset_rate, AssetRate]
17811781
// XCM
1782-
[pallet_xcm, XcmPallet]
1782+
[pallet_xcm, PalletXcmExtrinsiscsBenchmark::<Runtime>]
17831783
[pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::<Runtime>]
17841784
[pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::<Runtime>]
17851785
);
@@ -2291,6 +2291,7 @@ sp_api::impl_runtime_apis! {
22912291
use pallet_offences_benchmarking::Pallet as OffencesBench;
22922292
use pallet_election_provider_support_benchmarking::Pallet as ElectionProviderBench;
22932293
use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench;
2294+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
22942295
use frame_system_benchmarking::Pallet as SystemBench;
22952296
use frame_benchmarking::baseline::Pallet as Baseline;
22962297

@@ -2329,9 +2330,31 @@ sp_api::impl_runtime_apis! {
23292330
impl pallet_nomination_pools_benchmarking::Config for Runtime {}
23302331
impl runtime_parachains::disputes::slashing::benchmarking::Config for Runtime {}
23312332

2332-
let mut whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
2333-
let treasury_key = frame_system::Account::<Runtime>::hashed_key_for(Treasury::account_id());
2334-
whitelist.push(treasury_key.to_vec().into());
2333+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
2334+
impl pallet_xcm::benchmarking::Config for Runtime {
2335+
fn reachable_dest() -> Option<MultiLocation> {
2336+
Some(crate::xcm_config::AssetHubLocation::get())
2337+
}
2338+
2339+
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
2340+
// Relay/native token can be teleported to/from AH.
2341+
Some((
2342+
MultiAsset { fun: Fungible(EXISTENTIAL_DEPOSIT), id: Concrete(Here.into()) },
2343+
crate::xcm_config::AssetHubLocation::get(),
2344+
))
2345+
}
2346+
2347+
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
2348+
// Relay can reserve transfer native token to some random parachain.
2349+
Some((
2350+
MultiAsset {
2351+
fun: Fungible(EXISTENTIAL_DEPOSIT),
2352+
id: Concrete(Here.into())
2353+
},
2354+
crate::Junction::Parachain(43211234).into(),
2355+
))
2356+
}
2357+
}
23352358

23362359
parameter_types! {
23372360
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
@@ -2433,6 +2456,10 @@ sp_api::impl_runtime_apis! {
24332456
}
24342457
}
24352458

2459+
let mut whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
2460+
let treasury_key = frame_system::Account::<Runtime>::hashed_key_for(Treasury::account_id());
2461+
whitelist.push(treasury_key.to_vec().into());
2462+
24362463
let mut batches = Vec::<BenchmarkBatch>::new();
24372464
let params = (&config, &whitelist);
24382465

relay/polkadot/src/xcm_config.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,6 @@ parameter_types! {
382382
pub const TreasurerBodyId: BodyId = BodyId::Index(TREASURER_INDEX);
383383
}
384384

385-
#[cfg(feature = "runtime-benchmarks")]
386-
parameter_types! {
387-
pub ReachableDest: Option<MultiLocation> = Some(Parachain(1000).into());
388-
}
389-
390385
/// Type to convert the `GeneralAdmin` origin to a Plurality `MultiLocation` value.
391386
pub type GeneralAdminToPlurality =
392387
OriginToPluralityVoice<RuntimeOrigin, GeneralAdmin, GeneralAdminBodyId>;
@@ -454,7 +449,5 @@ impl pallet_xcm::Config for Runtime {
454449
type MaxRemoteLockConsumers = ConstU32<0>;
455450
type RemoteLockConsumerIdentifier = ();
456451
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
457-
#[cfg(feature = "runtime-benchmarks")]
458-
type ReachableDest = ReachableDest;
459452
type AdminOrigin = EnsureRoot<AccountId>;
460453
}

system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ mod benches {
974974
[pallet_collator_selection, CollatorSelection]
975975
[cumulus_pallet_xcmp_queue, XcmpQueue]
976976
// XCM
977-
[pallet_xcm, PolkadotXcm]
977+
[pallet_xcm, PalletXcmExtrinsiscsBenchmark::<Runtime>]
978978
// Bridges
979979
[pallet_xcm_bridge_hub_router, ToPolkadot]
980980
// NOTE: Make sure you point to the individual modules below.
@@ -1222,6 +1222,7 @@ impl_runtime_apis! {
12221222
) {
12231223
use frame_benchmarking::{Benchmarking, BenchmarkList};
12241224
use frame_support::traits::StorageInfoTrait;
1225+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
12251226
use frame_system_benchmarking::Pallet as SystemBench;
12261227
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
12271228
use pallet_xcm_bridge_hub_router::benchmarking::Pallet as XcmBridgeHubRouterBench;
@@ -1274,6 +1275,39 @@ impl_runtime_apis! {
12741275
use xcm_config::{KsmLocation, MaxAssetsIntoHolding};
12751276
use pallet_xcm_benchmarks::asset_instance_from;
12761277

1278+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
1279+
impl pallet_xcm::benchmarking::Config for Runtime {
1280+
fn reachable_dest() -> Option<MultiLocation> {
1281+
Some(Parent.into())
1282+
}
1283+
1284+
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
1285+
// Relay/native token can be teleported between AH and Relay.
1286+
Some((
1287+
MultiAsset {
1288+
fun: Fungible(EXISTENTIAL_DEPOSIT),
1289+
id: Concrete(Parent.into())
1290+
},
1291+
Parent.into(),
1292+
))
1293+
}
1294+
1295+
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
1296+
// AH can reserve transfer native token to some random parachain.
1297+
let random_para_id = 43211234;
1298+
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
1299+
random_para_id.into()
1300+
);
1301+
Some((
1302+
MultiAsset {
1303+
fun: Fungible(EXISTENTIAL_DEPOSIT),
1304+
id: Concrete(Parent.into())
1305+
},
1306+
ParentThen(Parachain(random_para_id).into()).into(),
1307+
))
1308+
}
1309+
}
1310+
12771311
parameter_types! {
12781312
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
12791313
KsmLocation::get(),

system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -629,11 +629,6 @@ pub type XcmRouter = WithUniqueTopic<(
629629
ToPolkadotXcmRouter,
630630
)>;
631631

632-
#[cfg(feature = "runtime-benchmarks")]
633-
parameter_types! {
634-
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
635-
}
636-
637632
impl pallet_xcm::Config for Runtime {
638633
type RuntimeEvent = RuntimeEvent;
639634
// We want to disallow users sending (arbitrary) XCMs from this chain.
@@ -663,8 +658,6 @@ impl pallet_xcm::Config for Runtime {
663658
type SovereignAccountOf = LocationToAccountId;
664659
type MaxLockers = ConstU32<8>;
665660
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
666-
#[cfg(feature = "runtime-benchmarks")]
667-
type ReachableDest = ReachableDest;
668661
type AdminOrigin = EnsureRoot<AccountId>;
669662
type MaxRemoteLockConsumers = ConstU32<0>;
670663
type RemoteLockConsumerIdentifier = ();

system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ mod benches {
890890
[pallet_collator_selection, CollatorSelection]
891891
[cumulus_pallet_xcmp_queue, XcmpQueue]
892892
// XCM
893-
[pallet_xcm, PolkadotXcm]
893+
[pallet_xcm, PalletXcmExtrinsiscsBenchmark::<Runtime>]
894894
// Bridges
895895
[pallet_xcm_bridge_hub_router, ToKusama]
896896
// NOTE: Make sure you point to the individual modules below.
@@ -1114,6 +1114,7 @@ impl_runtime_apis! {
11141114
) {
11151115
use frame_benchmarking::{Benchmarking, BenchmarkList};
11161116
use frame_support::traits::StorageInfoTrait;
1117+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
11171118
use frame_system_benchmarking::Pallet as SystemBench;
11181119
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
11191120
use pallet_xcm_bridge_hub_router::benchmarking::Pallet as XcmBridgeHubRouterBench;
@@ -1165,6 +1166,39 @@ impl_runtime_apis! {
11651166
use xcm_config::{DotLocation, MaxAssetsIntoHolding};
11661167
use pallet_xcm_benchmarks::asset_instance_from;
11671168

1169+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
1170+
impl pallet_xcm::benchmarking::Config for Runtime {
1171+
fn reachable_dest() -> Option<MultiLocation> {
1172+
Some(Parent.into())
1173+
}
1174+
1175+
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
1176+
// Relay/native token can be teleported between AH and Relay.
1177+
Some((
1178+
MultiAsset {
1179+
fun: Fungible(EXISTENTIAL_DEPOSIT),
1180+
id: Concrete(Parent.into())
1181+
},
1182+
Parent.into(),
1183+
))
1184+
}
1185+
1186+
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
1187+
// AH can reserve transfer native token to some random parachain.
1188+
let random_para_id = 43211234;
1189+
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
1190+
random_para_id.into()
1191+
);
1192+
Some((
1193+
MultiAsset {
1194+
fun: Fungible(EXISTENTIAL_DEPOSIT),
1195+
id: Concrete(Parent.into())
1196+
},
1197+
ParentThen(Parachain(random_para_id).into()).into(),
1198+
))
1199+
}
1200+
}
1201+
11681202
parameter_types! {
11691203
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
11701204
DotLocation::get(),

system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,6 @@ pub type XcmRouter = WithUniqueTopic<(
551551
ToKusamaXcmRouter,
552552
)>;
553553

554-
#[cfg(feature = "runtime-benchmarks")]
555-
parameter_types! {
556-
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
557-
}
558-
559554
impl pallet_xcm::Config for Runtime {
560555
type RuntimeEvent = RuntimeEvent;
561556
// We want to disallow users sending (arbitrary) XCMs from this chain.
@@ -585,8 +580,6 @@ impl pallet_xcm::Config for Runtime {
585580
type SovereignAccountOf = LocationToAccountId;
586581
type MaxLockers = ConstU32<8>;
587582
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
588-
#[cfg(feature = "runtime-benchmarks")]
589-
type ReachableDest = ReachableDest;
590583
type AdminOrigin = EnsureRoot<AccountId>;
591584
type MaxRemoteLockConsumers = ConstU32<0>;
592585
type RemoteLockConsumerIdentifier = ();

system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ mod benches {
490490
[pallet_collator_selection, CollatorSelection]
491491
[cumulus_pallet_xcmp_queue, XcmpQueue]
492492
// XCM
493-
[pallet_xcm, PolkadotXcm]
493+
[pallet_xcm, PalletXcmExtrinsiscsBenchmark::<Runtime>]
494494
// NOTE: Make sure you point to the individual modules below.
495495
[pallet_xcm_benchmarks::fungible, XcmBalances]
496496
[pallet_xcm_benchmarks::generic, XcmGeneric]
@@ -728,6 +728,7 @@ impl_runtime_apis! {
728728
) {
729729
use frame_benchmarking::{Benchmarking, BenchmarkList};
730730
use frame_support::traits::StorageInfoTrait;
731+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
731732
use frame_system_benchmarking::Pallet as SystemBench;
732733
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
733734

@@ -773,6 +774,29 @@ impl_runtime_apis! {
773774
use xcm::latest::prelude::*;
774775
use xcm_config::KsmRelayLocation;
775776

777+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
778+
impl pallet_xcm::benchmarking::Config for Runtime {
779+
fn reachable_dest() -> Option<MultiLocation> {
780+
Some(Parent.into())
781+
}
782+
783+
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
784+
// Relay/native token can be teleported between BH and Relay.
785+
Some((
786+
MultiAsset {
787+
fun: Fungible(EXISTENTIAL_DEPOSIT),
788+
id: Concrete(Parent.into())
789+
},
790+
Parent.into(),
791+
))
792+
}
793+
794+
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
795+
// Reserve transfers are disabled on BH.
796+
None
797+
}
798+
}
799+
776800
parameter_types! {
777801
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
778802
KsmRelayLocation::get(),

system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,6 @@ pub type XcmRouter = WithUniqueTopic<(
299299
XcmpQueue,
300300
)>;
301301

302-
#[cfg(feature = "runtime-benchmarks")]
303-
parameter_types! {
304-
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
305-
}
306-
307302
impl pallet_xcm::Config for Runtime {
308303
type RuntimeEvent = RuntimeEvent;
309304
// We want to disallow users sending (arbitrary) XCMs from this chain.
@@ -332,8 +327,6 @@ impl pallet_xcm::Config for Runtime {
332327
type SovereignAccountOf = LocationToAccountId;
333328
type MaxLockers = ConstU32<8>;
334329
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
335-
#[cfg(feature = "runtime-benchmarks")]
336-
type ReachableDest = ReachableDest;
337330
type AdminOrigin = EnsureRoot<AccountId>;
338331
type MaxRemoteLockConsumers = ConstU32<0>;
339332
type RemoteLockConsumerIdentifier = ();

0 commit comments

Comments
 (0)