Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Use 2D weights in XCM v3 (#6134)
Browse files Browse the repository at this point in the history
* Depend upon sp-core instead of sp-runtime

* Make sp-io a dev-dependency

* Use 2D weights in XCM v3

* cargo fmt

* Add XCM pallet migration to runtimes

* Use from_parts

* cargo fmt

* Fixes

* cargo fmt

* Remove XCMWeight import

* Fixes

* Fixes

* Fixes

* Fixes

* Use translate in migration

* Increase max upward message size in tests

* Fix doc test

* Remove most uses of from_ref_time

* cargo fmt

* Fixes

* Fixes

* Add extrinsic benchmarking to XCM pallet

* cargo fmt

* Fixes

* Use old syntax

* cargo fmt

* Fixes

* Remove hardcoded weights

* Add XCM pallet to benchmarks

* Use successful origin

* Fix weird type parameter compilation issue

* Fixes

* ".git/.scripts/bench-bot.sh" runtime westend-dev pallet_xcm

* ".git/.scripts/bench-bot.sh" runtime rococo-dev pallet_xcm

* ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_xcm

* ".git/.scripts/bench-bot.sh" runtime polkadot-dev pallet_xcm

* Use benchmarked XCM pallet weights

* Fixes

* Fixes

* Use override instead of skip

* Fixes

* Fixes

* Fixes

* Fixes

* ".git/.scripts/bench-bot.sh" runtime polkadot-dev pallet_xcm

* Fixes

* ".git/.scripts/bench-bot.sh" runtime polkadot-dev pallet_xcm

* ".git/.scripts/bench-bot.sh" runtime westend-dev pallet_xcm

Co-authored-by: command-bot <>
  • Loading branch information
KiChjang authored Nov 10, 2022
1 parent 9fc6b88 commit 41fb1f1
Show file tree
Hide file tree
Showing 78 changed files with 1,933 additions and 930 deletions.
5 changes: 4 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ fn default_parachains_host_configuration(
max_upward_queue_count: 8,
max_upward_queue_size: 1024 * 1024,
max_downward_message_size: 1024 * 1024,
ump_service_total_weight: Weight::from_ref_time(100_000_000_000)
.set_proof_size(MAX_POV_SIZE as u64),
ump_service_total_weight: Weight::from_parts(100_000_000_000, MAX_POV_SIZE as u64),
max_upward_message_size: 50 * 1024,
max_upward_message_num_per_candidate: 5,
hrmp_sender_deposit: 0,
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ mod tests {
weight.base_extrinsic = Weight::from_ref_time(100);
})
.for_class(DispatchClass::non_mandatory(), |weight| {
weight.max_total = Some(Weight::from_ref_time(1024).set_proof_size(u64::MAX));
weight.max_total = Some(Weight::from_parts(1024, u64::MAX));
})
.build_or_panic();
pub BlockLength: limits::BlockLength = limits::BlockLength::max(2 * 1024);
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ parameter_types! {
pub const BlockHashCount: u32 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(
Weight::from_ref_time(4 * 1024 * 1024).set_proof_size(u64::MAX),
Weight::from_parts(4 * 1024 * 1024, u64::MAX),
);
}

Expand Down
4 changes: 1 addition & 3 deletions runtime/common/src/paras_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,7 @@ mod tests {
parameter_types! {
pub const BlockHashCount: u32 = 250;
pub BlockWeights: limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(
Weight::from_ref_time(1024).set_proof_size(u64::MAX),
);
frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, u64::MAX));
pub BlockLength: limits::BlockLength =
limits::BlockLength::max_with_normal_ratio(4 * 1024 * 1024, NORMAL_RATIO);
}
Expand Down
3 changes: 3 additions & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,8 @@ pub type Executive = frame_executive::Executive<
// "Properly migrate weights to v2" <https://github.com/paritytech/polkadot/pull/6091>
parachains_configuration::migration::v3::MigrateToV3<Runtime>,
pallet_election_provider_multi_phase::migrations::v1::MigrateToV1<Runtime>,
// "Use 2D weights in XCM v3" <https://github.com/paritytech/polkadot/pull/6134>
pallet_xcm::migration::v1::MigrateToV1<Runtime>,
),
>;
/// The payload being signed in the transactions.
Expand Down Expand Up @@ -1545,6 +1547,7 @@ mod benches {
[pallet_vesting, Vesting]
[pallet_whitelist, Whitelist]
// XCM
[pallet_xcm, XcmPallet]
[pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::<Runtime>]
[pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::<Runtime>]
);
Expand Down
1 change: 1 addition & 0 deletions runtime/kusama/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub mod pallet_treasury;
pub mod pallet_utility;
pub mod pallet_vesting;
pub mod pallet_whitelist;
pub mod pallet_xcm;
pub mod runtime_common_auctions;
pub mod runtime_common_claims;
pub mod runtime_common_crowdloan;
Expand Down
111 changes: 111 additions & 0 deletions runtime/kusama/src/weights/pallet_xcm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_xcm`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-11-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024

// Executed Command:
// /home/benchbot/cargo_target_dir/production/polkadot
// benchmark
// pallet
// --steps=50
// --repeat=20
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json
// --pallet=pallet_xcm
// --chain=kusama-dev
// --header=./file_header.txt
// --output=./runtime/kusama/src/weights/

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;

/// Weight functions for `pallet_xcm`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
fn send() -> Weight {
// Minimum execution time: 32_807 nanoseconds.
Weight::from_ref_time(33_383_000 as u64)
.saturating_add(T::DbWeight::get().reads(5 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
fn teleport_assets() -> Weight {
// Minimum execution time: 28_036 nanoseconds.
Weight::from_ref_time(28_386_000 as u64)
}
fn reserve_transfer_assets() -> Weight {
// Minimum execution time: 26_239 nanoseconds.
Weight::from_ref_time(27_146_000 as u64)
}
fn execute() -> Weight {
// Minimum execution time: 14_327 nanoseconds.
Weight::from_ref_time(14_693_000 as u64)
}
// Storage: XcmPallet SupportedVersion (r:0 w:1)
fn force_xcm_version() -> Weight {
// Minimum execution time: 13_854 nanoseconds.
Weight::from_ref_time(14_658_000 as u64)
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: XcmPallet SafeXcmVersion (r:0 w:1)
fn force_default_xcm_version() -> Weight {
// Minimum execution time: 3_786 nanoseconds.
Weight::from_ref_time(3_986_000 as u64)
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: XcmPallet VersionNotifiers (r:1 w:1)
// Storage: XcmPallet QueryCounter (r:1 w:1)
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
// Storage: XcmPallet Queries (r:0 w:1)
fn force_subscribe_version_notify() -> Weight {
// Minimum execution time: 37_959 nanoseconds.
Weight::from_ref_time(38_689_000 as u64)
.saturating_add(T::DbWeight::get().reads(7 as u64))
.saturating_add(T::DbWeight::get().writes(6 as u64))
}
// Storage: XcmPallet VersionNotifiers (r:1 w:1)
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
// Storage: XcmPallet Queries (r:0 w:1)
fn force_unsubscribe_version_notify() -> Weight {
// Minimum execution time: 41_213 nanoseconds.
Weight::from_ref_time(41_668_000 as u64)
.saturating_add(T::DbWeight::get().reads(6 as u64))
.saturating_add(T::DbWeight::get().writes(5 as u64))
}
}
Loading

0 comments on commit 41fb1f1

Please sign in to comment.