git.delta.rocks / unique-network / refs/commits / 8cc39ba6d3e1

difftreelog

Implement autoseal in dev mode

Daniel Shiposha2022-03-15parent: #a78501c.patch.diff
in: master

4 files changed

modifiednode/cli/Cargo.tomldiffbeforeafterboth
--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -168,6 +168,9 @@
 [dependencies.serde_json]
 version = '1.0.68'
 
+[dependencies.sc-consensus-manual-seal]
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
 
 ################################################################################
 # Cumulus dependencies
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
before · node/cli/src/chain_spec.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use cumulus_primitives_core::ParaId;18use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};19use sc_service::ChainType;20use sp_core::{sr25519, Pair, Public};21use sp_runtime::traits::{IdentifyAccount, Verify};22use std::collections::BTreeMap;2324use serde::{Deserialize, Serialize};25use serde_json::map::Map;2627use unique_runtime_common::types::*;2829/// The `ChainSpec` parameterized for the unique runtime.30#[cfg(feature = "unique-runtime")]31pub type UniqueChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;3233/// The `ChainSpec` parameterized for the quartz runtime.34#[cfg(feature = "quartz-runtime")]35pub type QuartzChainSpec = sc_service::GenericChainSpec<quartz_runtime::GenesisConfig, Extensions>;3637/// The `ChainSpec` parameterized for the opal runtime.38pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;3940pub enum RuntimeId {41	Unique,42	Quartz,43	Opal,44	Unknown(String),45}4647pub trait RuntimeIdentification {48	fn runtime_id(&self) -> RuntimeId;49}5051impl RuntimeIdentification for Box<dyn sc_service::ChainSpec> {52	fn runtime_id(&self) -> RuntimeId {53		#[cfg(feature = "unique-runtime")]54		if self.id().starts_with("unique") {55			return RuntimeId::Unique;56		}5758		#[cfg(feature = "quartz-runtime")]59		if self.id().starts_with("quartz") {60			return RuntimeId::Quartz;61		}6263		if self.id().starts_with("opal") || self.id() == "dev" || self.id() == "local_testnet" {64			return RuntimeId::Opal;65		}6667		RuntimeId::Unknown(self.id().into())68	}69}7071/// Helper function to generate a crypto pair from seed72pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {73	TPublic::Pair::from_string(&format!("//{}", seed), None)74		.expect("static values are valid; qed")75		.public()76}7778/// The extensions for the [`ChainSpec`].79#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]80#[serde(deny_unknown_fields)]81pub struct Extensions {82	/// The relay chain of the Parachain.83	pub relay_chain: String,84	/// The id of the Parachain.85	pub para_id: u32,86}8788impl Extensions {89	/// Try to get the extension from the given `ChainSpec`.90	pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {91		sc_chain_spec::get_extension(chain_spec.extensions())92	}93}9495type AccountPublic = <Signature as Verify>::Signer;9697/// Helper function to generate an account ID from seed98pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId99where100	AccountPublic: From<<TPublic::Pair as Pair>::Public>,101{102	AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()103}104105pub fn development_config() -> OpalChainSpec {106	let mut properties = Map::new();107	properties.insert("tokenSymbol".into(), "OPL".into());108	properties.insert("tokenDecimals".into(), 15.into());109	properties.insert("ss58Format".into(), 42.into());110111	OpalChainSpec::from_genesis(112		// Name113		"Development",114		// ID115		"dev",116		ChainType::Local,117		move || {118			testnet_genesis(119				// Sudo account120				get_account_id_from_seed::<sr25519::Public>("Alice"),121				vec![122					get_from_seed::<AuraId>("Alice"),123					get_from_seed::<AuraId>("Bob"),124				],125				// Pre-funded accounts126				vec![127					get_account_id_from_seed::<sr25519::Public>("Alice"),128					get_account_id_from_seed::<sr25519::Public>("Bob"),129				],130				1000.into(),131			)132		},133		// Bootnodes134		vec![],135		// Telemetry136		None,137		// Protocol ID138		None,139		None,140		// Properties141		Some(properties),142		// Extensions143		Extensions {144			relay_chain: "rococo-dev".into(),145			para_id: 1000,146		},147	)148}149150pub fn local_testnet_rococo_config() -> OpalChainSpec {151	OpalChainSpec::from_genesis(152		// Name153		"Local Testnet",154		// ID155		"local_testnet",156		ChainType::Local,157		move || {158			testnet_genesis(159				// Sudo account160				get_account_id_from_seed::<sr25519::Public>("Alice"),161				vec![162					get_from_seed::<AuraId>("Alice"),163					get_from_seed::<AuraId>("Bob"),164				],165				// Pre-funded accounts166				vec![167					get_account_id_from_seed::<sr25519::Public>("Alice"),168					get_account_id_from_seed::<sr25519::Public>("Bob"),169					get_account_id_from_seed::<sr25519::Public>("Charlie"),170					get_account_id_from_seed::<sr25519::Public>("Dave"),171					get_account_id_from_seed::<sr25519::Public>("Eve"),172					get_account_id_from_seed::<sr25519::Public>("Ferdie"),173					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),174					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),175					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),176					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),177					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),178					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),179				],180				1000.into(),181			)182		},183		// Bootnodes184		vec![],185		// Telemetry186		None,187		// Protocol ID188		None,189		None,190		// Properties191		None,192		// Extensions193		Extensions {194			relay_chain: "rococo-local".into(),195			para_id: 1000,196		},197	)198}199200pub fn local_testnet_westend_config() -> OpalChainSpec {201	OpalChainSpec::from_genesis(202		// Name203		"Local Testnet",204		// ID205		"local_testnet",206		ChainType::Local,207		move || {208			testnet_genesis(209				// Sudo account210				get_account_id_from_seed::<sr25519::Public>("Alice"),211				vec![212					get_from_seed::<AuraId>("Alice"),213					get_from_seed::<AuraId>("Bob"),214					get_from_seed::<AuraId>("Charlie"),215					get_from_seed::<AuraId>("Dave"),216					get_from_seed::<AuraId>("Eve"),217				],218				// Pre-funded accounts219				vec![220					get_account_id_from_seed::<sr25519::Public>("Alice"),221					get_account_id_from_seed::<sr25519::Public>("Bob"),222					get_account_id_from_seed::<sr25519::Public>("Charlie"),223					get_account_id_from_seed::<sr25519::Public>("Dave"),224					get_account_id_from_seed::<sr25519::Public>("Eve"),225					get_account_id_from_seed::<sr25519::Public>("Ferdie"),226					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),227					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),228					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),229					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),230					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),231					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),232				],233				1000.into(),234			)235		},236		// Bootnodes237		vec![],238		// Telemetry239		None,240		// Protocol ID241		None,242		None,243		// Properties244		None,245		// Extensions246		Extensions {247			relay_chain: "westend-local".into(),248			para_id: 1000,249		},250	)251}252253fn testnet_genesis(254	root_key: AccountId,255	initial_authorities: Vec<AuraId>,256	endowed_accounts: Vec<AccountId>,257	id: ParaId,258) -> opal_runtime::GenesisConfig {259	use opal_runtime::*;260261	GenesisConfig {262		system: SystemConfig {263			code: WASM_BINARY264				.expect("WASM binary was not build, please build it!")265				.to_vec(),266		},267		balances: BalancesConfig {268			balances: endowed_accounts269				.iter()270				.cloned()271				// 1e13 UNQ272				.map(|k| (k, 1 << 100))273				.collect(),274		},275		treasury: Default::default(),276		sudo: SudoConfig {277			key: Some(root_key),278		},279		vesting: VestingConfig { vesting: vec![] },280		parachain_info: ParachainInfoConfig { parachain_id: id },281		parachain_system: Default::default(),282		aura: AuraConfig {283			authorities: initial_authorities,284		},285		aura_ext: Default::default(),286		evm: EVMConfig {287			accounts: BTreeMap::new(),288		},289		ethereum: EthereumConfig {},290	}291}
modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -33,9 +33,9 @@
 // limitations under the License.
 
 use crate::{
-	chain_spec::{self, RuntimeId, RuntimeIdentification},
+	chain_spec::{self, RuntimeId, RuntimeIdentification, ServiceId, ServiceIdentification},
 	cli::{Cli, RelayChainCli, Subcommand},
-	service::new_partial,
+	service::{new_partial, start_node, start_dev_node},
 };
 
 #[cfg(feature = "unique-runtime")]
