mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 08:21:03 +00:00
Add Control to Growth of the Staking Pallet (#8920)
* start count * track count * add max limit * min bonds for participating * respect min bond when unbonding * revert a bit of u32 * fix merge * more merge fixes * update to `Current*` * add helper functions * Update frame/staking/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * fix * minbond as storage * checkpoint * chill_other * better bond tracking * MinBond to MinNominatorBond * better doc * use helper function * oops * simple hard limits to validators / nominators. * better doc * update storage version * fix tests * enable migrations * min bond tests * chill other tests * tests for max cap * check `None` on cap too * benchmarks * Update frame/staking/src/lib.rs * Update frame/staking/src/lib.rs Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com> * Update frame/staking/src/lib.rs Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com> * Update frame/staking/src/tests.rs Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com> * fix benchmark * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs * nits * fix reap_stash benchmark * remove lower bound to min bond Co-authored-by: kianenigma <kian@parity.io> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Parity Bot <admin@parity.io> Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
This commit is contained in:
@@ -242,6 +242,7 @@ impl onchain::Config for Test {
|
||||
type Accuracy = Perbill;
|
||||
type DataProvider = Staking;
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
const MAX_NOMINATIONS: u32 = 16;
|
||||
type Currency = Balances;
|
||||
@@ -286,6 +287,8 @@ pub struct ExtBuilder {
|
||||
invulnerables: Vec<AccountId>,
|
||||
has_stakers: bool,
|
||||
initialize_first_session: bool,
|
||||
min_nominator_bond: Balance,
|
||||
min_validator_bond: Balance,
|
||||
}
|
||||
|
||||
impl Default for ExtBuilder {
|
||||
@@ -300,6 +303,8 @@ impl Default for ExtBuilder {
|
||||
invulnerables: vec![],
|
||||
has_stakers: true,
|
||||
initialize_first_session: true,
|
||||
min_nominator_bond: ExistentialDeposit::get(),
|
||||
min_validator_bond: ExistentialDeposit::get(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,7 +366,15 @@ impl ExtBuilder {
|
||||
OFFSET.with(|v| *v.borrow_mut() = offset);
|
||||
self
|
||||
}
|
||||
pub fn build(self) -> sp_io::TestExternalities {
|
||||
pub fn min_nominator_bond(mut self, amount: Balance) -> Self {
|
||||
self.min_nominator_bond = amount;
|
||||
self
|
||||
}
|
||||
pub fn min_validator_bond(mut self, amount: Balance) -> Self {
|
||||
self.min_validator_bond = amount;
|
||||
self
|
||||
}
|
||||
fn build(self) -> sp_io::TestExternalities {
|
||||
sp_tracing::try_init_simple();
|
||||
let mut storage = frame_system::GenesisConfig::default()
|
||||
.build_storage::<Test>()
|
||||
@@ -434,6 +447,8 @@ impl ExtBuilder {
|
||||
minimum_validator_count: self.minimum_validator_count,
|
||||
invulnerables: self.invulnerables,
|
||||
slash_reward_fraction: Perbill::from_percent(10),
|
||||
min_nominator_bond: self.min_nominator_bond,
|
||||
min_validator_bond: self.min_validator_bond,
|
||||
..Default::default()
|
||||
}
|
||||
.assimilate_storage(&mut storage);
|
||||
@@ -477,6 +492,14 @@ fn post_conditions() {
|
||||
check_nominators();
|
||||
check_exposures();
|
||||
check_ledgers();
|
||||
check_count();
|
||||
}
|
||||
|
||||
fn check_count() {
|
||||
let nominator_count = Nominators::<Test>::iter().count() as u32;
|
||||
let validator_count = Validators::<Test>::iter().count() as u32;
|
||||
assert_eq!(nominator_count, CurrentNominatorsCount::<Test>::get());
|
||||
assert_eq!(validator_count, CurrentValidatorsCount::<Test>::get());
|
||||
}
|
||||
|
||||
fn check_ledgers() {
|
||||
|
||||
Reference in New Issue
Block a user