From dcf9a9d28a38e7d882b14301559267559e145e8d Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Thu, 3 Oct 2024 12:44:02 +0300 Subject: [PATCH] polkadot-parachain: Remove shell node (#5911) Removing the shell node variant for the polkadot-parachain as discussed here: https://github.com/paritytech/polkadot-sdk/pull/5586#discussion_r1752635254 Resolves https://github.com/paritytech/polkadot-sdk/issues/5898 --- .../polkadot-parachain-lib/src/command.rs | 3 +- .../polkadot-parachain-lib/src/common/rpc.rs | 21 --- .../src/common/runtime.rs | 2 - .../polkadot-parachain-lib/src/nodes/mod.rs | 1 - .../polkadot-parachain-lib/src/nodes/shell.rs | 152 ------------------ .../polkadot-parachain/src/chain_spec/mod.rs | 18 +-- prdoc/pr_5911.prdoc | 16 ++ 7 files changed, 18 insertions(+), 195 deletions(-) delete mode 100644 cumulus/polkadot-parachain/polkadot-parachain-lib/src/nodes/shell.rs create mode 100644 prdoc/pr_5911.prdoc diff --git a/cumulus/polkadot-parachain/polkadot-parachain-lib/src/command.rs b/cumulus/polkadot-parachain/polkadot-parachain-lib/src/command.rs index ff85bdf9401b3..350dcfee1cdb7 100644 --- a/cumulus/polkadot-parachain/polkadot-parachain-lib/src/command.rs +++ b/cumulus/polkadot-parachain/polkadot-parachain-lib/src/command.rs @@ -26,7 +26,7 @@ use crate::{ NodeBlock, NodeExtraArgs, }, fake_runtime_api, - nodes::{shell::ShellNode, DynNodeSpecExt}, + nodes::DynNodeSpecExt, runtime::BlockNumber, }; #[cfg(feature = "runtime-benchmarks")] @@ -77,7 +77,6 @@ fn new_node_spec( let runtime = runtime_resolver.runtime(config.chain_spec.as_ref())?; Ok(match runtime { - Runtime::Shell => Box::new(ShellNode), Runtime::Omni(block_number, consensus) => match (block_number, consensus) { (BlockNumber::U32, Consensus::Aura(aura_id)) => new_aura_node_spec::>(aura_id, extra_args), diff --git a/cumulus/polkadot-parachain/polkadot-parachain-lib/src/common/rpc.rs b/cumulus/polkadot-parachain/polkadot-parachain-lib/src/common/rpc.rs index a4e157e87216e..85665c9b220fd 100644 --- a/cumulus/polkadot-parachain/polkadot-parachain-lib/src/common/rpc.rs +++ b/cumulus/polkadot-parachain/polkadot-parachain-lib/src/common/rpc.rs @@ -40,27 +40,6 @@ pub(crate) trait BuildRpcExtensions { ) -> sc_service::error::Result; } -pub(crate) struct BuildEmptyRpcExtensions(PhantomData<(Block, RuntimeApi)>); - -impl - BuildRpcExtensions< - ParachainClient, - ParachainBackend, - sc_transaction_pool::FullPool>, - > for BuildEmptyRpcExtensions -where - RuntimeApi: - ConstructNodeRuntimeApi> + Send + Sync + 'static, -{ - fn build_rpc_extensions( - _client: Arc>, - _backend: Arc>, - _pool: Arc>>, - ) -> sc_service::error::Result { - Ok(RpcExtension::new(())) - } -} - pub(crate) struct BuildParachainRpcExtensions(PhantomData<(Block, RuntimeApi)>); impl diff --git a/cumulus/polkadot-parachain/polkadot-parachain-lib/src/common/runtime.rs b/cumulus/polkadot-parachain/polkadot-parachain-lib/src/common/runtime.rs index bddbb0a85d036..509d13b9d7a26 100644 --- a/cumulus/polkadot-parachain/polkadot-parachain-lib/src/common/runtime.rs +++ b/cumulus/polkadot-parachain/polkadot-parachain-lib/src/common/runtime.rs @@ -49,8 +49,6 @@ pub enum Runtime { /// None of the system-chain runtimes, rather the node will act agnostic to the runtime ie. be /// an omni-node, and simply run a node with the given consensus algorithm. Omni(BlockNumber, Consensus), - /// Shell - Shell, } /// Helper trait used for extracting the Runtime variant from the chain spec ID. diff --git a/cumulus/polkadot-parachain/polkadot-parachain-lib/src/nodes/mod.rs b/cumulus/polkadot-parachain/polkadot-parachain-lib/src/nodes/mod.rs index 36f54fa3d051e..ab13322e80ab9 100644 --- a/cumulus/polkadot-parachain/polkadot-parachain-lib/src/nodes/mod.rs +++ b/cumulus/polkadot-parachain/polkadot-parachain-lib/src/nodes/mod.rs @@ -16,7 +16,6 @@ pub mod aura; mod manual_seal; -pub mod shell; use crate::common::spec::{DynNodeSpec, NodeSpec as NodeSpecT}; use cumulus_primitives_core::ParaId; diff --git a/cumulus/polkadot-parachain/polkadot-parachain-lib/src/nodes/shell.rs b/cumulus/polkadot-parachain/polkadot-parachain-lib/src/nodes/shell.rs deleted file mode 100644 index 5f9c671d71074..0000000000000 --- a/cumulus/polkadot-parachain/polkadot-parachain-lib/src/nodes/shell.rs +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . - -use crate::{ - common::{ - rpc::BuildEmptyRpcExtensions, - spec::{BaseNodeSpec, BuildImportQueue, NodeSpec, StartConsensus}, - types::{Block, Hash, ParachainBackend, ParachainBlockImport, ParachainClient}, - NodeExtraArgs, - }, - fake_runtime_api::aura_sr25519::RuntimeApi as FakeRuntimeApi, -}; -#[docify::export(slot_based_colator_import)] -#[allow(deprecated)] -use cumulus_client_service::old_consensus; -use cumulus_client_service::CollatorSybilResistance; -use cumulus_primitives_core::ParaId; -use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface}; -use polkadot_primitives::CollatorPair; -use prometheus_endpoint::Registry; -use sc_consensus::DefaultImportQueue; -use sc_service::{Configuration, Error, TaskManager}; -use sc_telemetry::TelemetryHandle; -use sc_transaction_pool::FullPool; -use sp_keystore::KeystorePtr; -use std::{sync::Arc, time::Duration}; - -/// Build the import queue for the shell runtime. -pub(crate) struct BuildShellImportQueue; - -impl BuildImportQueue, FakeRuntimeApi> for BuildShellImportQueue { - fn build_import_queue( - client: Arc, FakeRuntimeApi>>, - block_import: ParachainBlockImport, FakeRuntimeApi>, - config: &Configuration, - _telemetry_handle: Option, - task_manager: &TaskManager, - ) -> sc_service::error::Result>> { - cumulus_client_consensus_relay_chain::import_queue( - client, - block_import, - |_, _| async { Ok(()) }, - &task_manager.spawn_essential_handle(), - config.prometheus_registry(), - ) - .map_err(Into::into) - } -} - -/// Start relay-chain consensus that is free for all. Everyone can submit a block, the relay-chain -/// decides what is backed and included. -pub(crate) struct StartRelayChainConsensus; - -impl StartConsensus, FakeRuntimeApi> for StartRelayChainConsensus { - fn start_consensus( - client: Arc, FakeRuntimeApi>>, - block_import: ParachainBlockImport, FakeRuntimeApi>, - prometheus_registry: Option<&Registry>, - telemetry: Option, - task_manager: &TaskManager, - relay_chain_interface: Arc, - transaction_pool: Arc, ParachainClient, FakeRuntimeApi>>>, - _keystore: KeystorePtr, - _relay_chain_slot_duration: Duration, - para_id: ParaId, - collator_key: CollatorPair, - overseer_handle: OverseerHandle, - announce_block: Arc>) + Send + Sync>, - _backend: Arc>>, - _node_extra_args: NodeExtraArgs, - ) -> Result<(), Error> { - let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( - task_manager.spawn_handle(), - client.clone(), - transaction_pool, - prometheus_registry, - telemetry, - ); - - let free_for_all = cumulus_client_consensus_relay_chain::build_relay_chain_consensus( - cumulus_client_consensus_relay_chain::BuildRelayChainConsensusParams { - para_id, - proposer_factory, - block_import, - relay_chain_interface: relay_chain_interface.clone(), - create_inherent_data_providers: move |_, (relay_parent, validation_data)| { - let relay_chain_interface = relay_chain_interface.clone(); - async move { - let parachain_inherent = - cumulus_client_parachain_inherent::ParachainInherentDataProvider::create_at( - relay_parent, - &relay_chain_interface, - &validation_data, - para_id, - ).await; - let parachain_inherent = parachain_inherent.ok_or_else(|| { - Box::::from( - "Failed to create parachain inherent", - ) - })?; - Ok(parachain_inherent) - } - }, - }, - ); - - let spawner = task_manager.spawn_handle(); - - // Required for free-for-all consensus - #[allow(deprecated)] - old_consensus::start_collator_sync(old_consensus::StartCollatorParams { - para_id, - block_status: client.clone(), - announce_block, - overseer_handle, - spawner, - key: collator_key, - parachain_consensus: free_for_all, - runtime_api: client.clone(), - }); - - Ok(()) - } -} - -pub(crate) struct ShellNode; - -impl BaseNodeSpec for ShellNode { - type Block = Block; - type RuntimeApi = FakeRuntimeApi; - type BuildImportQueue = BuildShellImportQueue; -} - -impl NodeSpec for ShellNode { - type BuildRpcExtensions = BuildEmptyRpcExtensions, Self::RuntimeApi>; - type StartConsensus = StartRelayChainConsensus; - - const SYBIL_RESISTANCE: CollatorSybilResistance = CollatorSybilResistance::Unresistant; -} diff --git a/cumulus/polkadot-parachain/src/chain_spec/mod.rs b/cumulus/polkadot-parachain/src/chain_spec/mod.rs index adb3eb2c0e04a..29bcb41dc4c79 100644 --- a/cumulus/polkadot-parachain/src/chain_spec/mod.rs +++ b/cumulus/polkadot-parachain/src/chain_spec/mod.rs @@ -202,8 +202,6 @@ impl LoadSpec for ChainSpecLoader { #[derive(Debug, PartialEq)] enum LegacyRuntime { Omni, - Shell, - Seedling, AssetHubPolkadot, AssetHub, Penpal, @@ -218,11 +216,7 @@ impl LegacyRuntime { fn from_id(id: &str) -> LegacyRuntime { let id = id.replace('_', "-"); - if id.starts_with("shell") { - LegacyRuntime::Shell - } else if id.starts_with("seedling") { - LegacyRuntime::Seedling - } else if id.starts_with("asset-hub-polkadot") | id.starts_with("statemint") { + if id.starts_with("asset-hub-polkadot") | id.starts_with("statemint") { LegacyRuntime::AssetHubPolkadot } else if id.starts_with("asset-hub-kusama") | id.starts_with("statemine") | @@ -277,7 +271,6 @@ impl RuntimeResolverT for RuntimeResolver { LegacyRuntime::Penpal | LegacyRuntime::Omni => Runtime::Omni(BlockNumber::U32, Consensus::Aura(AuraConsensusId::Sr25519)), - LegacyRuntime::Shell | LegacyRuntime::Seedling => Runtime::Shell, }) } } @@ -336,15 +329,6 @@ mod tests { #[test] fn test_legacy_runtime_for_different_chain_specs() { - let chain_spec = create_default_with_extensions("shell-1", Extensions1::default()); - assert_eq!(LegacyRuntime::Shell, LegacyRuntime::from_id(chain_spec.id())); - - let chain_spec = create_default_with_extensions("shell-2", Extensions2::default()); - assert_eq!(LegacyRuntime::Shell, LegacyRuntime::from_id(chain_spec.id())); - - let chain_spec = create_default_with_extensions("seedling", Extensions2::default()); - assert_eq!(LegacyRuntime::Seedling, LegacyRuntime::from_id(chain_spec.id())); - let chain_spec = create_default_with_extensions("penpal-rococo-1000", Extensions2::default()); assert_eq!(LegacyRuntime::Penpal, LegacyRuntime::from_id(chain_spec.id())); diff --git a/prdoc/pr_5911.prdoc b/prdoc/pr_5911.prdoc new file mode 100644 index 0000000000000..8b063242f24f8 --- /dev/null +++ b/prdoc/pr_5911.prdoc @@ -0,0 +1,16 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Removed the possibility to start a shell parachain node + +doc: + - audience: Node Dev + description: | + Removed the possibility to start a shell parachain node using the polkadot-parachain-lib or + polkadot-parachain-bin. + +crates: + - name: polkadot-parachain-lib + bump: minor + - name: polkadot-parachain-bin + bump: minor