git.delta.rocks / unique-network / refs/commits / 10d04f3edadb

difftreelog

fix benchmark rmrk-core with opal-runtime

Daniel Shiposha2022-06-16parent: #5d82f75.patch.diff
in: master

10 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -8558,11 +8558,14 @@
  "fp-evm-mapping",
  "fp-rpc",
  "fp-self-contained",
+ "frame-benchmarking",
  "frame-executive",
  "frame-support",
  "frame-system",
+ "frame-system-benchmarking",
  "frame-system-rpc-runtime-api",
  "frame-try-runtime",
+ "hex-literal",
  "log",
  "orml-vesting",
  "pallet-aura",
modifiedMakefilediffbeforeafterboth
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,7 @@
 
 .PHONY: _bench
 _bench:
-	cargo run --release --features runtime-benchmarks,unique-runtime -- \
+	cargo run --release --features runtime-benchmarks,$(RUNTIME) -- \
 	benchmark pallet --pallet pallet-$(if $(PALLET),$(PALLET),$(error Must set PALLET)) \
 	--wasm-execution compiled --extrinsic '*' \
 	--template .maintain/frame-weight-template.hbs --steps=50 --repeat=80 --heap-pages=4096 \
modifiednode/cli/Cargo.tomldiffbeforeafterboth
--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -323,7 +323,9 @@
 [features]
 default = []
 runtime-benchmarks = [
-    'unique-runtime/runtime-benchmarks',
+    'unique-runtime?/runtime-benchmarks',
+    'quartz-runtime?/runtime-benchmarks',
+    'opal-runtime/runtime-benchmarks',
     'polkadot-service/runtime-benchmarks',
 ]
 try-runtime = []
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -26,13 +26,13 @@
 use unique_runtime_common::types::*;
 
 #[cfg(feature = "unique-runtime")]
-use unique_runtime as default_runtime;
+pub use unique_runtime as default_runtime;
 
 #[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]
-use quartz_runtime as default_runtime;
+pub use quartz_runtime as default_runtime;
 
 #[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
-use opal_runtime as default_runtime;
+pub use opal_runtime as default_runtime;
 
 /// The `ChainSpec` parameterized for the unique runtime.
 #[cfg(feature = "unique-runtime")]
modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -33,7 +33,7 @@
 // limitations under the License.
 
 use crate::{
-	chain_spec::{self, RuntimeId, RuntimeIdentification, ServiceId, ServiceIdentification},
+	chain_spec::{self, RuntimeId, RuntimeIdentification, ServiceId, ServiceIdentification, default_runtime},
 	cli::{Cli, RelayChainCli, Subcommand},
 	service::{new_partial, start_node, start_dev_node},
 };
@@ -44,7 +44,7 @@
 #[cfg(feature = "quartz-runtime")]
 use crate::service::QuartzRuntimeExecutor;
 
-use crate::service::OpalRuntimeExecutor;
+use crate::service::{OpalRuntimeExecutor, DefaultRuntimeExecutor};
 
 use codec::Encode;
 use cumulus_primitives_core::ParaId;
@@ -372,7 +372,6 @@
 
 			Ok(())
 		}
-		#[cfg(feature = "unique-runtime")]
 		Some(Subcommand::Benchmark(cmd)) => {
 			use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
 			let runner = cli.create_runner(cmd)?;
@@ -380,7 +379,7 @@
 			match cmd {
 				BenchmarkCmd::Pallet(cmd) => {
 					if cfg!(feature = "runtime-benchmarks") {
-						runner.sync_run(|config| cmd.run::<Block, UniqueRuntimeExecutor>(config))
+						runner.sync_run(|config| cmd.run::<Block, DefaultRuntimeExecutor>(config))
 					} else {
 						Err("Benchmarking wasn't enabled when building the node. \
 					You can enable it with `--features runtime-benchmarks`."
@@ -389,16 +388,16 @@
 				}
 				BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
 					let partials = new_partial::<
-						unique_runtime::RuntimeApi,
-						UniqueRuntimeExecutor,
+						default_runtime::RuntimeApi,
+						DefaultRuntimeExecutor,
 						_,
 					>(&config, crate::service::parachain_build_import_queue)?;
 					cmd.run(partials.client)
 				}),
 				BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
 					let partials = new_partial::<
-						unique_runtime::RuntimeApi,
-						UniqueRuntimeExecutor,
+						default_runtime::RuntimeApi,
+						DefaultRuntimeExecutor,
 						_,
 					>(&config, crate::service::parachain_build_import_queue)?;
 					let db = partials.backend.expose_db();
@@ -411,10 +410,6 @@
 				}
 				BenchmarkCmd::Overhead(_) => Err("Unsupported benchmarking command".into()),
 			}
