mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 19:07:57 +00:00
Companion for substrate#14435 (BenchmarkHelper for frame-system) (#2766)
* Temporary fix for frame_system::set_code benchmark
* Removed temprary fix
* BenchmarkHelper for frame-system (TODO: add stuff for ParachainSystem OnSetCode)
* BenchmarkHelper for frame-system (TODO: add stuff for ParachainSystem OnSetCode)
* Glutton
* Fix benchmarks for `set_code`
* Changed dummy values to non-zero
* update lockfile for {"polkadot", "substrate"}
---------
Co-authored-by: parity-processbot <>
This commit is contained in:
Generated
+281
-272
File diff suppressed because it is too large
Load Diff
@@ -1067,6 +1067,33 @@ impl<T: Config> Pallet<T> {
|
||||
)],
|
||||
})
|
||||
}
|
||||
|
||||
/// Prepare/insert relevant data for `schedule_code_upgrade` for benchmarks.
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub fn initialize_for_set_code_benchmark(max_code_size: u32) {
|
||||
// insert dummy ValidationData
|
||||
let vfp = PersistedValidationData {
|
||||
parent_head: polkadot_parachain::primitives::HeadData(Default::default()),
|
||||
relay_parent_number: 1,
|
||||
relay_parent_storage_root: Default::default(),
|
||||
max_pov_size: 1_000,
|
||||
};
|
||||
<ValidationData<T>>::put(&vfp);
|
||||
|
||||
// insert dummy HostConfiguration with
|
||||
let host_config = AbridgedHostConfiguration {
|
||||
max_code_size,
|
||||
max_head_data_size: 32 * 1024,
|
||||
max_upward_queue_count: 8,
|
||||
max_upward_queue_size: 1024 * 1024,
|
||||
max_upward_message_size: 4 * 1024,
|
||||
max_upward_message_num_per_candidate: 2,
|
||||
hrmp_max_message_num_per_candidate: 2,
|
||||
validation_upgrade_cooldown: 2,
|
||||
validation_upgrade_delay: 2,
|
||||
};
|
||||
<HostConfiguration<T>>::put(host_config);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ParachainSetCode<T>(sp_std::marker::PhantomData<T>);
|
||||
|
||||
@@ -138,6 +138,7 @@ runtime-benchmarks = [
|
||||
"pallet-xcm/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
"cumulus-pallet-parachain-system/runtime-benchmarks",
|
||||
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
|
||||
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
|
||||
]
|
||||
|
||||
@@ -703,10 +703,19 @@ impl_runtime_apis! {
|
||||
fn dispatch_benchmark(
|
||||
config: frame_benchmarking::BenchmarkConfig
|
||||
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch};
|
||||
use frame_benchmarking::{BenchmarkError, Benchmarking, BenchmarkBatch};
|
||||
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {
|
||||
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
|
||||
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_set_code() {
|
||||
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
|
||||
}
|
||||
}
|
||||
|
||||
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
|
||||
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
|
||||
|
||||
@@ -107,6 +107,7 @@ runtime-benchmarks = [
|
||||
"pallet-xcm/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
"cumulus-pallet-parachain-system/runtime-benchmarks",
|
||||
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
|
||||
"pallet-collator-selection/runtime-benchmarks",
|
||||
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
|
||||
|
||||
@@ -1053,7 +1053,16 @@ impl_runtime_apis! {
|
||||
TrackedStorageKey};
|
||||
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {
|
||||
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
|
||||
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_set_code() {
|
||||
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
|
||||
}
|
||||
}
|
||||
|
||||
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
|
||||
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
|
||||
|
||||
@@ -100,6 +100,7 @@ runtime-benchmarks = [
|
||||
"pallet-xcm/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
"cumulus-pallet-parachain-system/runtime-benchmarks",
|
||||
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
|
||||
"pallet-collator-selection/runtime-benchmarks",
|
||||
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
|
||||
|
||||
@@ -1067,7 +1067,16 @@ impl_runtime_apis! {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, BenchmarkError};
|
||||
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {
|
||||
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
|
||||
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_set_code() {
|
||||
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
|
||||
}
|
||||
}
|
||||
|
||||
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
|
||||
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
|
||||
|
||||
@@ -100,6 +100,7 @@ runtime-benchmarks = [
|
||||
"pallet-utility/runtime-benchmarks",
|
||||
"pallet-xcm/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"cumulus-pallet-parachain-system/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
|
||||
"pallet-collator-selection/runtime-benchmarks",
|
||||
|
||||
@@ -1092,7 +1092,16 @@ impl_runtime_apis! {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, BenchmarkError};
|
||||
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {
|
||||
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
|
||||
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_set_code() {
|
||||
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
|
||||
}
|
||||
}
|
||||
|
||||
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
|
||||
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
|
||||
|
||||
@@ -142,6 +142,7 @@ runtime-benchmarks = [
|
||||
"pallet-xcm/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
"cumulus-pallet-parachain-system/runtime-benchmarks",
|
||||
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
|
||||
"pallet-collator-selection/runtime-benchmarks",
|
||||
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
|
||||
|
||||
@@ -652,7 +652,16 @@ impl_runtime_apis! {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError, TrackedStorageKey};
|
||||
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {
|
||||
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
|
||||
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_set_code() {
|
||||
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
|
||||
}
|
||||
}
|
||||
|
||||
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
|
||||
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
|
||||
|
||||
@@ -142,6 +142,7 @@ runtime-benchmarks = [
|
||||
"pallet-xcm/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
"cumulus-pallet-parachain-system/runtime-benchmarks",
|
||||
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
|
||||
"pallet-collator-selection/runtime-benchmarks",
|
||||
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
|
||||
|
||||
@@ -652,7 +652,16 @@ impl_runtime_apis! {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError, TrackedStorageKey};
|
||||
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {
|
||||
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
|
||||
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_set_code() {
|
||||
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
|
||||
}
|
||||
}
|
||||
|
||||
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
|
||||
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
|
||||
|
||||
@@ -920,7 +920,16 @@ impl_runtime_apis! {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError, TrackedStorageKey};
|
||||
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {
|
||||
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
|
||||
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_set_code() {
|
||||
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
|
||||
}
|
||||
}
|
||||
|
||||
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
|
||||
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
|
||||
|
||||
@@ -98,6 +98,7 @@ runtime-benchmarks = [
|
||||
"pallet-xcm/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
"cumulus-pallet-parachain-system/runtime-benchmarks",
|
||||
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
|
||||
"pallet-collator-selection/runtime-benchmarks",
|
||||
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
|
||||
|
||||
@@ -861,10 +861,19 @@ impl_runtime_apis! {
|
||||
fn dispatch_benchmark(
|
||||
config: frame_benchmarking::BenchmarkConfig
|
||||
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError, TrackedStorageKey};
|
||||
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {
|
||||
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
|
||||
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_set_code() {
|
||||
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
|
||||
}
|
||||
}
|
||||
|
||||
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
|
||||
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
|
||||
|
||||
@@ -149,6 +149,7 @@ runtime-benchmarks = [
|
||||
"pallet-xcm/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
"cumulus-pallet-parachain-system/runtime-benchmarks",
|
||||
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
|
||||
]
|
||||
|
||||
|
||||
@@ -651,10 +651,19 @@ impl_runtime_apis! {
|
||||
fn dispatch_benchmark(
|
||||
config: frame_benchmarking::BenchmarkConfig
|
||||
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError, TrackedStorageKey};
|
||||
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {
|
||||
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
|
||||
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_set_code() {
|
||||
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
|
||||
}
|
||||
}
|
||||
|
||||
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
|
||||
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
|
||||
|
||||
@@ -52,6 +52,7 @@ runtime-benchmarks = [
|
||||
"frame-system-benchmarking/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"pallet-glutton/runtime-benchmarks",
|
||||
"cumulus-pallet-parachain-system/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
]
|
||||
std = [
|
||||
|
||||
@@ -379,9 +379,18 @@ impl_runtime_apis! {
|
||||
fn dispatch_benchmark(
|
||||
config: frame_benchmarking::BenchmarkConfig
|
||||
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError, TrackedStorageKey};
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {
|
||||
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
|
||||
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_set_code() {
|
||||
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
|
||||
}
|
||||
}
|
||||
|
||||
use frame_support::traits::WhitelistedStorageKeys;
|
||||
let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
|
||||
|
||||
Reference in New Issue
Block a user