Skip to content

Commit 20ad75f

Browse files
committed
[pallet_xcm] adapt paritytech/polkadot-sdk#1672 (new reserve_transfer_assets)
1 parent fa52b3e commit 20ad75f

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
@@ -978,7 +978,7 @@ mod benches {
978978
[pallet_collator_selection, CollatorSelection]
979979
[cumulus_pallet_xcmp_queue, XcmpQueue]
980980
// XCM
981-
[pallet_xcm, PolkadotXcm]
981+
[pallet_xcm, PalletXcmExtrinsiscsBenchmark::<Runtime>]
982982
// Bridges
983983
[pallet_xcm_bridge_hub_router, ToPolkadot]
984984
// NOTE: Make sure you point to the individual modules below.
@@ -1226,6 +1226,7 @@ impl_runtime_apis! {
12261226
) {
12271227
use frame_benchmarking::{Benchmarking, BenchmarkList};
12281228
use frame_support::traits::StorageInfoTrait;
1229+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
12291230
use frame_system_benchmarking::Pallet as SystemBench;
12301231
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
12311232
use pallet_xcm_bridge_hub_router::benchmarking::Pallet as XcmBridgeHubRouterBench;
@@ -1278,6 +1279,39 @@ impl_runtime_apis! {
12781279
use xcm_config::{KsmLocation, MaxAssetsIntoHolding};
12791280
use pallet_xcm_benchmarks::asset_instance_from;
12801281

1282+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
1283+
impl pallet_xcm::benchmarking::Config for Runtime {
1284+
fn reachable_dest() -> Option<MultiLocation> {
1285+
Some(Parent.into())
1286+
}
1287+
1288+
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
1289+
// Relay/native token can be teleported between AH and Relay.
1290+
Some((
1291+
MultiAsset {
1292+
fun: Fungible(EXISTENTIAL_DEPOSIT),
1293+
id: Concrete(Parent.into())
1294+
},
1295+
Parent.into(),
1296+
))
1297+
}
1298+
1299+
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
1300+
// AH can reserve transfer native token to some random parachain.
1301+
let random_para_id = 43211234;
1302+
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
1303+
random_para_id.into()
1304+
);
1305+
Some((
1306+
MultiAsset {
1307+
fun: Fungible(EXISTENTIAL_DEPOSIT),
1308+
id: Concrete(Parent.into())
1309+
},
1310+
ParentThen(Parachain(random_para_id).into()).into(),
1311+
))
1312+
}
1313+
}
1314+
12811315
parameter_types! {
12821316
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
12831317
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
@@ -894,7 +894,7 @@ mod benches {
894894
[pallet_collator_selection, CollatorSelection]
895895
[cumulus_pallet_xcmp_queue, XcmpQueue]
896896
// XCM
897-
[pallet_xcm, PolkadotXcm]
897+
[pallet_xcm, PalletXcmExtrinsiscsBenchmark::<Runtime>]
898898
// Bridges
899899
[pallet_xcm_bridge_hub_router, ToKusama]
900900
// NOTE: Make sure you point to the individual modules below.
@@ -1118,6 +1118,7 @@ impl_runtime_apis! {
11181118
) {
11191119
use frame_benchmarking::{Benchmarking, BenchmarkList};
11201120
use frame_support::traits::StorageInfoTrait;
1121+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
11211122
use frame_system_benchmarking::Pallet as SystemBench;
11221123
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
11231124
use pallet_xcm_bridge_hub_router::benchmarking::Pallet as XcmBridgeHubRouterBench;
@@ -1169,6 +1170,39 @@ impl_runtime_apis! {
11691170
use xcm_config::{DotLocation, MaxAssetsIntoHolding};
11701171
use pallet_xcm_benchmarks::asset_instance_from;
11711172

1173+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
1174+
impl pallet_xcm::benchmarking::Config for Runtime {
1175+
fn reachable_dest() -> Option<MultiLocation> {
1176+
Some(Parent.into())
1177+
}
1178+
1179+
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
1180+
// Relay/native token can be teleported between AH and Relay.
1181+
Some((
1182+
MultiAsset {
1183+
fun: Fungible(EXISTENTIAL_DEPOSIT),
1184+
id: Concrete(Parent.into())
1185+
},
1186+
Parent.into(),
1187+
))
1188+
}
1189+
1190+
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
1191+
// AH can reserve transfer native token to some random parachain.
1192+
let random_para_id = 43211234;
1193+
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
1194+
random_para_id.into()
1195+
);
1196+
Some((
1197+
MultiAsset {
1198+
fun: Fungible(EXISTENTIAL_DEPOSIT),
1199+
id: Concrete(Parent.into())
1200+
},
1201+
ParentThen(Parachain(random_para_id).into()).into(),
1202+
))
1203+
}
1204+
}
1205+
11721206
parameter_types! {
11731207
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
11741208
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
@@ -494,7 +494,7 @@ mod benches {
494494
[pallet_collator_selection, CollatorSelection]
495495
[cumulus_pallet_xcmp_queue, XcmpQueue]
496496
// XCM
497-
[pallet_xcm, PolkadotXcm]
497+
[pallet_xcm, PalletXcmExtrinsiscsBenchmark::<Runtime>]
498498
// NOTE: Make sure you point to the individual modules below.
499499
[pallet_xcm_benchmarks::fungible, XcmBalances]
500500
[pallet_xcm_benchmarks::generic, XcmGeneric]
@@ -732,6 +732,7 @@ impl_runtime_apis! {
732732
) {
733733
use frame_benchmarking::{Benchmarking, BenchmarkList};
734734
use frame_support::traits::StorageInfoTrait;
735+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
735736
use frame_system_benchmarking::Pallet as SystemBench;
736737
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
737738

@@ -777,6 +778,29 @@ impl_runtime_apis! {
777778
use xcm::latest::prelude::*;
778779
use xcm_config::KsmRelayLocation;
779780

781+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
782+
impl pallet_xcm::benchmarking::Config for Runtime {
783+
fn reachable_dest() -> Option<MultiLocation> {
784+
Some(Parent.into())
785+
}
786+
787+
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
788+
// Relay/native token can be teleported between BH and Relay.
789+
Some((
790+
MultiAsset {
791+
fun: Fungible(EXISTENTIAL_DEPOSIT),
792+
id: Concrete(Parent.into())
793+
},
794+
Parent.into(),
795+
))
796+
}
797+
798+
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
799+
// Reserve transfers are disabled on BH.
800+
None
801+
}
802+
}
803+
780804
parameter_types! {
781805
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
782806
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)