git.delta.rocks / unique-network / refs/commits / 5275b143cca5

difftreelog

fix(pallet-identity) benchmarking

Yaroslav Bolyukin2023-04-20parent: #30011e5.patch.diff
in: master

2 files changed

modifiedMakefilediffbeforeafterboth
146 make _bench PALLET=xcm OUTPUT=./runtime/common/weights/xcm.rs TEMPLATE="--template=.maintain/external-weight-template.hbs"146 make _bench PALLET=xcm OUTPUT=./runtime/common/weights/xcm.rs TEMPLATE="--template=.maintain/external-weight-template.hbs"
147147
148.PHONY: bench148.PHONY: bench
149# Disabled: bench-scheduler, bench-identity149# Disabled: bench-scheduler
150bench: bench-app-promotion bench-common bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-configuration bench-foreign-assets bench-maintenance bench-xcm bench-collator-selection150bench: bench-app-promotion bench-common bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-configuration bench-foreign-assets bench-maintenance bench-xcm bench-collator-selection bench-identity
151151
152.PHONY: check152.PHONY: check
153check:153check:
modifiedpallets/identity/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/identity/src/benchmarking.rs
+++ b/pallets/identity/src/benchmarking.rs
@@ -138,6 +138,12 @@
 	}
 }
 
+/// `Currency::minimum_balance` was used originally, but in unique-chain, we have
+/// zero existential deposit, thus triggering zero bond assertion.
+fn balance_unit<T: Config>() -> <T::Currency as Currency<T::AccountId>>::Balance {
+	200u32.into()
+}
+
 benchmarks! {
 	add_registrar {
 		let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;
@@ -167,7 +173,7 @@
 			for i in 0..r {
 				let registrar: T::AccountId = account("registrar", i, SEED);
 				let registrar_lookup = T::Lookup::unlookup(registrar.clone());
-				let balance_to_use =  T::Currency::minimum_balance() * 10u32.into();
+				let balance_to_use =  balance_unit::<T>() * 10u32.into();
 				let _ = T::Currency::make_free_balance_be(&registrar, balance_to_use);
 
 				Identity::<T>::request_judgement(caller_origin.clone(), i, 10u32.into())?;
@@ -240,7 +246,7 @@
 		// User requests judgement from all the registrars, and they approve
 		for i in 0..r {
 			let registrar: T::AccountId = account("registrar", i, SEED);
-			let balance_to_use =  T::Currency::minimum_balance() * 10u32.into();
+			let balance_to_use =  balance_unit::<T>() * 10u32.into();
 			let _ = T::Currency::make_free_balance_be(&registrar, balance_to_use);
 
 			Identity::<T>::request_judgement(caller_origin.clone(), i, 10u32.into())?;
@@ -393,7 +399,7 @@
 		// User requests judgement from all the registrars, and they approve
 		for i in 0..r {
 			let registrar: T::AccountId = account("registrar", i, SEED);
-			let balance_to_use =  T::Currency::minimum_balance() * 10u32.into();
+			let balance_to_use =  balance_unit::<T>() * 10u32.into();
 			let _ = T::Currency::make_free_balance_be(&registrar, balance_to_use);
 
 			Identity::<T>::request_judgement(target_origin.clone(), i, 10u32.into())?;