referrerpolicy=no-referrer-when-downgrade

polkadot_runtime_parachains/configuration/
benchmarking.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
16#![cfg(feature = "runtime-benchmarks")]
17
18use crate::configuration::*;
19use frame_benchmarking::v2::*;
20use frame_system::RawOrigin;
21use polkadot_primitives::{
22	ExecutorHostFunction, ExecutorParam, ExecutorParams, PvfExecKind, PvfPrepKind,
23};
24use sp_runtime::traits::One;
25
26#[benchmarks]
27mod benchmarks {
28	use super::*;
29
30	#[benchmark]
31	fn set_config_with_block_number() {
32		#[extrinsic_call]
33		set_code_retention_period(RawOrigin::Root, One::one());
34	}
35
36	#[benchmark]
37	fn set_config_with_u32() {
38		#[extrinsic_call]
39		set_max_code_size(RawOrigin::Root, 100);
40	}
41
42	#[benchmark]
43	fn set_config_with_option_u32() {
44		#[extrinsic_call]
45		set_max_validators(RawOrigin::Root, Some(10));
46	}
47
48	#[benchmark]
49	fn set_hrmp_open_request_ttl() -> Result<(), BenchmarkError> {
50		#[block]
51		{
52			Err(BenchmarkError::Override(BenchmarkResult::from_weight(
53				T::BlockWeights::get().max_block,
54			)))?;
55		}
56		Ok(())
57	}
58
59	#[benchmark]
60	fn set_config_with_balance() {
61		#[extrinsic_call]
62		set_hrmp_sender_deposit(RawOrigin::Root, 100_000_000_000);
63	}
64
65	#[benchmark]
66	fn set_config_with_executor_params() {
67		#[extrinsic_call]
68		set_executor_params(
69			RawOrigin::Root,
70			ExecutorParams::from(
71				&[
72					ExecutorParam::MaxMemoryPages(2080),
73					ExecutorParam::StackLogicalMax(65536),
74					ExecutorParam::StackNativeMax(256 * 1024 * 1024),
75					ExecutorParam::WasmExtBulkMemory,
76					ExecutorParam::EnabledHostFunction(ExecutorHostFunction::EccRfc163),
77					ExecutorParam::PrecheckingMaxMemory(2 * 1024 * 1024 * 1024),
78					ExecutorParam::PvfPrepTimeout(PvfPrepKind::Precheck, 60_000),
79					ExecutorParam::PvfPrepTimeout(PvfPrepKind::Prepare, 360_000),
80					ExecutorParam::PvfExecTimeout(PvfExecKind::Backing, 2_000),
81					ExecutorParam::PvfExecTimeout(PvfExecKind::Approval, 12_000),
82				][..],
83			),
84		);
85	}
86
87	#[benchmark]
88	fn set_config_with_perbill() {
89		#[extrinsic_call]
90		set_on_demand_fee_variability(RawOrigin::Root, Perbill::from_percent(100));
91	}
92
93	#[benchmark]
94	fn set_node_feature() {
95		#[extrinsic_call]
96		set_node_feature(RawOrigin::Root, 255, true);
97	}
98
99	#[benchmark]
100	fn set_config_with_scheduler_params() {
101		#[extrinsic_call]
102		set_scheduler_params(RawOrigin::Root, SchedulerParams::default());
103	}
104
105	impl_benchmark_test_suite!(
106		Pallet,
107		crate::mock::new_test_ext(Default::default()),
108		crate::mock::Test
109	);
110}