mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 19:11:04 +00:00
Only maintain at most 1 UnlockChunk per era (#10670)
* Only maintain at most 1 `UnlockChunk` per era * Bound `unlocking` * Run cargo +nightly-2021-10-29 fmt * Make benchmarks stuff compile * Update frame/staking/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Remove DerefMut; Implement neccesary methods directly * Doc comments for new BoundedVec methods * Fix benchmarks * wip bonded_vec macro * Correct rust doc * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update staking::Config impls * Add MaxUnlockingChunks to more places * Use defensive saturating add * FMT Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -618,7 +618,7 @@ benchmarks! {
|
||||
}
|
||||
|
||||
rebond {
|
||||
let l in 1 .. MAX_UNLOCKING_CHUNKS as u32;
|
||||
let l in 1 .. MaxUnlockingChunks::get() as u32;
|
||||
|
||||
// clean up any existing state.
|
||||
clear_validators_and_nominators::<T>();
|
||||
@@ -652,7 +652,7 @@ benchmarks! {
|
||||
let mut staking_ledger = Ledger::<T>::get(controller.clone()).unwrap();
|
||||
|
||||
for _ in 0 .. l {
|
||||
staking_ledger.unlocking.push(unlock_chunk.clone())
|
||||
staking_ledger.unlocking.try_push(unlock_chunk.clone()).unwrap()
|
||||
}
|
||||
Ledger::<T>::insert(controller.clone(), staking_ledger.clone());
|
||||
let original_bonded: BalanceOf<T> = staking_ledger.active;
|
||||
@@ -702,7 +702,7 @@ benchmarks! {
|
||||
stash: stash.clone(),
|
||||
active: T::Currency::minimum_balance() - One::one(),
|
||||
total: T::Currency::minimum_balance() - One::one(),
|
||||
unlocking: vec![],
|
||||
unlocking: Default::default(),
|
||||
claimed_rewards: vec![],
|
||||
};
|
||||
Ledger::<T>::insert(&controller, l);
|
||||
@@ -788,7 +788,7 @@ benchmarks! {
|
||||
|
||||
#[extra]
|
||||
do_slash {
|
||||
let l in 1 .. MAX_UNLOCKING_CHUNKS as u32;
|
||||
let l in 1 .. MaxUnlockingChunks::get() as u32;
|
||||
let (stash, controller) = create_stash_controller::<T>(0, 100, Default::default())?;
|
||||
let mut staking_ledger = Ledger::<T>::get(controller.clone()).unwrap();
|
||||
let unlock_chunk = UnlockChunk::<BalanceOf<T>> {
|
||||
@@ -796,7 +796,7 @@ benchmarks! {
|
||||
era: EraIndex::zero(),
|
||||
};
|
||||
for _ in 0 .. l {
|
||||
staking_ledger.unlocking.push(unlock_chunk.clone())
|
||||
staking_ledger.unlocking.try_push(unlock_chunk.clone()).unwrap();
|
||||
}
|
||||
Ledger::<T>::insert(controller, staking_ledger);
|
||||
let slash_amount = T::Currency::minimum_balance() * 10u32.into();
|
||||
|
||||
Reference in New Issue
Block a user