Add weight for decoding the call to benchmarks (#9781)

* First two bechmarks converted

* Add decoding weight to benchmarks.

* Update frame/democracy/src/benchmarking.rs

* Adapt to new Call-ing convention

* Resolve conflicts and change more calls

* Remove error impl for codec and use plain `expect` for error handling instead

* Compile fix

* Spaces to tabs

* Update frame/democracy/src/benchmarking.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Add origin-type specifier to benchmarks macro

* formatting

* Update frame/benchmarking/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Change manual to automatic benchmark syntax

* Formatting

* Revert "Change manual to automatic benchmark syntax"

This reverts commit ea5b5d906b318b6525c1e6d2bd05c5011595c21a.

Because tests are lost and cleanup code in the verify function is not run on failing calls.

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
Falco Hirschenberger
2021-09-27 17:17:38 +02:00
committed by GitHub
parent 1ebcbe1c34
commit 6ec82c7a83
9 changed files with 75 additions and 60 deletions
+9 -2
View File
@@ -23,6 +23,7 @@ use testing_utils::*;
use frame_election_provider_support::SortedListProvider;
use frame_support::{
dispatch::UnfilteredDispatchable,
pallet_prelude::*,
traits::{Currency, CurrencyToVote, Get, Imbalance},
};
@@ -764,9 +765,15 @@ benchmarks! {
<ErasValidatorReward<T>>::insert(current_era, total_payout);
let caller: T::AccountId = whitelisted_caller();
let origin = RawOrigin::Signed(caller);
let calls: Vec<_> = payout_calls_arg.iter().map(|arg|
Call::<T>::payout_stakers { validator_stash: arg.0.clone(), era: arg.1 }.encode()
).collect();
}: {
for arg in payout_calls_arg {
<Staking<T>>::payout_stakers(RawOrigin::Signed(caller.clone()).into(), arg.0, arg.1)?;
for call in calls {
<Call<T> as Decode>::decode(&mut &*call)
.expect("call is encoded above, encoding must be correct")
.dispatch_bypass_filter(origin.clone().into())?;
}
}