paras-scheduler: Fix migration to V1 (#1969)

The migration was missing to migrate `AvailabilityCores`. If this isn't
migrated, all parachains in the availability phase would stall until the
next session is started. This pull request fixes this by migrating this
data. Besides that it is doing some cosmetics.
This commit is contained in:
Bastian Köcher
2023-10-23 12:07:16 +02:00
committed by GitHub
parent 38c3c62588
commit f678b61c39
4 changed files with 86 additions and 52 deletions
+6 -10
View File
@@ -605,14 +605,10 @@ impl<T: Config> Pallet<T> {
/// Moves all elements in the claimqueue forward.
fn move_claimqueue_forward() {
let mut cq = ClaimQueue::<T>::get();
for (_, core_queue) in cq.iter_mut() {
for core_queue in cq.values_mut() {
// First pop the finished claims from the front.
match core_queue.front() {
None => {},
Some(None) => {
core_queue.pop_front();
},
Some(_) => {},
if let Some(None) = core_queue.front() {
core_queue.pop_front();
}
}
@@ -628,9 +624,10 @@ impl<T: Config> Pallet<T> {
// This can only happen on new sessions at which we move all assignments back to the
// provider. Hence, there's nothing we need to do here.
if ValidatorGroups::<T>::get().is_empty() {
if ValidatorGroups::<T>::decode_len().map_or(true, |l| l == 0) {
return
}
let n_lookahead = Self::claimqueue_lookahead();
let n_session_cores = T::AssignmentProvider::session_core_count();
let cq = ClaimQueue::<T>::get();
@@ -686,8 +683,7 @@ impl<T: Config> Pallet<T> {
fn add_to_claimqueue(core_idx: CoreIndex, pe: ParasEntry<BlockNumberFor<T>>) {
ClaimQueue::<T>::mutate(|la| {
let la_deque = la.entry(core_idx).or_insert_with(|| VecDeque::new());
la_deque.push_back(Some(pe));
la.entry(core_idx).or_default().push_back(Some(pe));
});
}