Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lowering XCM weights #3664

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bd4cca0
Add `reserve-transfer` to the doc for `ExecuteXcmOrigin`
bkontur Mar 12, 2024
1f4cd0e
Still we can open hrmp channel even if it is unpaid or whatever
bkontur Mar 12, 2024
424e598
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=pallet_xcm
Mar 12, 2024
d5be4e1
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=pallet_xcm
Mar 12, 2024
a1080fa
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=pallet_xcm
Mar 12, 2024
63874b0
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=pallet_xcm
Mar 12, 2024
75368fe
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=pallet_xcm
Mar 12, 2024
f8c0e03
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=pallet_xcm
Mar 12, 2024
f1819f4
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=pallet_xcm
Mar 12, 2024
7abad1d
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=pallet_xcm
Mar 12, 2024
ddb729e
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=pallet_xcm
Mar 12, 2024
cd333a5
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=pallet_xcm
Mar 12, 2024
94968cf
".git/.scripts/commands/bench-all/bench-all.sh" --pallet=pallet_xcm
Mar 12, 2024
10f8417
Adjust relay testnet runtimes to the new `DestinationDeliveryHelper`
bkontur Mar 13, 2024
8119fa1
typo
bkontur Mar 13, 2024
04be464
typo
bkontur Mar 13, 2024
3301fd1
Merge remote-tracking branch 'origin/master' into bko-xcm-benchmarks-…
bkontur Mar 13, 2024
32de45c
Merge remote-tracking branch 'origin/master' into bko-xcm-benchmarks-…
bkontur Mar 14, 2024
81b11f0
Adjust system parachain testnet runtimes to the new `DestinationDeliv…
bkontur Mar 14, 2024
3aa3a5f
Fix
bkontur Mar 14, 2024
dbbe1f0
Merge branch 'master' into bko-xcm-benchmarks-nits
bkontur Mar 14, 2024
575b3ac
Add `EnsureXcmVersionForDestination` implementation for XCM benchmarks
bkontur Mar 14, 2024
69929d0
Merge remote-tracking branch 'origin/master' into bko-xcm-benchmarks-…
bkontur Mar 14, 2024
5cc71c0
pallet-xcm: remove extrinsics guessed weight and rely on runtime benc…
bkontur Mar 18, 2024
fc36e62
Merge remote-tracking branch 'origin/bko-xcm-benchmarks-nits' into bk…
bkontur Mar 18, 2024
5b82a73
Merge remote-tracking branch 'origin/master' into bko-xcm-benchmarks-…
bkontur Mar 18, 2024
097cb7b
Merge remote-tracking branch 'origin/master' into bko-xcm-benchmarks-…
bkontur Mar 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1609,10 +1609,20 @@ impl<T: Config> UpwardMessageSender for Pallet<T> {
}

#[cfg(feature = "runtime-benchmarks")]
impl<T: Config> polkadot_runtime_common::xcm_sender::EnsureForParachain for Pallet<T> {
fn ensure(para_id: ParaId) {
if let ChannelStatus::Closed = Self::get_channel_status(para_id) {
Self::open_outbound_hrmp_channel_for_benchmarks_or_tests(para_id)
impl<T: Config> polkadot_runtime_common::xcm_sender::benchmarking::EnsureForDestination
for Pallet<T>
{
fn ensure_for(dest: &xcm::latest::Location) {
if let Some(xcm::latest::prelude::Parachain(para_id)) = dest.first_interior() {
let para_id = ParaId::from(*para_id);
if let ChannelStatus::Closed = Self::get_channel_status(para_id) {
Self::open_outbound_hrmp_channel_for_benchmarks_or_tests(para_id)
}
} else {
log::trace!(
target: "parachain_system",
"Unsupported destination: {dest:?}, an interior location should start with `Junction::Parachain`"
);
}
}
}
Expand Down
27 changes: 27 additions & 0 deletions cumulus/pallets/xcmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,33 @@ impl<T: Config> SendXcm for Pallet<T> {
}
}

/// Implementation of `MatchesDestination`, which can be utilized for `DestinationDeliveryHelper`,
/// while respecting the `SendXcm` implementation for the XCMP pallet.
#[cfg(feature = "runtime-benchmarks")]
pub struct SiblingParachainDestinationMatcher<Parachain>(sp_std::marker::PhantomData<Parachain>);
#[cfg(feature = "runtime-benchmarks")]
impl<Parachain: Get<ParaId>> polkadot_runtime_common::xcm_sender::benchmarking::MatchesDestination
for SiblingParachainDestinationMatcher<Parachain>
{
type PriceForDeliveryId = ParaId;

fn extract_price_for_delivery_id(d: &Location) -> Option<Self::PriceForDeliveryId> {
if let (1, [Parachain(id)]) = d.unpack() {
Some(ParaId::from(*id))
} else {
None
}
}
}
#[cfg(feature = "runtime-benchmarks")]
impl<Parachain: Get<ParaId>> frame_support::traits::Contains<Location>
for SiblingParachainDestinationMatcher<Parachain>
{
fn contains(location: &Location) -> bool {
matches!(location.unpack(), (1, [Parachain(id)]) if ParaId::from(*id) == Parachain::get())
}
}

/// Checks that the XCM is decodable with `MAX_XCM_DECODE_DEPTH`.
///
/// Note that this uses the limit of the sender - not the receiver. It it best effort.
Expand Down
38 changes: 21 additions & 17 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,21 +1359,29 @@ impl_runtime_apis! {
pub const RandomParaId: ParaId = ParaId::new(43211234);
}

type ToParentDeliveryHelper = polkadot_runtime_common::xcm_sender::benchmarking::DestinationDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
cumulus_primitives_utility::ParentDestinationMatcher,
(pallet_xcm::EnsureXcmVersionForDestination<Runtime>,),
>;
type ToParachainDeliveryHelper<ParachainId> = polkadot_runtime_common::xcm_sender::benchmarking::DestinationDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
cumulus_pallet_xcmp_queue::SiblingParachainDestinationMatcher<ParachainId>,
(
ParachainSystem,
pallet_xcm::EnsureXcmVersionForDestination<Runtime>
),
>;

use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
impl pallet_xcm::benchmarking::Config for Runtime {
type DeliveryHelper = (
cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>,
polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem,
>
ToParentDeliveryHelper,
ToParachainDeliveryHelper<RandomParaId>,
);

fn reachable_dest() -> Option<Location> {
Expand Down Expand Up @@ -1494,11 +1502,7 @@ impl_runtime_apis! {
impl pallet_xcm_benchmarks::Config for Runtime {
type XcmConfig = xcm_config::XcmConfig;
type AccountIdConverter = xcm_config::LocationToAccountId;
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>;
type DeliveryHelper = ToParentDeliveryHelper;
fn valid_destination() -> Result<Location, BenchmarkError> {
Ok(TokenLocation::get())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
//! Autogenerated weights for `pallet_xcm`
//!
//! 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: `[]`
//! DATE: 2024-03-12, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `runner-p5qp1txx-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: 22_136_000 picoseconds.
Weight::from_parts(22_518_000, 0)
// Minimum execution time: 21_565_000 picoseconds.
Weight::from_parts(22_086_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: 92_277_000 picoseconds.
Weight::from_parts(94_843_000, 0)
// Minimum execution time: 91_070_000 picoseconds.
Weight::from_parts(92_932_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: 120_110_000 picoseconds.
Weight::from_parts(122_968_000, 0)
// Minimum execution time: 119_154_000 picoseconds.
Weight::from_parts(121_667_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: 143_116_000 picoseconds.
Weight::from_parts(147_355_000, 0)
// Minimum execution time: 140_481_000 picoseconds.
Weight::from_parts(142_770_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: 6_517_000 picoseconds.
Weight::from_parts(6_756_000, 0)
// Minimum execution time: 6_342_000 picoseconds.
Weight::from_parts(6_669_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: 1_894_000 picoseconds.
Weight::from_parts(2_024_000, 0)
// Minimum execution time: 1_836_000 picoseconds.
Weight::from_parts(2_000_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: 27_314_000 picoseconds.
Weight::from_parts(28_787_000, 0)
// Minimum execution time: 26_676_000 picoseconds.
Weight::from_parts(27_490_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: 29_840_000 picoseconds.
Weight::from_parts(30_589_000, 0)
// Minimum execution time: 28_438_000 picoseconds.
Weight::from_parts(29_164_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,8 +246,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_893_000 picoseconds.
Weight::from_parts(2_017_000, 0)
// Minimum execution time: 1_833_000 picoseconds.
Weight::from_parts(1_993_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand All @@ -257,8 +257,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `159`
// Estimated: `13524`
// Minimum execution time: 19_211_000 picoseconds.
Weight::from_parts(19_552_000, 0)
// Minimum execution time: 18_684_000 picoseconds.
Weight::from_parts(19_291_000, 0)
.saturating_add(Weight::from_parts(0, 13524))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -269,8 +269,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `163`
// Estimated: `13528`
// Minimum execution time: 19_177_000 picoseconds.
Weight::from_parts(19_704_000, 0)
// Minimum execution time: 18_614_000 picoseconds.
Weight::from_parts(19_127_000, 0)
.saturating_add(Weight::from_parts(0, 13528))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -281,8 +281,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `173`
// Estimated: `16013`
// Minimum execution time: 20_449_000 picoseconds.
Weight::from_parts(21_075_000, 0)
// Minimum execution time: 21_161_000 picoseconds.
Weight::from_parts(21_531_000, 0)
.saturating_add(Weight::from_parts(0, 16013))
.saturating_add(T::DbWeight::get().reads(6))
}
Expand All @@ -304,8 +304,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `212`
// Estimated: `6152`
// Minimum execution time: 26_578_000 picoseconds.
Weight::from_parts(27_545_000, 0)
// Minimum execution time: 25_947_000 picoseconds.
Weight::from_parts(26_493_000, 0)
.saturating_add(Weight::from_parts(0, 6152))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(3))
Expand All @@ -316,8 +316,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `206`
// Estimated: `11096`
// Minimum execution time: 11_646_000 picoseconds.
Weight::from_parts(11_944_000, 0)
// Minimum execution time: 11_956_000 picoseconds.
Weight::from_parts(12_220_000, 0)
.saturating_add(Weight::from_parts(0, 11096))
.saturating_add(T::DbWeight::get().reads(4))
}
Expand All @@ -327,8 +327,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `170`
// Estimated: `13535`
// Minimum execution time: 19_301_000 picoseconds.
Weight::from_parts(19_664_000, 0)
// Minimum execution time: 19_370_000 picoseconds.
Weight::from_parts(19_970_000, 0)
.saturating_add(Weight::from_parts(0, 13535))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -351,8 +351,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `212`
// Estimated: `13577`
// Minimum execution time: 35_715_000 picoseconds.
Weight::from_parts(36_915_000, 0)
// Minimum execution time: 34_614_000 picoseconds.
Weight::from_parts(35_493_000, 0)
.saturating_add(Weight::from_parts(0, 13577))
.saturating_add(T::DbWeight::get().reads(11))
.saturating_add(T::DbWeight::get().writes(4))
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: 4_871_000 picoseconds.
Weight::from_parts(5_066_000, 0)
// Minimum execution time: 4_875_000 picoseconds.
Weight::from_parts(5_102_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,8 +377,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `7740`
// Estimated: `11205`
// Minimum execution time: 25_150_000 picoseconds.
Weight::from_parts(26_119_000, 0)
// Minimum execution time: 25_792_000 picoseconds.
Weight::from_parts(26_193_000, 0)
.saturating_add(Weight::from_parts(0, 11205))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -389,8 +389,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `160`
// Estimated: `3625`
// Minimum execution time: 38_248_000 picoseconds.
Weight::from_parts(39_122_000, 0)
// Minimum execution time: 37_469_000 picoseconds.
Weight::from_parts(38_276_000, 0)
.saturating_add(Weight::from_parts(0, 3625))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
Expand Down
38 changes: 21 additions & 17 deletions cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1431,21 +1431,29 @@ impl_runtime_apis! {
pub const RandomParaId: ParaId = ParaId::new(43211234);
}

type ToParentDeliveryHelper = polkadot_runtime_common::xcm_sender::benchmarking::DestinationDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
cumulus_primitives_utility::ParentDestinationMatcher,
(pallet_xcm::EnsureXcmVersionForDestination<Runtime>,),
>;
type ToParachainDeliveryHelper<ParachainId> = polkadot_runtime_common::xcm_sender::benchmarking::DestinationDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
cumulus_pallet_xcmp_queue::SiblingParachainDestinationMatcher<ParachainId>,
(
ParachainSystem,
pallet_xcm::EnsureXcmVersionForDestination<Runtime>
),
>;

use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
impl pallet_xcm::benchmarking::Config for Runtime {
type DeliveryHelper = (
cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>,
polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem,
>
ToParentDeliveryHelper,
ToParachainDeliveryHelper<RandomParaId>,
);

fn reachable_dest() -> Option<Location> {
Expand Down Expand Up @@ -1571,11 +1579,7 @@ impl_runtime_apis! {
impl pallet_xcm_benchmarks::Config for Runtime {
type XcmConfig = xcm_config::XcmConfig;
type AccountIdConverter = xcm_config::LocationToAccountId;
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>;
type DeliveryHelper = ToParentDeliveryHelper;
fn valid_destination() -> Result<Location, BenchmarkError> {
Ok(WestendLocation::get())
}
Expand Down
Loading
Loading