@@ -210,6 +210,7 @@
 			>(
 				&$config,
 				crate::service::parachain_build_import_queue,
+				ServiceId::Prod,
 			)?;
 			let task_manager = $components.task_manager;
 
@@ -245,6 +246,34 @@
 	}}
 }
 
+macro_rules! start_node_using_chain_runtime {
+	($start_node_fn:ident($config:expr $(, $($args:expr),+)?) $($code:tt)*) => {
+		match $config.chain_spec.runtime_id() {
+			#[cfg(feature = "unique-runtime")]
+			RuntimeId::Unique => $start_node_fn::<
+				unique_runtime::Runtime,
+				unique_runtime::RuntimeApi,
+				UniqueRuntimeExecutor,
+			>($config $(, $($args),+)?) $($code)*,
+
+			#[cfg(feature = "quartz-runtime")]
+			RuntimeId::Quartz => $start_node_fn::<
+				quartz_runtime::Runtime,
+				quartz_runtime::RuntimeApi,
+				QuartzRuntimeExecutor,
+			>($config $(, $($args),+)?) $($code)*,
+
+			RuntimeId::Opal => $start_node_fn::<
+				opal_runtime::Runtime,
+				opal_runtime::RuntimeApi,
+				OpalRuntimeExecutor,
+			>($config $(, $($args),+)?) $($code)*,
+
+			RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into()),
+		}
+	};
+}
+
 /// Parse command line arguments into service configuration.
 pub fn run() -> Result<()> {
 	let cli = Cli::from_args();
@@ -365,7 +394,20 @@
 			let runner = cli.create_runner(&cli.run.normalize())?;
 
 			runner.run_node_until_exit(|config| async move {
-				let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
+				let extensions = chain_spec::Extensions::try_get(&*config.chain_spec);
+
+				let service_id = config.chain_spec.service_id();
+				let relay_chain_id = extensions.map(|e| e.relay_chain.clone());
+				let is_dev_service = matches![service_id, ServiceId::Dev]
+									|| relay_chain_id == Some("dev-service".into());
+
+				if is_dev_service {
+					return start_node_using_chain_runtime! {
+						start_dev_node(config).map_err(Into::into)
+					};
+				};
+
+				let para_id = extensions
 					.map(|e| e.para_id)
 					.ok_or("Could not find parachain ID in chain-spec.")?;
 
@@ -376,10 +418,10 @@
 						.chain(cli.relaychain_args.iter()),
 				);
 
-				let id = ParaId::from(para_id);
+				let para_id = ParaId::from(para_id);
 
 				let parachain_account =
-					AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
+					AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&para_id);
 
 				let state_version =
 					RelayChainCli::native_runtime_version(&config.chain_spec).state_version();
@@ -395,7 +437,7 @@
 				)
 				.map_err(|err| format!("Relay chain argument error: {}", err))?;
 
