mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +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:
@@ -226,6 +226,7 @@ pub struct ExtBuilder {
|
||||
fair: bool,
|
||||
num_validators: Option<u32>,
|
||||
invulnerables: Vec<u64>,
|
||||
stakers: bool,
|
||||
}
|
||||
|
||||
impl Default for ExtBuilder {
|
||||
@@ -240,6 +241,7 @@ impl Default for ExtBuilder {
|
||||
fair: true,
|
||||
num_validators: None,
|
||||
invulnerables: vec![],
|
||||
stakers: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,6 +287,11 @@ impl ExtBuilder {
|
||||
EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = self.existential_deposit);
|
||||
SLASH_DEFER_DURATION.with(|v| *v.borrow_mut() = self.slash_defer_duration);
|
||||
}
|
||||
|
||||
pub fn stakers(mut self, has_stakers: bool) -> Self {
|
||||
self.stakers = has_stakers;
|
||||
self
|
||||
}
|
||||
pub fn build(self) -> sp_io::TestExternalities {
|
||||
self.set_associated_consts();
|
||||
let mut storage = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
@@ -320,16 +327,17 @@ impl ExtBuilder {
|
||||
],
|
||||
}.assimilate_storage(&mut storage);
|
||||
|
||||
let stake_21 = if self.fair { 1000 } else { 2000 };
|
||||
let stake_31 = if self.validator_pool { balance_factor * 1000 } else { 1 };
|
||||
let status_41 = if self.validator_pool {
|
||||
StakerStatus::<AccountId>::Validator
|
||||
} else {
|
||||
StakerStatus::<AccountId>::Idle
|
||||
};
|
||||
let nominated = if self.nominate { vec![11, 21] } else { vec![] };
|
||||
let _ = GenesisConfig::<Test>{
|
||||
stakers: vec![
|
||||
let mut stakers = vec![];
|
||||
if self.stakers {
|
||||
let stake_21 = if self.fair { 1000 } else { 2000 };
|
||||
let stake_31 = if self.validator_pool { balance_factor * 1000 } else { 1 };
|
||||
let status_41 = if self.validator_pool {
|
||||
StakerStatus::<AccountId>::Validator
|
||||
} else {
|
||||
StakerStatus::<AccountId>::Idle
|
||||
};
|
||||
let nominated = if self.nominate { vec![11, 21] } else { vec![] };
|
||||
stakers = vec![
|
||||
// (stash, controller, staked_amount, status)
|
||||
(11, 10, balance_factor * 1000, StakerStatus::<AccountId>::Validator),
|
||||
(21, 20, stake_21, StakerStatus::<AccountId>::Validator),
|
||||
@@ -337,7 +345,10 @@ impl ExtBuilder {
|
||||
(41, 40, balance_factor * 1000, status_41),
|
||||
// nominator
|
||||
(101, 100, balance_factor * 500, StakerStatus::<AccountId>::Nominator(nominated))
|
||||
],
|
||||
];
|
||||
}
|
||||
let _ = GenesisConfig::<Test>{
|
||||
stakers: stakers,
|
||||
validator_count: self.validator_count,
|
||||
minimum_validator_count: self.minimum_validator_count,
|
||||
invulnerables: self.invulnerables,
|
||||
|
||||
Reference in New Issue
Block a user