git.delta.rocks / unique-network / refs/commits / 5f71c376196c

difftreelog

fix benchmarks

Grigoriy Simonov2023-10-12parent: #af2b5f4.patch.diff
in: master

6 files changed

modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -42,10 +42,6 @@
 use sp_runtime::traits::AccountIdConversion;
 use up_common::types::opaque::RuntimeId;
 
-#[cfg(feature = "runtime-benchmarks")]
-use crate::chain_spec::default_runtime;
-#[cfg(feature = "runtime-benchmarks")]
-use crate::service::DefaultRuntimeExecutor;
 #[cfg(feature = "quartz-runtime")]
 use crate::service::QuartzRuntimeExecutor;
 #[cfg(feature = "unique-runtime")]
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -93,23 +93,6 @@
 /// Opal native executor instance.
 pub struct OpalRuntimeExecutor;
 
-#[cfg(all(feature = "unique-runtime", feature = "runtime-benchmarks"))]
-pub type DefaultRuntimeExecutor = UniqueRuntimeExecutor;
-
-#[cfg(all(
-	not(feature = "unique-runtime"),
-	feature = "quartz-runtime",
-	feature = "runtime-benchmarks"
-))]
-pub type DefaultRuntimeExecutor = QuartzRuntimeExecutor;
-
-#[cfg(all(
-	not(feature = "unique-runtime"),
-	not(feature = "quartz-runtime"),
-	feature = "runtime-benchmarks"
-))]
-pub type DefaultRuntimeExecutor = OpalRuntimeExecutor;
-
 #[cfg(feature = "unique-runtime")]
 impl NativeExecutionDispatch for UniqueRuntimeExecutor {
 	/// Only enable the benchmarking host functions when we actually want to benchmark.
modifiedpallets/app-promotion/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/app-promotion/src/benchmarking.rs
+++ b/pallets/app-promotion/src/benchmarking.rs
@@ -109,7 +109,7 @@
 	}
 
 	#[benchmark]