-				info!("Parachain id: {:?}", id);
+				info!("Parachain id: {:?}", para_id);
 				info!("Parachain Account: {}", parachain_account);
 				info!("Parachain genesis state: {}", genesis_state);
 				info!("Parachain genesis hash: {}", genesis_hash);
@@ -408,37 +450,11 @@
 					}
 				);
 
-				match config.chain_spec.runtime_id() {
-					#[cfg(feature = "unique-runtime")]
-					RuntimeId::Unique => crate::service::start_node::<
-						unique_runtime::Runtime,
-						unique_runtime::RuntimeApi,
-						UniqueRuntimeExecutor,
-					>(config, polkadot_config, id)
-					.await
-					.map(|r| r.0)
-					.map_err(Into::into),
-
-					#[cfg(feature = "quartz-runtime")]
-					RuntimeId::Quartz => crate::service::start_node::<
-						quartz_runtime::Runtime,
-						quartz_runtime::RuntimeApi,
-						QuartzRuntimeExecutor,
-					>(config, polkadot_config, id)
-					.await
-					.map(|r| r.0)
-					.map_err(Into::into),
-
-					RuntimeId::Opal => crate::service::start_node::<
-						opal_runtime::Runtime,
-						opal_runtime::RuntimeApi,
-						OpalRuntimeExecutor,
-					>(config, polkadot_config, id)
-					.await
-					.map(|r| r.0)
-					.map_err(Into::into),
-
-					RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into()),
+				start_node_using_chain_runtime! {
+					start_node(config, polkadot_config, para_id)
+						.await
+						.map(|r| r.0)
+						.map_err(Into::into)
 				}
 			})
 		}
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -57,6 +57,7 @@
 use fc_mapping_sync::{MappingSyncWorker, SyncStrategy};
 
 use unique_runtime_common::types::{AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block};