-		}
-		#[cfg(not(feature = "unique-runtime"))]
-		Some(Subcommand::Benchmark(..)) => {
-			Err("benchmarking is only available with unique runtime enabled".into())
 		}
 		Some(Subcommand::TryRuntime(cmd)) => {
 			if cfg!(feature = "try-runtime") {
modifiednode/cli/src/service.rsdiffbeforeafterboth
before · node/cli/src/service.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/>.1617// std18use std::sync::Arc;19use std::sync::Mutex;20use std::collections::BTreeMap;21use std::time::Duration;22use std::pin::Pin;23use fc_rpc_core::types::FeeHistoryCache;24use futures::{25	Stream, StreamExt,26	stream::select,27	task::{Context, Poll},28};29use tokio::time::Interval;3031use unique_rpc::overrides_handle;3233use serde::{Serialize, Deserialize};3435// Cumulus Imports36use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};37use cumulus_client_consensus_common::ParachainConsensus;38use cumulus_client_service::{39	prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,40};41use cumulus_client_cli::CollatorOptions;42use cumulus_client_network::BlockAnnounceValidator;43use cumulus_primitives_core::ParaId;44use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;45use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};46use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface;4748// Substrate Imports49use sc_client_api::ExecutorProvider;50use sc_executor::NativeElseWasmExecutor;51use sc_executor::NativeExecutionDispatch;52use sc_network::NetworkService;53use sc_service::{BasePath, Configuration, PartialComponents, Role, TaskManager};54use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};55use sp_keystore::SyncCryptoStorePtr;56use sp_runtime::traits::BlakeTwo256;57use substrate_prometheus_endpoint::Registry;58use sc_client_api::BlockchainEvents;5960use polkadot_service::CollatorPair;6162// Frontier Imports63use fc_rpc_core::types::FilterPool;64use fc_mapping_sync::{MappingSyncWorker, SyncStrategy};6566use unique_runtime_common::types::{AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block};6768// RMRK69use up_data_structs::{70	RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo, RmrkBaseInfo,71	RmrkPartType, RmrkTheme,72};7374/// Unique native executor instance.75#[cfg(feature = "unique-runtime")]76pub struct UniqueRuntimeExecutor;7778#[cfg(feature = "quartz-runtime")]79/// Quartz native executor instance.8081pub struct QuartzRuntimeExecutor;8283/// Opal native executor instance.84pub struct OpalRuntimeExecutor;8586#[cfg(feature = "unique-runtime")]87impl NativeExecutionDispatch for UniqueRuntimeExecutor {88	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;8990	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {91		unique_runtime::api::dispatch(method, data)92	}9394	fn native_version() -> sc_executor::NativeVersion {95		unique_runtime::native_version()96	}97}9899#[cfg(feature = "quartz-runtime")]100impl NativeExecutionDispatch for QuartzRuntimeExecutor {101	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;102103	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {104		quartz_runtime::api::dispatch(method, data)105	}106107	fn native_version() -> sc_executor::NativeVersion {108		quartz_runtime::native_version()109	}110}111112impl NativeExecutionDispatch for OpalRuntimeExecutor {113	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;114115	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {116		opal_runtime::api::dispatch(method, data)117	}118119	fn native_version() -> sc_executor::NativeVersion {120		opal_runtime::native_version()121	}122}123124pub struct AutosealInterval {125	interval: Interval,126}127128impl AutosealInterval {129	pub fn new(config: &Configuration, interval: Duration) -> Self {130		let _tokio_runtime = config.tokio_handle.enter();131		let interval = tokio::time::interval(interval);132133		Self { interval }134	}135}136137impl Stream for AutosealInterval {138	type Item = tokio::time::Instant;139140	fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {141		self.interval.poll_tick(cx).map(Some)142	}143}144145pub fn open_frontier_backend(config: &Configuration) -> Result<Arc<fc_db::Backend<Block>>, String> {146	let config_dir = config147		.base_path148		.as_ref()149		.map(|base_path| base_path.config_dir(config.chain_spec.id()))150		.unwrap_or_else(|| {151			BasePath::from_project("", "", "unique").config_dir(config.chain_spec.id())152		});153	let database_dir = config_dir.join("frontier").join("db");154155	Ok(Arc::new(fc_db::Backend::<Block>::new(156		&fc_db::DatabaseSettings {157			source: fc_db::DatabaseSource::RocksDb {158				path: database_dir,159				cache_size: 0,160			},161		},162	)?))163}164165type FullClient<RuntimeApi, ExecutorDispatch> =166	sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;167type FullBackend = sc_service::TFullBackend<Block>;168type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;169170/// Starts a `ServiceBuilder` for a full service.171///172/// Use this macro if you don't actually need the full service, but just the builder in order to173/// be able to perform chain operations.174#[allow(clippy::type_complexity)]175pub fn new_partial<RuntimeApi, ExecutorDispatch, BIQ>(176	config: &Configuration,177	build_import_queue: BIQ,178) -> Result<179	PartialComponents<180		FullClient<RuntimeApi, ExecutorDispatch>,181		FullBackend,182		FullSelectChain,183		sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,184		sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,185		(186			Option<Telemetry>,187			Option<FilterPool>,188			Arc<fc_db::Backend<Block>>,189			Option<TelemetryWorkerHandle>,190			FeeHistoryCache,191		),192	>,193	sc_service::Error,194>195where196	sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,197	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>198		+ Send199		+ Sync200		+ 'static,201	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,202	ExecutorDispatch: NativeExecutionDispatch + 'static,203	BIQ: FnOnce(204		Arc<FullClient<RuntimeApi, ExecutorDispatch>>,205		&Configuration,206		Option<TelemetryHandle>,207		&TaskManager,208	) -> Result<209		sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,210		sc_service::Error,211	>,212{213	let _telemetry = config214		.telemetry_endpoints215		.clone()216		.filter(|x| !x.is_empty())217		.map(|endpoints| -> Result<_, sc_telemetry::Error> {218			let worker = TelemetryWorker::new(16)?;219			let telemetry = worker.handle().new_telemetry(endpoints);220			Ok((worker, telemetry))221		})222		.transpose()?;223224	let telemetry = config225		.telemetry_endpoints226		.clone()227		.filter(|x| !x.is_empty())228		.map(|endpoints| -> Result<_, sc_telemetry::Error> {229			let worker = TelemetryWorker::new(16)?;230			let telemetry = worker.handle().new_telemetry(endpoints);231			Ok((worker, telemetry))232		})233		.transpose()?;234235	let executor = NativeElseWasmExecutor::<ExecutorDispatch>::new(236		config.wasm_method,237		config.default_heap_pages,238		config.max_runtime_instances,239		config.runtime_cache_size,240	);241242	let (client, backend, keystore_container, task_manager) =243		sc_service::new_full_parts::<Block, RuntimeApi, _>(244			config,245			telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),246			executor,247		)?;248	let client = Arc::new(client);249250	let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle());251252	let telemetry = telemetry.map(|(worker, telemetry)| {253		task_manager254			.spawn_handle()255			.spawn("telemetry", None, worker.run());256		telemetry257	});258259	let select_chain = sc_consensus::LongestChain::new(backend.clone());260261	let transaction_pool = sc_transaction_pool::BasicPool::new_full(262		config.transaction_pool.clone(),263		config.role.is_authority().into(),264		config.prometheus_registry(),265		task_manager.spawn_essential_handle(),266		client.clone(),267	);268269	let filter_pool: Option<FilterPool> = Some(Arc::new(Mutex::new(BTreeMap::new())));270271	let frontier_backend = open_frontier_backend(config)?;272273	let import_queue = build_import_queue(274		client.clone(),275		config,276		telemetry.as_ref().map(|telemetry| telemetry.handle()),277		&task_manager,278	)?;279	let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));280281	let params = PartialComponents {282		backend,283		client,284		import_queue,285		keystore_container,286		task_manager,287		transaction_pool,288		select_chain,289		other: (290			telemetry,291			filter_pool,292			frontier_backend,293			telemetry_worker_handle,294			fee_history_cache,295		),296	};297298	Ok(params)299}300301async fn build_relay_chain_interface(302	polkadot_config: Configuration,303	parachain_config: &Configuration,304	telemetry_worker_handle: Option<TelemetryWorkerHandle>,305	task_manager: &mut TaskManager,306	collator_options: CollatorOptions,307	hwbench: Option<sc_sysinfo::HwBench>,308) -> RelayChainResult<(309	Arc<(dyn RelayChainInterface + 'static)>,310	Option<CollatorPair>,311)> {312	match collator_options.relay_chain_rpc_url {313		Some(relay_chain_url) => Ok((314			Arc::new(RelayChainRPCInterface::new(relay_chain_url).await?) as Arc<_>,315			None,316		)),317		None => build_inprocess_relay_chain(318			polkadot_config,319			parachain_config,320			telemetry_worker_handle,321			task_manager,322			hwbench,323		),324	}325}326327/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.328///329/// This is the actual implementation that is abstract over the executor and the runtime api.330#[sc_tracing::logging::prefix_logs_with("Parachain")]331async fn start_node_impl<Runtime, RuntimeApi, ExecutorDispatch, BIQ, BIC>(332	parachain_config: Configuration,333	polkadot_config: Configuration,334	collator_options: CollatorOptions,335	id: ParaId,336	build_import_queue: BIQ,337	build_consensus: BIC,338	hwbench: Option<sc_sysinfo::HwBench>,339) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>340where341	sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,342	Runtime: RuntimeInstance + Send + Sync + 'static,343	<Runtime as RuntimeInstance>::CrossAccountId: Serialize,344	for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,345	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>346		+ Send347		+ Sync348		+ 'static,349	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>350		+ fp_rpc::EthereumRuntimeRPCApi<Block>351		+ fp_rpc::ConvertTransactionRuntimeApi<Block>352		+ sp_session::SessionKeys<Block>353		+ sp_block_builder::BlockBuilder<Block>354		+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>355		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>356		+ up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>357		+ rmrk_rpc::RmrkApi<358			Block,359			AccountId,360			RmrkCollectionInfo<AccountId>,361			RmrkInstanceInfo<AccountId>,362			RmrkResourceInfo,363			RmrkPropertyInfo,364			RmrkBaseInfo<AccountId>,365			RmrkPartType,366			RmrkTheme,367		> + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>368		+ sp_api::Metadata<Block>369		+ sp_offchain::OffchainWorkerApi<Block>370		+ cumulus_primitives_core::CollectCollationInfo<Block>,371	ExecutorDispatch: NativeExecutionDispatch + 'static,372	BIQ: FnOnce(373		Arc<FullClient<RuntimeApi, ExecutorDispatch>>,374		&Configuration,375		Option<TelemetryHandle>,376		&TaskManager,377	) -> Result<378		sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,379		sc_service::Error,380	>,381	BIC: FnOnce(382		Arc<FullClient<RuntimeApi, ExecutorDispatch>>,383		Option<&Registry>,384		Option<TelemetryHandle>,385		&TaskManager,386		Arc<dyn RelayChainInterface>,387		Arc<sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>>,388		Arc<NetworkService<Block, Hash>>,389		SyncCryptoStorePtr,390		bool,391	) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,392{393	if matches!(parachain_config.role, Role::Light) {394		return Err("Light client not supported!".into());395	}396397	let parachain_config = prepare_node_config(parachain_config);398399	let params =400		new_partial::<RuntimeApi, ExecutorDispatch, BIQ>(&parachain_config, build_import_queue)?;401	let (mut telemetry, filter_pool, frontier_backend, telemetry_worker_handle, fee_history_cache) =402		params.other;403404	let client = params.client.clone();405	let backend = params.backend.clone();406	let mut task_manager = params.task_manager;407408	let (relay_chain_interface, collator_key) = build_relay_chain_interface(409		polkadot_config,410		&parachain_config,411		telemetry_worker_handle,412		&mut task_manager,413		collator_options.clone(),414		hwbench.clone(),415	)416	.await417	.map_err(|e| match e {418		RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,419		s => s.to_string().into(),420	})?;421422	let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id);423424	let force_authoring = parachain_config.force_authoring;425	let validator = parachain_config.role.is_authority();426	let prometheus_registry = parachain_config.prometheus_registry().cloned();427	let transaction_pool = params.transaction_pool.clone();428	let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue);429430	let (network, system_rpc_tx, start_network) =431		sc_service::build_network(sc_service::BuildNetworkParams {432			config: &parachain_config,433			client: client.clone(),434			transaction_pool: transaction_pool.clone(),435			spawn_handle: task_manager.spawn_handle(),436			import_queue: import_queue.clone(),437			block_announce_validator_builder: Some(Box::new(|_| {438				Box::new(block_announce_validator)439			})),440			warp_sync: None,441		})?;442443	let rpc_client = client.clone();444	let rpc_pool = transaction_pool.clone();445	let select_chain = params.select_chain.clone();446	let rpc_network = network.clone();447448	let rpc_frontier_backend = frontier_backend.clone();449450	let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(451		task_manager.spawn_handle(),452		overrides_handle::<_, _, Runtime>(client.clone()),453		50,454		50,455		prometheus_registry.clone(),456	));457458	task_manager.spawn_essential_handle().spawn(459		"frontier-mapping-sync-worker",460		None,461		MappingSyncWorker::new(462			client.import_notification_stream(),463			Duration::new(6, 0),464			client.clone(),465			backend.clone(),466			frontier_backend.clone(),467			3,468			0,469			SyncStrategy::Normal,470		)471		.for_each(|()| futures::future::ready(())),472	);473474	let rpc_builder = Box::new(move |deny_unsafe, subscription_task_executor| {475		let full_deps = unique_rpc::FullDeps {476			backend: rpc_frontier_backend.clone(),477			deny_unsafe,478			client: rpc_client.clone(),479			pool: rpc_pool.clone(),480			graph: rpc_pool.pool().clone(),481			// TODO: Unhardcode482			enable_dev_signer: false,483			filter_pool: filter_pool.clone(),484			network: rpc_network.clone(),485			select_chain: select_chain.clone(),486			is_authority: validator,487			// TODO: Unhardcode488			max_past_logs: 10000,489			block_data_cache: block_data_cache.clone(),490			fee_history_cache: fee_history_cache.clone(),491			// TODO: Unhardcode492			fee_history_limit: 2048,493		};494495		unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(496			full_deps,497			subscription_task_executor,498		)499		.map_err(Into::into)500	});501502	sc_service::spawn_tasks(sc_service::SpawnTasksParams {503		rpc_builder,504		client: client.clone(),505		transaction_pool: transaction_pool.clone(),506		task_manager: &mut task_manager,507		config: parachain_config,508		keystore: params.keystore_container.sync_keystore(),509		backend: backend.clone(),510		network: network.clone(),511		system_rpc_tx,512		telemetry: telemetry.as_mut(),513	})?;514515	if let Some(hwbench) = hwbench {516		sc_sysinfo::print_hwbench(&hwbench);517518		if let Some(ref mut telemetry) = telemetry {519			let telemetry_handle = telemetry.handle();520			task_manager.spawn_handle().spawn(521				"telemetry_hwbench",522				None,523				sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench),524			);525		}526	}527528	let announce_block = {529		let network = network.clone();530		Arc::new(move |hash, data| network.announce_block(hash, data))531	};532533	let relay_chain_slot_duration = Duration::from_secs(6);534535	if validator {536		let parachain_consensus = build_consensus(537			client.clone(),538			prometheus_registry.as_ref(),539			telemetry.as_ref().map(|t| t.handle()),540			&task_manager,541			relay_chain_interface.clone(),542			transaction_pool,543			network,544			params.keystore_container.sync_keystore(),545			force_authoring,546		)?;547548		let spawner = task_manager.spawn_handle();549550		let params = StartCollatorParams {551			para_id: id,552			block_status: client.clone(),553			announce_block,554			client: client.clone(),555			task_manager: &mut task_manager,556			spawner,557			parachain_consensus,558			import_queue,559			collator_key: collator_key.expect("Command line arguments do not allow this. qed"),560			relay_chain_interface,561			relay_chain_slot_duration,562		};563564		start_collator(params).await?;565	} else {566		let params = StartFullNodeParams {567			client: client.clone(),568			announce_block,569			task_manager: &mut task_manager,570			para_id: id,571			import_queue,572			relay_chain_interface,573			relay_chain_slot_duration,574			collator_options,575		};576577		start_full_node(params)?;578	}579580	start_network.start_network();581582	Ok((task_manager, client))583}584585/// Build the import queue for the the parachain runtime.586pub fn parachain_build_import_queue<RuntimeApi, ExecutorDispatch>(587	client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,588	config: &Configuration,589	telemetry: Option<TelemetryHandle>,590	task_manager: &TaskManager,591) -> Result<592	sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,593	sc_service::Error,594>595where596	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>597		+ Send598		+ Sync599		+ 'static,600	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>601		+ sp_block_builder::BlockBuilder<Block>602		+ sp_consensus_aura::AuraApi<Block, AuraId>603		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,604	ExecutorDispatch: NativeExecutionDispatch + 'static,605{606	let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;607608	cumulus_client_consensus_aura::import_queue::<609		sp_consensus_aura::sr25519::AuthorityPair,610		_,611		_,612		_,613		_,614		_,615		_,616	>(cumulus_client_consensus_aura::ImportQueueParams {617		block_import: client.clone(),618		client: client.clone(),619		create_inherent_data_providers: move |_, _| async move {620			let time = sp_timestamp::InherentDataProvider::from_system_time();621622			let slot =623				sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(624					*time,625					slot_duration,626				);627628			Ok((time, slot))629		},630		registry: config.prometheus_registry(),631		can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),632		spawner: &task_manager.spawn_essential_handle(),633		telemetry,634	})635	.map_err(Into::into)636}637638/// Start a normal parachain node.639pub async fn start_node<Runtime, RuntimeApi, ExecutorDispatch>(640	parachain_config: Configuration,641	polkadot_config: Configuration,642	collator_options: CollatorOptions,643	id: ParaId,644	hwbench: Option<sc_sysinfo::HwBench>,645) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>646where647	Runtime: RuntimeInstance + Send + Sync + 'static,648	<Runtime as RuntimeInstance>::CrossAccountId: Serialize,649	for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,650	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>651		+ Send652		+ Sync653		+ 'static,654	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>655		+ fp_rpc::EthereumRuntimeRPCApi<Block>656		+ fp_rpc::ConvertTransactionRuntimeApi<Block>657		+ sp_session::SessionKeys<Block>658		+ sp_block_builder::BlockBuilder<Block>659		+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>660		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>661		+ up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>662		+ rmrk_rpc::RmrkApi<663			Block,664			AccountId,665			RmrkCollectionInfo<AccountId>,666			RmrkInstanceInfo<AccountId>,667			RmrkResourceInfo,668			RmrkPropertyInfo,669			RmrkBaseInfo<AccountId>,670			RmrkPartType,671			RmrkTheme,672		> + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>673		+ sp_api::Metadata<Block>674		+ sp_offchain::OffchainWorkerApi<Block>675		+ cumulus_primitives_core::CollectCollationInfo<Block>676		+ sp_consensus_aura::AuraApi<Block, AuraId>,677	ExecutorDispatch: NativeExecutionDispatch + 'static,678{679	start_node_impl::<Runtime, RuntimeApi, ExecutorDispatch, _, _>(680		parachain_config,681		polkadot_config,682		collator_options,683		id,684		parachain_build_import_queue,685		|client,686		 prometheus_registry,687		 telemetry,688		 task_manager,689		 relay_chain_interface,690		 transaction_pool,691		 sync_oracle,692		 keystore,693		 force_authoring| {694			let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;695696			let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(697				task_manager.spawn_handle(),698				client.clone(),699				transaction_pool,700				prometheus_registry,701				telemetry.clone(),702			);703704			Ok(AuraConsensus::build::<705				sp_consensus_aura::sr25519::AuthorityPair,706				_,707				_,708				_,709				_,710				_,711				_,712			>(BuildAuraConsensusParams {713				proposer_factory,714				create_inherent_data_providers: move |_, (relay_parent, validation_data)| {715					let relay_chain_interface = relay_chain_interface.clone();716					async move {717						let parachain_inherent =718						cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(719							relay_parent,720							&relay_chain_interface,721							&validation_data,722							id,723						).await;724725						let time = sp_timestamp::InherentDataProvider::from_system_time();726727						let slot =728						sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(729							*time,730							slot_duration,731						);732733						let parachain_inherent = parachain_inherent.ok_or_else(|| {734							Box::<dyn std::error::Error + Send + Sync>::from(735								"Failed to create parachain inherent",736							)737						})?;738						Ok((time, slot, parachain_inherent))739					}740				},741				block_import: client.clone(),742				para_client: client,743				backoff_authoring_blocks: Option::<()>::None,744				sync_oracle,745				keystore,746				force_authoring,747				slot_duration,748				// We got around 500ms for proposing749				block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),750				telemetry,751				max_block_proposal_slot_portion: None,752			}))753		},754		hwbench,755	)756	.await757}758759fn dev_build_import_queue<RuntimeApi, ExecutorDispatch>(760	client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,761	config: &Configuration,762	_: Option<TelemetryHandle>,763	task_manager: &TaskManager,764) -> Result<765	sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,766	sc_service::Error,767>768where769	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>770		+ Send771		+ Sync772		+ 'static,773	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>774		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,775	ExecutorDispatch: NativeExecutionDispatch + 'static,776{777	Ok(sc_consensus_manual_seal::import_queue(778		Box::new(client.clone()),779		&task_manager.spawn_essential_handle(),780		config.prometheus_registry(),781	))782}783784/// Builds a new development service. This service uses instant seal, and mocks785/// the parachain inherent786pub fn start_dev_node<Runtime, RuntimeApi, ExecutorDispatch>(787	config: Configuration,788	autoseal_interval: Duration,789) -> sc_service::error::Result<TaskManager>790where791	Runtime: RuntimeInstance + Send + Sync + 'static,792	<Runtime as RuntimeInstance>::CrossAccountId: Serialize,793	for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,794	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>795		+ Send796		+ Sync797		+ 'static,798	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>799		+ fp_rpc::EthereumRuntimeRPCApi<Block>800		+ fp_rpc::ConvertTransactionRuntimeApi<Block>801		+ sp_session::SessionKeys<Block>802		+ sp_block_builder::BlockBuilder<Block>803		+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>804		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>805		+ up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>806		+ rmrk_rpc::RmrkApi<807			Block,808			AccountId,809			RmrkCollectionInfo<AccountId>,810			RmrkInstanceInfo<AccountId>,811			RmrkResourceInfo,812			RmrkPropertyInfo,813			RmrkBaseInfo<AccountId>,814			RmrkPartType,815			RmrkTheme,816		> + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>817		+ sp_api::Metadata<Block>818		+ sp_offchain::OffchainWorkerApi<Block>819		+ cumulus_primitives_core::CollectCollationInfo<Block>820		+ sp_consensus_aura::AuraApi<Block, AuraId>,821	ExecutorDispatch: NativeExecutionDispatch + 'static,822{823	use sc_consensus_manual_seal::{run_manual_seal, EngineCommand, ManualSealParams};824	use fc_consensus::FrontierBlockImport;825	use sc_client_api::HeaderBackend;826827	let sc_service::PartialComponents {828		client,829		backend,830		mut task_manager,831		import_queue,832		keystore_container,833		select_chain: maybe_select_chain,834		transaction_pool,835		other:836			(telemetry, filter_pool, frontier_backend, _telemetry_worker_handle, fee_history_cache),837	} = new_partial::<RuntimeApi, ExecutorDispatch, _>(838		&config,839		dev_build_import_queue::<RuntimeApi, ExecutorDispatch>,840	)?;841	let prometheus_registry = config.prometheus_registry().cloned();842843	let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(844		task_manager.spawn_handle(),845		overrides_handle::<_, _, Runtime>(client.clone()),846		50,847		50,848		prometheus_registry.clone(),849	));850851	let (network, system_rpc_tx, network_starter) =852		sc_service::build_network(sc_service::BuildNetworkParams {853			config: &config,854			client: client.clone(),855			transaction_pool: transaction_pool.clone(),856			spawn_handle: task_manager.spawn_handle(),857			import_queue,858			block_announce_validator_builder: None,859			warp_sync: None,860		})?;861862	if config.offchain_worker.enabled {863		sc_service::build_offchain_workers(864			&config,865			task_manager.spawn_handle(),866			client.clone(),867			network.clone(),868		);869	}870871	let collator = config.role.is_authority();872873	let select_chain = maybe_select_chain.clone();874875	if collator {876		let block_import =877			FrontierBlockImport::new(client.clone(), client.clone(), frontier_backend.clone());878879		let env = sc_basic_authorship::ProposerFactory::new(880			task_manager.spawn_handle(),881			client.clone(),882			transaction_pool.clone(),883			prometheus_registry.as_ref(),884			telemetry.as_ref().map(|x| x.handle()),885		);886887		let transactions_commands_stream: Box<888			dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin,889		> = Box::new(890			transaction_pool891				.pool()892				.validated_pool()893				.import_notification_stream()894				.map(|_| EngineCommand::SealNewBlock {895					create_empty: true,896					finalize: false,897					parent_hash: None,898					sender: None,899				}),900		);901902		let autoseal_interval = Box::pin(AutosealInterval::new(&config, autoseal_interval));903		let idle_commands_stream: Box<904			dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin,905		> = Box::new(autoseal_interval.map(|_| EngineCommand::SealNewBlock {906			create_empty: true,907			finalize: false,908			parent_hash: None,909			sender: None,910		}));911912		let commands_stream = select(transactions_commands_stream, idle_commands_stream);913914		let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;915		let client_set_aside_for_cidp = client.clone();916917		task_manager.spawn_essential_handle().spawn_blocking(918			"authorship_task",919			Some("block-authoring"),920			run_manual_seal(ManualSealParams {921				block_import,922				env,923				client: client.clone(),924				pool: transaction_pool.clone(),925				commands_stream,926				select_chain: select_chain.clone(),927				consensus_data_provider: None,928				create_inherent_data_providers: move |block: Hash, ()| {929					let current_para_block = client_set_aside_for_cidp930						.number(block)931						.expect("Header lookup should succeed")932						.expect("Header passed in as parent should be present in backend.");933934					let client_for_xcm = client_set_aside_for_cidp.clone();935					async move {936						let time = sp_timestamp::InherentDataProvider::from_system_time();937938						let mocked_parachain = cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider {939							current_para_block,940							relay_offset: 1000,941							relay_blocks_per_para_block: 2,942							xcm_config: cumulus_primitives_parachain_inherent::MockXcmConfig::new(943								&*client_for_xcm,944								block,945								Default::default(),946								Default::default(),947							),948							raw_downward_messages: vec![],949							raw_horizontal_messages: vec![],950						};951952						let slot =953						sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(954							*time,955							slot_duration,956						);957958						Ok((time, slot, mocked_parachain))959					}960				},961			}),962		);963	}964965	task_manager.spawn_essential_handle().spawn(966		"frontier-mapping-sync-worker",967		Some("block-authoring"),968		MappingSyncWorker::new(969			client.import_notification_stream(),970			Duration::new(6, 0),971			client.clone(),972			backend.clone(),973			frontier_backend.clone(),974			3,975			0,976			SyncStrategy::Normal,977		)978		.for_each(|()| futures::future::ready(())),979	);980981	let rpc_client = client.clone();982	let rpc_pool = transaction_pool.clone();983	let rpc_network = network.clone();984	let rpc_frontier_backend = frontier_backend.clone();985	let rpc_builder = Box::new(move |deny_unsafe, subscription_executor| {986		let full_deps = unique_rpc::FullDeps {987			backend: rpc_frontier_backend.clone(),988			deny_unsafe,989			client: rpc_client.clone(),990			pool: rpc_pool.clone(),991			graph: rpc_pool.pool().clone(),992			// TODO: Unhardcode993			enable_dev_signer: false,994			filter_pool: filter_pool.clone(),995			network: rpc_network.clone(),996			select_chain: select_chain.clone(),997			is_authority: collator,998			// TODO: Unhardcode999			max_past_logs: 10000,1000			block_data_cache: block_data_cache.clone(),1001			fee_history_cache: fee_history_cache.clone(),1002			// TODO: Unhardcode1003			fee_history_limit: 2048,1004		};10051006		unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(1007			full_deps,1008			subscription_executor,1009		)1010		.map_err(Into::into)1011	});10121013	sc_service::spawn_tasks(sc_service::SpawnTasksParams {1014		network,1015		client,1016		keystore: keystore_container.sync_keystore(),1017		task_manager: &mut task_manager,1018		transaction_pool,1019		rpc_builder,1020		backend,1021		system_rpc_tx,1022		config,1023		telemetry: None,1024	})?;10251026	network_starter.start_network();1027	Ok(task_manager)1028}
after · node/cli/src/service.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/>.1617// std18use std::sync::Arc;19use std::sync::Mutex;20use std::collections::BTreeMap;21use std::time::Duration;22use std::pin::Pin;23use fc_rpc_core::types::FeeHistoryCache;24use futures::{25	Stream, StreamExt,26	stream::select,27	task::{Context, Poll},28};29use tokio::time::Interval;3031use unique_rpc::overrides_handle;3233use serde::{Serialize, Deserialize};3435// Cumulus Imports36use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};37use cumulus_client_consensus_common::ParachainConsensus;38use cumulus_client_service::{39	prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,40};41use cumulus_client_cli::CollatorOptions;42use cumulus_client_network::BlockAnnounceValidator;43use cumulus_primitives_core::ParaId;44use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;45use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};46use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface;4748// Substrate Imports49use sc_client_api::ExecutorProvider;50use sc_executor::NativeElseWasmExecutor;51use sc_executor::NativeExecutionDispatch;52use sc_network::NetworkService;53use sc_service::{BasePath, Configuration, PartialComponents, Role, TaskManager};54use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};55use sp_keystore::SyncCryptoStorePtr;56use sp_runtime::traits::BlakeTwo256;57use substrate_prometheus_endpoint::Registry;58use sc_client_api::BlockchainEvents;5960use polkadot_service::CollatorPair;6162// Frontier Imports63use fc_rpc_core::types::FilterPool;64use fc_mapping_sync::{MappingSyncWorker, SyncStrategy};6566use unique_runtime_common::types::{AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block};6768// RMRK69use up_data_structs::{70	RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo, RmrkBaseInfo,71	RmrkPartType, RmrkTheme,72};7374/// Unique native executor instance.75#[cfg(feature = "unique-runtime")]76pub struct UniqueRuntimeExecutor;7778#[cfg(feature = "quartz-runtime")]79/// Quartz native executor instance.80pub struct QuartzRuntimeExecutor;8182/// Opal native executor instance.83pub struct OpalRuntimeExecutor;8485#[cfg(feature = "unique-runtime")]86pub type DefaultRuntimeExecutor = UniqueRuntimeExecutor;8788#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]89pub type DefaultRuntimeExecutor = QuartzRuntimeExecutor;9091#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]92pub type DefaultRuntimeExecutor = OpalRuntimeExecutor;9394#[cfg(feature = "unique-runtime")]95impl NativeExecutionDispatch for UniqueRuntimeExecutor {96	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;9798	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {99		unique_runtime::api::dispatch(method, data)100	}101102	fn native_version() -> sc_executor::NativeVersion {103		unique_runtime::native_version()104	}105}106107#[cfg(feature = "quartz-runtime")]108impl NativeExecutionDispatch for QuartzRuntimeExecutor {109	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;110111	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {112		quartz_runtime::api::dispatch(method, data)113	}114115	fn native_version() -> sc_executor::NativeVersion {116		quartz_runtime::native_version()117	}118}119120impl NativeExecutionDispatch for OpalRuntimeExecutor {121	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;122123	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {124		opal_runtime::api::dispatch(method, data)125	}126127	fn native_version() -> sc_executor::NativeVersion {128		opal_runtime::native_version()129	}130}131132pub struct AutosealInterval {133	interval: Interval,134}135136impl AutosealInterval {137	pub fn new(config: &Configuration, interval: Duration) -> Self {138		let _tokio_runtime = config.tokio_handle.enter();139		let interval = tokio::time::interval(interval);140141		Self { interval }142	}143}144145impl Stream for AutosealInterval {146	type Item = tokio::time::Instant;147148	fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {149		self.interval.poll_tick(cx).map(Some)150	}151}152153pub fn open_frontier_backend(config: &Configuration) -> Result<Arc<fc_db::Backend<Block>>, String> {154	let config_dir = config155		.base_path156		.as_ref()157		.map(|base_path| base_path.config_dir(config.chain_spec.id()))158		.unwrap_or_else(|| {159			BasePath::from_project("", "", "unique").config_dir(config.chain_spec.id())160		});161	let database_dir = config_dir.join("frontier").join("db");162163	Ok(Arc::new(fc_db::Backend::<Block>::new(164		&fc_db::DatabaseSettings {165			source: fc_db::DatabaseSource::RocksDb {166				path: database_dir,167				cache_size: 0,168			},169		},170	)?))171}172173type FullClient<RuntimeApi, ExecutorDispatch> =174	sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;175type FullBackend = sc_service::TFullBackend<Block>;176type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;177178/// Starts a `ServiceBuilder` for a full service.179///180/// Use this macro if you don't actually need the full service, but just the builder in order to181/// be able to perform chain operations.182#[allow(clippy::type_complexity)]183pub fn new_partial<RuntimeApi, ExecutorDispatch, BIQ>(184	config: &Configuration,185	build_import_queue: BIQ,186) -> Result<187	PartialComponents<188		FullClient<RuntimeApi, ExecutorDispatch>,189		FullBackend,190		FullSelectChain,191		sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,192		sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,193		(194			Option<Telemetry>,195			Option<FilterPool>,196			Arc<fc_db::Backend<Block>>,197			Option<TelemetryWorkerHandle>,198			FeeHistoryCache,199		),200	>,201	sc_service::Error,202>203where204	sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,205	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>206		+ Send207		+ Sync208		+ 'static,209	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,210	ExecutorDispatch: NativeExecutionDispatch + 'static,211	BIQ: FnOnce(212		Arc<FullClient<RuntimeApi, ExecutorDispatch>>,213		&Configuration,214		Option<TelemetryHandle>,215		&TaskManager,216	) -> Result<217		sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,218		sc_service::Error,219	>,220{221	let _telemetry = config222		.telemetry_endpoints223		.clone()224		.filter(|x| !x.is_empty())225		.map(|endpoints| -> Result<_, sc_telemetry::Error> {226			let worker = TelemetryWorker::new(16)?;227			let telemetry = worker.handle().new_telemetry(endpoints);228			Ok((worker, telemetry))229		})230		.transpose()?;231232	let telemetry = config233		.telemetry_endpoints234		.clone()235		.filter(|x| !x.is_empty())236		.map(|endpoints| -> Result<_, sc_telemetry::Error> {237			let worker = TelemetryWorker::new(16)?;238			let telemetry = worker.handle().new_telemetry(endpoints);239			Ok((worker, telemetry))240		})241		.transpose()?;242243	let executor = NativeElseWasmExecutor::<ExecutorDispatch>::new(244		config.wasm_method,245		config.default_heap_pages,246		config.max_runtime_instances,247		config.runtime_cache_size,248	);249250	let (client, backend, keystore_container, task_manager) =251		sc_service::new_full_parts::<Block, RuntimeApi, _>(252			config,253			telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),254			executor,255		)?;256	let client = Arc::new(client);257258	let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle());259260	let telemetry = telemetry.map(|(worker, telemetry)| {261		task_manager262			.spawn_handle()263			.spawn("telemetry", None, worker.run());264		telemetry265	});266267	let select_chain = sc_consensus::LongestChain::new(backend.clone());268269	let transaction_pool = sc_transaction_pool::BasicPool::new_full(270		config.transaction_pool.clone(),271		config.role.is_authority().into(),272		config.prometheus_registry(),273		task_manager.spawn_essential_handle(),274		client.clone(),275	);276277	let filter_pool: Option<FilterPool> = Some(Arc::new(Mutex::new(BTreeMap::new())));278279	let frontier_backend = open_frontier_backend(config)?;280281	let import_queue = build_import_queue(282		client.clone(),283		config,284		telemetry.as_ref().map(|telemetry| telemetry.handle()),285		&task_manager,286	)?;287	let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));288289	let params = PartialComponents {290		backend,291		client,292		import_queue,293		keystore_container,294		task_manager,295		transaction_pool,296		select_chain,297		other: (298			telemetry,299			filter_pool,300			frontier_backend,301			telemetry_worker_handle,302			fee_history_cache,303		),304	};305306	Ok(params)307}308309async fn build_relay_chain_interface(310	polkadot_config: Configuration,311	parachain_config: &Configuration,312	telemetry_worker_handle: Option<TelemetryWorkerHandle>,313	task_manager: &mut TaskManager,314	collator_options: CollatorOptions,315	hwbench: Option<sc_sysinfo::HwBench>,316) -> RelayChainResult<(317	Arc<(dyn RelayChainInterface + 'static)>,318	Option<CollatorPair>,319)> {320	match collator_options.relay_chain_rpc_url {321		Some(relay_chain_url) => Ok((322			Arc::new(RelayChainRPCInterface::new(relay_chain_url).await?) as Arc<_>,323			None,324		)),325		None => build_inprocess_relay_chain(326			polkadot_config,327			parachain_config,328			telemetry_worker_handle,329			task_manager,330			hwbench,331		),332	}333}334335/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.336///337/// This is the actual implementation that is abstract over the executor and the runtime api.338#[sc_tracing::logging::prefix_logs_with("Parachain")]339async fn start_node_impl<Runtime, RuntimeApi, ExecutorDispatch, BIQ, BIC>(340	parachain_config: Configuration,341	polkadot_config: Configuration,342	collator_options: CollatorOptions,343	id: ParaId,344	build_import_queue: BIQ,345	build_consensus: BIC,346	hwbench: Option<sc_sysinfo::HwBench>,347) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>348where349	sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,350	Runtime: RuntimeInstance + Send + Sync + 'static,351	<Runtime as RuntimeInstance>::CrossAccountId: Serialize,352	for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,353	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>354		+ Send355		+ Sync356		+ 'static,357	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>358		+ fp_rpc::EthereumRuntimeRPCApi<Block>359		+ fp_rpc::ConvertTransactionRuntimeApi<Block>360		+ sp_session::SessionKeys<Block>361		+ sp_block_builder::BlockBuilder<Block>362		+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>363		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>364		+ up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>365		+ rmrk_rpc::RmrkApi<366			Block,367			AccountId,368			RmrkCollectionInfo<AccountId>,369			RmrkInstanceInfo<AccountId>,370			RmrkResourceInfo,371			RmrkPropertyInfo,372			RmrkBaseInfo<AccountId>,373			RmrkPartType,374			RmrkTheme,375		> + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>376		+ sp_api::Metadata<Block>377		+ sp_offchain::OffchainWorkerApi<Block>378		+ cumulus_primitives_core::CollectCollationInfo<Block>,379	ExecutorDispatch: NativeExecutionDispatch + 'static,380	BIQ: FnOnce(381		Arc<FullClient<RuntimeApi, ExecutorDispatch>>,382		&Configuration,383		Option<TelemetryHandle>,384		&TaskManager,385	) -> Result<386		sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,387		sc_service::Error,388	>,389	BIC: FnOnce(390		Arc<FullClient<RuntimeApi, ExecutorDispatch>>,391		Option<&Registry>,392		Option<TelemetryHandle>,393		&TaskManager,394		Arc<dyn RelayChainInterface>,395		Arc<sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>>,396		Arc<NetworkService<Block, Hash>>,397		SyncCryptoStorePtr,398		bool,399	) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,400{401	if matches!(parachain_config.role, Role::Light) {402		return Err("Light client not supported!".into());403	}404405	let parachain_config = prepare_node_config(parachain_config);406407	let params =408		new_partial::<RuntimeApi, ExecutorDispatch, BIQ>(&parachain_config, build_import_queue)?;409	let (mut telemetry, filter_pool, frontier_backend, telemetry_worker_handle, fee_history_cache) =410		params.other;411412	let client = params.client.clone();413	let backend = params.backend.clone();414	let mut task_manager = params.task_manager;415416	let (relay_chain_interface, collator_key) = build_relay_chain_interface(417		polkadot_config,418		&parachain_config,419		telemetry_worker_handle,420		&mut task_manager,421		collator_options.clone(),422		hwbench.clone(),423	)424	.await425	.map_err(|e| match e {426		RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,427		s => s.to_string().into(),428	})?;429430	let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id);431432	let force_authoring = parachain_config.force_authoring;433	let validator = parachain_config.role.is_authority();434	let prometheus_registry = parachain_config.prometheus_registry().cloned();435	let transaction_pool = params.transaction_pool.clone();436	let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue);437438	let (network, system_rpc_tx, start_network) =439		sc_service::build_network(sc_service::BuildNetworkParams {440			config: &parachain_config,441			client: client.clone(),442			transaction_pool: transaction_pool.clone(),443			spawn_handle: task_manager.spawn_handle(),444			import_queue: import_queue.clone(),445			block_announce_validator_builder: Some(Box::new(|_| {446				Box::new(block_announce_validator)447			})),448			warp_sync: None,449		})?;450451	let rpc_client = client.clone();452	let rpc_pool = transaction_pool.clone();453	let select_chain = params.select_chain.clone();454	let rpc_network = network.clone();455456	let rpc_frontier_backend = frontier_backend.clone();457458	let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(459		task_manager.spawn_handle(),460		overrides_handle::<_, _, Runtime>(client.clone()),461		50,462		50,463		prometheus_registry.clone(),464	));465466	task_manager.spawn_essential_handle().spawn(467		"frontier-mapping-sync-worker",468		None,469		MappingSyncWorker::new(470			client.import_notification_stream(),471			Duration::new(6, 0),472			client.clone(),473			backend.clone(),474			frontier_backend.clone(),475			3,476			0,477			SyncStrategy::Normal,478		)479		.for_each(|()| futures::future::ready(())),480	);481482	let rpc_builder = Box::new(move |deny_unsafe, subscription_task_executor| {483		let full_deps = unique_rpc::FullDeps {484			backend: rpc_frontier_backend.clone(),485			deny_unsafe,486			client: rpc_client.clone(),487			pool: rpc_pool.clone(),488			graph: rpc_pool.pool().clone(),489			// TODO: Unhardcode490			enable_dev_signer: false,491			filter_pool: filter_pool.clone(),492			network: rpc_network.clone(),493			select_chain: select_chain.clone(),494			is_authority: validator,495			// TODO: Unhardcode496			max_past_logs: 10000,497			block_data_cache: block_data_cache.clone(),498			fee_history_cache: fee_history_cache.clone(),499			// TODO: Unhardcode500			fee_history_limit: 2048,501		};502503		unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(504			full_deps,505			subscription_task_executor,506		)507		.map_err(Into::into)508	});509510	sc_service::spawn_tasks(sc_service::SpawnTasksParams {511		rpc_builder,512		client: client.clone(),513		transaction_pool: transaction_pool.clone(),514		task_manager: &mut task_manager,515		config: parachain_config,516		keystore: params.keystore_container.sync_keystore(),517		backend: backend.clone(),518		network: network.clone(),519		system_rpc_tx,520		telemetry: telemetry.as_mut(),521	})?;522523	if let Some(hwbench) = hwbench {524		sc_sysinfo::print_hwbench(&hwbench);525526		if let Some(ref mut telemetry) = telemetry {527			let telemetry_handle = telemetry.handle();528			task_manager.spawn_handle().spawn(529				"telemetry_hwbench",530				None,531				sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench),532			);533		}534	}535536	let announce_block = {537		let network = network.clone();538		Arc::new(move |hash, data| network.announce_block(hash, data))539	};540541	let relay_chain_slot_duration = Duration::from_secs(6);542543	if validator {544		let parachain_consensus = build_consensus(545			client.clone(),546			prometheus_registry.as_ref(),547			telemetry.as_ref().map(|t| t.handle()),548			&task_manager,549			relay_chain_interface.clone(),550			transaction_pool,551			network,552			params.keystore_container.sync_keystore(),553			force_authoring,554		)?;555556		let spawner = task_manager.spawn_handle();557558		let params = StartCollatorParams {559			para_id: id,560			block_status: client.clone(),561			announce_block,562			client: client.clone(),563			task_manager: &mut task_manager,564			spawner,565			parachain_consensus,566			import_queue,567			collator_key: collator_key.expect("Command line arguments do not allow this. qed"),568			relay_chain_interface,569			relay_chain_slot_duration,570		};571572		start_collator(params).await?;573	} else {574		let params = StartFullNodeParams {575			client: client.clone(),576			announce_block,577			task_manager: &mut task_manager,578			para_id: id,579			import_queue,580			relay_chain_interface,581			relay_chain_slot_duration,582			collator_options,583		};584585		start_full_node(params)?;586	}587588	start_network.start_network();589590	Ok((task_manager, client))591}592593/// Build the import queue for the the parachain runtime.594pub fn parachain_build_import_queue<RuntimeApi, ExecutorDispatch>(595	client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,596	config: &Configuration,597	telemetry: Option<TelemetryHandle>,598	task_manager: &TaskManager,599) -> Result<600	sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,601	sc_service::Error,602>603where604	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>605		+ Send606		+ Sync607		+ 'static,608	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>609		+ sp_block_builder::BlockBuilder<Block>610		+ sp_consensus_aura::AuraApi<Block, AuraId>611		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,612	ExecutorDispatch: NativeExecutionDispatch + 'static,613{614	let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;615616	cumulus_client_consensus_aura::import_queue::<617		sp_consensus_aura::sr25519::AuthorityPair,618		_,619		_,620		_,621		_,622		_,623		_,624	>(cumulus_client_consensus_aura::ImportQueueParams {625		block_import: client.clone(),626		client: client.clone(),627		create_inherent_data_providers: move |_, _| async move {628			let time = sp_timestamp::InherentDataProvider::from_system_time();629630			let slot =631				sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(632					*time,633					slot_duration,634				);635636			Ok((time, slot))637		},638		registry: config.prometheus_registry(),639		can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),640		spawner: &task_manager.spawn_essential_handle(),641		telemetry,642	})643	.map_err(Into::into)644}645646/// Start a normal parachain node.647pub async fn start_node<Runtime, RuntimeApi, ExecutorDispatch>(648	parachain_config: Configuration,649	polkadot_config: Configuration,650	collator_options: CollatorOptions,651	id: ParaId,652	hwbench: Option<sc_sysinfo::HwBench>,653) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>654where655	Runtime: RuntimeInstance + Send + Sync + 'static,656	<Runtime as RuntimeInstance>::CrossAccountId: Serialize,657	for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,658	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>659		+ Send660		+ Sync661		+ 'static,662	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>663		+ fp_rpc::EthereumRuntimeRPCApi<Block>664		+ fp_rpc::ConvertTransactionRuntimeApi<Block>665		+ sp_session::SessionKeys<Block>666		+ sp_block_builder::BlockBuilder<Block>667		+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>668		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>669		+ up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>670		+ rmrk_rpc::RmrkApi<671			Block,672			AccountId,673			RmrkCollectionInfo<AccountId>,674			RmrkInstanceInfo<AccountId>,675			RmrkResourceInfo,676			RmrkPropertyInfo,677			RmrkBaseInfo<AccountId>,678			RmrkPartType,679			RmrkTheme,680		> + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>681		+ sp_api::Metadata<Block>682		+ sp_offchain::OffchainWorkerApi<Block>683		+ cumulus_primitives_core::CollectCollationInfo<Block>684		+ sp_consensus_aura::AuraApi<Block, AuraId>,685	ExecutorDispatch: NativeExecutionDispatch + 'static,686{687	start_node_impl::<Runtime, RuntimeApi, ExecutorDispatch, _, _>(688		parachain_config,689		polkadot_config,690		collator_options,691		id,692		parachain_build_import_queue,693		|client,694		 prometheus_registry,695		 telemetry,696		 task_manager,697		 relay_chain_interface,698		 transaction_pool,699		 sync_oracle,700		 keystore,701		 force_authoring| {702			let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;703704			let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(705				task_manager.spawn_handle(),706				client.clone(),707				transaction_pool,708				prometheus_registry,709				telemetry.clone(),710			);711712			Ok(AuraConsensus::build::<713				sp_consensus_aura::sr25519::AuthorityPair,714				_,715				_,716				_,717				_,718				_,719				_,720			>(BuildAuraConsensusParams {721				proposer_factory,722				create_inherent_data_providers: move |_, (relay_parent, validation_data)| {723					let relay_chain_interface = relay_chain_interface.clone();724					async move {725						let parachain_inherent =726						cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(727							relay_parent,728							&relay_chain_interface,729							&validation_data,730							id,731						).await;732733						let time = sp_timestamp::InherentDataProvider::from_system_time();734735						let slot =736						sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(737							*time,738							slot_duration,739						);740741						let parachain_inherent = parachain_inherent.ok_or_else(|| {742							Box::<dyn std::error::Error + Send + Sync>::from(743								"Failed to create parachain inherent",744							)745						})?;746						Ok((time, slot, parachain_inherent))747					}748				},749				block_import: client.clone(),750				para_client: client,751				backoff_authoring_blocks: Option::<()>::None,752				sync_oracle,753				keystore,754				force_authoring,755				slot_duration,756				// We got around 500ms for proposing757				block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),758				telemetry,759				max_block_proposal_slot_portion: None,760			}))761		},762		hwbench,763	)764	.await765}766767fn dev_build_import_queue<RuntimeApi, ExecutorDispatch>(768	client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,769	config: &Configuration,770	_: Option<TelemetryHandle>,771	task_manager: &TaskManager,772) -> Result<773	sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,774	sc_service::Error,775>776where777	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>778		+ Send779		+ Sync780		+ 'static,781	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>782		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,783	ExecutorDispatch: NativeExecutionDispatch + 'static,784{785	Ok(sc_consensus_manual_seal::import_queue(786		Box::new(client.clone()),787		&task_manager.spawn_essential_handle(),788		config.prometheus_registry(),789	))790}791792/// Builds a new development service. This service uses instant seal, and mocks793/// the parachain inherent794pub fn start_dev_node<Runtime, RuntimeApi, ExecutorDispatch>(795	config: Configuration,796	autoseal_interval: Duration,797) -> sc_service::error::Result<TaskManager>798where799	Runtime: RuntimeInstance + Send + Sync + 'static,800	<Runtime as RuntimeInstance>::CrossAccountId: Serialize,801	for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,802	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>803		+ Send804		+ Sync805		+ 'static,806	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>807		+ fp_rpc::EthereumRuntimeRPCApi<Block>808		+ fp_rpc::ConvertTransactionRuntimeApi<Block>809		+ sp_session::SessionKeys<Block>810		+ sp_block_builder::BlockBuilder<Block>811		+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>812		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>813		+ up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>814		+ rmrk_rpc::RmrkApi<815			Block,816			AccountId,817			RmrkCollectionInfo<AccountId>,818			RmrkInstanceInfo<AccountId>,819			RmrkResourceInfo,820			RmrkPropertyInfo,821			RmrkBaseInfo<AccountId>,822			RmrkPartType,823			RmrkTheme,824		> + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>825		+ sp_api::Metadata<Block>826		+ sp_offchain::OffchainWorkerApi<Block>827		+ cumulus_primitives_core::CollectCollationInfo<Block>828		+ sp_consensus_aura::AuraApi<Block, AuraId>,829	ExecutorDispatch: NativeExecutionDispatch + 'static,830{831	use sc_consensus_manual_seal::{run_manual_seal, EngineCommand, ManualSealParams};832	use fc_consensus::FrontierBlockImport;833	use sc_client_api::HeaderBackend;834835	let sc_service::PartialComponents {836		client,837		backend,838		mut task_manager,839		import_queue,840		keystore_container,841		select_chain: maybe_select_chain,842		transaction_pool,843		other:844			(telemetry, filter_pool, frontier_backend, _telemetry_worker_handle, fee_history_cache),845	} = new_partial::<RuntimeApi, ExecutorDispatch, _>(846		&config,847		dev_build_import_queue::<RuntimeApi, ExecutorDispatch>,848	)?;849	let prometheus_registry = config.prometheus_registry().cloned();850851	let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(852		task_manager.spawn_handle(),853		overrides_handle::<_, _, Runtime>(client.clone()),854		50,855		50,856		prometheus_registry.clone(),857	));858859	let (network, system_rpc_tx, network_starter) =860		sc_service::build_network(sc_service::BuildNetworkParams {861			config: &config,862			client: client.clone(),863			transaction_pool: transaction_pool.clone(),864			spawn_handle: task_manager.spawn_handle(),865			import_queue,866			block_announce_validator_builder: None,867			warp_sync: None,868		})?;869870	if config.offchain_worker.enabled {871		sc_service::build_offchain_workers(872			&config,873			task_manager.spawn_handle(),874			client.clone(),875			network.clone(),876		);877	}878879	let collator = config.role.is_authority();880881	let select_chain = maybe_select_chain.clone();882883	if collator {884		let block_import =885			FrontierBlockImport::new(client.clone(), client.clone(), frontier_backend.clone());886887		let env = sc_basic_authorship::ProposerFactory::new(888			task_manager.spawn_handle(),889			client.clone(),890			transaction_pool.clone(),891			prometheus_registry.as_ref(),892			telemetry.as_ref().map(|x| x.handle()),893		);894895		let transactions_commands_stream: Box<896			dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin,897		> = Box::new(898			transaction_pool899				.pool()900				.validated_pool()901				.import_notification_stream()902				.map(|_| EngineCommand::SealNewBlock {903					create_empty: true,904					finalize: false,905					parent_hash: None,906					sender: None,907				}),908		);909910		let autoseal_interval = Box::pin(AutosealInterval::new(&config, autoseal_interval));911		let idle_commands_stream: Box<912			dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin,913		> = Box::new(autoseal_interval.map(|_| EngineCommand::SealNewBlock {914			create_empty: true,915			finalize: false,916			parent_hash: None,917			sender: None,918		}));919920		let commands_stream = select(transactions_commands_stream, idle_commands_stream);921922		let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;923		let client_set_aside_for_cidp = client.clone();924925		task_manager.spawn_essential_handle().spawn_blocking(926			"authorship_task",927			Some("block-authoring"),928			run_manual_seal(ManualSealParams {929				block_import,930				env,931				client: client.clone(),932				pool: transaction_pool.clone(),933				commands_stream,934				select_chain: select_chain.clone(),935				consensus_data_provider: None,936				create_inherent_data_providers: move |block: Hash, ()| {937					let current_para_block = client_set_aside_for_cidp938						.number(block)939						.expect("Header lookup should succeed")940						.expect("Header passed in as parent should be present in backend.");941942					let client_for_xcm = client_set_aside_for_cidp.clone();943					async move {944						let time = sp_timestamp::InherentDataProvider::from_system_time();945946						let mocked_parachain = cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider {947							current_para_block,948							relay_offset: 1000,949							relay_blocks_per_para_block: 2,950							xcm_config: cumulus_primitives_parachain_inherent::MockXcmConfig::new(951								&*client_for_xcm,952								block,953								Default::default(),954								Default::default(),955							),956							raw_downward_messages: vec![],957							raw_horizontal_messages: vec![],958						};959960						let slot =961						sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(962							*time,963							slot_duration,964						);965966						Ok((time, slot, mocked_parachain))967					}968				},969			}),970		);971	}972973	task_manager.spawn_essential_handle().spawn(974		"frontier-mapping-sync-worker",975		Some("block-authoring"),976		MappingSyncWorker::new(977			client.import_notification_stream(),978			Duration::new(6, 0),979			client.clone(),980			backend.clone(),981			frontier_backend.clone(),982			3,983			0,984			SyncStrategy::Normal,985		)986		.for_each(|()| futures::future::ready(())),987	);988989	let rpc_client = client.clone();990	let rpc_pool = transaction_pool.clone();991	let rpc_network = network.clone();992	let rpc_frontier_backend = frontier_backend.clone();993	let rpc_builder = Box::new(move |deny_unsafe, subscription_executor| {994		let full_deps = unique_rpc::FullDeps {995			backend: rpc_frontier_backend.clone(),996			deny_unsafe,997			client: rpc_client.clone(),998			pool: rpc_pool.clone(),999			graph: rpc_pool.pool().clone(),1000			// TODO: Unhardcode1001			enable_dev_signer: false,1002			filter_pool: filter_pool.clone(),1003			network: rpc_network.clone(),1004			select_chain: select_chain.clone(),1005			is_authority: collator,1006			// TODO: Unhardcode1007			max_past_logs: 10000,1008			block_data_cache: block_data_cache.clone(),1009			fee_history_cache: fee_history_cache.clone(),1010			// TODO: Unhardcode1011			fee_history_limit: 2048,1012		};10131014		unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(1015			full_deps,1016			subscription_executor,1017		)1018		.map_err(Into::into)1019	});10201021	sc_service::spawn_tasks(sc_service::SpawnTasksParams {1022		network,1023		client,1024		keystore: keystore_container.sync_keystore(),1025		task_manager: &mut task_manager,1026		transaction_pool,1027		rpc_builder,1028		backend,1029		system_rpc_tx,1030		config,1031		telemetry: None,1032	})?;10331034	network_starter.start_network();1035	Ok(task_manager)1036}
modifiedpallets/proxy-rmrk-core/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/benchmarking.rs
+++ b/pallets/proxy-rmrk-core/src/benchmarking.rs
@@ -220,7 +220,6 @@
 		let b in 0..100;
 
 		let caller: T::AccountId = account("caller", 0, SEED);
-		<T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
 
 		create_max_collection::<T>(&caller)?;
 		let collection_id = 0;
@@ -381,7 +380,6 @@
 
 	add_basic_resource {
 		let caller: T::AccountId = account("caller", 0, SEED);
-		<T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
 
 		create_max_collection::<T>(&caller)?;
 		let collection_id = 0;
@@ -398,7 +396,6 @@
 
 	add_composable_resource {
 		let caller: T::AccountId = account("caller", 0, SEED);
-		<T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
 
 		create_max_collection::<T>(&caller)?;
 		let collection_id = 0;
@@ -415,7 +412,6 @@
 
 	add_slot_resource {
 		let caller: T::AccountId = account("caller", 0, SEED);
-		<T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
 
 		create_max_collection::<T>(&caller)?;
 		let collection_id = 0;
@@ -432,7 +428,6 @@
 
 	remove_resource {
 		let caller: T::AccountId = account("caller", 0, SEED);
-		<T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
 
 		create_max_collection::<T>(&caller)?;
 		let collection_id = 0;
@@ -448,7 +443,7 @@
 			resource
 		)?;
 
-		let resource_id = 1;
+		let resource_id = 0;
 	}: _(
 		RawOrigin::Signed(caller),
 		collection_id,
@@ -460,8 +455,6 @@
 		let caller: T::AccountId = account("caller", 0, SEED);
 		let admin: T::AccountId = account("admin", 0, SEED);
 
-		<T as pallet_common::Config>::Currency::deposit_creating(&admin, T::CollectionCreationPrice::get());
-
 		create_max_collection::<T>(&admin)?;
 		let collection_id = 0;
 
@@ -486,7 +479,7 @@
 			resource
 		)?;
 
-		let resource_id = 1;
+		let resource_id = 0;
 	}: _(
 		RawOrigin::Signed(caller),
 		collection_id,
@@ -498,8 +491,6 @@
 		let caller: T::AccountId = account("caller", 0, SEED);
 		let admin: T::AccountId = account("admin", 0, SEED);
 
-		<T as pallet_common::Config>::Currency::deposit_creating(&admin, T::CollectionCreationPrice::get());
-
 		create_max_collection::<T>(&admin)?;
 		let collection_id = 0;
 
@@ -515,7 +506,7 @@
 			resource
 		)?;
 
-		let resource_id = 1;
+		let resource_id = 0;
 
 		let new_owner = <RmrkAccountIdOrCollectionNftTuple<T::AccountId>>::AccountId(caller.clone());
 
modifiedpallets/proxy-rmrk-core/src/weights.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/weights.rs
+++ b/pallets/proxy-rmrk-core/src/weights.rs
@@ -3,7 +3,7 @@
 //! Autogenerated weights for pallet_proxy_rmrk_core
 //!
 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2022-06-14, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2022-06-16, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`
 //! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
 
 // Executed Command:
@@ -19,7 +19,7 @@
 // --template
 // .maintain/frame-weight-template.hbs
 // --steps=50
-// --repeat=200
+// --repeat=80
 // --heap-pages=4096
 // --output=./pallets/proxy-rmrk-core/src/weights.rs
 
@@ -64,7 +64,7 @@
 	// Storage: Common CollectionById (r:0 w:1)
 	// Storage: RmrkCore UniqueCollectionId (r:0 w:1)
 	fn create_collection() -> Weight {
-		(41_277_000 as Weight)
+		(41_768_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(5 as Weight))
 			.saturating_add(T::DbWeight::get().writes(8 as Weight))
 	}
@@ -77,7 +77,7 @@
 	// Storage: Nonfungible TokensBurnt (r:0 w:1)
 	// Storage: Common AdminAmount (r:0 w:1)
 	fn destroy_collection() -> Weight {
-		(43_371_000 as Weight)
+		(43_402_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(5 as Weight))
 			.saturating_add(T::DbWeight::get().writes(6 as Weight))
 	}
@@ -85,7 +85,7 @@
 	// Storage: Common CollectionById (r:1 w:1)
 	// Storage: Common CollectionProperties (r:1 w:0)
 	fn change_collection_issuer() -> Weight {
-		(21_891_000 as Weight)
+		(21_711_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(3 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
@@ -95,7 +95,7 @@
 	// Storage: Nonfungible TokensMinted (r:1 w:0)
 	// Storage: Nonfungible TokensBurnt (r:1 w:0)
 	fn lock_collection() -> Weight {
-		(23_144_000 as Weight)
+		(23_204_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(5 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
@@ -107,18 +107,15 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:1)
-	// Storage: Common CreatedCollectionCount (r:1 w:1)
-	// Storage: Common DestroyedCollectionCount (r:1 w:0)
-	// Storage: System Account (r:2 w:2)
-	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
+	// Storage: Nonfungible TokenSysProperties (r:2 w:2)
 	fn mint_nft(b: u32, ) -> Weight {
-		(68_329_000 as Weight)
-			// Standard Error: 3_000
-			.saturating_add((21_470_000 as Weight).saturating_mul(b as Weight))
-			.saturating_add(T::DbWeight::get().reads(12 as Weight))
+		(44_655_000 as Weight)
+			// Standard Error: 2_000
+			.saturating_add((10_953_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(T::DbWeight::get().reads(6 as Weight))
 			.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
-			.saturating_add(T::DbWeight::get().writes(12 as Weight))
-			.saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))
+			.saturating_add(T::DbWeight::get().writes(5 as Weight))
+			.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(b as Weight)))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
 	// Storage: Common CollectionProperties (r:1 w:0)
@@ -132,8 +129,8 @@
 	// Storage: Nonfungible TokenProperties (r:0 w:1)
 	fn burn_nft(b: u32, ) -> Weight {
 		(0 as Weight)
-			// Standard Error: 959_000
-			.saturating_add((305_872_000 as Weight).saturating_mul(b as Weight))
+			// Standard Error: 3_677_000
+			.saturating_add((357_082_000 as Weight).saturating_mul(b as Weight))
 			.saturating_add(T::DbWeight::get().reads(9 as Weight))
 			.saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
 			.saturating_add(T::DbWeight::get().writes(6 as Weight))
@@ -149,7 +146,7 @@
 	// Storage: Nonfungible TokenChildren (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:2)
 	fn send() -> Weight {
-		(71_405_000 as Weight)
+		(73_968_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(12 as Weight))
 			.saturating_add(T::DbWeight::get().writes(6 as Weight))
 	}
@@ -163,22 +160,22 @@
 	// Storage: Nonfungible TokenChildren (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:2)
 	fn accept_nft() -> Weight {
-		(79_159_000 as Weight)
+		(81_954_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(15 as Weight))
 			.saturating_add(T::DbWeight::get().writes(7 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
 	// Storage: Common CollectionProperties (r:1 w:0)
 	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:5 w:5)
 	// Storage: Nonfungible TokenProperties (r:1 w:5)
-	// Storage: Nonfungible TokenData (r:5 w:5)
 	// Storage: Nonfungible TokenChildren (r:9 w:4)
 	// Storage: Nonfungible TokensBurnt (r:1 w:1)
 	// Storage: Nonfungible AccountBalance (r:5 w:5)
 	// Storage: Nonfungible Allowance (r:5 w:0)
 	// Storage: Nonfungible Owned (r:0 w:5)
 	fn reject_nft() -> Weight {
-		(238_179_000 as Weight)
+		(250_041_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(29 as Weight))
 			.saturating_add(T::DbWeight::get().writes(25 as Weight))
 	}
@@ -188,7 +185,7 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn set_property() -> Weight {
-		(47_770_000 as Weight)
+		(48_631_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(9 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
@@ -198,100 +195,72 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn set_priority() -> Weight {
-		(46_679_000 as Weight)
+		(47_830_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(9 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
-	// Storage: Common CollectionProperties (r:1 w:1)
-	// Storage: Common CollectionById (r:1 w:1)
-	// Storage: Nonfungible TokenData (r:5 w:1)
-	// Storage: Nonfungible TokenProperties (r:2 w:2)
-	// Storage: Common CreatedCollectionCount (r:1 w:1)
-	// Storage: Common DestroyedCollectionCount (r:1 w:0)
-	// Storage: System Account (r:2 w:2)
-	// Storage: Nonfungible TokensMinted (r:1 w:1)
-	// Storage: Nonfungible AccountBalance (r:1 w:1)
-	// Storage: Nonfungible Owned (r:0 w:1)
-	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
+	// Storage: Common CollectionProperties (r:1 w:0)
+	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:5 w:0)
+	// Storage: Nonfungible TokenProperties (r:1 w:1)
+	// Storage: Nonfungible TokenSysProperties (r:1 w:1)
 	fn add_basic_resource() -> Weight {
-		(100_770_000 as Weight)
-			.saturating_add(T::DbWeight::get().reads(16 as Weight))
-			.saturating_add(T::DbWeight::get().writes(12 as Weight))
+		(54_773_000 as Weight)
+			.saturating_add(T::DbWeight::get().reads(10 as Weight))
+			.saturating_add(T::DbWeight::get().writes(2 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
-	// Storage: Common CollectionProperties (r:1 w:1)
-	// Storage: Common CollectionById (r:1 w:1)
-	// Storage: Nonfungible TokenData (r:5 w:1)
-	// Storage: Nonfungible TokenProperties (r:2 w:2)
-	// Storage: Common CreatedCollectionCount (r:1 w:1)
-	// Storage: Common DestroyedCollectionCount (r:1 w:0)
-	// Storage: System Account (r:2 w:2)
-	// Storage: Nonfungible TokensMinted (r:1 w:1)
-	// Storage: Nonfungible AccountBalance (r:1 w:1)
-	// Storage: Nonfungible Owned (r:0 w:1)
-	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
+	// Storage: Common CollectionProperties (r:1 w:0)
+	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:5 w:0)
+	// Storage: Nonfungible TokenProperties (r:1 w:1)
+	// Storage: Nonfungible TokenSysProperties (r:1 w:1)
 	fn add_composable_resource() -> Weight {
-		(101_791_000 as Weight)
-			.saturating_add(T::DbWeight::get().reads(16 as Weight))
-			.saturating_add(T::DbWeight::get().writes(12 as Weight))
+		(55_214_000 as Weight)
+			.saturating_add(T::DbWeight::get().reads(10 as Weight))
+			.saturating_add(T::DbWeight::get().writes(2 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
-	// Storage: Common CollectionProperties (r:1 w:1)
-	// Storage: Common CollectionById (r:1 w:1)
-	// Storage: Nonfungible TokenData (r:5 w:1)
-	// Storage: Nonfungible TokenProperties (r:2 w:2)
-	// Storage: Common CreatedCollectionCount (r:1 w:1)
-	// Storage: Common DestroyedCollectionCount (r:1 w:0)
-	// Storage: System Account (r:2 w:2)
-	// Storage: Nonfungible TokensMinted (r:1 w:1)
-	// Storage: Nonfungible AccountBalance (r:1 w:1)
-	// Storage: Nonfungible Owned (r:0 w:1)
-	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
+	// Storage: Common CollectionProperties (r:1 w:0)
+	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:5 w:0)
+	// Storage: Nonfungible TokenProperties (r:1 w:1)
+	// Storage: Nonfungible TokenSysProperties (r:1 w:1)
 	fn add_slot_resource() -> Weight {
-		(101_610_000 as Weight)
-			.saturating_add(T::DbWeight::get().reads(16 as Weight))
-			.saturating_add(T::DbWeight::get().writes(12 as Weight))
+		(54_863_000 as Weight)
+			.saturating_add(T::DbWeight::get().reads(10 as Weight))
+			.saturating_add(T::DbWeight::get().writes(2 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
-	// Storage: Common CollectionProperties (r:2 w:0)
-	// Storage: Common CollectionById (r:2 w:0)
-	// Storage: Nonfungible TokenProperties (r:1 w:1)
-	// Storage: Nonfungible TokenData (r:6 w:1)
-	// Storage: Nonfungible TokenChildren (r:1 w:0)
-	// Storage: Nonfungible TokensBurnt (r:1 w:1)
-	// Storage: Nonfungible AccountBalance (r:1 w:1)
-	// Storage: Nonfungible Allowance (r:1 w:0)
-	// Storage: Nonfungible Owned (r:0 w:1)
+	// Storage: Common CollectionProperties (r:1 w:0)
+	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenSysProperties (r:1 w:1)
+	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn remove_resource() -> Weight {
-		(80_571_000 as Weight)
-			.saturating_add(T::DbWeight::get().reads(16 as Weight))
-			.saturating_add(T::DbWeight::get().writes(5 as Weight))
+		(46_848_000 as Weight)
+			.saturating_add(T::DbWeight::get().reads(9 as Weight))
+			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
 	// Storage: Common CollectionProperties (r:1 w:0)
 	// Storage: Common CollectionById (r:1 w:0)
 	// Storage: Nonfungible TokenData (r:5 w:0)
-	// Storage: Nonfungible TokenProperties (r:2 w:1)
+	// Storage: Nonfungible TokenSysProperties (r:1 w:1)
 	fn accept_resource() -> Weight {
-		(54_733_000 as Weight)
-			.saturating_add(T::DbWeight::get().reads(10 as Weight))
+		(45_635_000 as Weight)
+			.saturating_add(T::DbWeight::get().reads(9 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
-	// Storage: Common CollectionProperties (r:2 w:0)
-	// Storage: Common CollectionById (r:2 w:0)
-	// Storage: Nonfungible TokenData (r:6 w:1)
-	// Storage: Nonfungible TokenProperties (r:2 w:1)
-	// Storage: Nonfungible TokenChildren (r:1 w:0)
-	// Storage: Nonfungible TokensBurnt (r:1 w:1)
-	// Storage: Nonfungible AccountBalance (r:1 w:1)
-	// Storage: Nonfungible Allowance (r:1 w:0)
-	// Storage: Nonfungible Owned (r:0 w:1)
+	// Storage: Common CollectionProperties (r:1 w:0)
+	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:5 w:0)
+	// Storage: Nonfungible TokenSysProperties (r:1 w:1)
 	fn accept_resource_removal() -> Weight {
-		(84_138_000 as Weight)
-			.saturating_add(T::DbWeight::get().reads(17 as Weight))
-			.saturating_add(T::DbWeight::get().writes(5 as Weight))
+		(45_535_000 as Weight)
+			.saturating_add(T::DbWeight::get().reads(9 as Weight))
+			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
 }
 
@@ -306,7 +275,7 @@
 	// Storage: Common CollectionById (r:0 w:1)
 	// Storage: RmrkCore UniqueCollectionId (r:0 w:1)
 	fn create_collection() -> Weight {
-		(41_277_000 as Weight)
+		(41_768_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(5 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(8 as Weight))
 	}
@@ -319,7 +288,7 @@
 	// Storage: Nonfungible TokensBurnt (r:0 w:1)
 	// Storage: Common AdminAmount (r:0 w:1)
 	fn destroy_collection() -> Weight {
-		(43_371_000 as Weight)
+		(43_402_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(5 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(6 as Weight))
 	}
@@ -327,7 +296,7 @@
 	// Storage: Common CollectionById (r:1 w:1)
 	// Storage: Common CollectionProperties (r:1 w:0)
 	fn change_collection_issuer() -> Weight {
-		(21_891_000 as Weight)
+		(21_711_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(3 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
@@ -337,7 +306,7 @@
 	// Storage: Nonfungible TokensMinted (r:1 w:0)
 	// Storage: Nonfungible TokensBurnt (r:1 w:0)
 	fn lock_collection() -> Weight {
-		(23_144_000 as Weight)
+		(23_204_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(5 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
@@ -349,18 +318,15 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:1)
-	// Storage: Common CreatedCollectionCount (r:1 w:1)
-	// Storage: Common DestroyedCollectionCount (r:1 w:0)
-	// Storage: System Account (r:2 w:2)
-	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
+	// Storage: Nonfungible TokenSysProperties (r:2 w:2)
 	fn mint_nft(b: u32, ) -> Weight {
-		(68_329_000 as Weight)
-			// Standard Error: 3_000
-			.saturating_add((21_470_000 as Weight).saturating_mul(b as Weight))
-			.saturating_add(RocksDbWeight::get().reads(12 as Weight))
+		(44_655_000 as Weight)
+			// Standard Error: 2_000
+			.saturating_add((10_953_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(RocksDbWeight::get().reads(6 as Weight))
 			.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
-			.saturating_add(RocksDbWeight::get().writes(12 as Weight))
-			.saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))
+			.saturating_add(RocksDbWeight::get().writes(5 as Weight))
+			.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(b as Weight)))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
 	// Storage: Common CollectionProperties (r:1 w:0)
@@ -374,8 +340,8 @@
 	// Storage: Nonfungible TokenProperties (r:0 w:1)
 	fn burn_nft(b: u32, ) -> Weight {
 		(0 as Weight)
-			// Standard Error: 959_000
-			.saturating_add((305_872_000 as Weight).saturating_mul(b as Weight))
+			// Standard Error: 3_677_000
+			.saturating_add((357_082_000 as Weight).saturating_mul(b as Weight))
 			.saturating_add(RocksDbWeight::get().reads(9 as Weight))
 			.saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
 			.saturating_add(RocksDbWeight::get().writes(6 as Weight))
@@ -391,7 +357,7 @@
 	// Storage: Nonfungible TokenChildren (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:2)
 	fn send() -> Weight {
-		(71_405_000 as Weight)
+		(73_968_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(12 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(6 as Weight))
 	}
@@ -405,22 +371,22 @@
 	// Storage: Nonfungible TokenChildren (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:2)
 	fn accept_nft() -> Weight {
-		(79_159_000 as Weight)
+		(81_954_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(15 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(7 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
 	// Storage: Common CollectionProperties (r:1 w:0)
 	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:5 w:5)
 	// Storage: Nonfungible TokenProperties (r:1 w:5)
-	// Storage: Nonfungible TokenData (r:5 w:5)
 	// Storage: Nonfungible TokenChildren (r:9 w:4)
 	// Storage: Nonfungible TokensBurnt (r:1 w:1)
 	// Storage: Nonfungible AccountBalance (r:5 w:5)
 	// Storage: Nonfungible Allowance (r:5 w:0)
 	// Storage: Nonfungible Owned (r:0 w:5)
 	fn reject_nft() -> Weight {
-		(238_179_000 as Weight)
+		(250_041_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(29 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(25 as Weight))
 	}
@@ -430,7 +396,7 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn set_property() -> Weight {
-		(47_770_000 as Weight)
+		(48_631_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(9 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
@@ -440,99 +406,71 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn set_priority() -> Weight {
-		(46_679_000 as Weight)
+		(47_830_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(9 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
-	// Storage: Common CollectionProperties (r:1 w:1)
-	// Storage: Common CollectionById (r:1 w:1)
-	// Storage: Nonfungible TokenData (r:5 w:1)
-	// Storage: Nonfungible TokenProperties (r:2 w:2)
-	// Storage: Common CreatedCollectionCount (r:1 w:1)
-	// Storage: Common DestroyedCollectionCount (r:1 w:0)
-	// Storage: System Account (r:2 w:2)
-	// Storage: Nonfungible TokensMinted (r:1 w:1)
-	// Storage: Nonfungible AccountBalance (r:1 w:1)
-	// Storage: Nonfungible Owned (r:0 w:1)
-	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
+	// Storage: Common CollectionProperties (r:1 w:0)
+	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:5 w:0)
+	// Storage: Nonfungible TokenProperties (r:1 w:1)
+	// Storage: Nonfungible TokenSysProperties (r:1 w:1)
 	fn add_basic_resource() -> Weight {
-		(100_770_000 as Weight)
-			.saturating_add(RocksDbWeight::get().reads(16 as Weight))
-			.saturating_add(RocksDbWeight::get().writes(12 as Weight))
+		(54_773_000 as Weight)
+			.saturating_add(RocksDbWeight::get().reads(10 as Weight))
+			.saturating_add(RocksDbWeight::get().writes(2 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
-	// Storage: Common CollectionProperties (r:1 w:1)
-	// Storage: Common CollectionById (r:1 w:1)
-	// Storage: Nonfungible TokenData (r:5 w:1)
-	// Storage: Nonfungible TokenProperties (r:2 w:2)
-	// Storage: Common CreatedCollectionCount (r:1 w:1)
-	// Storage: Common DestroyedCollectionCount (r:1 w:0)
-	// Storage: System Account (r:2 w:2)
-	// Storage: Nonfungible TokensMinted (r:1 w:1)
-	// Storage: Nonfungible AccountBalance (r:1 w:1)
-	// Storage: Nonfungible Owned (r:0 w:1)
-	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
+	// Storage: Common CollectionProperties (r:1 w:0)
+	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:5 w:0)
+	// Storage: Nonfungible TokenProperties (r:1 w:1)
+	// Storage: Nonfungible TokenSysProperties (r:1 w:1)
 	fn add_composable_resource() -> Weight {
-		(101_791_000 as Weight)
-			.saturating_add(RocksDbWeight::get().reads(16 as Weight))
-			.saturating_add(RocksDbWeight::get().writes(12 as Weight))
+		(55_214_000 as Weight)
+			.saturating_add(RocksDbWeight::get().reads(10 as Weight))
+			.saturating_add(RocksDbWeight::get().writes(2 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
-	// Storage: Common CollectionProperties (r:1 w:1)
-	// Storage: Common CollectionById (r:1 w:1)
-	// Storage: Nonfungible TokenData (r:5 w:1)
-	// Storage: Nonfungible TokenProperties (r:2 w:2)
-	// Storage: Common CreatedCollectionCount (r:1 w:1)
-	// Storage: Common DestroyedCollectionCount (r:1 w:0)
-	// Storage: System Account (r:2 w:2)
-	// Storage: Nonfungible TokensMinted (r:1 w:1)
-	// Storage: Nonfungible AccountBalance (r:1 w:1)
-	// Storage: Nonfungible Owned (r:0 w:1)
-	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
+	// Storage: Common CollectionProperties (r:1 w:0)
+	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:5 w:0)
+	// Storage: Nonfungible TokenProperties (r:1 w:1)
+	// Storage: Nonfungible TokenSysProperties (r:1 w:1)
 	fn add_slot_resource() -> Weight {
-		(101_610_000 as Weight)
-			.saturating_add(RocksDbWeight::get().reads(16 as Weight))
-			.saturating_add(RocksDbWeight::get().writes(12 as Weight))
+		(54_863_000 as Weight)
+			.saturating_add(RocksDbWeight::get().reads(10 as Weight))
+			.saturating_add(RocksDbWeight::get().writes(2 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
-	// Storage: Common CollectionProperties (r:2 w:0)
-	// Storage: Common CollectionById (r:2 w:0)
-	// Storage: Nonfungible TokenProperties (r:1 w:1)
-	// Storage: Nonfungible TokenData (r:6 w:1)
-	// Storage: Nonfungible TokenChildren (r:1 w:0)
-	// Storage: Nonfungible TokensBurnt (r:1 w:1)
-	// Storage: Nonfungible AccountBalance (r:1 w:1)
-	// Storage: Nonfungible Allowance (r:1 w:0)
-	// Storage: Nonfungible Owned (r:0 w:1)
+	// Storage: Common CollectionProperties (r:1 w:0)
+	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenSysProperties (r:1 w:1)
+	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn remove_resource() -> Weight {
-		(80_571_000 as Weight)
-			.saturating_add(RocksDbWeight::get().reads(16 as Weight))
-			.saturating_add(RocksDbWeight::get().writes(5 as Weight))
+		(46_848_000 as Weight)
+			.saturating_add(RocksDbWeight::get().reads(9 as Weight))
+			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
 	// Storage: Common CollectionProperties (r:1 w:0)
 	// Storage: Common CollectionById (r:1 w:0)
 	// Storage: Nonfungible TokenData (r:5 w:0)
-	// Storage: Nonfungible TokenProperties (r:2 w:1)
+	// Storage: Nonfungible TokenSysProperties (r:1 w:1)
 	fn accept_resource() -> Weight {
-		(54_733_000 as Weight)
-			.saturating_add(RocksDbWeight::get().reads(10 as Weight))
+		(45_635_000 as Weight)
+			.saturating_add(RocksDbWeight::get().reads(9 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
-	// Storage: Common CollectionProperties (r:2 w:0)
-	// Storage: Common CollectionById (r:2 w:0)
-	// Storage: Nonfungible TokenData (r:6 w:1)
-	// Storage: Nonfungible TokenProperties (r:2 w:1)
-	// Storage: Nonfungible TokenChildren (r:1 w:0)
-	// Storage: Nonfungible TokensBurnt (r:1 w:1)
-	// Storage: Nonfungible AccountBalance (r:1 w:1)
-	// Storage: Nonfungible Allowance (r:1 w:0)
-	// Storage: Nonfungible Owned (r:0 w:1)
+	// Storage: Common CollectionProperties (r:1 w:0)
+	// Storage: Common CollectionById (r:1 w:0)
+	// Storage: Nonfungible TokenData (r:5 w:0)
+	// Storage: Nonfungible TokenSysProperties (r:1 w:1)
 	fn accept_resource_removal() -> Weight {
-		(84_138_000 as Weight)
-			.saturating_add(RocksDbWeight::get().reads(17 as Weight))
-			.saturating_add(RocksDbWeight::get().writes(5 as Weight))
+		(45_535_000 as Weight)
+			.saturating_add(RocksDbWeight::get().reads(9 as Weight))
+			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
 }
modifiedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/src/runtime_apis.rs
+++ b/runtime/common/src/runtime_apis.rs
@@ -454,6 +454,10 @@
                     list_benchmark!(list, extra, pallet_refungible, Refungible);
                     list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);
                     list_benchmark!(list, extra, pallet_unique_scheduler, Scheduler);
+
+                    #[cfg(not(feature = "unique-runtime"))]
+                    list_benchmark!(list, extra, pallet_proxy_rmrk_core, RmrkCore);
+
                     // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);
 
                     let storage_info = AllPalletsReversedWithSystemFirst::storage_info();
@@ -498,6 +502,10 @@
                     add_benchmark!(params, batches, pallet_refungible, Refungible);
                     add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);
                     add_benchmark!(params, batches, pallet_unique_scheduler, Scheduler);
+
+                    #[cfg(not(feature = "unique-runtime"))]
+                    add_benchmark!(params, batches, pallet_proxy_rmrk_core, RmrkCore);
+
                     // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);
 
                     if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -16,7 +16,7 @@
 targets = ['x86_64-unknown-linux-gnu']
 
 [features]
-default = ['std']
+default = ['std', 'unique-runtime']
 runtime-benchmarks = [
     'hex-literal',
     'frame-benchmarking',
@@ -119,6 +119,7 @@
     "orml-vesting/std",
 ]
 limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
+unique-runtime = []
 
 ################################################################################
 # Substrate Dependencies