Improve call, and usage in pallet utility (#9418)

* WIP

* WIP

* WIP

* add some tests and limit

* remove wip test

* fmt

* Update bin/node/runtime/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* fmt

* use primitives allocation limit

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Guillaume Thiolliere
2021-08-07 11:34:25 +02:00
committed by GitHub
parent 27d4177f93
commit 38db14089b
17 changed files with 197 additions and 92 deletions
@@ -26,7 +26,10 @@ use rand::{prelude::SliceRandom, rngs::SmallRng, SeedableRng};
use sp_arithmetic::{per_things::Percent, traits::One};
use sp_npos_elections::IndexAssignment;
use sp_runtime::InnerOf;
use sp_std::convert::{TryFrom, TryInto};
use sp_std::{
boxed::Box,
convert::{TryFrom, TryInto},
};
const SEED: u32 = 999;
@@ -317,7 +320,7 @@ frame_benchmarking::benchmarks! {
let caller = frame_benchmarking::whitelisted_caller();
T::Currency::make_free_balance_be(&caller, T::Currency::minimum_balance() * 10u32.into());
}: _(RawOrigin::Signed(caller), solution, c)
}: _(RawOrigin::Signed(caller), Box::new(solution), c)
verify {
assert!(<MultiPhase<T>>::signed_submissions().len() as u32 == c + 1);
}
@@ -344,9 +347,15 @@ frame_benchmarking::benchmarks! {
// encode the most significant storage item that needs to be decoded in the dispatch.
let encoded_snapshot = <MultiPhase<T>>::snapshot().unwrap().encode();
let encoded_call = <Call<T>>::submit_unsigned(raw_solution.clone(), witness).encode();
let encoded_call = <Call<T>>::submit_unsigned(Box::new(raw_solution.clone()), witness).encode();
}: {
assert_ok!(<MultiPhase<T>>::submit_unsigned(RawOrigin::None.into(), raw_solution, witness));
assert_ok!(
<MultiPhase<T>>::submit_unsigned(
RawOrigin::None.into(),
Box::new(raw_solution),
witness,
)
);
let _decoded_snap = <RoundSnapshot<T::AccountId> as Decode>::decode(&mut &*encoded_snapshot)
.unwrap();
let _decoded_call = <Call<T> as Decode>::decode(&mut &*encoded_call).unwrap();