From 9d50761da2ffab0fa1c9fa955faa4ad549a2a785 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 5 Aug 2020 11:13:42 +0200 Subject: [PATCH] try using dynamic whitelist --- frame/balances/src/benchmarking.rs | 6 +++++- frame/benchmarking/src/lib.rs | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/frame/balances/src/benchmarking.rs b/frame/balances/src/benchmarking.rs index 73547fe814aa2..6a6afa2d69a1d 100644 --- a/frame/balances/src/benchmarking.rs +++ b/frame/balances/src/benchmarking.rs @@ -39,8 +39,12 @@ benchmarks! { // * Transfer will kill the sender account. // * Transfer will create the recipient account. transfer { + let u in 0 .. 1000; + let existential_deposit = T::ExistentialDeposit::get(); - let caller = account("caller", 0, SEED); + let caller = account("caller", u, SEED); + + __whitelist.append(frame_system::Account::::hashed_key_for(caller)); // Give some multiple of the existential deposit + creation fee + transfer fee let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into()); diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index 40fda71b646a6..e36fdfa03a2f8 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -583,7 +583,7 @@ macro_rules! benchmark_backend { ] } - fn instance(&self, mut _whitelist: &[Vec], components: &[($crate::BenchmarkParameter, u32)]) + fn instance(&self, mut __whitelist: &[Vec], components: &[($crate::BenchmarkParameter, u32)]) -> Result Result<(), &'static str>>, &'static str> { $( @@ -603,7 +603,7 @@ macro_rules! benchmark_backend { // Add whitelist to DB #[cfg(not(test))] - $crate::benchmarking::set_whitelist(_whitelist.to_vec()); + $crate::benchmarking::set_whitelist(__whitelist.to_vec()); Ok(Box::new(move || -> Result<(), &'static str> { $eval; Ok(()) })) } @@ -611,6 +611,7 @@ macro_rules! benchmark_backend { fn verify(&self, components: &[($crate::BenchmarkParameter, u32)]) -> Result Result<(), &'static str>>, &'static str> { + let mut __whitelist = Vec::>::new(); $( let $common = $common_from; )*