mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 02:48:03 +00:00
Benchmark Staking and Session Pallet (#5183)
* starting bench * More * more * Payout Validator * Give each validator exactly n nominators * Update with test * Try to add accounts to chain spec * Undo changes to chainspec * Payout nominator * Rebond and Reap Stash * Set history depth * fix smelly code * cancel deferred slash * new_era bench * do_slash benchmark * Add features * undo extrinsic move * lower * Update new era * Update benchmarking.rs * whitespace * Apply suggestions from code review Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * fixes * nit * Refactor tests, initial code * Move session benchmarks to avoid cyclic deps * Update lib.rs * Fix warnings * Move impl * Update to do random nominator allocation * add feature to benchmark pallet * Remove extra stuff * Update based on feedback * Less intrusive * Remove `transfer_idle_users` * remove again * unused dep * test feature flag * Update to latest substrate Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -254,6 +254,8 @@ mod mock;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
mod slashing;
|
||||
#[cfg(any(feature = "runtime-benchmarks", test))]
|
||||
pub mod benchmarking;
|
||||
|
||||
pub mod inflation;
|
||||
|
||||
@@ -287,7 +289,7 @@ use sp_phragmen::ExtendedBalance;
|
||||
use frame_support::traits::MigrateAccount;
|
||||
|
||||
const DEFAULT_MINIMUM_VALIDATOR_COUNT: u32 = 4;
|
||||
const MAX_NOMINATIONS: usize = 16;
|
||||
pub const MAX_NOMINATIONS: usize = 16;
|
||||
const MAX_UNLOCKING_CHUNKS: usize = 32;
|
||||
const STAKING_ID: LockIdentifier = *b"staking ";
|
||||
|
||||
@@ -1281,6 +1283,8 @@ decl_module! {
|
||||
}
|
||||
}
|
||||
|
||||
// ----- Root calls.
|
||||
|
||||
/// The ideal number of validators.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000)]
|
||||
fn set_validator_count(origin, #[compact] new: u32) {
|
||||
@@ -1288,8 +1292,6 @@ decl_module! {
|
||||
ValidatorCount::put(new);
|
||||
}
|
||||
|
||||
// ----- Root calls.
|
||||
|
||||
/// Force there to be no new eras indefinitely.
|
||||
///
|
||||
/// # <weight>
|
||||
@@ -1357,7 +1359,7 @@ decl_module! {
|
||||
.or_else(ensure_root)?;
|
||||
|
||||
ensure!(!slash_indices.is_empty(), Error::<T>::EmptyTargets);
|
||||
ensure!(Self::is_sorted_and_unique(&slash_indices), Error::<T>::NotSortedAndUnique);
|
||||
ensure!(is_sorted_and_unique(&slash_indices), Error::<T>::NotSortedAndUnique);
|
||||
|
||||
let mut unapplied = <Self as Store>::UnappliedSlashes::get(&era);
|
||||
let last_item = slash_indices[slash_indices.len() - 1];
|
||||
@@ -1510,11 +1512,6 @@ impl<T: Trait> Module<T> {
|
||||
Self::bonded(stash).and_then(Self::ledger).map(|l| l.active).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Check that list is sorted and has no duplicates.
|
||||
fn is_sorted_and_unique(list: &Vec<u32>) -> bool {
|
||||
list.windows(2).all(|w| w[0] < w[1])
|
||||
}
|
||||
|
||||
// MUTABLES (DANGEROUS)
|
||||
|
||||
fn do_payout_nominator(who: T::AccountId, era: EraIndex, validators: Vec<(T::AccountId, u32)>)
|
||||
@@ -2220,3 +2217,8 @@ impl<T, Reporter, Offender, R, O> ReportOffence<Reporter, Offender, O>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Check that list is sorted and has no duplicates.
|
||||
fn is_sorted_and_unique(list: &[u32]) -> bool {
|
||||
list.windows(2).all(|w| w[0] < w[1])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user