Skip to content

Commit cc5065d

Browse files
transfer_assets benchmarking and weights for coretime chains (#8752)
Introduces implementation of `set_up_complex_asset_transfer()` to correctly benchmark weights for `transfer_assets` extrinsics on Rococo Coretime and Westend Coretime. Introducing also test scenarios to cover common xcm teleport use cases --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 1fcaaa4 commit cc5065d

File tree

14 files changed

+476
-197
lines changed

14 files changed

+476
-197
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-rococo/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ sp-runtime = { workspace = true }
2121
polkadot-runtime-parachains = { workspace = true, default-features = true }
2222
rococo-runtime-constants = { workspace = true, default-features = true }
2323
xcm = { workspace = true }
24-
xcm-executor = { workspace = true }
2524

2625
# Cumulus
2726
cumulus-pallet-parachain-system = { workspace = true, default-features = true }

cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-rococo/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@ mod imports {
2727
assert_expected_events, Chain, Parachain, TestExt,
2828
};
2929
pub(crate) use rococo_system_emulated_network::{
30+
asset_hub_rococo_emulated_chain::genesis::ED as ASSET_HUB_ROCOCO_ED,
3031
coretime_rococo_emulated_chain::{
3132
coretime_rococo_runtime::ExistentialDeposit as CoretimeRococoExistentialDeposit,
32-
CoretimeRococoParaPallet as CoretimeRococoPallet,
33+
genesis::ED as CORETIME_ROCOCO_ED, CoretimeRococoParaPallet as CoretimeRococoPallet,
3334
},
34-
CoretimeRococoPara as CoretimeRococo, CoretimeRococoParaReceiver as CoretimeRococoReceiver,
35+
rococo_emulated_chain::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet},
36+
AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver,
37+
AssetHubRococoParaSender as AssetHubRococoSender, CoretimeRococoPara as CoretimeRococo,
38+
CoretimeRococoParaReceiver as CoretimeRococoReceiver,
3539
CoretimeRococoParaSender as CoretimeRococoSender, RococoRelay as Rococo,
40+
RococoRelayReceiver as RococoReceiver, RococoRelaySender as RococoSender,
3641
};
3742
}
3843

cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-rococo/src/tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515

1616
mod claim_assets;
1717
mod coretime_interface;
18+
mod teleport;
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Copyright (C) Parity Technologies (UK) Ltd.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
use crate::imports::*;
17+
use emulated_integration_tests_common::{
18+
test_parachain_is_trusted_teleporter, test_parachain_is_trusted_teleporter_for_relay,
19+
test_relay_is_trusted_teleporter,
20+
};
21+
22+
#[test]
23+
fn teleport_via_limited_teleport_assets_from_and_to_relay() {
24+
let amount = ROCOCO_ED * 10;
25+
let native_asset: Assets = (Here, amount).into();
26+
27+
test_relay_is_trusted_teleporter!(
28+
Rococo, // Origin
29+
vec![CoretimeRococo], // Destinations
30+
(native_asset, amount),
31+
limited_teleport_assets
32+
);
33+
34+
test_parachain_is_trusted_teleporter_for_relay!(
35+
CoretimeRococo, // Origin
36+
Rococo, // Destination
37+
amount,
38+
limited_teleport_assets
39+
);
40+
}
41+
42+
#[test]
43+
fn teleport_via_transfer_assets_from_and_to_relay() {
44+
let amount = ROCOCO_ED * 10;
45+
let native_asset: Assets = (Here, amount).into();
46+
47+
test_relay_is_trusted_teleporter!(
48+
Rococo, // Origin
49+
vec![CoretimeRococo], // Destinations
50+
(native_asset, amount),
51+
transfer_assets
52+
);
53+
54+
test_parachain_is_trusted_teleporter_for_relay!(
55+
CoretimeRococo, // Origin
56+
Rococo, // Destination
57+
amount,
58+
transfer_assets
59+
);
60+
}
61+
62+
#[test]
63+
fn teleport_via_limited_teleport_assets_from_coretime_to_asset_hub() {
64+
let amount = ASSET_HUB_ROCOCO_ED * 100;
65+
let native_asset: Assets = (Parent, amount).into();
66+
67+
test_parachain_is_trusted_teleporter!(
68+
CoretimeRococo, // Origin
69+
vec![AssetHubRococo], // Destinations
70+
(native_asset, amount),
71+
limited_teleport_assets
72+
);
73+
}
74+
75+
#[test]
76+
fn teleport_via_transfer_assets_from_coretime_to_asset_hub() {
77+
let amount = ASSET_HUB_ROCOCO_ED * 100;
78+
let native_asset: Assets = (Parent, amount).into();
79+
80+
test_parachain_is_trusted_teleporter!(
81+
CoretimeRococo, // Origin
82+
vec![AssetHubRococo], // Destinations
83+
(native_asset, amount),
84+
transfer_assets
85+
);
86+
}
87+
88+
#[test]
89+
fn teleport_via_limited_teleport_assets_from_asset_hub_to_coretime() {
90+
let amount = CORETIME_ROCOCO_ED * 100;
91+
let native_asset: Assets = (Parent, amount).into();
92+
93+
test_parachain_is_trusted_teleporter!(
94+
AssetHubRococo, // Origin
95+
vec![CoretimeRococo], // Destinations
96+
(native_asset, amount),
97+
limited_teleport_assets
98+
);
99+
}
100+
101+
#[test]
102+
fn teleport_via_transfer_assets_from_asset_hub_to_coretime() {
103+
let amount = CORETIME_ROCOCO_ED * 100;
104+
let native_asset: Assets = (Parent, amount).into();
105+
106+
test_parachain_is_trusted_teleporter!(
107+
AssetHubRococo, // Origin
108+
vec![CoretimeRococo], // Destinations
109+
(native_asset, amount),
110+
transfer_assets
111+
);
112+
}

cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-westend/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ workspace = true
1515
frame-support = { workspace = true }
1616
pallet-broker = { workspace = true, default-features = true }
1717
pallet-message-queue = { workspace = true }
18-
pallet-xcm = { workspace = true }
1918
sp-runtime = { workspace = true }
2019

2120
# Polkadot

cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-westend/src/lib.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,28 @@ mod imports {
2727
assert_expected_events, Chain, Parachain, TestExt,
2828
};
2929
pub(crate) use westend_system_emulated_network::{
30-
asset_hub_westend_emulated_chain::AssetHubWestendParaPallet as AssetHubWestendPallet,
30+
asset_hub_westend_emulated_chain::{
31+
genesis::ED as ASSET_HUB_WESTEND_ED, AssetHubWestendParaPallet as AssetHubWestendPallet,
32+
},
3133
bridge_hub_westend_emulated_chain::BridgeHubWestendParaPallet as BridgeHubWestendPallet,
3234
collectives_westend_emulated_chain::CollectivesWestendParaPallet as CollectivesWestendPallet,
3335
coretime_westend_emulated_chain::{
3436
self,
3537
coretime_westend_runtime::ExistentialDeposit as CoretimeWestendExistentialDeposit,
36-
CoretimeWestendParaPallet as CoretimeWestendPallet,
38+
genesis::ED as CORETIME_WESTEND_ED, CoretimeWestendParaPallet as CoretimeWestendPallet,
3739
},
3840
penpal_emulated_chain::{PenpalAssetOwner, PenpalBParaPallet as PenpalBPallet},
3941
people_westend_emulated_chain::PeopleWestendParaPallet as PeopleWestendPallet,
40-
westend_emulated_chain::genesis::ED as WESTEND_ED,
41-
AssetHubWestendPara as AssetHubWestend, BridgeHubWestendPara as BridgeHubWestend,
42-
CollectivesWestendPara as CollectivesWestend, CoretimeWestendPara as CoretimeWestend,
42+
westend_emulated_chain::{genesis::ED as WESTEND_ED, WestendRelayPallet as WestendPallet},
43+
AssetHubWestendPara as AssetHubWestend,
44+
AssetHubWestendParaReceiver as AssetHubWestendReceiver,
45+
AssetHubWestendParaSender as AssetHubWestendSender,
46+
BridgeHubWestendPara as BridgeHubWestend, CollectivesWestendPara as CollectivesWestend,
47+
CoretimeWestendPara as CoretimeWestend,
4348
CoretimeWestendParaReceiver as CoretimeWestendReceiver,
4449
CoretimeWestendParaSender as CoretimeWestendSender, PenpalBPara as PenpalB,
4550
PeopleWestendPara as PeopleWestend, WestendRelay as Westend,
51+
WestendRelayReceiver as WestendReceiver, WestendRelaySender as WestendSender,
4652
};
4753
}
4854

cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-westend/src/tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
mod aliases;
1717
mod claim_assets;
1818
mod coretime_interface;
19+
mod teleport;
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Copyright (C) Parity Technologies (UK) Ltd.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
use crate::imports::*;
17+
use emulated_integration_tests_common::{
18+
test_parachain_is_trusted_teleporter, test_parachain_is_trusted_teleporter_for_relay,
19+
test_relay_is_trusted_teleporter,
20+
};
21+
22+
#[test]
23+
fn teleport_via_limited_teleport_assets_from_and_to_relay() {
24+
let amount = WESTEND_ED * 10;
25+
let native_asset: Assets = (Here, amount).into();
26+
27+
test_relay_is_trusted_teleporter!(
28+
Westend, // Origin
29+
vec![CoretimeWestend], // Destinations
30+
(native_asset, amount),
31+
limited_teleport_assets
32+
);
33+
34+
test_parachain_is_trusted_teleporter_for_relay!(
35+
CoretimeWestend, // Origin
36+
Westend, // Destination
37+
amount,
38+
limited_teleport_assets
39+
);
40+
}
41+
42+
#[test]
43+
fn teleport_via_transfer_assets_from_and_to_relay() {
44+
let amount = WESTEND_ED * 10;
45+
let native_asset: Assets = (Here, amount).into();
46+
47+
test_relay_is_trusted_teleporter!(
48+
Westend, // Origin
49+
vec![CoretimeWestend], // Destinations
50+
(native_asset, amount),
51+
transfer_assets
52+
);
53+
54+
test_parachain_is_trusted_teleporter_for_relay!(
55+
CoretimeWestend, // Origin
56+
Westend, // Destination
57+
amount,
58+
transfer_assets
59+
);
60+
}
61+
62+
#[test]
63+
fn teleport_via_limited_teleport_assets_from_coretime_to_asset_hub() {
64+
let amount = ASSET_HUB_WESTEND_ED * 100;
65+
let native_asset: Assets = (Parent, amount).into();
66+
67+
test_parachain_is_trusted_teleporter!(
68+
CoretimeWestend, // Origin
69+
vec![AssetHubWestend], // Destinations
70+
(native_asset, amount),
71+
limited_teleport_assets
72+
);
73+
}
74+
75+
#[test]
76+
fn teleport_via_transfer_assets_from_coretime_to_asset_hub() {
77+
let amount = ASSET_HUB_WESTEND_ED * 100;
78+
let native_asset: Assets = (Parent, amount).into();
79+
80+
test_parachain_is_trusted_teleporter!(
81+
CoretimeWestend, // Origin
82+
vec![AssetHubWestend], // Destinations
83+
(native_asset, amount),
84+
transfer_assets
85+
);
86+
}
87+
88+
#[test]
89+
fn teleport_via_limited_teleport_assets_from_asset_hub_to_coretime() {
90+
let amount = CORETIME_WESTEND_ED * 100;
91+
let native_asset: Assets = (Parent, amount).into();
92+
93+
test_parachain_is_trusted_teleporter!(
94+
AssetHubWestend, // Origin
95+
vec![CoretimeWestend], // Destinations
96+
(native_asset, amount),
97+
limited_teleport_assets
98+
);
99+
}
100+
101+
#[test]
102+
fn teleport_via_transfer_assets_from_asset_hub_to_coretime() {
103+
let amount = CORETIME_WESTEND_ED * 100;
104+
let native_asset: Assets = (Parent, amount).into();
105+
106+
test_parachain_is_trusted_teleporter!(
107+
AssetHubWestend, // Origin
108+
vec![CoretimeWestend], // Destinations
109+
(native_asset, amount),
110+
transfer_assets
111+
);
112+
}

cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,16 @@ impl_runtime_apis! {
10301030
))
10311031
}
10321032

1033+
fn set_up_complex_asset_transfer() -> Option<(Assets, u32, Location, alloc::boxed::Box<dyn FnOnce()>)> {
1034+
let native_location = Parent.into();
1035+
let dest = Parent.into();
1036+
1037+
pallet_xcm::benchmarking::helpers::native_teleport_as_asset_transfer::<Runtime>(
1038+
native_location,
1039+
dest,
1040+
)
1041+
}
1042+
10331043
fn get_asset() -> Asset {
10341044
Asset {
10351045
id: AssetId(Location::parent()),

0 commit comments

Comments
 (0)