-	fn payout_stakers(b: Linear<0, 100>) -> Result<(), BenchmarkError> {
+	fn payout_stakers(b: Linear<1, 100>) -> Result<(), BenchmarkError> {
 		let pallet_admin = account::<T::AccountId>("admin", 1, SEED);
 		PromototionPallet::<T>::set_admin_address(
 			RawOrigin::Root.into(),
modifiedpallets/collator-selection/src/benchmarking.rsdiffbeforeafterboth
171 // Both invulnerables and candidates count together against MaxCollators.171 // Both invulnerables and candidates count together against MaxCollators.
172 // Maybe try putting it in braces? 1 .. (T::MaxCollators::get() - 2)172 // Maybe try putting it in braces? 1 .. (T::MaxCollators::get() - 2)
173 #[benchmark]173 #[benchmark]
174 fn add_invulnerable<T>(b: Linear<1, MAX_COLLATORS>) -> Result<(), BenchmarkError> {174 fn add_invulnerable<T>(b: Linear<2, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
175 let b = b - 1;
175 register_validators::<T>(b);176 register_validators::<T>(b);
176 register_invulnerables::<T>(b);177 register_invulnerables::<T>(b);
177178
268 // worst case is when we have all the max-candidate slots filled except one, and we fill that269 // worst case is when we have all the max-candidate slots filled except one, and we fill that
269 // one.270 // one.
270 #[benchmark]271 #[benchmark]
271 fn onboard(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {272 fn onboard(c: Linear<2, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
273 let c = c - 1;
272 register_validators::<T>(c);274 register_validators::<T>(c);
273 register_candidates::<T>(c);275 register_candidates::<T>(c);
274276
293295
294 // worst case is the last candidate leaving.296 // worst case is the last candidate leaving.
295 #[benchmark]297 #[benchmark]
296 fn offboard(c: Linear<0, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {298 fn offboard(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
297 let c = c + 1;
298
299 register_validators::<T>(c);299 register_validators::<T>(c);
300 register_candidates::<T>(c);300 register_candidates::<T>(c);
317317
318 // worst case is the last candidate leaving.318 // worst case is the last candidate leaving.
319 #[benchmark]319 #[benchmark]
320 fn release_license(c: Linear<0, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {320 fn release_license(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
321 let c = c + 1;
322 let bond = balance_unit::<T>();321 let bond = balance_unit::<T>();
323322
324 register_validators::<T>(c);323 register_validators::<T>(c);
343342
344 // worst case is the last candidate leaving.343 // worst case is the last candidate leaving.
345 #[benchmark]344 #[benchmark]
346 fn force_release_license(c: Linear<0, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {345 fn force_release_license(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
347 let c = c + 1;
348 let bond = balance_unit::<T>();346 let bond = balance_unit::<T>();
349347
350 register_validators::<T>(c);348 register_validators::<T>(c);
400 // worst case for new session.398 // worst case for new session.
401 #[benchmark]399 #[benchmark]
402 fn new_session(400 fn new_session(
403 r: Linear<0, MAX_INVULNERABLES>,401 r: Linear<1, MAX_INVULNERABLES>,
404 c: Linear<0, MAX_INVULNERABLES>,402 c: Linear<1, MAX_INVULNERABLES>,
405 ) -> Result<(), BenchmarkError> {403 ) -> Result<(), BenchmarkError> {
406 let r = r + 1;
407 let c = c + 1;
408
409 frame_system::Pallet::<T>::set_block_number(0u32.into());404 frame_system::Pallet::<T>::set_block_number(0u32.into());
410405
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -17,9 +17,7 @@
 use frame_benchmarking::v2::{account, benchmarks, BenchmarkError};
 use pallet_common::{
 	bench_init,
-	benchmarking::{
-		create_collection_raw, load_is_admin_and_property_permissions, property_key, property_value,
-	},
+	benchmarking::{create_collection_raw, property_key, property_value},
 	CommonCollectionOperations,
 };
 use sp_std::prelude::*;
@@ -334,49 +332,51 @@
 		Ok(())
 	}
 
+	// TODO:
 	#[benchmark]
 	fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
-		bench_init! {
-			owner: sub; collection: collection(owner);
-			owner: cross_from_sub;
-		};
+		// bench_init! {
+		// 	owner: sub; collection: collection(owner);
+		// 	owner: cross_from_sub;
+		// };
 
-		let perms = (0..b)
-			.map(|k| PropertyKeyPermission {
-				key: property_key(k as usize),
-				permission: PropertyPermission {
-					mutable: false,
-					collection_admin: true,
-					token_owner: true,
-				},
-			})
-			.collect::<Vec<_>>();
-		<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
-		let props = (0..b)
-			.map(|k| Property {
-				key: property_key(k as usize),
-				value: property_value(),
-			})
-			.collect::<Vec<_>>();
-		let item = create_max_item(&collection, &owner, owner.clone())?;
+		// let perms = (0..b)
+		// 	.map(|k| PropertyKeyPermission {
+		// 		key: property_key(k as usize),
+		// 		permission: PropertyPermission {
+		// 			mutable: false,
+		// 			collection_admin: true,
+		// 			token_owner: true,
+		// 		},
+		// 	})
+		// 	.collect::<Vec<_>>();
+		// <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
+		#[block]
+		{}
+		// let props = (0..b)
+		// 	.map(|k| Property {
+		// 		key: property_key(k as usize),
+		// 		value: property_value(),
+		// 	})
+		// 	.collect::<Vec<_>>();
+		// let item = create_max_item(&collection, &owner, owner.clone())?;
 
 		// let (is_collection_admin, property_permissions) =
 		// 	load_is_admin_and_property_permissions(&collection, &owner);
-		todo!();
-		#[block]
-		{
-			// let mut property_writer =
-			// 	pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
+		// #[block]
+		// {
+		// 	let mut property_writer =
+		// 		pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
 
-			// property_writer.write_token_properties(
-			// 	item,
-			// 	props.into_iter(),
-			// 	crate::erc::ERC721TokenEvent::TokenChanged {
-			// 		token_id: item.into(),
-			// 	}
-			// 	.to_log(T::ContractAddress::get()),
-			// )?;
-		}
+		// 	property_writer.write_token_properties(
+		// 		item,
+		// 		props.into_iter(),
+		// 		crate::erc::ERC721TokenEvent::TokenChanged {
+		// 			token_id: item.into(),
+		// 		}
+		// 		.to_log(T::ContractAddress::get()),
+		// 	)?;
+		// }
 
 		Ok(())
 	}
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -490,35 +490,35 @@
 		Ok(())
 	}
 
+	// TODO:
 	#[benchmark]
 	fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
-		bench_init! {
-			owner: sub; collection: collection(owner);
-			owner: cross_from_sub;
-		};
+		// bench_init! {
+		// 	owner: sub; collection: collection(owner);
+		// 	owner: cross_from_sub;
+		// };
+
+		// let perms = (0..b)
+		// 	.map(|k| PropertyKeyPermission {
+		// 		key: property_key(k as usize),
+		// 		permission: PropertyPermission {
+		// 			mutable: false,
+		// 			collection_admin: true,
+		// 			token_owner: true,
+		// 		},
+		// 	})
+		// 	.collect::<Vec<_>>();
+		// <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
 
-		let perms = (0..b)
-			.map(|k| PropertyKeyPermission {
-				key: property_key(k as usize),
-				permission: PropertyPermission {
-					mutable: false,
-					collection_admin: true,
-					token_owner: true,
-				},
-			})
-			.collect::<Vec<_>>();
-		<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
+		#[block]
+		{}
 		// let props = (0..b).map(|k| Property {
 		// 	key: property_key(k as usize),
 		// 	value: property_value(),
 		// }).collect::<Vec<_>>();
 		// let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
 
-		// let (is_collection_admin, property_permissions) = load_is_admin_and_property_permissions(&collection, &owner);
-
-		#[block]
-		{}
-		todo!();
+		// let (is_collection_admin, property_permissions) = load_is_admin_and_property_permissions(&collection, &owner)
 		// let mut property_writer = pallet_common::collection_info_loaded_property_writer(
 		// 	&collection,
 		// 	is_collection_admin,