From 0ceee42e00c533c515d5dc2f34642d6225c3be1b Mon Sep 17 00:00:00 2001 From: Daan van der Plas Date: Tue, 5 Sep 2023 12:33:11 +0200 Subject: [PATCH 01/13] Draft benchmark sanity weight test --- cumulus/parachain-template/runtime/src/lib.rs | 10 +- polkadot/runtime/rococo/src/lib.rs | 8 +- .../bin/node-template/runtime/src/lib.rs | 13 +- substrate/bin/node/runtime/src/lib.rs | 8 +- substrate/frame/benchmarking/src/utils.rs | 7 +- .../benchmarking-cli/src/pallet/command.rs | 108 ++++++++---- .../frame/benchmarking-cli/src/pallet/mod.rs | 5 + .../benchmarking-cli/src/pallet/writer.rs | 159 +++++++++++++++--- 8 files changed, 244 insertions(+), 74 deletions(-) diff --git a/cumulus/parachain-template/runtime/src/lib.rs b/cumulus/parachain-template/runtime/src/lib.rs index 038597096f6a..9417ce80c16a 100644 --- a/cumulus/parachain-template/runtime/src/lib.rs +++ b/cumulus/parachain-template/runtime/src/lib.rs @@ -31,8 +31,8 @@ use frame_support::{ parameter_types, traits::{ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything}, weights::{ - constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient, - WeightToFeeCoefficients, WeightToFeePolynomial, + constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, RuntimeDbWeight, Weight, + WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }, PalletId, }; @@ -698,6 +698,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -708,7 +710,9 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - (list, storage_info) + let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index e043852901f1..30eb9abc80c9 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -63,7 +63,7 @@ use frame_support::{ Contains, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, PrivilegeCmp, ProcessMessage, ProcessMessageError, StorageMapShim, WithdrawReasons, }, - weights::{ConstantMultiplier, WeightMeter}, + weights::{ConstantMultiplier, RuntimeDbWeight, WeightMeter}, PalletId, }; use frame_system::EnsureRoot; @@ -2092,6 +2092,8 @@ sp_api::impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -2103,7 +2105,9 @@ sp_api::impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/substrate/bin/node-template/runtime/src/lib.rs b/substrate/bin/node-template/runtime/src/lib.rs index 216be9588bca..e102c85d8b70 100644 --- a/substrate/bin/node-template/runtime/src/lib.rs +++ b/substrate/bin/node-template/runtime/src/lib.rs @@ -25,7 +25,9 @@ use sp_version::RuntimeVersion; // A few exports that help ease life for downstream crates. pub use frame_support::{ - construct_runtime, parameter_types, + construct_runtime, + dispatch::DispatchClass, + parameter_types, traits::{ ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, KeyOwnerProofSystem, Randomness, StorageInfo, @@ -34,7 +36,7 @@ pub use frame_support::{ constants::{ BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND, }, - IdentityFee, Weight, + IdentityFee, RuntimeDbWeight, Weight, }, StorageValue, }; @@ -514,6 +516,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + RuntimeDbWeight, ) { use frame_benchmarking::{baseline, Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -524,8 +528,9 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - - (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 4f34e4ecd812..8c6bf9cfeeeb 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -45,7 +45,7 @@ use frame_support::{ constants::{ BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND, }, - ConstantMultiplier, IdentityFee, Weight, + ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight, }, BoundedVec, PalletId, }; @@ -2683,6 +2683,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + RuntimeDbWeight, ) { use frame_benchmarking::{baseline, Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -2701,8 +2703,10 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); + let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: RuntimeDbWeight = ::DbWeight::get(); - (list, storage_info) + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/substrate/frame/benchmarking/src/utils.rs b/substrate/frame/benchmarking/src/utils.rs index b9b3f91e2dd7..1374ebca2c90 100644 --- a/substrate/frame/benchmarking/src/utils.rs +++ b/substrate/frame/benchmarking/src/utils.rs @@ -17,7 +17,10 @@ //! Interfaces, types and utils for benchmarking a FRAME runtime. use codec::{Decode, Encode}; -use frame_support::{dispatch::DispatchErrorWithPostInfo, pallet_prelude::*, traits::StorageInfo}; +use frame_support::{ + dispatch::DispatchErrorWithPostInfo, pallet_prelude::*, traits::StorageInfo, + weights::RuntimeDbWeight, +}; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; @@ -235,7 +238,7 @@ sp_api::decl_runtime_apis! { /// Parameters /// - `extra`: Also list benchmarks marked "extra" which would otherwise not be /// needed for weight calculation. - fn benchmark_metadata(extra: bool) -> (Vec, Vec); + fn benchmark_metadata(extra: bool) -> (Vec, Vec, Weight, RuntimeDbWeight); /// Dispatch the given benchmark. fn dispatch_benchmark(config: BenchmarkConfig) -> Result, sp_runtime::RuntimeString>; diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index 84da3aaa02c0..80e1feaab19b 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -18,10 +18,13 @@ use super::{writer, PalletCmd}; use codec::{Decode, Encode}; use frame_benchmarking::{ - Analysis, BenchmarkBatch, BenchmarkBatchSplitResults, BenchmarkList, BenchmarkParameter, - BenchmarkResult, BenchmarkSelector, + Analysis, AnalysisChoice, BenchmarkBatch, BenchmarkBatchSplitResults, BenchmarkList, + BenchmarkParameter, BenchmarkResult, BenchmarkSelector, +}; +use frame_support::{ + traits::StorageInfo, + weights::{RuntimeDbWeight, Weight}, }; -use frame_support::traits::StorageInfo; use linked_hash_map::LinkedHashMap; use sc_cli::{execution_method_from_cli, CliConfiguration, Result, SharedParams}; use sc_client_db::BenchmarkingState; @@ -48,11 +51,11 @@ const LOG_TARGET: &'static str = "frame::benchmark::pallet"; #[derive(Serialize, Debug, Clone, Eq, PartialEq)] pub(crate) struct ComponentRange { /// Name of the component. - name: String, + pub(crate) name: String, /// Minimal valid value of the component. min: u32, /// Maximal valid value of the component. - max: u32, + pub(crate) max: u32, } /// How the PoV size of a storage item should be estimated. @@ -175,20 +178,6 @@ impl PalletCmd { }; } - if let Some(json_input) = &self.json_input { - let raw_data = match std::fs::read(json_input) { - Ok(raw_data) => raw_data, - Err(error) => - return Err(format!("Failed to read {:?}: {}", json_input, error).into()), - }; - let batches: Vec = match serde_json::from_slice(&raw_data) { - Ok(batches) => batches, - Err(error) => - return Err(format!("Failed to deserialize {:?}: {}", json_input, error).into()), - }; - return self.output_from_results(&batches) - } - let spec = config.chain_spec; let pallet = self.pallet.clone().unwrap_or_default(); let pallet = pallet.as_bytes(); @@ -257,9 +246,25 @@ impl PalletCmd { .execute() .map_err(|e| format!("{}: {}", ERROR_METADATA_NOT_FOUND, e))?; - let (list, storage_info) = - <(Vec, Vec) as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark metadata: {:?}", e))?; + let (list, storage_info, max_extrinsic_weight, db_weight) = + <(Vec, Vec, Weight, RuntimeDbWeight) as Decode>::decode( + &mut &result[..], + ) + .map_err(|e| format!("Failed to decode benchmark metadata: {:?}", e))?; + + if let Some(json_input) = &self.json_input { + let raw_data = match std::fs::read(json_input) { + Ok(raw_data) => raw_data, + Err(error) => + return Err(format!("Failed to read {:?}: {}", json_input, error).into()), + }; + let batches: Vec = match serde_json::from_slice(&raw_data) { + Ok(batches) => batches, + Err(error) => + return Err(format!("Failed to deserialize {:?}: {}", json_input, error).into()), + }; + return self.output_from_results(&batches, max_extrinsic_weight, db_weight) + } // Use the benchmark list and the user input to determine the set of benchmarks to run. let mut benchmarks_to_run = Vec::new(); @@ -501,7 +506,14 @@ impl PalletCmd { // Combine all of the benchmark results, so that benchmarks of the same pallet/function // are together. let batches = combine_batches(batches, batches_db); - self.output(&batches, &storage_info, &component_ranges, pov_modes) + self.output( + &batches, + &storage_info, + &component_ranges, + pov_modes, + max_extrinsic_weight, + db_weight, + ) } fn output( @@ -510,6 +522,8 @@ impl PalletCmd { storage_info: &[StorageInfo], component_ranges: &HashMap<(Vec, Vec), Vec>, pov_modes: PovModesMap, + max_extrinsic_weight: Weight, + db_weight: RuntimeDbWeight, ) -> Result<()> { // Jsonify the result and write it to a file or stdout if desired. if !self.jsonify(&batches)? { @@ -517,24 +531,43 @@ impl PalletCmd { self.print_summary(&batches, &storage_info, pov_modes.clone()) } + // Which analysis function should be used when outputting benchmarks + let analysis_choice: AnalysisChoice = + self.output_analysis.clone().try_into().map_err(writer::io_error)?; + let pov_analysis_choice: AnalysisChoice = + self.output_pov_analysis.clone().try_into().map_err(writer::io_error)?; + + // // Organize results by pallet into a JSON map + let all_results = writer::map_results( + &batches, + &storage_info, + &component_ranges, + pov_modes.clone(), + self.default_pov_mode, + &analysis_choice, + &pov_analysis_choice, + self.worst_case_map_values, + self.additional_trie_layers, + max_extrinsic_weight, + db_weight, + self.sanity_check, + )?; + // Create the weights.rs file. if let Some(output_path) = &self.output { - writer::write_results( - &batches, - &storage_info, - &component_ranges, - pov_modes, - self.default_pov_mode, - output_path, - self, - )?; + writer::write_results(output_path, self, analysis_choice, all_results)?; } Ok(()) } /// Re-analyze a batch historic benchmark timing data. Will not take the PoV into account. - fn output_from_results(&self, batches: &[BenchmarkBatchSplitResults]) -> Result<()> { + fn output_from_results( + &self, + batches: &[BenchmarkBatchSplitResults], + max_extrinsic_weight: Weight, + db_weight: RuntimeDbWeight, + ) -> Result<()> { let mut component_ranges = HashMap::<(Vec, Vec), HashMap>::new(); for batch in batches { @@ -566,7 +599,14 @@ impl PalletCmd { }) .collect(); - self.output(batches, &[], &component_ranges, Default::default()) + self.output( + batches, + &[], + &component_ranges, + Default::default(), + max_extrinsic_weight, + db_weight, + ) } /// Jsonifies the passed batches and writes them to stdout or into a file. diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs index c69ce1765fc9..d895657c91b9 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -201,4 +201,9 @@ pub struct PalletCmd { /// This exists only to restore legacy behaviour. It should never actually be needed. #[arg(long)] pub unsafe_overwrite_results: bool, + + /// Sanity check for benchmarks. Checks whether an extrinsic's maximum weight exceeds the max + /// extrinsic weight. If present, it takes the max value within the component range. + #[arg(long)] + pub sanity_check: bool, } diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs index 69c95d13c098..a2a20d11e6cd 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs @@ -35,7 +35,10 @@ use crate::{ use frame_benchmarking::{ Analysis, AnalysisChoice, BenchmarkBatchSplitResults, BenchmarkResult, BenchmarkSelector, }; -use frame_support::traits::StorageInfo; +use frame_support::{ + traits::StorageInfo, + weights::{RuntimeDbWeight, Weight}, +}; use sp_core::hexdisplay::HexDisplay; use sp_runtime::traits::Zero; @@ -59,7 +62,7 @@ struct TemplateData { // This was the final data we have about each benchmark. #[derive(Serialize, Default, Debug, Clone, PartialEq)] -struct BenchmarkData { +pub(crate) struct BenchmarkData { name: String, components: Vec, #[serde(serialize_with = "string_serialize")] @@ -116,7 +119,7 @@ struct ComponentSlope { } // Small helper to create an `io::Error` from a string. -fn io_error(s: &str) -> std::io::Error { +pub(crate) fn io_error(s: &str) -> std::io::Error { use std::io::{Error, ErrorKind}; Error::new(ErrorKind::Other, s) } @@ -129,7 +132,7 @@ fn io_error(s: &str) -> std::io::Error { // p1 -> [b1, b2, b3] // p2 -> [b1, b2] // ``` -fn map_results( +pub(crate) fn map_results( batches: &[BenchmarkBatchSplitResults], storage_info: &[StorageInfo], component_ranges: &HashMap<(Vec, Vec), Vec>, @@ -139,6 +142,9 @@ fn map_results( pov_analysis_choice: &AnalysisChoice, worst_case_map_values: u32, additional_trie_layers: u8, + max_extrinsic_weight: Weight, + db_weight: RuntimeDbWeight, + sanity_check: bool, ) -> Result>, std::io::Error> { // Skip if batches is empty. if batches.is_empty() { @@ -166,12 +172,86 @@ fn map_results( worst_case_map_values, additional_trie_layers, ); + // Sanity check for benchmarks. Checks whether an extrinsic's maximum weight (based on max + // component) exceeds the max extrinsic weight. + benchmark_sanity_check(&benchmark_data, max_extrinsic_weight, db_weight, sanity_check)?; let pallet_benchmarks = all_benchmarks.entry((pallet_string, instance_string)).or_default(); pallet_benchmarks.push(benchmark_data); } Ok(all_benchmarks) } +// Calculates the total maximum weight of an extrinsic, based on the max component, and compares it +// with the max extrinsic weight. +// +// `max_extrinsic_weight` & `db_weight` are obtained from the runtime. +fn benchmark_sanity_check( + result: &BenchmarkData, + max_extrinsic_weight: Weight, + db_weight: RuntimeDbWeight, + sanity_check: bool, +) -> Result<(), std::io::Error> { + fn max_component(parameter: &ComponentSlope, component_ranges: &Vec) -> u64 { + for component in component_ranges { + if parameter.name == component.name { + return component.max.into() + } + } + 0 + } + + let mut total_weight = Weight::from_parts( + result.base_weight.try_into().unwrap(), + result.base_calculated_proof_size.try_into().unwrap(), + ); + for component in &result.component_weight { + total_weight = total_weight.saturating_add( + Weight::from_parts(component.slope.try_into().unwrap(), 0) + .saturating_mul(max_component(&component, &result.component_ranges)), + ); + } + total_weight = + total_weight.saturating_add(db_weight.reads(result.base_reads.try_into().unwrap())); + for component in &result.component_reads { + total_weight = total_weight.saturating_add( + db_weight + .reads(component.slope.try_into().unwrap()) + .saturating_mul(max_component(&component, &result.component_ranges)), + ); + } + total_weight = + total_weight.saturating_add(db_weight.writes(result.base_writes.try_into().unwrap())); + for component in &result.component_writes { + total_weight = total_weight.saturating_add( + db_weight + .writes(component.slope.try_into().unwrap()) + .saturating_mul(max_component(&component, &result.component_ranges)), + ); + } + for component in &result.component_calculated_proof_size { + total_weight = total_weight.saturating_add( + Weight::from_parts(0, component.slope.try_into().unwrap()) + .saturating_mul(max_component(&component, &result.component_ranges)), + ); + } + if total_weight.ref_time() > max_extrinsic_weight.ref_time() || + total_weight.proof_size() > max_extrinsic_weight.proof_size() + { + let err_message = format!("Extrinsic {} exceeds the max extrinsic weight", result.name); + println!("\u{1b}[31mWARNING!!!\u{1b}[39m {:?}", err_message); + println!("Extrinsic {}: {:?}\nPercentage of max extrinsic weight: {:.2}% (ref_time), {:.2}% (proof_size)", + result.name, + total_weight, + (total_weight.ref_time() as f64 / max_extrinsic_weight.ref_time() as f64) * 100.0, + (total_weight.proof_size() as f64 / max_extrinsic_weight.proof_size() as f64) * 100.0, + ); + if sanity_check { + return Err(io_error(&err_message)) + } + } + Ok(()) +} + // Get an iterator of errors. fn extract_errors(errors: &Option>) -> impl Iterator + '_ { errors @@ -376,13 +456,10 @@ fn get_benchmark_data( /// Create weight file from benchmark data and Handlebars template. pub(crate) fn write_results( - batches: &[BenchmarkBatchSplitResults], - storage_info: &[StorageInfo], - component_ranges: &HashMap<(Vec, Vec), Vec>, - pov_modes: PovModesMap, - default_pov_mode: PovEstimationMode, path: &PathBuf, cmd: &PalletCmd, + analysis_choice: AnalysisChoice, + all_results: HashMap<(String, String), Vec>, ) -> Result<(), sc_cli::Error> { // Use custom template if provided. let template: String = match &cmd.template { @@ -405,12 +482,6 @@ pub(crate) fn write_results( // Full CLI args passed to trigger the benchmark. let args = std::env::args().collect::>(); - // Which analysis function should be used when outputting benchmarks - let analysis_choice: AnalysisChoice = - cmd.output_analysis.clone().try_into().map_err(io_error)?; - let pov_analysis_choice: AnalysisChoice = - cmd.output_pov_analysis.clone().try_into().map_err(io_error)?; - if cmd.additional_trie_layers > 4 { println!( "WARNING: `additional_trie_layers` is unexpectedly large. It assumes {} storage items.", @@ -439,18 +510,6 @@ pub(crate) fn write_results( // Don't HTML escape any characters. handlebars.register_escape_fn(|s| -> String { s.to_string() }); - // Organize results by pallet into a JSON map - let all_results = map_results( - batches, - storage_info, - component_ranges, - pov_modes, - default_pov_mode, - &analysis_choice, - &pov_analysis_choice, - cmd.worst_case_map_values, - cmd.additional_trie_layers, - )?; let mut created_files = Vec::new(); for ((pallet, instance), results) in all_results.iter() { @@ -964,6 +1023,9 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, + Weight::MAX, + RuntimeDbWeight { read: 1000, write: 1000 }, + false, ) .unwrap(); let result = @@ -1021,6 +1083,9 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, + Weight::MAX, + RuntimeDbWeight { read: 1000, write: 1000 }, + false, ) .unwrap(); let result = @@ -1078,6 +1143,9 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, + Weight::MAX, + RuntimeDbWeight { read: 1000, write: 1000 }, + false, ) .unwrap(); let result = @@ -1133,6 +1201,9 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, + Weight::MAX, + RuntimeDbWeight { read: 1000, write: 1000 }, + false, ) .unwrap(); let result = @@ -1190,6 +1261,9 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, + Weight::MAX, + RuntimeDbWeight { read: 1000, write: 1000 }, + false, ) .unwrap(); let result = @@ -1218,6 +1292,9 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, + Weight::MAX, + RuntimeDbWeight { read: 1000, write: 1000 }, + false, ) .unwrap(); @@ -1253,6 +1330,25 @@ mod test { ); } + #[test] + fn sanity_check_works() { + assert!(map_results( + &[test_data(b"first", b"first", BenchmarkParameter::a, 10, 3),], + &test_storage_info(), + &Default::default(), + Default::default(), + PovEstimationMode::MaxEncodedLen, + &AnalysisChoice::default(), + &AnalysisChoice::MedianSlopes, + 1_000_000, + 0, + Weight::from_parts(20_000, 1_000_000), + RuntimeDbWeight { read: 1000, write: 1000 }, + true, + ) + .is_err()); + } + #[test] fn additional_trie_layers_work() { let mapped_results = map_results( @@ -1265,6 +1361,9 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 2, + Weight::MAX, + RuntimeDbWeight { read: 1000, write: 1000 }, + false, ) .unwrap(); let with_layer = &mapped_results @@ -1280,6 +1379,9 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, + Weight::MAX, + RuntimeDbWeight { read: 1000, write: 1000 }, + false, ) .unwrap(); let without_layer = &mapped_results @@ -1313,6 +1415,9 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, + Weight::MAX, + RuntimeDbWeight { read: 1000, write: 1000 }, + false, ) .unwrap(); From 81165e3e6ffe80ee5003ad9f03a18d6ed751fdb2 Mon Sep 17 00:00:00 2001 From: Daan van der Plas Date: Tue, 17 Oct 2023 08:55:12 +0200 Subject: [PATCH 02/13] error || warning --- .../benchmarking-cli/src/pallet/command.rs | 9 +- .../frame/benchmarking-cli/src/pallet/mod.rs | 8 +- .../benchmarking-cli/src/pallet/writer.rs | 130 ++++++++++-------- 3 files changed, 79 insertions(+), 68 deletions(-) diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index 80e1feaab19b..f09b7e336ad8 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -548,16 +548,17 @@ impl PalletCmd { &pov_analysis_choice, self.worst_case_map_values, self.additional_trie_layers, - max_extrinsic_weight, - db_weight, - self.sanity_check, )?; // Create the weights.rs file. if let Some(output_path) = &self.output { - writer::write_results(output_path, self, analysis_choice, all_results)?; + writer::write_results(output_path, self, analysis_choice, &all_results)?; } + // Sanity check for benchmarks. Checks whether an extrinsic's maximum weight (based on max + // component) exceeds the max extrinsic weight. + writer::sanity_weight_check(all_results, max_extrinsic_weight, db_weight, self.sanity_weight_check_warning)?; + Ok(()) } diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs index d895657c91b9..917896264d2b 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -202,8 +202,10 @@ pub struct PalletCmd { #[arg(long)] pub unsafe_overwrite_results: bool, - /// Sanity check for benchmarks. Checks whether an extrinsic's maximum weight exceeds the max - /// extrinsic weight. If present, it takes the max value within the component range. + /// Sanity weight check for benchmarks. Checks whether an extrinsic's maximum weight exceeds the max + /// extrinsic weight. If present, it takes the max value of the component range. + /// + /// Default will error out if max extrinsic weight is exceeded. #[arg(long)] - pub sanity_check: bool, + pub sanity_weight_check_warning: bool, } diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs index a2a20d11e6cd..b8f9f863c97b 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs @@ -19,6 +19,7 @@ use std::{ collections::{HashMap, HashSet}, + fmt::Write, fs, path::PathBuf, }; @@ -142,9 +143,6 @@ pub(crate) fn map_results( pov_analysis_choice: &AnalysisChoice, worst_case_map_values: u32, additional_trie_layers: u8, - max_extrinsic_weight: Weight, - db_weight: RuntimeDbWeight, - sanity_check: bool, ) -> Result>, std::io::Error> { // Skip if batches is empty. if batches.is_empty() { @@ -172,25 +170,26 @@ pub(crate) fn map_results( worst_case_map_values, additional_trie_layers, ); - // Sanity check for benchmarks. Checks whether an extrinsic's maximum weight (based on max - // component) exceeds the max extrinsic weight. - benchmark_sanity_check(&benchmark_data, max_extrinsic_weight, db_weight, sanity_check)?; let pallet_benchmarks = all_benchmarks.entry((pallet_string, instance_string)).or_default(); pallet_benchmarks.push(benchmark_data); } Ok(all_benchmarks) } -// Calculates the total maximum weight of an extrinsic, based on the max component, and compares it -// with the max extrinsic weight. +// Calculates the total maximum weight of an extrinsic (if present, based on the max component) and compares it +// with the max extrinsic weight allowed in a single block. // -// `max_extrinsic_weight` & `db_weight` are obtained from the runtime. -fn benchmark_sanity_check( - result: &BenchmarkData, +// `max_extrinsic_weight` & `db_weight` are obtained from the runtime configuration. +pub(crate) fn sanity_weight_check( + all_results: HashMap<(String, String), Vec>, max_extrinsic_weight: Weight, db_weight: RuntimeDbWeight, - sanity_check: bool, + sanity_weight_check_warning: bool, ) -> Result<(), std::io::Error> { + let mut err_message = String::new(); + let mut sanity_weight_check_failed = false; + + // Helper function to return max component value. fn max_component(parameter: &ComponentSlope, component_ranges: &Vec) -> u64 { for component in component_ranges { if parameter.name == component.name { @@ -200,56 +199,65 @@ fn benchmark_sanity_check( 0 } - let mut total_weight = Weight::from_parts( - result.base_weight.try_into().unwrap(), - result.base_calculated_proof_size.try_into().unwrap(), - ); - for component in &result.component_weight { - total_weight = total_weight.saturating_add( - Weight::from_parts(component.slope.try_into().unwrap(), 0) - .saturating_mul(max_component(&component, &result.component_ranges)), - ); - } - total_weight = - total_weight.saturating_add(db_weight.reads(result.base_reads.try_into().unwrap())); - for component in &result.component_reads { - total_weight = total_weight.saturating_add( - db_weight - .reads(component.slope.try_into().unwrap()) - .saturating_mul(max_component(&component, &result.component_ranges)), - ); - } - total_weight = - total_weight.saturating_add(db_weight.writes(result.base_writes.try_into().unwrap())); - for component in &result.component_writes { - total_weight = total_weight.saturating_add( - db_weight - .writes(component.slope.try_into().unwrap()) - .saturating_mul(max_component(&component, &result.component_ranges)), - ); - } - for component in &result.component_calculated_proof_size { - total_weight = total_weight.saturating_add( - Weight::from_parts(0, component.slope.try_into().unwrap()) - .saturating_mul(max_component(&component, &result.component_ranges)), - ); - } - if total_weight.ref_time() > max_extrinsic_weight.ref_time() || - total_weight.proof_size() > max_extrinsic_weight.proof_size() - { - let err_message = format!("Extrinsic {} exceeds the max extrinsic weight", result.name); - println!("\u{1b}[31mWARNING!!!\u{1b}[39m {:?}", err_message); - println!("Extrinsic {}: {:?}\nPercentage of max extrinsic weight: {:.2}% (ref_time), {:.2}% (proof_size)", - result.name, - total_weight, - (total_weight.ref_time() as f64 / max_extrinsic_weight.ref_time() as f64) * 100.0, - (total_weight.proof_size() as f64 / max_extrinsic_weight.proof_size() as f64) * 100.0, - ); - if sanity_check { - return Err(io_error(&err_message)) + // Loop through all benchmark results. + for ((_, _), results) in all_results.iter() { + // Per pallet where there can be multiple instances of a pallet. + for result in results { + let mut total_weight = Weight::from_parts( + result.base_weight.try_into().unwrap(), + result.base_calculated_proof_size.try_into().unwrap(), + ); + for component in &result.component_weight { + total_weight = total_weight.saturating_add( + Weight::from_parts(component.slope.try_into().unwrap(), 0) + .saturating_mul(max_component(&component, &result.component_ranges)), + ); + } + total_weight = + total_weight.saturating_add(db_weight.reads(result.base_reads.try_into().unwrap())); + for component in &result.component_reads { + total_weight = total_weight.saturating_add( + db_weight + .reads(component.slope.try_into().unwrap()) + .saturating_mul(max_component(&component, &result.component_ranges)), + ); + } + total_weight = + total_weight.saturating_add(db_weight.writes(result.base_writes.try_into().unwrap())); + for component in &result.component_writes { + total_weight = total_weight.saturating_add( + db_weight + .writes(component.slope.try_into().unwrap()) + .saturating_mul(max_component(&component, &result.component_ranges)), + ); + } + for component in &result.component_calculated_proof_size { + total_weight = total_weight.saturating_add( + Weight::from_parts(0, component.slope.try_into().unwrap()) + .saturating_mul(max_component(&component, &result.component_ranges)), + ); + } + if total_weight.ref_time() > max_extrinsic_weight.ref_time() || + total_weight.proof_size() > max_extrinsic_weight.proof_size() + { + sanity_weight_check_failed = true; + let error = format!("\nExtrinsic {} exceeds the max extrinsic weight", result.name); + println!("\u{1b}[31mWARNING!!!\u{1b}[39m {:?}", error); + println!("Extrinsic {}: {:?}\nPercentage of max extrinsic weight: {:.2}% (ref_time), {:.2}% (proof_size)", + result.name, + total_weight, + (total_weight.ref_time() as f64 / max_extrinsic_weight.ref_time() as f64) * 100.0, + (total_weight.proof_size() as f64 / max_extrinsic_weight.proof_size() as f64) * 100.0, + ); + write!(&mut err_message, "{}", error); + } } } - Ok(()) + if sanity_weight_check_failed && !sanity_weight_check_warning { + Err(io_error(&err_message)) + } else { + Ok(()) + } } // Get an iterator of errors. @@ -459,7 +467,7 @@ pub(crate) fn write_results( path: &PathBuf, cmd: &PalletCmd, analysis_choice: AnalysisChoice, - all_results: HashMap<(String, String), Vec>, + all_results: &HashMap<(String, String), Vec>, ) -> Result<(), sc_cli::Error> { // Use custom template if provided. let template: String = match &cmd.template { From 8fc1fcaad8c8fc7e593ca11fb90ddd5fbd90d20d Mon Sep 17 00:00:00 2001 From: Daan van der Plas Date: Wed, 18 Oct 2023 12:06:01 +0200 Subject: [PATCH 03/13] allow enable, warning & ignore + output improvement --- substrate/client/cli/src/arg_enums.rs | 15 +++ .../client/cli/src/params/shared_params.rs | 12 +- .../benchmarking-cli/src/pallet/command.rs | 2 +- .../frame/benchmarking-cli/src/pallet/mod.rs | 7 -- .../benchmarking-cli/src/pallet/writer.rs | 119 ++++++++++-------- 5 files changed, 92 insertions(+), 63 deletions(-) diff --git a/substrate/client/cli/src/arg_enums.rs b/substrate/client/cli/src/arg_enums.rs index 40d86fd97988..1ed275f498a4 100644 --- a/substrate/client/cli/src/arg_enums.rs +++ b/substrate/client/cli/src/arg_enums.rs @@ -70,6 +70,21 @@ impl std::fmt::Display for WasmExecutionMethod { } } +/// What to do when an extrinsic's weight exceeds the max extrinsic weight +/// per block. +#[allow(missing_docs)] +#[derive(Debug, Clone, Copy, ValueEnum, PartialEq)] +#[value(rename_all = "kebab-case")] +pub enum SanityWeightCheck { + Error, + Warning, + Ignore, +} + +/// The default [`SanityWeightCheck`]. +pub const DEFAULT_SANITY_WEIGHT_CHECK: SanityWeightCheck = + SanityWeightCheck::Error; + /// Converts the execution method and instantiation strategy command line arguments /// into an execution method which can be used internally. pub fn execution_method_from_cli( diff --git a/substrate/client/cli/src/params/shared_params.rs b/substrate/client/cli/src/params/shared_params.rs index 3d20ca504a69..b6ae22f0af83 100644 --- a/substrate/client/cli/src/params/shared_params.rs +++ b/substrate/client/cli/src/params/shared_params.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::arg_enums::TracingReceiver; +use crate::{SanityWeightCheck, DEFAULT_SANITY_WEIGHT_CHECK, arg_enums::TracingReceiver}; use clap::Args; use sc_service::config::BasePath; use std::path::PathBuf; @@ -71,6 +71,16 @@ pub struct SharedParams { /// Receiver to process tracing messages. #[arg(long, value_name = "RECEIVER", value_enum, ignore_case = true, default_value_t = TracingReceiver::Log)] pub tracing_receiver: TracingReceiver, + + /// Sanity weight check for benchmarks. Checks whether an extrinsic's maximum weight exceeds the max + /// extrinsic weight. + #[arg( + long, + value_name = "OUTPUT", + value_enum, + default_value_t = DEFAULT_SANITY_WEIGHT_CHECK, + )] + pub sanity_weight_check: SanityWeightCheck, } impl SharedParams { diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index f09b7e336ad8..cada8169b3d9 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -557,7 +557,7 @@ impl PalletCmd { // Sanity check for benchmarks. Checks whether an extrinsic's maximum weight (based on max // component) exceeds the max extrinsic weight. - writer::sanity_weight_check(all_results, max_extrinsic_weight, db_weight, self.sanity_weight_check_warning)?; + writer::sanity_weight_check(all_results, max_extrinsic_weight, db_weight, self.shared_params.sanity_weight_check)?; Ok(()) } diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs index 917896264d2b..c69ce1765fc9 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -201,11 +201,4 @@ pub struct PalletCmd { /// This exists only to restore legacy behaviour. It should never actually be needed. #[arg(long)] pub unsafe_overwrite_results: bool, - - /// Sanity weight check for benchmarks. Checks whether an extrinsic's maximum weight exceeds the max - /// extrinsic weight. If present, it takes the max value of the component range. - /// - /// Default will error out if max extrinsic weight is exceeded. - #[arg(long)] - pub sanity_weight_check_warning: bool, } diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs index b8f9f863c97b..4d340b3b1ba9 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs @@ -19,7 +19,6 @@ use std::{ collections::{HashMap, HashSet}, - fmt::Write, fs, path::PathBuf, }; @@ -27,6 +26,7 @@ use std::{ use inflector::Inflector; use itertools::Itertools; use serde::Serialize; +use sc_cli::SanityWeightCheck; use crate::{ pallet::command::{ComponentRange, PovEstimationMode, PovModesMap}, @@ -184,12 +184,12 @@ pub(crate) fn sanity_weight_check( all_results: HashMap<(String, String), Vec>, max_extrinsic_weight: Weight, db_weight: RuntimeDbWeight, - sanity_weight_check_warning: bool, + sanity_weight_check: SanityWeightCheck, ) -> Result<(), std::io::Error> { - let mut err_message = String::new(); - let mut sanity_weight_check_failed = false; - - // Helper function to return max component value. + if sanity_weight_check == SanityWeightCheck::Ignore { + return Ok(()); + } + // Helper function to return max. component value (i.e. max. complexity parameter). fn max_component(parameter: &ComponentSlope, component_ranges: &Vec) -> u64 { for component in component_ranges { if parameter.name == component.name { @@ -199,22 +199,33 @@ pub(crate) fn sanity_weight_check( 0 } + println!("\n\x1B[1mSanity Weight Check 🧐:\x1B[0m each extrinsic's weight function is executed \ + in the worst case scenario and compared with the maximum extrinsic weight (the maximum weight \ + that can be put in a single block for an extrinsic with `DispatchClass::Normal`). In other words, \ + each extrinsic is checked whether it will fit in an empty (meaning; empty of \ + `DispatchClass::Normal` extrinsics) block.\n\n\x1B[4mResults:\x1B[0m\n" + ); + let mut sanity_weight_check_passed = true; // Loop through all benchmark results. for ((_, _), results) in all_results.iter() { - // Per pallet where there can be multiple instances of a pallet. + // Per pallet, because there can be multiple instances of a pallet. for result in results { + // Constant `ref_time` & `pov_size`. let mut total_weight = Weight::from_parts( result.base_weight.try_into().unwrap(), result.base_calculated_proof_size.try_into().unwrap(), ); + // `ref_time` multiplied by complexity parameter. for component in &result.component_weight { total_weight = total_weight.saturating_add( Weight::from_parts(component.slope.try_into().unwrap(), 0) .saturating_mul(max_component(&component, &result.component_ranges)), ); } + // Constant storage reads. total_weight = total_weight.saturating_add(db_weight.reads(result.base_reads.try_into().unwrap())); + // Storage reads multiplied by complexity parameter. for component in &result.component_reads { total_weight = total_weight.saturating_add( db_weight @@ -222,8 +233,10 @@ pub(crate) fn sanity_weight_check( .saturating_mul(max_component(&component, &result.component_ranges)), ); } + // Constant storage writes. total_weight = total_weight.saturating_add(db_weight.writes(result.base_writes.try_into().unwrap())); + // Storage writes multiplied by complexity parameter. for component in &result.component_writes { total_weight = total_weight.saturating_add( db_weight @@ -231,33 +244,41 @@ pub(crate) fn sanity_weight_check( .saturating_mul(max_component(&component, &result.component_ranges)), ); } + // `pov_size` multiplied by complexity parameter. for component in &result.component_calculated_proof_size { total_weight = total_weight.saturating_add( Weight::from_parts(0, component.slope.try_into().unwrap()) .saturating_mul(max_component(&component, &result.component_ranges)), ); } + // Comparing (worst case scenario) the extrinsic weight against the maximum extrinsic weight. if total_weight.ref_time() > max_extrinsic_weight.ref_time() || - total_weight.proof_size() > max_extrinsic_weight.proof_size() - { - sanity_weight_check_failed = true; - let error = format!("\nExtrinsic {} exceeds the max extrinsic weight", result.name); - println!("\u{1b}[31mWARNING!!!\u{1b}[39m {:?}", error); - println!("Extrinsic {}: {:?}\nPercentage of max extrinsic weight: {:.2}% (ref_time), {:.2}% (proof_size)", - result.name, - total_weight, - (total_weight.ref_time() as f64 / max_extrinsic_weight.ref_time() as f64) * 100.0, - (total_weight.proof_size() as f64 / max_extrinsic_weight.proof_size() as f64) * 100.0, - ); - write!(&mut err_message, "{}", error); + total_weight.proof_size() > max_extrinsic_weight.proof_size() { + sanity_weight_check_passed = false; + println!("\x1B[31m\x1B[1mWARNING!!!\x1B[0m",); + println!("\x1B[31mThe following extrinsic exceeds the maximum extrinsic weight:\x1B[0m",); } + println!("- \x1B[1m'{}'\x1B[0m: {:?}\nPercentage of max extrinsic weight: {:.2}% (ref_time), {:.2}% (proof_size)\n", + result.name, + total_weight, + (total_weight.ref_time() as f64 / max_extrinsic_weight.ref_time() as f64) * 100.0, + (total_weight.proof_size() as f64 / max_extrinsic_weight.proof_size() as f64) * 100.0, + ); } } - if sanity_weight_check_failed && !sanity_weight_check_warning { - Err(io_error(&err_message)) - } else { - Ok(()) + match sanity_weight_check_passed { + false => { + println!("\x1B[31mYour extrinsics failed the Sanity Weight Check, please review \ + the extrinsic's logic and/or the associated benchmark function.\x1B[0m\n",); + if sanity_weight_check == SanityWeightCheck::Error { + return Err(io_error(&String::from("One or more extrinsics exceed the maximum extrinsic weight"))); + } + }, + true => { + println!("\x1B[32mYour extrinsics passed the Sanity Weight Check 😃!\x1B[0m\n"); + }, } + Ok(()) } // Get an iterator of errors. @@ -1031,9 +1052,6 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, - Weight::MAX, - RuntimeDbWeight { read: 1000, write: 1000 }, - false, ) .unwrap(); let result = @@ -1091,9 +1109,6 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, - Weight::MAX, - RuntimeDbWeight { read: 1000, write: 1000 }, - false, ) .unwrap(); let result = @@ -1151,9 +1166,6 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, - Weight::MAX, - RuntimeDbWeight { read: 1000, write: 1000 }, - false, ) .unwrap(); let result = @@ -1209,9 +1221,6 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, - Weight::MAX, - RuntimeDbWeight { read: 1000, write: 1000 }, - false, ) .unwrap(); let result = @@ -1269,9 +1278,6 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, - Weight::MAX, - RuntimeDbWeight { read: 1000, write: 1000 }, - false, ) .unwrap(); let result = @@ -1300,9 +1306,6 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, - Weight::MAX, - RuntimeDbWeight { read: 1000, write: 1000 }, - false, ) .unwrap(); @@ -1340,7 +1343,7 @@ mod test { #[test] fn sanity_check_works() { - assert!(map_results( + let mapped_results = map_results( &[test_data(b"first", b"first", BenchmarkParameter::a, 10, 3),], &test_storage_info(), &Default::default(), @@ -1350,11 +1353,28 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, + ).unwrap(); + + assert!(sanity_weight_check( + mapped_results.clone(), Weight::from_parts(20_000, 1_000_000), RuntimeDbWeight { read: 1000, write: 1000 }, - true, - ) - .is_err()); + SanityWeightCheck::Error, + ).is_err()); + + assert!(sanity_weight_check( + mapped_results.clone(), + Weight::from_parts(20_000, 1_000_000), + RuntimeDbWeight { read: 1000, write: 1000 }, + SanityWeightCheck::Warning, + ).is_ok()); + + assert!(sanity_weight_check( + mapped_results, + Weight::from_parts(20_000, 1_000_000), + RuntimeDbWeight { read: 1000, write: 1000 }, + SanityWeightCheck::Ignore, + ).is_ok()); } #[test] @@ -1369,9 +1389,6 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 2, - Weight::MAX, - RuntimeDbWeight { read: 1000, write: 1000 }, - false, ) .unwrap(); let with_layer = &mapped_results @@ -1387,9 +1404,6 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, - Weight::MAX, - RuntimeDbWeight { read: 1000, write: 1000 }, - false, ) .unwrap(); let without_layer = &mapped_results @@ -1423,9 +1437,6 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, - Weight::MAX, - RuntimeDbWeight { read: 1000, write: 1000 }, - false, ) .unwrap(); From d476d7f0eefa4a7702580b5be1e2a96ead02eaf0 Mon Sep 17 00:00:00 2001 From: Daan van der Plas Date: Wed, 18 Oct 2023 13:18:23 +0200 Subject: [PATCH 04/13] fmt --- polkadot/runtime/rococo/src/lib.rs | 6 +-- substrate/client/cli/src/arg_enums.rs | 3 +- .../client/cli/src/params/shared_params.rs | 6 +-- .../benchmarking-cli/src/pallet/command.rs | 7 ++- .../benchmarking-cli/src/pallet/writer.rs | 51 ++++++++++++------- 5 files changed, 45 insertions(+), 28 deletions(-) diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 5b8816d69433..6bd55a55ee39 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -71,7 +71,7 @@ use frame_support::{ InstanceFilter, KeyOwnerProofSystem, LinearStoragePrice, PrivilegeCmp, ProcessMessage, ProcessMessageError, StorageMapShim, WithdrawReasons, }, - weights::{ConstantMultiplier, RuntimeDbWeight, WeightMeter}, + weights::{ConstantMultiplier, WeightMeter}, PalletId, }; use frame_system::EnsureRoot; @@ -2046,7 +2046,7 @@ sp_api::impl_runtime_apis! { Vec, Vec, Weight, - RuntimeDbWeight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -2059,7 +2059,7 @@ sp_api::impl_runtime_apis! { let storage_info = AllPalletsWithSystem::storage_info(); let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); - let db_weight: RuntimeDbWeight = ::DbWeight::get(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/substrate/client/cli/src/arg_enums.rs b/substrate/client/cli/src/arg_enums.rs index 85a30b80c60f..ce7bf15e80bd 100644 --- a/substrate/client/cli/src/arg_enums.rs +++ b/substrate/client/cli/src/arg_enums.rs @@ -76,8 +76,7 @@ pub enum SanityWeightCheck { } /// The default [`SanityWeightCheck`]. -pub const DEFAULT_SANITY_WEIGHT_CHECK: SanityWeightCheck = - SanityWeightCheck::Error; +pub const DEFAULT_SANITY_WEIGHT_CHECK: SanityWeightCheck = SanityWeightCheck::Error; /// Converts the execution method and instantiation strategy command line arguments /// into an execution method which can be used internally. diff --git a/substrate/client/cli/src/params/shared_params.rs b/substrate/client/cli/src/params/shared_params.rs index b6ae22f0af83..30750734bed4 100644 --- a/substrate/client/cli/src/params/shared_params.rs +++ b/substrate/client/cli/src/params/shared_params.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::{SanityWeightCheck, DEFAULT_SANITY_WEIGHT_CHECK, arg_enums::TracingReceiver}; +use crate::{arg_enums::TracingReceiver, SanityWeightCheck, DEFAULT_SANITY_WEIGHT_CHECK}; use clap::Args; use sc_service::config::BasePath; use std::path::PathBuf; @@ -72,8 +72,8 @@ pub struct SharedParams { #[arg(long, value_name = "RECEIVER", value_enum, ignore_case = true, default_value_t = TracingReceiver::Log)] pub tracing_receiver: TracingReceiver, - /// Sanity weight check for benchmarks. Checks whether an extrinsic's maximum weight exceeds the max - /// extrinsic weight. + /// Sanity weight check for benchmarks. Checks whether an extrinsic's maximum weight exceeds + /// the max extrinsic weight. #[arg( long, value_name = "OUTPUT", diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index cada8169b3d9..e184aef91a05 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -557,7 +557,12 @@ impl PalletCmd { // Sanity check for benchmarks. Checks whether an extrinsic's maximum weight (based on max // component) exceeds the max extrinsic weight. - writer::sanity_weight_check(all_results, max_extrinsic_weight, db_weight, self.shared_params.sanity_weight_check)?; + writer::sanity_weight_check( + all_results, + max_extrinsic_weight, + db_weight, + self.shared_params.sanity_weight_check, + )?; Ok(()) } diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs index 6aaa4c702fbc..5ee3fc2ed197 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs @@ -25,8 +25,8 @@ use std::{ use inflector::Inflector; use itertools::Itertools; -use serde::Serialize; use sc_cli::SanityWeightCheck; +use serde::Serialize; use crate::{ pallet::command::{ComponentRange, PovEstimationMode, PovModesMap}, @@ -176,8 +176,8 @@ pub(crate) fn map_results( Ok(all_benchmarks) } -// Calculates the total maximum weight of an extrinsic (if present, based on the max component) and compares it -// with the max extrinsic weight allowed in a single block. +// Calculates the total maximum weight of an extrinsic (if present, based on the max component) and +// compares it with the max extrinsic weight allowed in a single block. // // `max_extrinsic_weight` & `db_weight` are obtained from the runtime configuration. pub(crate) fn sanity_weight_check( @@ -187,7 +187,7 @@ pub(crate) fn sanity_weight_check( sanity_weight_check: SanityWeightCheck, ) -> Result<(), std::io::Error> { if sanity_weight_check == SanityWeightCheck::Ignore { - return Ok(()); + return Ok(()) } // Helper function to return max. component value (i.e. max. complexity parameter). fn max_component(parameter: &ComponentSlope, component_ranges: &Vec) -> u64 { @@ -199,14 +199,15 @@ pub(crate) fn sanity_weight_check( 0 } - println!("\n\x1B[1mSanity Weight Check 🧐:\x1B[0m each extrinsic's weight function is executed \ + println!( + "\n\x1B[1mSanity Weight Check 🧐:\x1B[0m each extrinsic's weight function is executed \ in the worst case scenario and compared with the maximum extrinsic weight (the maximum weight \ that can be put in a single block for an extrinsic with `DispatchClass::Normal`). In other words, \ each extrinsic is checked whether it will fit in an empty (meaning; empty of \ `DispatchClass::Normal` extrinsics) block.\n\n\x1B[4mResults:\x1B[0m\n" ); let mut sanity_weight_check_passed = true; - // Loop through all benchmark results. + // Loop through all benchmark results. for ((_, _), results) in all_results.iter() { // Per pallet, because there can be multiple instances of a pallet. for result in results { @@ -234,8 +235,8 @@ pub(crate) fn sanity_weight_check( ); } // Constant storage writes. - total_weight = - total_weight.saturating_add(db_weight.writes(result.base_writes.try_into().unwrap())); + total_weight = total_weight + .saturating_add(db_weight.writes(result.base_writes.try_into().unwrap())); // Storage writes multiplied by complexity parameter. for component in &result.component_writes { total_weight = total_weight.saturating_add( @@ -251,12 +252,16 @@ pub(crate) fn sanity_weight_check( .saturating_mul(max_component(&component, &result.component_ranges)), ); } - // Comparing (worst case scenario) the extrinsic weight against the maximum extrinsic weight. + // Comparing (worst case scenario) the extrinsic weight against the maximum extrinsic + // weight. if total_weight.ref_time() > max_extrinsic_weight.ref_time() || - total_weight.proof_size() > max_extrinsic_weight.proof_size() { + total_weight.proof_size() > max_extrinsic_weight.proof_size() + { sanity_weight_check_passed = false; println!("\x1B[31m\x1B[1mWARNING!!!\x1B[0m",); - println!("\x1B[31mThe following extrinsic exceeds the maximum extrinsic weight:\x1B[0m",); + println!( + "\x1B[31mThe following extrinsic exceeds the maximum extrinsic weight:\x1B[0m", + ); } println!("- \x1B[1m'{}'\x1B[0m: {:?}\nPercentage of max extrinsic weight: {:.2}% (ref_time), {:.2}% (proof_size)\n", result.name, @@ -268,10 +273,14 @@ pub(crate) fn sanity_weight_check( } match sanity_weight_check_passed { false => { - println!("\x1B[31mYour extrinsics failed the Sanity Weight Check, please review \ - the extrinsic's logic and/or the associated benchmark function.\x1B[0m\n",); + println!( + "\x1B[31mYour extrinsics failed the Sanity Weight Check, please review \ + the extrinsic's logic and/or the associated benchmark function.\x1B[0m\n", + ); if sanity_weight_check == SanityWeightCheck::Error { - return Err(io_error(&String::from("One or more extrinsics exceed the maximum extrinsic weight"))); + return Err(io_error(&String::from( + "One or more extrinsics exceed the maximum extrinsic weight", + ))) } }, true => { @@ -1345,7 +1354,7 @@ mod test { #[test] fn sanity_check_works() { let mapped_results = map_results( - &[test_data(b"first", b"first", BenchmarkParameter::a, 10, 3),], + &[test_data(b"first", b"first", BenchmarkParameter::a, 10, 3)], &test_storage_info(), &Default::default(), Default::default(), @@ -1354,28 +1363,32 @@ mod test { &AnalysisChoice::MedianSlopes, 1_000_000, 0, - ).unwrap(); + ) + .unwrap(); assert!(sanity_weight_check( mapped_results.clone(), Weight::from_parts(20_000, 1_000_000), RuntimeDbWeight { read: 1000, write: 1000 }, SanityWeightCheck::Error, - ).is_err()); + ) + .is_err()); assert!(sanity_weight_check( mapped_results.clone(), Weight::from_parts(20_000, 1_000_000), RuntimeDbWeight { read: 1000, write: 1000 }, SanityWeightCheck::Warning, - ).is_ok()); + ) + .is_ok()); assert!(sanity_weight_check( mapped_results, Weight::from_parts(20_000, 1_000_000), RuntimeDbWeight { read: 1000, write: 1000 }, SanityWeightCheck::Ignore, - ).is_ok()); + ) + .is_ok()); } #[test] From a6982589c15c408e1b4b256831cce92f1033fb9d Mon Sep 17 00:00:00 2001 From: Daan van der Plas Date: Wed, 18 Oct 2023 14:08:22 +0200 Subject: [PATCH 05/13] spelling & ci tests --- cumulus/parachain-template/runtime/src/lib.rs | 8 ++++---- substrate/bin/node-template/runtime/src/lib.rs | 6 +++--- substrate/bin/node/runtime/src/lib.rs | 6 +++--- substrate/client/cli/src/arg_enums.rs | 2 +- substrate/client/cli/src/params/shared_params.rs | 4 ++-- .../utils/frame/benchmarking-cli/src/pallet/command.rs | 4 ++-- .../utils/frame/benchmarking-cli/src/pallet/writer.rs | 6 +++--- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cumulus/parachain-template/runtime/src/lib.rs b/cumulus/parachain-template/runtime/src/lib.rs index 741629202f89..a21babbb8721 100644 --- a/cumulus/parachain-template/runtime/src/lib.rs +++ b/cumulus/parachain-template/runtime/src/lib.rs @@ -32,8 +32,8 @@ use frame_support::{ parameter_types, traits::{ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything}, weights::{ - constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, RuntimeDbWeight, Weight, - WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, + constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient, + WeightToFeeCoefficients, WeightToFeePolynomial, }, PalletId, }; @@ -700,7 +700,7 @@ impl_runtime_apis! { Vec, Vec, Weight, - RuntimeDbWeight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -712,7 +712,7 @@ impl_runtime_apis! { let storage_info = AllPalletsWithSystem::storage_info(); let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); - let db_weight: RuntimeDbWeight = ::DbWeight::get(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/substrate/bin/node-template/runtime/src/lib.rs b/substrate/bin/node-template/runtime/src/lib.rs index 1157e231ce10..3fd281d24586 100644 --- a/substrate/bin/node-template/runtime/src/lib.rs +++ b/substrate/bin/node-template/runtime/src/lib.rs @@ -37,7 +37,7 @@ pub use frame_support::{ constants::{ BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND, }, - IdentityFee, RuntimeDbWeight, Weight, + IdentityFee, Weight, }, StorageValue, }; @@ -518,7 +518,7 @@ impl_runtime_apis! { Vec, Vec, Weight, - RuntimeDbWeight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{baseline, Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -530,7 +530,7 @@ impl_runtime_apis! { let storage_info = AllPalletsWithSystem::storage_info(); let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); - let db_weight: RuntimeDbWeight = ::DbWeight::get(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 490c6e89caf1..a870d3a493fc 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -47,7 +47,7 @@ use frame_support::{ constants::{ BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND, }, - ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight, + ConstantMultiplier, IdentityFee, Weight, }, BoundedVec, PalletId, }; @@ -2746,7 +2746,7 @@ impl_runtime_apis! { Vec, Vec, Weight, - RuntimeDbWeight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{baseline, Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -2766,7 +2766,7 @@ impl_runtime_apis! { let storage_info = AllPalletsWithSystem::storage_info(); let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); - let db_weight: RuntimeDbWeight = ::DbWeight::get(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/substrate/client/cli/src/arg_enums.rs b/substrate/client/cli/src/arg_enums.rs index ce7bf15e80bd..b9b47a11551f 100644 --- a/substrate/client/cli/src/arg_enums.rs +++ b/substrate/client/cli/src/arg_enums.rs @@ -64,7 +64,7 @@ impl std::fmt::Display for WasmExecutionMethod { } } -/// What to do when an extrinsic's weight exceeds the max extrinsic weight +/// What to do when a (`DispatchClass::Normal`) extrinsic's weight exceeds the max. extrinsic weight /// per block. #[allow(missing_docs)] #[derive(Debug, Clone, Copy, ValueEnum, PartialEq)] diff --git a/substrate/client/cli/src/params/shared_params.rs b/substrate/client/cli/src/params/shared_params.rs index 30750734bed4..3963064c9770 100644 --- a/substrate/client/cli/src/params/shared_params.rs +++ b/substrate/client/cli/src/params/shared_params.rs @@ -72,8 +72,8 @@ pub struct SharedParams { #[arg(long, value_name = "RECEIVER", value_enum, ignore_case = true, default_value_t = TracingReceiver::Log)] pub tracing_receiver: TracingReceiver, - /// Sanity weight check for benchmarks. Checks whether an extrinsic's maximum weight exceeds - /// the max extrinsic weight. + /// Sanity weight check for benchmarks. Checks whether an (`DispatchClass::Normal`) extrinsic's + /// weight exceeds the max. extrinsic weight. #[arg( long, value_name = "OUTPUT", diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index e184aef91a05..7a55694a32ad 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -555,8 +555,8 @@ impl PalletCmd { writer::write_results(output_path, self, analysis_choice, &all_results)?; } - // Sanity check for benchmarks. Checks whether an extrinsic's maximum weight (based on max - // component) exceeds the max extrinsic weight. + // Sanity check for benchmarks. Checks whether an (`DispatchClass::Normal`) extrinsic's + // weight exceeds the max. extrinsic weight. writer::sanity_weight_check( all_results, max_extrinsic_weight, diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs index 5ee3fc2ed197..d64081404164 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs @@ -176,8 +176,8 @@ pub(crate) fn map_results( Ok(all_benchmarks) } -// Calculates the total maximum weight of an extrinsic (if present, based on the max component) and -// compares it with the max extrinsic weight allowed in a single block. +// Calculates the total maximum weight of an extrinsic (if present, based on the max. component +// value) and compares it with the max. extrinsic weight allowed in a single block. // // `max_extrinsic_weight` & `db_weight` are obtained from the runtime configuration. pub(crate) fn sanity_weight_check( @@ -263,7 +263,7 @@ pub(crate) fn sanity_weight_check( "\x1B[31mThe following extrinsic exceeds the maximum extrinsic weight:\x1B[0m", ); } - println!("- \x1B[1m'{}'\x1B[0m: {:?}\nPercentage of max extrinsic weight: {:.2}% (ref_time), {:.2}% (proof_size)\n", + println!("- \x1B[1m'{}'\x1B[0m: {:?}\nPercentage of max. extrinsic weight: {:.2}% (ref_time), {:.2}% (proof_size)\n", result.name, total_weight, (total_weight.ref_time() as f64 / max_extrinsic_weight.ref_time() as f64) * 100.0, From 6081db0c271c3068abcecd9b6900c185641b32c4 Mon Sep 17 00:00:00 2001 From: Daan van der Plas Date: Wed, 18 Oct 2023 15:44:17 +0200 Subject: [PATCH 06/13] fix failing ci tests --- polkadot/runtime/westend/src/lib.rs | 6 +++++- substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 0e93b3449fec..13ed373cc0aa 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -2132,6 +2132,8 @@ sp_api::impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -2149,7 +2151,9 @@ sp_api::impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs index d64081404164..57e358542c96 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs @@ -208,8 +208,8 @@ pub(crate) fn sanity_weight_check( ); let mut sanity_weight_check_passed = true; // Loop through all benchmark results. - for ((_, _), results) in all_results.iter() { - // Per pallet, because there can be multiple instances of a pallet. + for ((pallet, instance), results) in all_results.iter() { + println!("Pallet: {}\nInstance: {}\n", pallet, instance); for result in results { // Constant `ref_time` & `pov_size`. let mut total_weight = Weight::from_parts( From 540ce57540910ca603c3030f78bd706ef6db617c Mon Sep 17 00:00:00 2001 From: Daan van der Plas Date: Wed, 18 Oct 2023 17:06:09 +0200 Subject: [PATCH 07/13] more ci tests --- .../parachains/runtimes/assets/asset-hub-kusama/src/lib.rs | 6 +++++- .../runtimes/assets/asset-hub-polkadot/src/lib.rs | 6 +++++- .../parachains/runtimes/assets/asset-hub-rococo/src/lib.rs | 6 +++++- .../parachains/runtimes/assets/asset-hub-westend/src/lib.rs | 6 +++++- .../runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs | 6 +++++- .../runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs | 6 +++++- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 6 +++++- .../runtimes/collectives/collectives-polkadot/src/lib.rs | 6 +++++- .../runtimes/contracts/contracts-rococo/src/lib.rs | 6 +++++- .../parachains/runtimes/glutton/glutton-kusama/src/lib.rs | 6 +++++- cumulus/parachains/runtimes/testing/penpal/src/lib.rs | 6 +++++- 11 files changed, 55 insertions(+), 11 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs index 40ce122112d2..8bd349227ea4 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs @@ -1159,6 +1159,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -1183,7 +1185,9 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs index d4f7d6ef3616..f0809f48f6f5 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs @@ -1039,6 +1039,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -1062,7 +1064,9 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 3328ff0edaf4..0f014c6c1a94 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -1226,6 +1226,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -1254,7 +1256,9 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 943332087627..26e0c287b0a2 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -1210,6 +1210,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -1234,7 +1236,9 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index 791751e77368..03218445dc20 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -628,6 +628,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -644,7 +646,9 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 928b9d091ec5..79be1dc232a6 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -628,6 +628,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -644,7 +646,9 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic, db_weight) } fn dispatch_benchmark( diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 3a8507ccf93e..107f407ec66c 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -967,6 +967,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -987,7 +989,9 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs index ff16f93d8f54..46ed9a4f88cd 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs @@ -885,6 +885,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -895,7 +897,9 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs index 70392c5ecbcc..258a3df80f4d 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs @@ -640,6 +640,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -650,7 +652,9 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/cumulus/parachains/runtimes/glutton/glutton-kusama/src/lib.rs b/cumulus/parachains/runtimes/glutton/glutton-kusama/src/lib.rs index f5d52239e543..d5fda3ca837c 100644 --- a/cumulus/parachains/runtimes/glutton/glutton-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/glutton/glutton-kusama/src/lib.rs @@ -437,6 +437,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -447,7 +449,9 @@ impl_runtime_apis! { let storage_info = AllPalletsWithSystem::storage_info(); - (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs index fe0f19c30632..5584c90d25cb 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs @@ -787,6 +787,8 @@ impl_runtime_apis! { fn benchmark_metadata(extra: bool) -> ( Vec, Vec, + Weight, + frame_support::weights::RuntimeDbWeight, ) { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; @@ -797,7 +799,9 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - (list, storage_info) + let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( From df4f1c4689b666bf7884e95999b9cebf858ab467 Mon Sep 17 00:00:00 2001 From: Daan van der Plas Date: Thu, 19 Oct 2023 10:04:49 +0200 Subject: [PATCH 08/13] more... --- .../parachains/runtimes/assets/asset-hub-kusama/src/lib.rs | 3 ++- .../runtimes/assets/asset-hub-polkadot/src/lib.rs | 3 ++- .../parachains/runtimes/assets/asset-hub-rococo/src/lib.rs | 3 ++- .../parachains/runtimes/assets/asset-hub-westend/src/lib.rs | 3 ++- .../runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs | 3 ++- .../runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs | 5 +++-- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 3 ++- .../runtimes/collectives/collectives-polkadot/src/lib.rs | 3 ++- .../runtimes/contracts/contracts-rococo/src/lib.rs | 3 ++- .../parachains/runtimes/glutton/glutton-kusama/src/lib.rs | 4 ++-- cumulus/parachains/runtimes/testing/penpal/src/lib.rs | 3 ++- substrate/client/cli/src/arg_enums.rs | 3 +-- .../utils/frame/benchmarking-cli/src/pallet/command.rs | 4 ++-- substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs | 6 +++++- 14 files changed, 31 insertions(+), 18 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs index 8bd349227ea4..b4202acf64f4 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs @@ -1166,6 +1166,7 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types @@ -1185,7 +1186,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs index f0809f48f6f5..f3b5530b70f4 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs @@ -1046,6 +1046,7 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types @@ -1064,7 +1065,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 0f014c6c1a94..e56fa1d89474 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -1234,6 +1234,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; use pallet_xcm_bridge_hub_router::benchmarking::Pallet as XcmBridgeHubRouterBench; + use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types @@ -1256,7 +1257,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 26e0c287b0a2..9cb95b0e9f2f 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -1217,6 +1217,7 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types @@ -1236,7 +1237,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index 03218445dc20..5a42a4e82c82 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -635,6 +635,7 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types @@ -646,7 +647,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 79be1dc232a6..f2115935a2e9 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -635,6 +635,7 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types @@ -646,9 +647,9 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); - (list, storage_info, max_extrinsic, db_weight) + (list, storage_info, max_extrinsic_weight, db_weight) } fn dispatch_benchmark( diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 107f407ec66c..bd1b027e5281 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -974,6 +974,7 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types @@ -989,7 +990,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs index 46ed9a4f88cd..3af98ed27baa 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs @@ -892,12 +892,13 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + use sp_core::Get; let mut list = Vec::::new(); list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs index 258a3df80f4d..a131d027a228 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs @@ -647,12 +647,13 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + use sp_core::Get; let mut list = Vec::::new(); list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/cumulus/parachains/runtimes/glutton/glutton-kusama/src/lib.rs b/cumulus/parachains/runtimes/glutton/glutton-kusama/src/lib.rs index d5fda3ca837c..fa4448343723 100644 --- a/cumulus/parachains/runtimes/glutton/glutton-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/glutton/glutton-kusama/src/lib.rs @@ -443,13 +443,13 @@ impl_runtime_apis! { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; + use sp_core::Get; let mut list = Vec::::new(); list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - - let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs index 5584c90d25cb..bbe5328d93e2 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs @@ -794,12 +794,13 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + use sp_core::Get; let mut list = Vec::::new(); list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - let max_extrinsic_weight = BlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); + let max_extrinsic_weight = RuntimeBlockWeights::get().per_class.get(DispatchClass::Normal).max_extrinsic.unwrap(); let db_weight: frame_support::weights::RuntimeDbWeight = ::DbWeight::get(); (list, storage_info, max_extrinsic_weight, db_weight) } diff --git a/substrate/client/cli/src/arg_enums.rs b/substrate/client/cli/src/arg_enums.rs index b9b47a11551f..c0a40f0eff1b 100644 --- a/substrate/client/cli/src/arg_enums.rs +++ b/substrate/client/cli/src/arg_enums.rs @@ -64,8 +64,7 @@ impl std::fmt::Display for WasmExecutionMethod { } } -/// What to do when a (`DispatchClass::Normal`) extrinsic's weight exceeds the max. extrinsic weight -/// per block. +/// How to output the result of the sanity weight check. #[allow(missing_docs)] #[derive(Debug, Clone, Copy, ValueEnum, PartialEq)] #[value(rename_all = "kebab-case")] diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index 7a55694a32ad..fd3fed0030b7 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -555,8 +555,8 @@ impl PalletCmd { writer::write_results(output_path, self, analysis_choice, &all_results)?; } - // Sanity check for benchmarks. Checks whether an (`DispatchClass::Normal`) extrinsic's - // weight exceeds the max. extrinsic weight. + // Sanity weight check for benchmark results. Checks whether an (`DispatchClass::Normal`) + // extrinsic's weight exceeds the max. extrinsic weight. writer::sanity_weight_check( all_results, max_extrinsic_weight, diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs index 57e358542c96..cc22425a61ea 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs @@ -1352,7 +1352,8 @@ mod test { } #[test] - fn sanity_check_works() { + fn sanity_weight_check_works() { + // Create benchmark results that will fail the sanity weight check. let mapped_results = map_results( &[test_data(b"first", b"first", BenchmarkParameter::a, 10, 3)], &test_storage_info(), @@ -1366,6 +1367,7 @@ mod test { ) .unwrap(); + // Flag set to `error`. assert!(sanity_weight_check( mapped_results.clone(), Weight::from_parts(20_000, 1_000_000), @@ -1374,6 +1376,7 @@ mod test { ) .is_err()); + // Flag set to `warning`. assert!(sanity_weight_check( mapped_results.clone(), Weight::from_parts(20_000, 1_000_000), @@ -1382,6 +1385,7 @@ mod test { ) .is_ok()); + // Flag set to `ignore`. assert!(sanity_weight_check( mapped_results, Weight::from_parts(20_000, 1_000_000), From d64188f6d1ebf53f93409e1b77a3182e95ef136b Mon Sep 17 00:00:00 2001 From: Daan van der Plas Date: Wed, 25 Oct 2023 12:14:33 +0200 Subject: [PATCH 09/13] add to gitlab pipeline --- .gitlab/pipeline/short-benchmarks.yml | 5 ++--- .gitlab/pipeline/test.yml | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.gitlab/pipeline/short-benchmarks.yml b/.gitlab/pipeline/short-benchmarks.yml index 6d060077a7c7..eef90e8f416a 100644 --- a/.gitlab/pipeline/short-benchmarks.yml +++ b/.gitlab/pipeline/short-benchmarks.yml @@ -24,7 +24,7 @@ short-benchmark-westend: &short-bench tags: - benchmark script: - - ./artifacts/polkadot benchmark pallet --chain $RUNTIME-dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1 + - ./artifacts/polkadot benchmark pallet --chain $RUNTIME-dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1 --sanity-weight-check ignore # run short-benchmarks for system parachain runtimes from cumulus @@ -47,8 +47,7 @@ short-benchmark-westend: &short-bench tags: - benchmark script: - - ./artifacts/polkadot-parachain benchmark pallet --chain $RUNTIME_CHAIN --pallet "*" --extrinsic "*" --steps 2 --repeat 1 - + - ./artifacts/polkadot-parachain benchmark pallet --chain $RUNTIME_CHAIN --pallet "*" --extrinsic "*" --steps 2 --repeat 1 --sanity-weight-check ignore short-benchmark-asset-hub-polkadot: <<: *short-bench-cumulus variables: diff --git a/.gitlab/pipeline/test.yml b/.gitlab/pipeline/test.yml index 7d7007acd8a8..972005bd29d4 100644 --- a/.gitlab/pipeline/test.yml +++ b/.gitlab/pipeline/test.yml @@ -69,7 +69,6 @@ test-linux-stable-runtime-benchmarks: RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" script: - time cargo nextest run --workspace --features runtime-benchmarks benchmark --locked --cargo-profile testnet - # can be used to run all tests # test-linux-stable-all: # stage: test @@ -352,8 +351,7 @@ quick-benchmarks: WASM_BUILD_NO_COLOR: 1 WASM_BUILD_RUSTFLAGS: "-C debug-assertions -D warnings" script: - - time cargo run --locked --release -p node-cli --bin substrate-node --features runtime-benchmarks -- benchmark pallet --execution wasm --wasm-execution compiled --chain dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1 - + - time cargo run --locked --release -p node-cli --bin substrate-node --features runtime-benchmarks -- benchmark pallet --execution wasm --wasm-execution compiled --chain dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1 --sanity-weight-check ignore test-frame-examples-compile-to-wasm: # into one job stage: test From eace65b09e7a20287d1b4c72458afdf4793abed1 Mon Sep 17 00:00:00 2001 From: Daan van der Plas Date: Wed, 25 Oct 2023 14:35:53 +0200 Subject: [PATCH 10/13] fix: unused import --- .../assets/asset-hub-kusama/src/lib.rs | 150 ++++++++--------- .../assets/asset-hub-polkadot/src/lib.rs | 146 ++++++++--------- .../assets/asset-hub-rococo/src/lib.rs | 150 ++++++++--------- .../assets/asset-hub-westend/src/lib.rs | 152 +++++++++--------- .../bridge-hubs/bridge-hub-kusama/src/lib.rs | 1 - .../bridge-hub-polkadot/src/lib.rs | 1 - .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 1 - .../collectives-polkadot/src/lib.rs | 47 +++--- .../contracts/contracts-rococo/src/lib.rs | 1 - .../runtimes/testing/penpal/src/lib.rs | 1 - 10 files changed, 322 insertions(+), 328 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs index c506b2be46d3..e960bb9ea090 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs @@ -481,97 +481,98 @@ impl InstanceFilter for ProxyType { ProxyType::Any => true, ProxyType::NonTransfer => !matches!( c, - RuntimeCall::Balances { .. } | - RuntimeCall::Assets { .. } | - RuntimeCall::NftFractionalization { .. } | - RuntimeCall::Nfts { .. } | - RuntimeCall::Uniques { .. } + RuntimeCall::Balances { .. } + | RuntimeCall::Assets { .. } + | RuntimeCall::NftFractionalization { .. } + | RuntimeCall::Nfts { .. } + | RuntimeCall::Uniques { .. } ), ProxyType::CancelProxy => matches!( c, - RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::Assets => { matches!( c, - RuntimeCall::Assets { .. } | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } | - RuntimeCall::NftFractionalization { .. } | - RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } + RuntimeCall::Assets { .. } + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } + | RuntimeCall::NftFractionalization { .. } + | RuntimeCall::Nfts { .. } + | RuntimeCall::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::Collator => matches!( c, - RuntimeCall::CollatorSelection { .. } | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::CollatorSelection { .. } + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), } } @@ -1169,7 +1170,6 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; - use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types diff --git a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs index d29727e2091a..ae0b6248325d 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs @@ -419,95 +419,96 @@ impl InstanceFilter for ProxyType { ProxyType::Any => true, ProxyType::NonTransfer => !matches!( c, - RuntimeCall::Balances { .. } | - RuntimeCall::Assets { .. } | - RuntimeCall::Nfts { .. } | - RuntimeCall::Uniques { .. } + RuntimeCall::Balances { .. } + | RuntimeCall::Assets { .. } + | RuntimeCall::Nfts { .. } + | RuntimeCall::Uniques { .. } ), ProxyType::CancelProxy => matches!( c, - RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::Assets => { matches!( c, - RuntimeCall::Assets { .. } | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } | - RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } + RuntimeCall::Assets { .. } + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } + | RuntimeCall::Nfts { .. } + | RuntimeCall::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::Collator => matches!( c, - RuntimeCall::CollatorSelection { .. } | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::CollatorSelection { .. } + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), } } @@ -1049,7 +1050,6 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; - use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 8d020b98b254..9652cea5d250 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -487,97 +487,98 @@ impl InstanceFilter for ProxyType { ProxyType::Any => true, ProxyType::NonTransfer => !matches!( c, - RuntimeCall::Balances { .. } | - RuntimeCall::Assets { .. } | - RuntimeCall::NftFractionalization { .. } | - RuntimeCall::Nfts { .. } | - RuntimeCall::Uniques { .. } + RuntimeCall::Balances { .. } + | RuntimeCall::Assets { .. } + | RuntimeCall::NftFractionalization { .. } + | RuntimeCall::Nfts { .. } + | RuntimeCall::Uniques { .. } ), ProxyType::CancelProxy => matches!( c, - RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::Assets => { matches!( c, - RuntimeCall::Assets { .. } | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } | - RuntimeCall::NftFractionalization { .. } | - RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } + RuntimeCall::Assets { .. } + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } + | RuntimeCall::NftFractionalization { .. } + | RuntimeCall::Nfts { .. } + | RuntimeCall::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::Collator => matches!( c, - RuntimeCall::CollatorSelection { .. } | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::CollatorSelection { .. } + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), } } @@ -1249,7 +1250,6 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; use pallet_xcm_bridge_hub_router::benchmarking::Pallet as XcmBridgeHubRouterBench; - use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index a88963a62f54..ad3ff77d85c5 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -456,97 +456,98 @@ impl InstanceFilter for ProxyType { ProxyType::Any => true, ProxyType::NonTransfer => !matches!( c, - RuntimeCall::Balances { .. } | - RuntimeCall::Assets { .. } | - RuntimeCall::NftFractionalization { .. } | - RuntimeCall::Nfts { .. } | - RuntimeCall::Uniques { .. } + RuntimeCall::Balances { .. } + | RuntimeCall::Assets { .. } + | RuntimeCall::NftFractionalization { .. } + | RuntimeCall::Nfts { .. } + | RuntimeCall::Uniques { .. } ), ProxyType::CancelProxy => matches!( c, - RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::Assets => { matches!( c, - RuntimeCall::Assets { .. } | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } | - RuntimeCall::NftFractionalization { .. } | - RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } + RuntimeCall::Assets { .. } + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } + | RuntimeCall::NftFractionalization { .. } + | RuntimeCall::Nfts { .. } + | RuntimeCall::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) | - RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) | - RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) + | RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) + | RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) + | RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::Collator => matches!( c, - RuntimeCall::CollatorSelection { .. } | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::CollatorSelection { .. } + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), } } @@ -1233,7 +1234,6 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; - use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types @@ -1492,7 +1492,7 @@ pub mod migrations { let pool_asset_id = pool_info.lp_token.clone(); if old_pool_id.0.as_ref() != &invalid_native_asset { // skip, if ok - continue + continue; } // fix new account diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index d4b8a13cfe23..40e81c7105f3 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -638,7 +638,6 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; - use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index a37571a26663..b22aa714f836 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -638,7 +638,6 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; - use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index a27678cfb540..4d63eb0cc0b2 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -818,7 +818,6 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; - use sp_core::Get; // This is defined once again in dispatch_benchmark, because list_benchmarks! // and add_benchmarks! are macros exported by define_benchmarks! macros and those types diff --git a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs index f715f716f64f..078a7d6432f3 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs @@ -312,41 +312,41 @@ impl InstanceFilter for ProxyType { ProxyType::NonTransfer => !matches!(c, RuntimeCall::Balances { .. }), ProxyType::CancelProxy => matches!( c, - RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::Collator => matches!( c, - RuntimeCall::CollatorSelection { .. } | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::CollatorSelection { .. } + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::Alliance => matches!( c, - RuntimeCall::AllianceMotion { .. } | - RuntimeCall::Alliance { .. } | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::AllianceMotion { .. } + | RuntimeCall::Alliance { .. } + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::Fellowship => matches!( c, - RuntimeCall::FellowshipCollective { .. } | - RuntimeCall::FellowshipReferenda { .. } | - RuntimeCall::FellowshipCore { .. } | - RuntimeCall::FellowshipSalary { .. } | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::FellowshipCollective { .. } + | RuntimeCall::FellowshipReferenda { .. } + | RuntimeCall::FellowshipCore { .. } + | RuntimeCall::FellowshipSalary { .. } + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), ProxyType::Ambassador => matches!( c, - RuntimeCall::AmbassadorCollective { .. } | - RuntimeCall::AmbassadorReferenda { .. } | - RuntimeCall::AmbassadorContent { .. } | - RuntimeCall::AmbassadorCore { .. } | - RuntimeCall::AmbassadorSalary { .. } | - RuntimeCall::Utility { .. } | - RuntimeCall::Multisig { .. } + RuntimeCall::AmbassadorCollective { .. } + | RuntimeCall::AmbassadorReferenda { .. } + | RuntimeCall::AmbassadorContent { .. } + | RuntimeCall::AmbassadorCore { .. } + | RuntimeCall::AmbassadorSalary { .. } + | RuntimeCall::Utility { .. } + | RuntimeCall::Multisig { .. } ), } } @@ -909,7 +909,6 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; - use sp_core::Get; let mut list = Vec::::new(); list_benchmarks!(list, extra); diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs index f917380d8f24..2cde9e4ac041 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs @@ -652,7 +652,6 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; - use sp_core::Get; let mut list = Vec::::new(); list_benchmarks!(list, extra); diff --git a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs index 4c8f7ec187a7..fd08b1dd7a3e 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs @@ -797,7 +797,6 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; - use sp_core::Get; let mut list = Vec::::new(); list_benchmarks!(list, extra); From 98485c5d7d38e0fff2558bc141c831db2b5f966c Mon Sep 17 00:00:00 2001 From: Daan van der Plas Date: Wed, 25 Oct 2023 14:43:21 +0200 Subject: [PATCH 11/13] fmt --- .../assets/asset-hub-kusama/src/lib.rs | 149 +++++++++-------- .../assets/asset-hub-polkadot/src/lib.rs | 145 +++++++++-------- .../assets/asset-hub-rococo/src/lib.rs | 149 +++++++++-------- .../assets/asset-hub-westend/src/lib.rs | 151 +++++++++--------- .../collectives-polkadot/src/lib.rs | 46 +++--- 5 files changed, 318 insertions(+), 322 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs index e960bb9ea090..17ef1653e8a0 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs @@ -481,98 +481,97 @@ impl InstanceFilter for ProxyType { ProxyType::Any => true, ProxyType::NonTransfer => !matches!( c, - RuntimeCall::Balances { .. } - | RuntimeCall::Assets { .. } - | RuntimeCall::NftFractionalization { .. } - | RuntimeCall::Nfts { .. } - | RuntimeCall::Uniques { .. } + RuntimeCall::Balances { .. } | + RuntimeCall::Assets { .. } | + RuntimeCall::NftFractionalization { .. } | + RuntimeCall::Nfts { .. } | + RuntimeCall::Uniques { .. } ), ProxyType::CancelProxy => matches!( c, - RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::Assets => { matches!( c, - RuntimeCall::Assets { .. } - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } - | RuntimeCall::NftFractionalization { .. } - | RuntimeCall::Nfts { .. } - | RuntimeCall::Uniques { .. } + RuntimeCall::Assets { .. } | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } | + RuntimeCall::NftFractionalization { .. } | + RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::Collator => matches!( c, - RuntimeCall::CollatorSelection { .. } - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::CollatorSelection { .. } | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs index ae0b6248325d..03e34521a049 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs @@ -419,96 +419,95 @@ impl InstanceFilter for ProxyType { ProxyType::Any => true, ProxyType::NonTransfer => !matches!( c, - RuntimeCall::Balances { .. } - | RuntimeCall::Assets { .. } - | RuntimeCall::Nfts { .. } - | RuntimeCall::Uniques { .. } + RuntimeCall::Balances { .. } | + RuntimeCall::Assets { .. } | + RuntimeCall::Nfts { .. } | + RuntimeCall::Uniques { .. } ), ProxyType::CancelProxy => matches!( c, - RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::Assets => { matches!( c, - RuntimeCall::Assets { .. } - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } - | RuntimeCall::Nfts { .. } - | RuntimeCall::Uniques { .. } + RuntimeCall::Assets { .. } | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } | + RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::Collator => matches!( c, - RuntimeCall::CollatorSelection { .. } - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::CollatorSelection { .. } | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 9652cea5d250..1004b7d7a716 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -487,98 +487,97 @@ impl InstanceFilter for ProxyType { ProxyType::Any => true, ProxyType::NonTransfer => !matches!( c, - RuntimeCall::Balances { .. } - | RuntimeCall::Assets { .. } - | RuntimeCall::NftFractionalization { .. } - | RuntimeCall::Nfts { .. } - | RuntimeCall::Uniques { .. } + RuntimeCall::Balances { .. } | + RuntimeCall::Assets { .. } | + RuntimeCall::NftFractionalization { .. } | + RuntimeCall::Nfts { .. } | + RuntimeCall::Uniques { .. } ), ProxyType::CancelProxy => matches!( c, - RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::Assets => { matches!( c, - RuntimeCall::Assets { .. } - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } - | RuntimeCall::NftFractionalization { .. } - | RuntimeCall::Nfts { .. } - | RuntimeCall::Uniques { .. } + RuntimeCall::Assets { .. } | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } | + RuntimeCall::NftFractionalization { .. } | + RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::Collator => matches!( c, - RuntimeCall::CollatorSelection { .. } - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::CollatorSelection { .. } | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index ad3ff77d85c5..ec8cb168a171 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -456,98 +456,97 @@ impl InstanceFilter for ProxyType { ProxyType::Any => true, ProxyType::NonTransfer => !matches!( c, - RuntimeCall::Balances { .. } - | RuntimeCall::Assets { .. } - | RuntimeCall::NftFractionalization { .. } - | RuntimeCall::Nfts { .. } - | RuntimeCall::Uniques { .. } + RuntimeCall::Balances { .. } | + RuntimeCall::Assets { .. } | + RuntimeCall::NftFractionalization { .. } | + RuntimeCall::Nfts { .. } | + RuntimeCall::Uniques { .. } ), ProxyType::CancelProxy => matches!( c, - RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::Assets => { matches!( c, - RuntimeCall::Assets { .. } - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } - | RuntimeCall::NftFractionalization { .. } - | RuntimeCall::Nfts { .. } - | RuntimeCall::Uniques { .. } + RuntimeCall::Assets { .. } | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } | + RuntimeCall::NftFractionalization { .. } | + RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_team { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_attribute { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::clear_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::clear_attribute { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) - | RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) - | RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) - | RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) | + RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::freeze_collection { .. }) | + RuntimeCall::Uniques(pallet_uniques::Call::thaw_collection { .. }) | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::Collator => matches!( c, - RuntimeCall::CollatorSelection { .. } - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::CollatorSelection { .. } | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), } } @@ -1492,7 +1491,7 @@ pub mod migrations { let pool_asset_id = pool_info.lp_token.clone(); if old_pool_id.0.as_ref() != &invalid_native_asset { // skip, if ok - continue; + continue } // fix new account diff --git a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs index 078a7d6432f3..8867e6bbbf01 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs @@ -312,41 +312,41 @@ impl InstanceFilter for ProxyType { ProxyType::NonTransfer => !matches!(c, RuntimeCall::Balances { .. }), ProxyType::CancelProxy => matches!( c, - RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::Collator => matches!( c, - RuntimeCall::CollatorSelection { .. } - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::CollatorSelection { .. } | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::Alliance => matches!( c, - RuntimeCall::AllianceMotion { .. } - | RuntimeCall::Alliance { .. } - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::AllianceMotion { .. } | + RuntimeCall::Alliance { .. } | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::Fellowship => matches!( c, - RuntimeCall::FellowshipCollective { .. } - | RuntimeCall::FellowshipReferenda { .. } - | RuntimeCall::FellowshipCore { .. } - | RuntimeCall::FellowshipSalary { .. } - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::FellowshipCollective { .. } | + RuntimeCall::FellowshipReferenda { .. } | + RuntimeCall::FellowshipCore { .. } | + RuntimeCall::FellowshipSalary { .. } | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), ProxyType::Ambassador => matches!( c, - RuntimeCall::AmbassadorCollective { .. } - | RuntimeCall::AmbassadorReferenda { .. } - | RuntimeCall::AmbassadorContent { .. } - | RuntimeCall::AmbassadorCore { .. } - | RuntimeCall::AmbassadorSalary { .. } - | RuntimeCall::Utility { .. } - | RuntimeCall::Multisig { .. } + RuntimeCall::AmbassadorCollective { .. } | + RuntimeCall::AmbassadorReferenda { .. } | + RuntimeCall::AmbassadorContent { .. } | + RuntimeCall::AmbassadorCore { .. } | + RuntimeCall::AmbassadorSalary { .. } | + RuntimeCall::Utility { .. } | + RuntimeCall::Multisig { .. } ), } } From 8795558f6231a366a19b9ba7100f8a23473a9b0f Mon Sep 17 00:00:00 2001 From: Daan van der Plas Date: Fri, 27 Oct 2023 13:13:30 +0200 Subject: [PATCH 12/13] improve based on first comments (1/2) --- substrate/client/cli/src/arg_enums.rs | 5 ++++- .../client/cli/src/params/shared_params.rs | 6 ++--- .../utils/frame/benchmarking-cli/Cargo.toml | 1 + .../benchmarking-cli/src/pallet/command.rs | 3 +-- .../benchmarking-cli/src/pallet/writer.rs | 22 +++++++++---------- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/substrate/client/cli/src/arg_enums.rs b/substrate/client/cli/src/arg_enums.rs index c0a40f0eff1b..24183dbd012f 100644 --- a/substrate/client/cli/src/arg_enums.rs +++ b/substrate/client/cli/src/arg_enums.rs @@ -64,13 +64,16 @@ impl std::fmt::Display for WasmExecutionMethod { } } -/// How to output the result of the sanity weight check. +/// How to output the result of the sanity weight check and what to do when it fails. #[allow(missing_docs)] #[derive(Debug, Clone, Copy, ValueEnum, PartialEq)] #[value(rename_all = "kebab-case")] pub enum SanityWeightCheck { + /// Prints the results in the terminal and on failing returns an error. Error, + /// Prints the results in the terminal. Warning, + /// Sanity weight check is ignored. Ignore, } diff --git a/substrate/client/cli/src/params/shared_params.rs b/substrate/client/cli/src/params/shared_params.rs index 3963064c9770..923543a09dfa 100644 --- a/substrate/client/cli/src/params/shared_params.rs +++ b/substrate/client/cli/src/params/shared_params.rs @@ -72,11 +72,11 @@ pub struct SharedParams { #[arg(long, value_name = "RECEIVER", value_enum, ignore_case = true, default_value_t = TracingReceiver::Log)] pub tracing_receiver: TracingReceiver, - /// Sanity weight check for benchmarks. Checks whether an (`DispatchClass::Normal`) extrinsic's - /// weight exceeds the max. extrinsic weight. + /// Sanity weight check for benchmarks. Checks that no benchmark function has a weight larger + /// than the (`DispatchClass::Normal`) max. normal class extrinsic weight. #[arg( long, - value_name = "OUTPUT", + value_name = "ERROR-LEVEL", value_enum, default_value_t = DEFAULT_SANITY_WEIGHT_CHECK, )] diff --git a/substrate/utils/frame/benchmarking-cli/Cargo.toml b/substrate/utils/frame/benchmarking-cli/Cargo.toml index e32fe47b7297..c5ecc1785a83 100644 --- a/substrate/utils/frame/benchmarking-cli/Cargo.toml +++ b/substrate/utils/frame/benchmarking-cli/Cargo.toml @@ -17,6 +17,7 @@ array-bytes = "6.1" chrono = "0.4" clap = { version = "4.4.6", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.6.1" } +color-print = "0.3.4" comfy-table = { version = "7.0.1", default-features = false } handlebars = "4.2.2" Inflector = "0.11.4" diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs index fd3fed0030b7..d76e37e866db 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -555,8 +555,7 @@ impl PalletCmd { writer::write_results(output_path, self, analysis_choice, &all_results)?; } - // Sanity weight check for benchmark results. Checks whether an (`DispatchClass::Normal`) - // extrinsic's weight exceeds the max. extrinsic weight. + // Execute sanity weight check. writer::sanity_weight_check( all_results, max_extrinsic_weight, diff --git a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs index cc22425a61ea..dcec7ffc256d 100644 --- a/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs +++ b/substrate/utils/frame/benchmarking-cli/src/pallet/writer.rs @@ -199,12 +199,12 @@ pub(crate) fn sanity_weight_check( 0 } - println!( - "\n\x1B[1mSanity Weight Check 🧐:\x1B[0m each extrinsic's weight function is executed \ + color_print::cprintln!( + "\nSanity Weight Check 🧐: each extrinsic's weight function is executed \ in the worst case scenario and compared with the maximum extrinsic weight (the maximum weight \ that can be put in a single block for an extrinsic with `DispatchClass::Normal`). In other words, \ each extrinsic is checked whether it will fit in an empty (meaning; empty of \ - `DispatchClass::Normal` extrinsics) block.\n\n\x1B[4mResults:\x1B[0m\n" + `DispatchClass::Normal` extrinsics) block.\n\nResults:\n" ); let mut sanity_weight_check_passed = true; // Loop through all benchmark results. @@ -258,12 +258,12 @@ pub(crate) fn sanity_weight_check( total_weight.proof_size() > max_extrinsic_weight.proof_size() { sanity_weight_check_passed = false; - println!("\x1B[31m\x1B[1mWARNING!!!\x1B[0m",); - println!( - "\x1B[31mThe following extrinsic exceeds the maximum extrinsic weight:\x1B[0m", + color_print::cprintln!("WARNING!!!",); + color_print::cprintln!( + "The following extrinsic exceeds the maximum extrinsic weight:", ); } - println!("- \x1B[1m'{}'\x1B[0m: {:?}\nPercentage of max. extrinsic weight: {:.2}% (ref_time), {:.2}% (proof_size)\n", + color_print::cprintln!("- '{}': {:?}\nPercentage of max. extrinsic weight: {:.2}% (ref_time), {:.2}% (proof_size)\n", result.name, total_weight, (total_weight.ref_time() as f64 / max_extrinsic_weight.ref_time() as f64) * 100.0, @@ -273,9 +273,9 @@ pub(crate) fn sanity_weight_check( } match sanity_weight_check_passed { false => { - println!( - "\x1B[31mYour extrinsics failed the Sanity Weight Check, please review \ - the extrinsic's logic and/or the associated benchmark function.\x1B[0m\n", + color_print::cprintln!( + "Your extrinsics failed the Sanity Weight Check, please review \ + the extrinsic's logic and/or the associated benchmark function.\n", ); if sanity_weight_check == SanityWeightCheck::Error { return Err(io_error(&String::from( @@ -284,7 +284,7 @@ pub(crate) fn sanity_weight_check( } }, true => { - println!("\x1B[32mYour extrinsics passed the Sanity Weight Check 😃!\x1B[0m\n"); + color_print::cprintln!("Your extrinsics passed the Sanity Weight Check 😃!\n"); }, } Ok(()) From 741329f8ab17df700a629240ea92b9184d06fe27 Mon Sep 17 00:00:00 2001 From: Daan van der Plas Date: Fri, 27 Oct 2023 14:03:32 +0200 Subject: [PATCH 13/13] add Cargo.lock --- Cargo.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.lock b/Cargo.lock index d1a1b1877a92..d0449acb3280 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5233,6 +5233,7 @@ dependencies = [ "array-bytes 6.1.0", "chrono", "clap 4.4.6", + "color-print", "comfy-table", "frame-benchmarking", "frame-support",