+use crate::chain_spec::ServiceId;
 
 /// Native executor instance.
 pub struct UniqueRuntimeExecutor;
@@ -125,6 +126,7 @@
 	sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;
 type FullBackend = sc_service::TFullBackend<Block>;
 type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
+type MaybeSelectChain = Option<FullSelectChain>;
 
 /// Starts a `ServiceBuilder` for a full service.
 ///
@@ -134,11 +136,12 @@
 pub fn new_partial<RuntimeApi, ExecutorDispatch, BIQ>(
 	config: &Configuration,
 	build_import_queue: BIQ,
+	service_id: ServiceId,
 ) -> Result<
 	PartialComponents<
 		FullClient<RuntimeApi, ExecutorDispatch>,
 		FullBackend,
-		FullSelectChain,
+		MaybeSelectChain,
 		sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
 		sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
 		(
@@ -215,7 +218,10 @@
 		telemetry
 	});
 
-	let select_chain = sc_consensus::LongestChain::new(backend.clone());
+	let select_chain = match service_id {
+		ServiceId::Prod => Some(sc_consensus::LongestChain::new(backend.clone())),
+		ServiceId::Dev => None
+	};
 
 	let transaction_pool = sc_transaction_pool::BasicPool::new_full(
 		config.transaction_pool.clone(),
@@ -317,7 +323,9 @@
 	let parachain_config = prepare_node_config(parachain_config);
 
 	let params =
-		new_partial::<RuntimeApi, ExecutorDispatch, BIQ>(&parachain_config, build_import_queue)?;
+		new_partial::<RuntimeApi, ExecutorDispatch, BIQ>(
+			&parachain_config, build_import_queue, ServiceId::Prod
+		)?;
 	let (mut telemetry, filter_pool, frontier_backend, telemetry_worker_handle, fee_history_cache) =
 		params.other;
 
@@ -356,7 +364,9 @@
 	let subscription_executor = sc_rpc::SubscriptionTaskExecutor::new(task_manager.spawn_handle());
 	let rpc_client = client.clone();
 	let rpc_pool = transaction_pool.clone();
-	let select_chain = params.select_chain.clone();
+	let select_chain = params.select_chain
+							.expect("select_chain always exists when running Prod service; qed")
+							.clone();
 	let rpc_network = network.clone();
 
 	let rpc_frontier_backend = frontier_backend.clone();
@@ -638,3 +648,255 @@
 	)
 	.await
 }
