From ac58dddd80946253d2df2399faa68c45185e8dd2 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 20 Nov 2024 12:15:21 +0100 Subject: [PATCH 1/3] Only mess with coretime if we are registering an actual parachain. --- polkadot/runtime/common/src/paras_sudo_wrapper.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/polkadot/runtime/common/src/paras_sudo_wrapper.rs b/polkadot/runtime/common/src/paras_sudo_wrapper.rs index af93c70b4783..9db6592e7c49 100644 --- a/polkadot/runtime/common/src/paras_sudo_wrapper.rs +++ b/polkadot/runtime/common/src/paras_sudo_wrapper.rs @@ -24,7 +24,7 @@ pub use pallet::*; use polkadot_primitives::Id as ParaId; use polkadot_runtime_parachains::{ configuration, dmp, hrmp, - paras::{self, AssignCoretime, ParaGenesisArgs}, + paras::{self, AssignCoretime, ParaGenesisArgs, ParaKind}, ParaLifecycle, }; @@ -83,7 +83,9 @@ pub mod pallet { polkadot_runtime_parachains::schedule_para_initialize::(id, genesis) .map_err(|_| Error::::ParaAlreadyExists)?; - T::AssignCoretime::assign_coretime(id)?; + if genesis.para_kind == ParaKind::Parachain { + T::AssignCoretime::assign_coretime(id)?; + } Ok(()) } From e1c1c9371835bed0b4d3d320ff65ebbfcf1c7e5b Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 20 Nov 2024 12:22:54 +0100 Subject: [PATCH 2/3] Make borrow checker happy. --- polkadot/runtime/common/src/paras_sudo_wrapper.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/polkadot/runtime/common/src/paras_sudo_wrapper.rs b/polkadot/runtime/common/src/paras_sudo_wrapper.rs index 9db6592e7c49..721e89d919fa 100644 --- a/polkadot/runtime/common/src/paras_sudo_wrapper.rs +++ b/polkadot/runtime/common/src/paras_sudo_wrapper.rs @@ -80,13 +80,14 @@ pub mod pallet { genesis: ParaGenesisArgs, ) -> DispatchResult { ensure_root(origin)?; - polkadot_runtime_parachains::schedule_para_initialize::(id, genesis) - .map_err(|_| Error::::ParaAlreadyExists)?; - if genesis.para_kind == ParaKind::Parachain { + if genesis.para_kind == ParaKind::Parachain { T::AssignCoretime::assign_coretime(id)?; } + polkadot_runtime_parachains::schedule_para_initialize::(id, genesis) + .map_err(|_| Error::::ParaAlreadyExists)?; + Ok(()) } From 773c0c66903e6280fdcb265cc51024ec9c3c665b Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 20 Nov 2024 12:37:13 +0100 Subject: [PATCH 3/3] Fix error case --- polkadot/runtime/common/src/paras_sudo_wrapper.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/polkadot/runtime/common/src/paras_sudo_wrapper.rs b/polkadot/runtime/common/src/paras_sudo_wrapper.rs index 721e89d919fa..a93c209e9279 100644 --- a/polkadot/runtime/common/src/paras_sudo_wrapper.rs +++ b/polkadot/runtime/common/src/paras_sudo_wrapper.rs @@ -81,13 +81,15 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; - if genesis.para_kind == ParaKind::Parachain { - T::AssignCoretime::assign_coretime(id)?; - } + let assign_coretime = genesis.para_kind == ParaKind::Parachain; polkadot_runtime_parachains::schedule_para_initialize::(id, genesis) .map_err(|_| Error::::ParaAlreadyExists)?; + if assign_coretime { + T::AssignCoretime::assign_coretime(id)?; + } + Ok(()) }