paras: Prune upgrade cooldowns (#7470)

After an upgrade cooldown triggered to remove a signal we also need to
prune it from the list.
This commit is contained in:
Bastian Köcher
2023-07-10 17:08:12 +02:00
committed by GitHub
parent 1abddc2efe
commit e3ee909e9e
2 changed files with 25 additions and 7 deletions
+10 -4
View File
@@ -1262,7 +1262,7 @@ impl<T: Config> Pallet<T> {
// Persist parachains into the storage explicitly.
drop(parachains);
return outgoing
outgoing
}
// note replacement of the code of para with given `id`, which occured in the
@@ -1389,9 +1389,15 @@ impl<T: Config> Pallet<T> {
/// See `process_scheduled_upgrade_changes` for more details.
fn process_scheduled_upgrade_cooldowns(now: T::BlockNumber) {
UpgradeCooldowns::<T>::mutate(|upgrade_cooldowns: &mut Vec<(ParaId, T::BlockNumber)>| {
for &(para, _) in upgrade_cooldowns.iter().take_while(|&(_, at)| at <= &now) {
UpgradeRestrictionSignal::<T>::remove(&para);
}
// Remove all expired signals and also prune the cooldowns.
upgrade_cooldowns.retain(|(para, at)| {
if at <= &now {
UpgradeRestrictionSignal::<T>::remove(&para);
false
} else {
true
}
});
});
}