Skip to content

Commit 70f49b1

Browse files
bkonturclaravanstaden
authored andcommitted
[pallet_xcm] adapt paritytech/polkadot-sdk#1672 (new reserve_transfer_assets)
1 parent e60088e commit 70f49b1

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
@@ -1751,7 +1751,7 @@ mod benches {
17511751
[pallet_whitelist, Whitelist]
17521752
[pallet_asset_rate, AssetRate]
17531753
// XCM
1754-
[pallet_xcm, XcmPallet]
1754+
[pallet_xcm, PalletXcmExtrinsiscsBenchmark::<Runtime>]
17551755
[pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::<Runtime>]
17561756
[pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::<Runtime>]
17571757
);
@@ -2279,6 +2279,7 @@ sp_api::impl_runtime_apis! {
22792279
use pallet_session_benchmarking::Pallet as SessionBench;
22802280
use pallet_offences_benchmarking::Pallet as OffencesBench;
22812281
use pallet_election_provider_support_benchmarking::Pallet as ElectionProviderBench;
2282+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
22822283
use frame_system_benchmarking::Pallet as SystemBench;
22832284
use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench;
22842285
use frame_benchmarking::baseline::Pallet as Baseline;
@@ -2327,6 +2328,32 @@ sp_api::impl_runtime_apis! {
23272328
impl pallet_nomination_pools_benchmarking::Config for Runtime {}
23282329
impl runtime_parachains::disputes::slashing::benchmarking::Config for Runtime {}
23292330

2331+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
2332+
impl pallet_xcm::benchmarking::Config for Runtime {
2333+
fn reachable_dest() -> Option<MultiLocation> {
2334+
Some(crate::xcm_config::AssetHubLocation::get())
2335+
}
2336+
2337+
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
2338+
// Relay/native token can be teleported to/from AH.
2339+
Some((
2340+
MultiAsset { fun: Fungible(EXISTENTIAL_DEPOSIT), id: Concrete(Here.into()) },
2341+
crate::xcm_config::AssetHubLocation::get(),
2342+
))
2343+
}
2344+
2345+
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
2346+
// Relay can reserve transfer native token to some random parachain.
2347+
Some((
2348+
MultiAsset {
2349+
fun: Fungible(EXISTENTIAL_DEPOSIT),
2350+
id: Concrete(Here.into())
2351+
},
2352+
crate::Junction::Parachain(43211234).into(),
2353+
))
2354+
}
2355+
}
2356+
23302357
parameter_types! {
23312358
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
23322359
TokenLocation::get(),

relay/kusama/src/xcm_config.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,6 @@ parameter_types! {
222222
pub const FellowsBodyId: BodyId = BodyId::Technical;
223223
}
224224

225-
#[cfg(feature = "runtime-benchmarks")]
226-
parameter_types! {
227-
pub ReachableDest: Option<MultiLocation> = Some(Parachain(1000).into());
228-
}
229-
230225
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior
231226
/// location of this chain.
232227
pub type LocalOriginToLocation = (
@@ -286,8 +281,6 @@ impl pallet_xcm::Config for Runtime {
286281
type MaxRemoteLockConsumers = ConstU32<0>;
287282
type RemoteLockConsumerIdentifier = ();
288283
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
289-
#[cfg(feature = "runtime-benchmarks")]
290-
type ReachableDest = ReachableDest;
291284
type AdminOrigin = EnsureRoot<AccountId>;
292285
}
293286

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((
@@ -2440,6 +2463,10 @@ sp_api::impl_runtime_apis! {
24402463
}
24412464
}
24422465

2466+
let mut whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
2467+
let treasury_key = frame_system::Account::<Runtime>::hashed_key_for(Treasury::account_id());
2468+
whitelist.push(treasury_key.to_vec().into());
2469+
24432470
let mut batches = Vec::<BenchmarkBatch>::new();
24442471
let params = (&config, &whitelist);
24452472

relay/polkadot/src/xcm_config.rs

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

244-
#[cfg(feature = "runtime-benchmarks")]
245-
parameter_types! {
246-
pub ReachableDest: Option<MultiLocation> = Some(Parachain(1000).into());
247-
}
248-
249244
/// Type to convert the `GeneralAdmin` origin to a Plurality `MultiLocation` value.
250245
pub type GeneralAdminToPlurality =
251246
OriginToPluralityVoice<RuntimeOrigin, GeneralAdmin, GeneralAdminBodyId>;
@@ -313,7 +308,5 @@ impl pallet_xcm::Config for Runtime {
313308
type MaxRemoteLockConsumers = ConstU32<0>;
314309
type RemoteLockConsumerIdentifier = ();
315310
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
316-
#[cfg(feature = "runtime-benchmarks")]
317-
type ReachableDest = ReachableDest;
318311
type AdminOrigin = EnsureRoot<AccountId>;
319312
}

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ mod benches {
976976
[pallet_collator_selection, CollatorSelection]
977977
[cumulus_pallet_xcmp_queue, XcmpQueue]
978978
// XCM
979-
[pallet_xcm, PolkadotXcm]
979+
[pallet_xcm, PalletXcmExtrinsiscsBenchmark::<Runtime>]
980980
// Bridges
981981
[pallet_xcm_bridge_hub_router, ToPolkadot]
982982
// NOTE: Make sure you point to the individual modules below.
@@ -1224,6 +1224,7 @@ impl_runtime_apis! {
12241224
) {
12251225
use frame_benchmarking::{Benchmarking, BenchmarkList};
12261226
use frame_support::traits::StorageInfoTrait;
1227+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
12271228
use frame_system_benchmarking::Pallet as SystemBench;
12281229
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
12291230
use pallet_xcm_bridge_hub_router::benchmarking::Pallet as XcmBridgeHubRouterBench;
@@ -1276,6 +1277,39 @@ impl_runtime_apis! {
12761277
use xcm_config::{KsmLocation, MaxAssetsIntoHolding};
12771278
use pallet_xcm_benchmarks::asset_instance_from;
12781279

1280+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
1281+
impl pallet_xcm::benchmarking::Config for Runtime {
1282+
fn reachable_dest() -> Option<MultiLocation> {
1283+
Some(Parent.into())
1284+
}
1285+
1286+
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
1287+
// Relay/native token can be teleported between AH and Relay.
1288+
Some((
1289+
MultiAsset {
1290+
fun: Fungible(EXISTENTIAL_DEPOSIT),
1291+
id: Concrete(Parent.into())
1292+
},
1293+
Parent.into(),
1294+
))
1295+
}
1296+
1297+
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
1298+
// AH can reserve transfer native token to some random parachain.
1299+
let random_para_id = 43211234;
1300+
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
1301+
random_para_id.into()
1302+
);
1303+
Some((
1304+
MultiAsset {
1305+
fun: Fungible(EXISTENTIAL_DEPOSIT),
1306+
id: Concrete(Parent.into())
1307+
},
1308+
ParentThen(Parachain(random_para_id).into()).into(),
1309+
))
1310+
}
1311+
}
1312+
12791313
parameter_types! {
12801314
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
12811315
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
@@ -654,11 +654,6 @@ pub type XcmRouter = WithUniqueTopic<(
654654
SovereignPaidRemoteExporter<bridging::EthereumNetworkExportTable, XcmpQueue, UniversalLocation>,
655655
)>;
656656

657-
#[cfg(feature = "runtime-benchmarks")]
658-
parameter_types! {
659-
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
660-
}
661-
662657
impl pallet_xcm::Config for Runtime {
663658
type RuntimeEvent = RuntimeEvent;
664659
// We want to disallow users sending (arbitrary) XCMs from this chain.
@@ -688,8 +683,6 @@ impl pallet_xcm::Config for Runtime {
688683
type SovereignAccountOf = LocationToAccountId;
689684
type MaxLockers = ConstU32<8>;
690685
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
691-
#[cfg(feature = "runtime-benchmarks")]
692-
type ReachableDest = ReachableDest;
693686
type AdminOrigin = EnsureRoot<AccountId>;
694687
type MaxRemoteLockConsumers = ConstU32<0>;
695688
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
@@ -893,7 +893,7 @@ mod benches {
893893
[pallet_collator_selection, CollatorSelection]
894894
[cumulus_pallet_xcmp_queue, XcmpQueue]
895895
// XCM
896-
[pallet_xcm, PolkadotXcm]
896+
[pallet_xcm, PalletXcmExtrinsiscsBenchmark::<Runtime>]
897897
// Bridges
898898
[pallet_xcm_bridge_hub_router, ToKusama]
899899
// NOTE: Make sure you point to the individual modules below.
@@ -1117,6 +1117,7 @@ impl_runtime_apis! {
11171117
) {
11181118
use frame_benchmarking::{Benchmarking, BenchmarkList};
11191119
use frame_support::traits::StorageInfoTrait;
1120+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
11201121
use frame_system_benchmarking::Pallet as SystemBench;
11211122
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
11221123
use pallet_xcm_bridge_hub_router::benchmarking::Pallet as XcmBridgeHubRouterBench;
@@ -1168,6 +1169,39 @@ impl_runtime_apis! {
11681169
use xcm_config::{DotLocation, MaxAssetsIntoHolding};
11691170
use pallet_xcm_benchmarks::asset_instance_from;
11701171

1172+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
1173+
impl pallet_xcm::benchmarking::Config for Runtime {
1174+
fn reachable_dest() -> Option<MultiLocation> {
1175+
Some(Parent.into())
1176+
}
1177+
1178+
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
1179+
// Relay/native token can be teleported between AH and Relay.
1180+
Some((
1181+
MultiAsset {
1182+
fun: Fungible(EXISTENTIAL_DEPOSIT),
1183+
id: Concrete(Parent.into())
1184+
},
1185+
Parent.into(),
1186+
))
1187+
}
1188+
1189+
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
1190+
// AH can reserve transfer native token to some random parachain.
1191+
let random_para_id = 43211234;
1192+
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
1193+
random_para_id.into()
1194+
);
1195+
Some((
1196+
MultiAsset {
1197+
fun: Fungible(EXISTENTIAL_DEPOSIT),
1198+
id: Concrete(Parent.into())
1199+
},
1200+
ParentThen(Parachain(random_para_id).into()).into(),
1201+
))
1202+
}
1203+
}
1204+
11711205
parameter_types! {
11721206
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
11731207
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
@@ -579,11 +579,6 @@ pub type XcmRouter = WithUniqueTopic<(
579579
SovereignPaidRemoteExporter<bridging::EthereumNetworkExportTable, XcmpQueue, UniversalLocation>,
580580
)>;
581581

582-
#[cfg(feature = "runtime-benchmarks")]
583-
parameter_types! {
584-
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
585-
}
586-
587582
impl pallet_xcm::Config for Runtime {
588583
type RuntimeEvent = RuntimeEvent;
589584
// We want to disallow users sending (arbitrary) XCMs from this chain.
@@ -613,8 +608,6 @@ impl pallet_xcm::Config for Runtime {
613608
type SovereignAccountOf = LocationToAccountId;
614609
type MaxLockers = ConstU32<8>;
615610
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
616-
#[cfg(feature = "runtime-benchmarks")]
617-
type ReachableDest = ReachableDest;
618611
type AdminOrigin = EnsureRoot<AccountId>;
619612
type MaxRemoteLockConsumers = ConstU32<0>;
620613
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
@@ -670,7 +670,7 @@ mod benches {
670670
[pallet_collator_selection, CollatorSelection]
671671
[cumulus_pallet_xcmp_queue, XcmpQueue]
672672
// XCM
673-
[pallet_xcm, PolkadotXcm]
673+
[pallet_xcm, PalletXcmExtrinsiscsBenchmark::<Runtime>]
674674
// NOTE: Make sure you point to the individual modules below.
675675
[pallet_xcm_benchmarks::fungible, XcmBalances]
676676
[pallet_xcm_benchmarks::generic, XcmGeneric]
@@ -929,6 +929,7 @@ impl_runtime_apis! {
929929
) {
930930
use frame_benchmarking::{Benchmarking, BenchmarkList};
931931
use frame_support::traits::StorageInfoTrait;
932+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
932933
use frame_system_benchmarking::Pallet as SystemBench;
933934
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
934935

@@ -974,6 +975,29 @@ impl_runtime_apis! {
974975
use xcm::latest::prelude::*;
975976
use xcm_config::KsmRelayLocation;
976977

978+
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsiscsBenchmark;
979+
impl pallet_xcm::benchmarking::Config for Runtime {
980+
fn reachable_dest() -> Option<MultiLocation> {
981+
Some(Parent.into())
982+
}
983+
984+
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
985+
// Relay/native token can be teleported between BH and Relay.
986+
Some((
987+
MultiAsset {
988+
fun: Fungible(EXISTENTIAL_DEPOSIT),
989+
id: Concrete(Parent.into())
990+
},
991+
Parent.into(),
992+
))
993+
}
994+
995+
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
996+
// Reserve transfers are disabled on BH.
997+
None
998+
}
999+
}
1000+
9771001
parameter_types! {
9781002
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
9791003
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
@@ -328,11 +328,6 @@ pub type XcmRouter = WithUniqueTopic<(
328328
XcmpQueue,
329329
)>;
330330

331-
#[cfg(feature = "runtime-benchmarks")]
332-
parameter_types! {
333-
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
334-
}
335-
336331
impl pallet_xcm::Config for Runtime {
337332
type RuntimeEvent = RuntimeEvent;
338333
// We want to disallow users sending (arbitrary) XCMs from this chain.
@@ -361,8 +356,6 @@ impl pallet_xcm::Config for Runtime {
361356
type SovereignAccountOf = LocationToAccountId;
362357
type MaxLockers = ConstU32<8>;
363358
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
364-
#[cfg(feature = "runtime-benchmarks")]
365-
type ReachableDest = ReachableDest;
366359
type AdminOrigin = EnsureRoot<AccountId>;
367360
type MaxRemoteLockConsumers = ConstU32<0>;
368361
type RemoteLockConsumerIdentifier = ();

0 commit comments

Comments
 (0)