+
+fn dev_build_import_queue<RuntimeApi, ExecutorDispatch>(
+	client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
+	config: &Configuration,
+	_: Option<TelemetryHandle>,
+	task_manager: &TaskManager,
+) -> Result<sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>, sc_service::Error>
+where
+	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+	+ Send
+	+ Sync
+	+ 'static,
+	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+							+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
+	ExecutorDispatch: NativeExecutionDispatch + 'static,
+{
+	Ok(sc_consensus_manual_seal::import_queue(
+		Box::new(client.clone()),
+		&task_manager.spawn_essential_handle(),
+		config.prometheus_registry(),
+	))
+}
+
+/// Builds a new development service. This service uses instant seal, and mocks
+/// the parachain inherent
+pub fn start_dev_node<Runtime, RuntimeApi, ExecutorDispatch>(config: Configuration)
+	-> sc_service::error::Result<TaskManager>
+where
+	Runtime: RuntimeInstance + Send + Sync + 'static,
+	<Runtime as RuntimeInstance>::CrossAccountId: Serialize,
+	for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,
+	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+		+ Send
+		+ Sync
+		+ 'static,
+	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+							+ fp_rpc::EthereumRuntimeRPCApi<Block>
+							+ sp_session::SessionKeys<Block>
+							+ sp_block_builder::BlockBuilder<Block>
+							+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+							+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
+							+ up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>
+							+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
+							+ sp_api::Metadata<Block>
+							+ sp_offchain::OffchainWorkerApi<Block>
+							+ cumulus_primitives_core::CollectCollationInfo<Block>
+							+ sp_consensus_aura::AuraApi<Block, AuraId>,
+	ExecutorDispatch: NativeExecutionDispatch + 'static,
+{
+	use futures::Stream;
+	use sc_consensus_manual_seal::{run_manual_seal, EngineCommand, ManualSealParams};
+	use fc_consensus::FrontierBlockImport;
+	use sc_client_api::HeaderBackend;
+
+	let sc_service::PartialComponents {
+		client,
+		backend,
+		mut task_manager,
+		import_queue,
+		keystore_container,
+		select_chain: maybe_select_chain,
+		transaction_pool,
+		other:
+			(
+				telemetry,
+				filter_pool,
+				frontier_backend,
+				_telemetry_worker_handle,
+				fee_history_cache,
+			),
+	} = new_partial::<RuntimeApi, ExecutorDispatch, _>(
+		&config,
+		dev_build_import_queue::<RuntimeApi, ExecutorDispatch>,
+		ServiceId::Dev
+	)?;
+
+	let block_data_cache = Arc::new(fc_rpc::EthBlockDataCache::new(
+		task_manager.spawn_handle(),
+		overrides_handle::<_, _, Runtime>(client.clone()),
+		50,
+		50,
+	));
+
+	let (network, system_rpc_tx, network_starter) =
+		sc_service::build_network(sc_service::BuildNetworkParams {
+			config: &config,
+			client: client.clone(),
+			transaction_pool: transaction_pool.clone(),
+			spawn_handle: task_manager.spawn_handle(),
+			import_queue,
+			block_announce_validator_builder: None,
+			warp_sync: None,
+		})?;
+
+	if config.offchain_worker.enabled {
+		sc_service::build_offchain_workers(
+			&config,
+			task_manager.spawn_handle(),
+			client.clone(),
+			network.clone(),
+		);
+	}
+
+	let prometheus_registry = config.prometheus_registry().cloned();
+	let collator = config.role.is_authority();
+
+	let select_chain = maybe_select_chain.clone().expect(
+		"`new_partial` builds a `LongestChainRule` when building dev service.\
+			We specified the dev service when calling `new_partial`.\
+			Therefore, a `LongestChainRule` is present. qed.",
+	);
+
+	if collator {
+		let block_import =
+			FrontierBlockImport::new(client.clone(), client.clone(), frontier_backend.clone());
+
+		let env = sc_basic_authorship::ProposerFactory::new(
+			task_manager.spawn_handle(),
+			client.clone(),
+			transaction_pool.clone(),
+			prometheus_registry.as_ref(),
+			telemetry.as_ref().map(|x| x.handle()),
+		);
+
+		let commands_stream: Box<dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin> =
+			Box::new(
+				// This bit cribbed from the implementation of instant seal.
+				transaction_pool
+					.pool()
+					.validated_pool()
+					.import_notification_stream()
+					.map(|_| EngineCommand::SealNewBlock {
+						create_empty: true, // was false in Moonbeam
+						finalize: false,
+						parent_hash: None,
+						sender: None,
+					}),
+			);
+
+		let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
+		let client_set_aside_for_cidp = client.clone();
+
+		task_manager.spawn_essential_handle().spawn_blocking(
+			"authorship_task",
+			Some("block-authoring"),
+			run_manual_seal(ManualSealParams {
+				block_import,
+				env,
+				client: client.clone(),
+				pool: transaction_pool.clone(),
+				commands_stream,
+				select_chain: select_chain.clone(),
+				consensus_data_provider: None,
+				create_inherent_data_providers: move |block: Hash, ()| {
+					let current_para_block = client_set_aside_for_cidp
+						.number(block)
+						.expect("Header lookup should succeed")
+						.expect("Header passed in as parent should be present in backend.");
+
+					let client_for_xcm = client_set_aside_for_cidp.clone();
+					async move {
+						let time = sp_timestamp::InherentDataProvider::from_system_time();
+
+						let mocked_parachain = cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider {
+							current_para_block,
+							relay_offset: 1000,
+							relay_blocks_per_para_block: 2,
+							xcm_config: cumulus_primitives_parachain_inherent::MockXcmConfig::new(
+								&*client_for_xcm,
+								block,
+								Default::default(),
+								Default::default(),
+							),
+							raw_downward_messages: vec![],
+							raw_horizontal_messages: vec![],
+						};
+
+						let slot =
+						sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
+							*time,
+							slot_duration.slot_duration(),
+						);
+
+						Ok((time, slot, mocked_parachain))
+					}
+				},
+			}),
+		);
+	}
+
+	task_manager.spawn_essential_handle().spawn(
+		"frontier-mapping-sync-worker",
+		Some("block-authoring"),
+		MappingSyncWorker::new(
+			client.import_notification_stream(),
+			Duration::new(6, 0),
+			client.clone(),
+			backend.clone(),
+			frontier_backend.clone(),
+			SyncStrategy::Normal,
+		)
+		.for_each(|()| futures::future::ready(())),
+	);
+
+	let subscription_executor = sc_rpc::SubscriptionTaskExecutor::new(task_manager.spawn_handle());
+	let rpc_client = client.clone();
+	let rpc_pool = transaction_pool.clone();
+	let rpc_network = network.clone();
+	let rpc_frontier_backend = frontier_backend.clone();
+	let rpc_extensions_builder = Box::new(move |deny_unsafe, _| {
+		let full_deps = unique_rpc::FullDeps {
+			backend: rpc_frontier_backend.clone(),
+			deny_unsafe,
+			client: rpc_client.clone(),
+			pool: rpc_pool.clone(),
+			graph: rpc_pool.pool().clone(),
+			// TODO: Unhardcode
+			enable_dev_signer: false,
+			filter_pool: filter_pool.clone(),
+			network: rpc_network.clone(),
+			select_chain: select_chain.clone(),
+			is_authority: collator,
+			// TODO: Unhardcode
+			max_past_logs: 10000,
+			block_data_cache: block_data_cache.clone(),
+			fee_history_cache: fee_history_cache.clone(),
+			// TODO: Unhardcode
+			fee_history_limit: 2048,
+		};
+
+		Ok(unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(
+			full_deps,
+			subscription_executor.clone(),
+		))
+	});
+
+	sc_service::spawn_tasks(sc_service::SpawnTasksParams {
+		network,
+		client,
+		keystore: keystore_container.sync_keystore(),
+		task_manager: &mut task_manager,
+		transaction_pool,
+		rpc_extensions_builder,
+		backend,
+		system_rpc_tx,
+		config,
+		telemetry: None,
+	})?;
+
+	network_starter.start_network();
+	Ok(task_manager)
+}