Relax Origin Checks in Registrar, Add Lock to Registration (#2808)

* Relax Origin Checks in Registrar

* fix tests

* Update runtime/common/src/paras_registrar.rs

* introduce para locks

* apply a lock after upgrade

* add test

* add lock when creating crowdloan
This commit is contained in:
Shawn Tabrizi
2021-04-07 15:16:35 +02:00
committed by GitHub
parent 251b6ca7bf
commit 45be2ac97e
6 changed files with 136 additions and 53 deletions
+10 -5
View File
@@ -660,20 +660,25 @@ impl<T: Config> Module<T> {
/// Schedule a para to be cleaned up at the start of the next session.
///
/// Will return error if para is not a stable parachain or parathread.
///
/// No-op if para is not registered at all.
pub(crate) fn schedule_para_cleanup(id: ParaId) -> DispatchResult {
let scheduled_session = Self::scheduled_session();
let lifecycle = ParaLifecycles::get(&id).ok_or(Error::<T>::NotRegistered)?;
let lifecycle = ParaLifecycles::get(&id);
match lifecycle {
ParaLifecycle::Parathread => {
// If para is not registered, nothing to do!
None => {
return Ok(())
},
Some(ParaLifecycle::Parathread) => {
ParaLifecycles::insert(&id, ParaLifecycle::OffboardingParathread);
},
ParaLifecycle::Parachain => {
Some(ParaLifecycle::Parachain) => {
ParaLifecycles::insert(&id, ParaLifecycle::OffboardingParachain);
},
_ => return Err(Error::<T>::CannotOffboard)?,
}
let scheduled_session = Self::scheduled_session();
ActionsQueue::mutate(scheduled_session, |v| {
if let Err(i) = v.binary_search(&id) {
v.insert(i, id);