mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 10:01:17 +00:00
Tips Benchmarking to be Runtime Agnostic (#10368)
* use config traits instead of constants * bounties too * do bounties too * update docs
This commit is contained in:
@@ -84,12 +84,9 @@ fn setup_pot_account<T: Config>() {
|
||||
let _ = T::Currency::make_free_balance_be(&pot_account, value);
|
||||
}
|
||||
|
||||
const MAX_BYTES: u32 = 16384;
|
||||
const MAX_TIPPERS: u32 = 100;
|
||||
|
||||
benchmarks! {
|
||||
report_awesome {
|
||||
let r in 0 .. MAX_BYTES;
|
||||
let r in 0 .. T::MaximumReasonLength::get();
|
||||
let (caller, reason, awesome_person) = setup_awesome::<T>(r);
|
||||
// Whitelist caller account from further DB operations.
|
||||
let caller_key = frame_system::Account::<T>::hashed_key_for(&caller);
|
||||
@@ -97,7 +94,7 @@ benchmarks! {
|
||||
}: _(RawOrigin::Signed(caller), reason, awesome_person)
|
||||
|
||||
retract_tip {
|
||||
let r = MAX_BYTES;
|
||||
let r = T::MaximumReasonLength::get();
|
||||
let (caller, reason, awesome_person) = setup_awesome::<T>(r);
|
||||
TipsMod::<T>::report_awesome(
|
||||
RawOrigin::Signed(caller.clone()).into(),
|
||||
@@ -112,8 +109,8 @@ benchmarks! {
|
||||
}: _(RawOrigin::Signed(caller), hash)
|
||||
|
||||
tip_new {
|
||||
let r in 0 .. MAX_BYTES;
|
||||
let t in 1 .. MAX_TIPPERS;
|
||||
let r in 0 .. T::MaximumReasonLength::get();
|
||||
let t in 1 .. T::Tippers::max_len() as u32;
|
||||
|
||||
let (caller, reason, beneficiary, value) = setup_tip::<T>(r, t)?;
|
||||
// Whitelist caller account from further DB operations.
|
||||
@@ -122,7 +119,7 @@ benchmarks! {
|
||||
}: _(RawOrigin::Signed(caller), reason, beneficiary, value)
|
||||
|
||||
tip {
|
||||
let t in 1 .. MAX_TIPPERS;
|
||||
let t in 1 .. T::Tippers::max_len() as u32;
|
||||
let (member, reason, beneficiary, value) = setup_tip::<T>(0, t)?;
|
||||
let value = T::Currency::minimum_balance().saturating_mul(100u32.into());
|
||||
TipsMod::<T>::tip_new(
|
||||
@@ -142,7 +139,7 @@ benchmarks! {
|
||||
}: _(RawOrigin::Signed(caller), hash, value)
|
||||
|
||||
close_tip {
|
||||
let t in 1 .. MAX_TIPPERS;
|
||||
let t in 1 .. T::Tippers::max_len() as u32;
|
||||
|
||||
// Make sure pot is funded
|
||||
setup_pot_account::<T>();
|
||||
@@ -171,7 +168,7 @@ benchmarks! {
|
||||
}: _(RawOrigin::Signed(caller), hash)
|
||||
|
||||
slash_tip {
|
||||
let t in 1 .. MAX_TIPPERS;
|
||||
let t in 1 .. T::Tippers::max_len() as u32;
|
||||
|
||||
// Make sure pot is funded
|
||||
setup_pot_account::<T>();
|
||||
|
||||
@@ -128,6 +128,8 @@ pub mod pallet {
|
||||
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
|
||||
|
||||
/// Maximum acceptable reason length.
|
||||
///
|
||||
/// Benchmarks depend on this value, be sure to update weights file when changing this value
|
||||
#[pallet::constant]
|
||||
type MaximumReasonLength: Get<u32>;
|
||||
|
||||
@@ -150,7 +152,8 @@ pub mod pallet {
|
||||
/// Origin from which tippers must come.
|
||||
///
|
||||
/// `ContainsLengthBound::max_len` must be cost free (i.e. no storage read or heavy
|
||||
/// operation).
|
||||
/// operation). Benchmarks depend on the value of `ContainsLengthBound::max_len` be sure to
|
||||
/// update weights file when altering this method.
|
||||
type Tippers: SortedMembers<Self::AccountId> + ContainsLengthBound;
|
||||
|
||||
/// Weight information for extrinsics in this pallet.
|
||||
|
||||
Reference in New Issue
Block a user