Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix migration
  • Loading branch information
kianenigma committed Sep 30, 2022
commit 0ba02aab54ea090e90ca7d88a3cbe2f11b1fc5c0
12 changes: 7 additions & 5 deletions frame/fast-unstake/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ fn l<T: Config>(
}

fn create_unexposed_nominators<T: Config>() -> Vec<T::AccountId> {
(0..T::BatchSize::get()).map(|i| {
let account = frame_benchmarking::account::<T::AccountId>("nominator_42", i, USER_SEED);
fund_and_bond_account::<T>(&account);
account
}).collect()
(0..T::BatchSize::get())
.map(|i| {
let account = frame_benchmarking::account::<T::AccountId>("nominator_42", i, USER_SEED);
fund_and_bond_account::<T>(&account);
account
})
.collect()
}

fn fund_and_bond_account<T: Config>(account: &T::AccountId) {
Expand Down
23 changes: 23 additions & 0 deletions frame/fast-unstake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,29 @@ pub mod pallet {
return Weight::from_ref_time(0)
}

// Temporary for migration.
if Head::<T>::exists() && Head::<T>::get().is_none() {
// Migrate head.
let key = Head::<T>::hashed_key();
let (stash, deposit) = match frame_support::storage::unhashed::get::<(
T::AccountId,
Vec<EraIndex>,
BalanceOf<T>,
)>(&key)
.defensive()
{
Some((stash, _, deposit)) => (stash, deposit),
None => {
Head::<T>::kill();
return T::DbWeight::get().reads_writes(1, 1)
},
};
// insert them back into the queue.
Queue::<T>::insert(stash, deposit);
Head::<T>::kill();
return T::DbWeight::get().reads_writes(1, 2)
}

Self::do_on_idle(remaining_weight)
}
}
Expand Down
2 changes: 0 additions & 2 deletions frame/fast-unstake/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,3 @@ pub struct UnstakeRequest<T: Config> {
/// The list of eras for which they have been checked.
pub(crate) checked: BoundedVec<EraIndex, MaxChecking<T>>,
}

// TODO: If we fail at reading the head, we should just remove it.