Skip to content

Commit b1e0fa9

Browse files
authored
feat(mainnet): include all benchmarks (#478)
* refactor(benchmakrs): benchmarks mod in its own file (#477) refactor(benchmark): reorg files * feat(benchmarks): add every pallet benchmark to mainnet without XCM * refactor(benchmarks): rename Assets to TrustBackedAssets * fix(motion): map to Weightless Error one origin check failure * fix(monetary): Treausyr BenchmarkHelper to use correct ExistentialDeposit * refactor(mainnet): remove default weights for assets * refactor(mainnet): remove default weights for pallet_session * refactor(mainnet): remove default weights from governance modules * refactor(mainnet): remove default weights from monetary module * refactor(mainnet): remove default weights from proxy * refactor(mainnet): remove default weights from revive * refactor(mainnet): remove default weights from system modules * refactor(mainnet): remove default weights from utiliy * feat(mainnet): introduce benchmarks-ci.sh * refactor(mainnet): remove default weights for pallet_collator_selection * style(collation): more correct comment. * refactor(collation): amend candidates_disabled test * docs(governance): provide docs for CouncilCollective * docs(benchmakrs): allow missing docs * chore(benchmarks): update weights results * refactor(benchmark): rename TrustBackedAssets to Assets * feat(mainnet): include xcm benchmarks (#479) * feat(benchmark): add pallet_xcm extrinsic benchmarks * refactor(benchmkars): amend xcm transfer_assets benchmark fmt * style(benchmarks): pretty comments. * refactor(benchmarks): fund SA of AH on pop in reserve_transfer benchmark * feat(mainnet): add generic & fungible xcm benchmarks * refactor(benchmarks): don't define CheckAccount for pallet_xcm_benchmarks::fungible * refactor(benchmarks): amend benchmarks for pallet_xcm_benchmarks::generic::unsubscribe_version * feat(mainnet): configure xcm Weigher as WeightInfoBounds * docs(xcm): missing doc * refactor(weights): MAX_ASSETS is MaxAssetsIntoHolding * refactor(mainnet): remove default weights from queue pallets * docs(xcm): credit source for WeighAssets impl * docs(xcm): reminders for updating benchmarks * refactor(mainnet): DeliveryHelper considers delivery to parent * docs(benchmarks): clarify xcm NonFungible AllOf weight comments * refactor(api): reorg imports * style(benchmark): refactor import syntax * docs(bencmark): better docs for XcmBalances * refactor(benchmark): define locations via xcm config definitions * test(xcm): ensure xcm encoding size * refactor(benchmark): improve worst_case_response * chore(benchmark): update results for query_response bench * style(benchmarks): remove RelayAsset * docs(benchmarks): explain ExistentialDepositAsset * docs(xcm): note worst_case_holding needs updating * style(benchmark): better naming * chore(benchmarks): update xcm benchmarks visibility * test(xcm): amend router_uses_ump_for_relay_and_xcmp_for_para * test(xcm): amend router_uses_ump_for_relay_and_xcmp_for_para * refactor(benchmarks): unnecessary ParaId::from * refactor(xcm): unnecessary u64 cast * test(xcm): msg_length factor is > 1 in price_for_parent_delivery~ * refactor(motion): improve pallet_motion benchmarking * test(governance): amend simple_majority_is_never_origin * refactor(weights): move weights into pop_runtime_common * syle: fmt * chore(benchmark): improve benchmarking script * fix(ci): add and properly propagate pop-runtime-common try-runtime feat
1 parent a51ea5f commit b1e0fa9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+6780
-82
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk
153153

154154
# Polkadot
155155
pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412", default-features = false }
156+
pallet-xcm-benchmarks = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412", default-features = false }
156157
polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
157158
polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412", default-features = false }
158159
polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412", default-features = false }

integration-tests/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ try-runtime = [
123123
"pallet-balances/std",
124124
"pallet-message-queue/try-runtime",
125125
"paseo-runtime?/try-runtime",
126+
"pop-runtime-common/try-runtime",
126127
"pop-runtime-devnet/try-runtime",
127128
"pop-runtime-mainnet/try-runtime",
128129
"pop-runtime-testnet/try-runtime",

node/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ std = [
137137
]
138138
try-runtime = [
139139
"polkadot-cli/try-runtime",
140+
"pop-runtime-common/try-runtime",
140141
"pop-runtime-devnet/try-runtime",
141142
"pop-runtime-mainnet/try-runtime",
142143
"pop-runtime-testnet/try-runtime",

pallets/motion/src/benchmarking.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,42 @@ mod benchmarks {
1919
use super::*;
2020

2121
#[benchmark]
22-
fn simple_majority() {
22+
fn simple_majority() -> Result<(), BenchmarkError> {
2323
let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into();
24-
let origin = <T as Config>::SimpleMajorityOrigin::try_successful_origin().unwrap();
24+
let origin = <T as Config>::SimpleMajorityOrigin::try_successful_origin()
25+
.map_err(|_| BenchmarkError::Stop("Origin should be present"))?;
2526

2627
#[extrinsic_call]
2728
_(origin as T::RuntimeOrigin, Box::new(call));
2829

29-
assert_last_event::<T>(Event::DispatchSimpleMajority { motion_result: Ok(()) }.into())
30+
assert_last_event::<T>(Event::DispatchSimpleMajority { motion_result: Ok(()) }.into());
31+
Ok(())
3032
}
3133

3234
#[benchmark]
33-
fn super_majority() {
35+
fn super_majority() -> Result<(), BenchmarkError> {
3436
let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into();
35-
let origin = <T as Config>::SuperMajorityOrigin::try_successful_origin().unwrap();
37+
let origin = <T as Config>::SuperMajorityOrigin::try_successful_origin()
38+
.map_err(|_| BenchmarkError::Stop("Origin should be present"))?;
3639

3740
#[extrinsic_call]
3841
_(origin as T::RuntimeOrigin, Box::new(call));
3942

40-
assert_last_event::<T>(Event::DispatchSuperMajority { motion_result: Ok(()) }.into())
43+
assert_last_event::<T>(Event::DispatchSuperMajority { motion_result: Ok(()) }.into());
44+
Ok(())
4145
}
4246

4347
#[benchmark]
44-
fn unanimous() {
48+
fn unanimous() -> Result<(), BenchmarkError> {
4549
let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into();
46-
let origin = <T as Config>::UnanimousOrigin::try_successful_origin().unwrap();
50+
let origin = <T as Config>::UnanimousOrigin::try_successful_origin()
51+
.map_err(|_| BenchmarkError::Stop("Origin should be present"))?;
4752

4853
#[extrinsic_call]
4954
_(origin as T::RuntimeOrigin, Box::new(call));
5055

51-
assert_last_event::<T>(Event::DispatchUnanimous { motion_result: Ok(()) }.into())
56+
assert_last_event::<T>(Event::DispatchUnanimous { motion_result: Ok(()) }.into());
57+
Ok(())
5258
}
5359

5460
impl_benchmark_test_suite!(Motion, crate::mock::new_test_ext(), crate::mock::Test);

runtime/common/Cargo.toml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,119 @@ docify.workspace = true
1717
scale-info = { workspace = true, features = [ "derive" ] }
1818
serde_json = { features = [ "alloc" ], workspace = true }
1919

20+
# Local
21+
pallet-motion.workspace = true
22+
2023
# Substrate
2124
frame-support.workspace = true
25+
frame-system.workspace = true
26+
pallet-assets.workspace = true
27+
pallet-aura.workspace = true
28+
pallet-authorship.workspace = true
29+
pallet-balances.workspace = true
30+
pallet-collective.workspace = true
31+
pallet-message-queue.workspace = true
2232
pallet-multisig.workspace = true
33+
pallet-nfts-sdk.workspace = true
34+
pallet-preimage.workspace = true
35+
pallet-proxy.workspace = true
36+
pallet-revive.workspace = true
37+
pallet-scheduler.workspace = true
38+
pallet-session.workspace = true
39+
pallet-sudo.workspace = true
40+
pallet-timestamp.workspace = true
41+
pallet-transaction-payment.workspace = true
42+
pallet-treasury.workspace = true
43+
pallet-utility.workspace = true
2344
sp-keyring.workspace = true
2445
sp-runtime.workspace = true
2546

47+
# Polkadot
48+
pallet-xcm.workspace = true
49+
pallet-xcm-benchmarks.workspace = true
50+
xcm.workspace = true
51+
xcm-builder.workspace = true
52+
xcm-executor.workspace = true
53+
2654
# Cumulus
55+
cumulus-pallet-aura-ext.workspace = true
56+
cumulus-pallet-parachain-system.workspace = true
57+
cumulus-pallet-xcmp-queue.workspace = true
58+
pallet-collator-selection.workspace = true
2759
parachains-common.workspace = true
2860
polkadot-parachain-primitives.workspace = true
2961
polkadot-primitives.workspace = true
3062

3163
[features]
3264
default = [ "std" ]
3365
runtime-benchmarks = [
66+
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
3467
"frame-support/runtime-benchmarks",
68+
"frame-system/runtime-benchmarks",
69+
"pallet-assets/runtime-benchmarks",
70+
"pallet-balances/runtime-benchmarks",
71+
"pallet-collator-selection/runtime-benchmarks",
72+
"pallet-collective/runtime-benchmarks",
73+
"pallet-message-queue/runtime-benchmarks",
74+
"pallet-motion/runtime-benchmarks",
75+
"pallet-multisig/runtime-benchmarks",
76+
"pallet-nfts-sdk/runtime-benchmarks",
77+
"pallet-preimage/runtime-benchmarks",
78+
"pallet-proxy/runtime-benchmarks",
79+
"pallet-revive/runtime-benchmarks",
80+
"pallet-scheduler/runtime-benchmarks",
81+
"pallet-sudo/runtime-benchmarks",
82+
"pallet-timestamp/runtime-benchmarks",
83+
"pallet-transaction-payment/runtime-benchmarks",
84+
"pallet-treasury/runtime-benchmarks",
85+
"pallet-utility/runtime-benchmarks",
86+
"pallet-xcm-benchmarks/runtime-benchmarks",
87+
"pallet-xcm/runtime-benchmarks",
3588
"parachains-common/runtime-benchmarks",
3689
"polkadot-primitives/runtime-benchmarks",
3790
"sp-runtime/runtime-benchmarks",
91+
"xcm-builder/runtime-benchmarks",
92+
"xcm-executor/runtime-benchmarks",
3893
]
3994
std = [
4095
"codec/std",
96+
"cumulus-pallet-aura-ext/std",
97+
"cumulus-pallet-xcmp-queue/std",
4198
"frame-support/std",
99+
"frame-system/std",
100+
"pallet-assets/std",
101+
"pallet-aura/std",
102+
"pallet-authorship/std",
103+
"pallet-balances/std",
104+
"pallet-collator-selection/std",
105+
"pallet-collective/std",
106+
"pallet-message-queue/std",
107+
"pallet-motion/std",
108+
"pallet-multisig/std",
109+
"pallet-nfts-sdk/std",
110+
"pallet-preimage/std",
111+
"pallet-proxy/std",
112+
"pallet-revive/std",
113+
"pallet-scheduler/std",
114+
"pallet-session/std",
115+
"pallet-sudo/std",
116+
"pallet-timestamp/std",
117+
"pallet-transaction-payment/std",
118+
"pallet-treasury/std",
119+
"pallet-utility/std",
120+
"pallet-xcm-benchmarks/std",
121+
"pallet-xcm/std",
42122
"parachains-common/std",
43123
"polkadot-parachain-primitives/std",
44124
"polkadot-primitives/std",
45125
"scale-info/std",
46126
"serde_json/std",
47127
"sp-runtime/std",
128+
"xcm-builder/std",
129+
"xcm-executor/std",
130+
]
131+
try-runtime = [
132+
"pallet-motion/try-runtime",
133+
"pallet-nfts-sdk/try-runtime",
134+
"pallet-revive/try-runtime",
48135
]

runtime/common/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ extern crate alloc;
1010

1111
/// Functions used for defining the genesis state of a chain.
1212
pub mod genesis;
13+
/// Benchmarked weight functions.
14+
pub mod weights;
1315

1416
/// Nonce for an account
1517
pub type Nonce = u32;

runtime/mainnet/src/weights/block_weights.rs renamed to runtime/common/src/weights/block_weights.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
// See the License for the specific language governing permissions and
1616
// limitations under the License.
1717

18+
#![allow(unused_parens)]
19+
#![allow(unused_imports)]
20+
#![allow(missing_docs)]
1821
pub mod constants {
1922
use frame_support::{
2023
parameter_types,
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
//! Autogenerated weights for `cumulus_pallet_parachain_system`
3+
//!
4+
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 46.0.0
5+
//! DATE: 2025-02-28, STEPS: `5`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]`
6+
//! WORST CASE MAP SIZE: `1000000`
7+
//! HOSTNAME: `tux`, CPU: `12th Gen Intel(R) Core(TM) i7-12700H`
8+
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("pop")`, DB CACHE: `1024`
9+
10+
// Executed Command:
11+
// ./target/release//pop-node
12+
// benchmark
13+
// pallet
14+
// --template=./scripts/templates/runtime-weight-template.hbs
15+
// --chain=pop
16+
// --wasm-execution=compiled
17+
// --pallet=cumulus_pallet_parachain_system
18+
// --extrinsic=*
19+
// --steps=5
20+
// --repeat=5
21+
// --output=./runtime/mainnet/src/weights/
22+
23+
#![cfg_attr(rustfmt, rustfmt_skip)]
24+
#![allow(unused_parens)]
25+
#![allow(unused_imports)]
26+
#![allow(missing_docs)]
27+
28+
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
29+
use core::marker::PhantomData;
30+
31+
/// Weights for `cumulus_pallet_parachain_system`.
32+
pub struct WeightInfo<T>(PhantomData<T>);
33+
impl<T: frame_system::Config> cumulus_pallet_parachain_system::WeightInfo for WeightInfo<T> {
34+
/// Storage: `ParachainSystem::LastDmqMqcHead` (r:1 w:1)
35+
/// Proof: `ParachainSystem::LastDmqMqcHead` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
36+
/// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
37+
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
38+
/// Storage: `MessageQueue::ServiceHead` (r:1 w:1)
39+
/// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`)
40+
/// Storage: `ParachainSystem::ProcessedDownwardMessages` (r:0 w:1)
41+
/// Proof: `ParachainSystem::ProcessedDownwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
42+
/// Storage: `MessageQueue::Pages` (r:0 w:1000)
43+
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(65585), added: 68060, mode: `MaxEncodedLen`)
44+
/// The range of component `n` is `[0, 1000]`.
45+
fn enqueue_inbound_downward_messages(n: u32, ) -> Weight {
46+
// Proof Size summary in bytes:
47+
// Measured: `12`
48+
// Estimated: `3517`
49+
// Minimum execution time: 2_337_000 picoseconds.
50+
Weight::from_parts(2_339_000, 3517)
51+
// Standard Error: 1_263_086
52+
.saturating_add(Weight::from_parts(179_837_875, 0).saturating_mul(n.into()))
53+
.saturating_add(T::DbWeight::get().reads(2_u64))
54+
.saturating_add(T::DbWeight::get().writes(2_u64))
55+
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into())))
56+
}
57+
}

0 commit comments

Comments
 (0)