git.delta.rocks / unique-network / refs/commits / 6f7886be8aab

difftreelog

fix make node build on 0.9.42

Yaroslav Bolyukin2023-05-22parent: #cbbf2e9.patch.diff
in: master

6 files changed

modifiedclient/rpc/src/pov_estimate.rsdiffbeforeafterboth
before · client/rpc/src/pov_estimate.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use std::sync::Arc;1819use codec::{Encode, Decode};20use sp_externalities::Extensions;2122use up_pov_estimate_rpc::{PovEstimateApi as PovEstimateRuntimeApi};23use up_common::types::opaque::RuntimeId;2425use sc_service::{NativeExecutionDispatch, config::ExecutionStrategy};26use sp_state_machine::{StateMachine, TrieBackendBuilder};27use trie_db::{Trie, TrieDBBuilder};2829use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};30use anyhow::anyhow;3132use sc_client_api::backend::Backend;33use sp_blockchain::HeaderBackend;34use sp_core::{35	Bytes,36	offchain::{37		testing::{TestOffchainExt, TestTransactionPoolExt},38		OffchainDbExt, OffchainWorkerExt, TransactionPoolExt,39	},40	testing::TaskExecutor,41	traits::TaskExecutorExt,42};43use sp_keystore::{testing::KeyStore, KeystoreExt};44use sp_api::{AsTrieBackend, BlockId, BlockT, ProvideRuntimeApi};4546use sc_executor::NativeElseWasmExecutor;47use sc_rpc_api::DenyUnsafe;4849use sp_runtime::traits::Header;5051use up_pov_estimate_rpc::{PovInfo, TrieKeyValue};5253use crate::define_struct_for_server_api;5455type HasherOf<Block> = <<Block as BlockT>::Header as Header>::Hashing;56type StateOf<Block> = <sc_service::TFullBackend<Block> as Backend<Block>>::State;5758pub struct ExecutorParams {59	pub wasm_method: sc_service::config::WasmExecutionMethod,60	pub default_heap_pages: Option<u64>,61	pub max_runtime_instances: usize,62	pub runtime_cache_size: u8,63}6465#[cfg(feature = "unique-runtime")]66pub struct UniqueRuntimeExecutor;6768#[cfg(feature = "quartz-runtime")]69pub struct QuartzRuntimeExecutor;7071pub struct OpalRuntimeExecutor;7273#[cfg(feature = "unique-runtime")]74impl NativeExecutionDispatch for UniqueRuntimeExecutor {75	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;7677	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {78		unique_runtime::api::dispatch(method, data)79	}8081	fn native_version() -> sc_executor::NativeVersion {82		unique_runtime::native_version()83	}84}8586#[cfg(feature = "quartz-runtime")]87impl NativeExecutionDispatch for QuartzRuntimeExecutor {88	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;8990	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {91		quartz_runtime::api::dispatch(method, data)92	}9394	fn native_version() -> sc_executor::NativeVersion {95		quartz_runtime::native_version()96	}97}9899impl NativeExecutionDispatch for OpalRuntimeExecutor {100	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;101102	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {103		opal_runtime::api::dispatch(method, data)104	}105106	fn native_version() -> sc_executor::NativeVersion {107		opal_runtime::native_version()108	}109}110111#[cfg(feature = "pov-estimate")]112define_struct_for_server_api! {113	PovEstimate {114		client: Arc<Client>,115		backend: Arc<sc_service::TFullBackend<Block>>,116		deny_unsafe: DenyUnsafe,117		exec_params: ExecutorParams,118		runtime_id: RuntimeId,119	}120}121122#[rpc(server)]123#[async_trait]124pub trait PovEstimateApi<BlockHash> {125	#[method(name = "povinfo_estimateExtrinsicPoV")]126	fn estimate_extrinsic_pov(127		&self,128		encoded_xts: Vec<Bytes>,129		at: Option<BlockHash>,130	) -> Result<PovInfo>;131}132133#[allow(deprecated)]134#[cfg(feature = "pov-estimate")]135impl<C, Block> PovEstimateApiServer<<Block as BlockT>::Hash> for PovEstimate<C, Block>136where137	Block: BlockT,138	C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,139	C::Api: PovEstimateRuntimeApi<Block>,140{141	fn estimate_extrinsic_pov(142		&self,143		encoded_xts: Vec<Bytes>,144		at: Option<<Block as BlockT>::Hash>,145	) -> Result<PovInfo> {146		self.deny_unsafe.check_if_safe()?;147148		let at = at.unwrap_or_else(|| self.client.info().best_hash);149		let state = self150			.backend151			.state_at(at)152			.map_err(|_| anyhow!("unable to fetch the state at {at:?}"))?;153154		match &self.runtime_id {155			#[cfg(feature = "unique-runtime")]156			RuntimeId::Unique => execute_extrinsic_in_sandbox::<Block, UniqueRuntimeExecutor>(157				state,158				&self.exec_params,159				encoded_xts,160			),161162			#[cfg(feature = "quartz-runtime")]163			RuntimeId::Quartz => execute_extrinsic_in_sandbox::<Block, QuartzRuntimeExecutor>(164				state,165				&self.exec_params,166				encoded_xts,167			),168169			RuntimeId::Opal => execute_extrinsic_in_sandbox::<Block, OpalRuntimeExecutor>(170				state,171				&self.exec_params,172				encoded_xts,173			),174175			runtime_id => Err(anyhow!("unknown runtime id {:?}", runtime_id).into()),176		}177	}178}179180fn full_extensions() -> Extensions {181	let mut extensions = Extensions::default();182	extensions.register(TaskExecutorExt::new(TaskExecutor::new()));183	let (offchain, _offchain_state) = TestOffchainExt::new();184	let (pool, _pool_state) = TestTransactionPoolExt::new();185	extensions.register(OffchainDbExt::new(offchain.clone()));186	extensions.register(OffchainWorkerExt::new(offchain));187	extensions.register(KeystoreExt(std::sync::Arc::new(KeyStore::new())));188	extensions.register(TransactionPoolExt::new(pool));189190	extensions191}192193fn execute_extrinsic_in_sandbox<Block, D>(194	state: StateOf<Block>,195	exec_params: &ExecutorParams,196	encoded_xts: Vec<Bytes>,197) -> Result<PovInfo>198where199	Block: BlockT,200	D: NativeExecutionDispatch + 'static,201{202	let backend = state.as_trie_backend().clone();203	let mut changes = Default::default();204	let runtime_code_backend = sp_state_machine::backend::BackendRuntimeCode::new(backend);205206	let proving_backend = TrieBackendBuilder::wrap(&backend)207		.with_recorder(Default::default())208		.build();209210	let runtime_code = runtime_code_backend211		.runtime_code()212		.map_err(|_| anyhow!("runtime code backend creation failed"))?;213214	let pre_root = *backend.root();215216	let executor = NativeElseWasmExecutor::<D>::new(217		exec_params.wasm_method,218		exec_params.default_heap_pages,219		exec_params.max_runtime_instances,220		exec_params.runtime_cache_size,221	);222	let execution = ExecutionStrategy::NativeElseWasm;223224	let mut results = Vec::new();225226	for encoded_xt in encoded_xts {227		let encoded_bytes = encoded_xt.encode();228229		let xt_result = StateMachine::new(230			&proving_backend,231			&mut changes,232			&executor,233			"PovEstimateApi_pov_estimate",234			encoded_bytes.as_slice(),235			full_extensions(),236			&runtime_code,237			sp_core::testing::TaskExecutor::new(),238		)239		.execute(execution.into())240		.map_err(|e| anyhow!("failed to execute the extrinsic {:?}", e))?;241242		let xt_result = Decode::decode(&mut &*xt_result)243			.map_err(|e| anyhow!("failed to decode the extrinsic result {:?}", e))?;244245		results.push(xt_result);246	}247248	let root = proving_backend.root().clone();249250	let proof = proving_backend251		.extract_proof()252		.expect("A recorder was set and thus, a storage proof can be extracted; qed");253	let proof_size = proof.encoded_size();254255	let memory_db = proof.clone().into_memory_db();256257	let tree_db =258		TrieDBBuilder::<sp_trie::LayoutV1<HasherOf<Block>>>::new(&memory_db, &root).build();259260	let key_values = tree_db261		.iter()262		.map_err(|e| anyhow!("failed to retrieve tree db key values: {:?}", e))?263		.filter_map(|item| {264			let item = item.ok()?;265266			Some(TrieKeyValue {267				key: item.0,268				value: item.1,269			})270		})271		.collect();272273	let compact_proof = proof274		.clone()275		.into_compact_proof::<HasherOf<Block>>(pre_root)276		.map_err(|e| anyhow!("failed to generate compact proof {:?}", e))?;277	let compact_proof_size = compact_proof.encoded_size();278279	let compressed_proof = zstd::stream::encode_all(&compact_proof.encode()[..], 0)280		.map_err(|e| anyhow!("failed to generate compact proof {:?}", e))?;281	let compressed_proof_size = compressed_proof.len();282283	Ok(PovInfo {284		proof_size: proof_size as u64,285		compact_proof_size: compact_proof_size as u64,286		compressed_proof_size: compressed_proof_size as u64,287		results,288		key_values,289	})290}
after · client/rpc/src/pov_estimate.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use std::sync::Arc;1819use codec::{Encode, Decode};20use sp_externalities::Extensions;2122use up_pov_estimate_rpc::{PovEstimateApi as PovEstimateRuntimeApi};23use up_common::types::opaque::RuntimeId;2425use sc_service::{NativeExecutionDispatch, config::ExecutionStrategy};26use sp_state_machine::{StateMachine, TrieBackendBuilder};27use trie_db::{Trie, TrieDBBuilder};2829use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};30use anyhow::anyhow;3132use sc_client_api::backend::Backend;33use sp_blockchain::HeaderBackend;34use sp_core::{35	Bytes,36	offchain::{37		testing::{TestOffchainExt, TestTransactionPoolExt},38		OffchainDbExt, OffchainWorkerExt, TransactionPoolExt,39	},40	testing::TaskExecutor,41	traits::TaskExecutorExt,42};43use sp_keystore::{testing::KeyStore, KeystoreExt};44use sp_api::{AsTrieBackend, BlockId, BlockT, ProvideRuntimeApi};4546use sc_executor::NativeElseWasmExecutor;47use sc_rpc_api::DenyUnsafe;4849use sp_runtime::traits::Header;5051use up_pov_estimate_rpc::{PovInfo, TrieKeyValue};5253use crate::define_struct_for_server_api;5455type HasherOf<Block> = <<Block as BlockT>::Header as Header>::Hashing;56type StateOf<Block> = <sc_service::TFullBackend<Block> as Backend<Block>>::State;5758pub struct ExecutorParams {59	pub wasm_method: sc_service::config::WasmExecutionMethod,60	pub default_heap_pages: Option<u64>,61	pub max_runtime_instances: usize,62	pub runtime_cache_size: u8,63}6465#[cfg(feature = "unique-runtime")]66pub struct UniqueRuntimeExecutor;6768#[cfg(feature = "quartz-runtime")]69pub struct QuartzRuntimeExecutor;7071pub struct OpalRuntimeExecutor;7273#[cfg(feature = "unique-runtime")]74impl NativeExecutionDispatch for UniqueRuntimeExecutor {75	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;7677	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {78		unique_runtime::api::dispatch(method, data)79	}8081	fn native_version() -> sc_executor::NativeVersion {82		unique_runtime::native_version()83	}84}8586#[cfg(feature = "quartz-runtime")]87impl NativeExecutionDispatch for QuartzRuntimeExecutor {88	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;8990	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {91		quartz_runtime::api::dispatch(method, data)92	}9394	fn native_version() -> sc_executor::NativeVersion {95		quartz_runtime::native_version()96	}97}9899impl NativeExecutionDispatch for OpalRuntimeExecutor {100	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;101102	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {103		opal_runtime::api::dispatch(method, data)104	}105106	fn native_version() -> sc_executor::NativeVersion {107		opal_runtime::native_version()108	}109}110111#[cfg(feature = "pov-estimate")]112define_struct_for_server_api! {113	PovEstimate {114		client: Arc<Client>,115		backend: Arc<sc_service::TFullBackend<Block>>,116		deny_unsafe: DenyUnsafe,117		exec_params: ExecutorParams,118		runtime_id: RuntimeId,119	}120}121122#[rpc(server)]123#[async_trait]124pub trait PovEstimateApi<BlockHash> {125	#[method(name = "povinfo_estimateExtrinsicPoV")]126	fn estimate_extrinsic_pov(127		&self,128		encoded_xts: Vec<Bytes>,129		at: Option<BlockHash>,130	) -> Result<PovInfo>;131}132133#[allow(deprecated)]134#[cfg(feature = "pov-estimate")]135impl<C, Block> PovEstimateApiServer<<Block as BlockT>::Hash> for PovEstimate<C, Block>136where137	Block: BlockT,138	C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,139	C::Api: PovEstimateRuntimeApi<Block>,140{141	fn estimate_extrinsic_pov(142		&self,143		encoded_xts: Vec<Bytes>,144		at: Option<<Block as BlockT>::Hash>,145	) -> Result<PovInfo> {146		self.deny_unsafe.check_if_safe()?;147148		let at = at.unwrap_or_else(|| self.client.info().best_hash);149		let state = self150			.backend151			.state_at(at)152			.map_err(|_| anyhow!("unable to fetch the state at {at:?}"))?;153154		match &self.runtime_id {155			#[cfg(feature = "unique-runtime")]156			RuntimeId::Unique => execute_extrinsic_in_sandbox::<Block, UniqueRuntimeExecutor>(157				state,158				&self.exec_params,159				encoded_xts,160			),161162			#[cfg(feature = "quartz-runtime")]163			RuntimeId::Quartz => execute_extrinsic_in_sandbox::<Block, QuartzRuntimeExecutor>(164				state,165				&self.exec_params,166				encoded_xts,167			),168169			RuntimeId::Opal => execute_extrinsic_in_sandbox::<Block, OpalRuntimeExecutor>(170				state,171				&self.exec_params,172				encoded_xts,173			),174175			runtime_id => Err(anyhow!("unknown runtime id {:?}", runtime_id).into()),176		}177	}178}179180fn full_extensions() -> Extensions {181	let mut extensions = Extensions::default();182	extensions.register(TaskExecutorExt::new(TaskExecutor::new()));183	let (offchain, _offchain_state) = TestOffchainExt::new();184	let (pool, _pool_state) = TestTransactionPoolExt::new();185	extensions.register(OffchainDbExt::new(offchain.clone()));186	extensions.register(OffchainWorkerExt::new(offchain));187	extensions.register(KeystoreExt(std::sync::Arc::new(KeyStore::new())));188	extensions.register(TransactionPoolExt::new(pool));189190	extensions191}192193fn execute_extrinsic_in_sandbox<Block, D>(194	state: StateOf<Block>,195	exec_params: &ExecutorParams,196	encoded_xts: Vec<Bytes>,197) -> Result<PovInfo>198where199	Block: BlockT,200	D: NativeExecutionDispatch + 'static,201{202	let backend = state.as_trie_backend().clone();203	let mut changes = Default::default();204	let runtime_code_backend = sp_state_machine::backend::BackendRuntimeCode::new(backend);205206	let proving_backend = TrieBackendBuilder::wrap(&backend)207		.with_recorder(Default::default())208		.build();209210	let runtime_code = runtime_code_backend211		.runtime_code()212		.map_err(|_| anyhow!("runtime code backend creation failed"))?;213214	let pre_root = *backend.root();215216	let executor = sc_service::new_native_or_wasm_executor(exec_params);217	let execution = ExecutionStrategy::NativeElseWasm;218219	let mut results = Vec::new();220221	for encoded_xt in encoded_xts {222		let encoded_bytes = encoded_xt.encode();223224		let xt_result = StateMachine::new(225			&proving_backend,226			&mut changes,227			&executor,228			"PovEstimateApi_pov_estimate",229			encoded_bytes.as_slice(),230			full_extensions(),231			&runtime_code,232			sp_core::testing::TaskExecutor::new(),233		)234		.execute(execution.into())235		.map_err(|e| anyhow!("failed to execute the extrinsic {:?}", e))?;236237		let xt_result = Decode::decode(&mut &*xt_result)238			.map_err(|e| anyhow!("failed to decode the extrinsic result {:?}", e))?;239240		results.push(xt_result);241	}242243	let root = proving_backend.root().clone();244245	let proof = proving_backend246		.extract_proof()247		.expect("A recorder was set and thus, a storage proof can be extracted; qed");248	let proof_size = proof.encoded_size();249250	let memory_db = proof.clone().into_memory_db();251252	let tree_db =253		TrieDBBuilder::<sp_trie::LayoutV1<HasherOf<Block>>>::new(&memory_db, &root).build();254255	let key_values = tree_db256		.iter()257		.map_err(|e| anyhow!("failed to retrieve tree db key values: {:?}", e))?258		.filter_map(|item| {259			let item = item.ok()?;260261			Some(TrieKeyValue {262				key: item.0,263				value: item.1,264			})265		})266		.collect();267268	let compact_proof = proof269		.clone()270		.into_compact_proof::<HasherOf<Block>>(pre_root)271		.map_err(|e| anyhow!("failed to generate compact proof {:?}", e))?;272	let compact_proof_size = compact_proof.encoded_size();273274	let compressed_proof = zstd::stream::encode_all(&compact_proof.encode()[..], 0)275		.map_err(|e| anyhow!("failed to generate compact proof {:?}", e))?;276	let compressed_proof_size = compressed_proof.len();277278	Ok(PovInfo {279		proof_size: proof_size as u64,280		compact_proof_size: compact_proof_size as u64,281		compressed_proof_size: compressed_proof_size as u64,282		results,283		key_values,284	})285}
modifiednode/cli/Cargo.tomldiffbeforeafterboth
--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -100,30 +100,8 @@
 
 [features]
 default = ["opal-runtime"]
-all-runtimes = [
-	'opal-runtime',
-	'quartz-runtime',
-	'unique-runtime',
-]
-pov-estimate = [
-	'opal-runtime/pov-estimate',
-	'quartz-runtime?/pov-estimate',
-	'uc-rpc/pov-estimate',
-	'unique-rpc/pov-estimate',
-	'unique-runtime?/pov-estimate',
-]
-runtime-benchmarks = [
-	'opal-runtime/runtime-benchmarks',
-	'polkadot-cli/runtime-benchmarks',
-	'polkadot-service/runtime-benchmarks',
-	'quartz-runtime?/runtime-benchmarks',
-	'sc-service/runtime-benchmarks',
-	'unique-runtime?/runtime-benchmarks',
-]
+all-runtimes = ['opal-runtime', 'quartz-runtime', 'unique-runtime']
+pov-estimate = ['opal-runtime/pov-estimate', 'quartz-runtime?/pov-estimate', 'uc-rpc/pov-estimate', 'unique-rpc/pov-estimate', 'unique-runtime?/pov-estimate']
+runtime-benchmarks = ['opal-runtime/runtime-benchmarks', 'polkadot-cli/runtime-benchmarks', 'polkadot-service/runtime-benchmarks', 'quartz-runtime?/runtime-benchmarks', 'sc-service/runtime-benchmarks', 'unique-runtime?/runtime-benchmarks']
 sapphire-runtime = ['quartz-runtime', 'quartz-runtime/become-sapphire']
-try-runtime = [
-	'opal-runtime?/try-runtime',
-	'quartz-runtime?/try-runtime',
-	'try-runtime-cli/try-runtime',
-	'unique-runtime?/try-runtime',
-]
+try-runtime = ['opal-runtime?/try-runtime', 'quartz-runtime?/try-runtime', 'try-runtime-cli/try-runtime', 'unique-runtime?/try-runtime']
modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -505,7 +505,10 @@
 
 				let para_id = ParaId::from(para_id);
 
-				let parachain_account = AccountIdConversion::<polkadot_primitives::v2::AccountId>::into_account_truncating(&para_id);
+				let parachain_account =
+					AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(
+						&para_id,
+					);
 
 				let state_version =
 					RelayChainCli::native_runtime_version(&config.chain_spec).state_version();
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -26,6 +26,7 @@
 	stream::select,
 	task::{Context, Poll},
 };
+use sp_keystore::KeystorePtr;
 use tokio::time::Interval;
 
 use unique_rpc::overrides_handle;
@@ -55,7 +56,6 @@
 use sc_network_sync::SyncingService;
 use sc_service::{BasePath, Configuration, PartialComponents, TaskManager};
 use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
-use sp_keystore::SyncCryptoStorePtr;
 use sp_runtime::traits::BlakeTwo256;
 use substrate_prometheus_endpoint::Registry;
 use sc_client_api::BlockchainEvents;
@@ -270,12 +270,7 @@
 		})
 		.transpose()?;
 
-	let executor = NativeElseWasmExecutor::<ExecutorDispatch>::new(
-		config.wasm_method,
-		config.default_heap_pages,
-		config.max_runtime_instances,
-		config.runtime_cache_size,
-	);
+	let executor = sc_service::new_native_or_wasm_executor(config);
 
 	let (client, backend, keystore_container, task_manager) =
 		sc_service::new_full_parts::<Block, RuntimeApi, _>(
@@ -366,6 +361,14 @@
 	}
 }
 
+macro_rules! clone {
+    ($($i:ident),* $(,)?) => {
+		$(
+			let $i = $i.clone();
+		)*
+    };
+}
+
 /// Start a node with the given parachain `Configuration` and relay chain `Configuration`.
 ///
 /// This is the actual implementation that is abstract over the executor and the runtime api.
@@ -422,7 +425,7 @@
 		Arc<dyn RelayChainInterface>,
 		Arc<sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>>,
 		Arc<SyncingService<Block>>,
-		SyncCryptoStorePtr,
+		KeystorePtr,
 		bool,
 	) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,
 {
@@ -469,13 +472,7 @@
 			warp_sync_params: None,
 		})?;
 
-	let rpc_client = client.clone();
-	let rpc_pool = transaction_pool.clone();
 	let select_chain = params.select_chain.clone();
-	let rpc_network = network.clone();
-	let rpc_sync_service = sync_service.clone();
-
-	let rpc_frontier_backend = frontier_backend.clone();
 
 	let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(
 		task_manager.spawn_handle(),
@@ -485,9 +482,14 @@
 		prometheus_registry.clone(),
 	));
 
+	let pubsub_notification_sinks: fc_mapping_sync::EthereumBlockNotificationSinks<
+		fc_mapping_sync::EthereumBlockNotification<Block>,
+	> = Default::default();
+	let pubsub_notification_sinks = Arc::new(pubsub_notification_sinks);
+
 	task_manager.spawn_essential_handle().spawn(
 		"frontier-mapping-sync-worker",
-		None,
+		Some("frontier"),
 		MappingSyncWorker::new(
 			client.import_notification_stream(),
 			Duration::new(6, 0),
@@ -498,55 +500,83 @@
 			3,
 			0,
 			SyncStrategy::Normal,
+			sync_service.clone(),
+			pubsub_notification_sinks.clone(),
 		)
 		.for_each(|()| futures::future::ready(())),
 	);
 
-	#[cfg(feature = "pov-estimate")]
-	let rpc_backend = backend.clone();
+	let runtime_id = parachain_config.chain_spec.runtime_id();
+
+	let rpc_builder = Box::new({
+		clone!(
+			client,
+			backend,
+			pubsub_notification_sinks,
+			transaction_pool,
+			network,
+			sync_service,
+			frontier_backend,
+		);
+		move |deny_unsafe, subscription_task_executor| {
+			clone!(
+				backend,
+				runtime_id,
+				client,
+				transaction_pool,
+				filter_pool,
+				network,
+				select_chain,
+				block_data_cache,
+				fee_history_cache,
+				pubsub_notification_sinks,
+				frontier_backend,
+			);
 
-	let runtime_id = parachain_config.chain_spec.runtime_id();
+			#[cfg(not(feature = "pov-estimate"))]
+			let _ = backend;
 
-	let rpc_builder = Box::new(move |deny_unsafe, subscription_task_executor| {
-		let full_deps = unique_rpc::FullDeps {
-			runtime_id: runtime_id.clone(),
+			let full_deps = unique_rpc::FullDeps {
+				runtime_id,
 
-			#[cfg(feature = "pov-estimate")]
-			exec_params: uc_rpc::pov_estimate::ExecutorParams {
-				wasm_method: parachain_config.wasm_method,
-				default_heap_pages: parachain_config.default_heap_pages,
-				max_runtime_instances: parachain_config.max_runtime_instances,
-				runtime_cache_size: parachain_config.runtime_cache_size,
-			},
+				#[cfg(feature = "pov-estimate")]
+				exec_params: uc_rpc::pov_estimate::ExecutorParams {
+					wasm_method: parachain_config.wasm_method,
+					default_heap_pages: parachain_config.default_heap_pages,
+					max_runtime_instances: parachain_config.max_runtime_instances,
+					runtime_cache_size: parachain_config.runtime_cache_size,
+				},
 
-			#[cfg(feature = "pov-estimate")]
-			backend: rpc_backend.clone(),
+				#[cfg(feature = "pov-estimate")]
+				backend,
 
-			eth_backend: rpc_frontier_backend.clone(),
-			deny_unsafe,
-			client: rpc_client.clone(),
-			pool: rpc_pool.clone(),
-			graph: rpc_pool.pool().clone(),
-			// TODO: Unhardcode
-			enable_dev_signer: false,
-			filter_pool: filter_pool.clone(),
-			network: rpc_network.clone(),
-			sync: rpc_sync_service.clone(),
-			select_chain: select_chain.clone(),
-			is_authority: validator,
-			// TODO: Unhardcode
-			max_past_logs: 10000,
-			block_data_cache: block_data_cache.clone(),
-			fee_history_cache: fee_history_cache.clone(),
-			// TODO: Unhardcode
-			fee_history_limit: 2048,
-		};
+				eth_backend: frontier_backend,
+				deny_unsafe,
+				client,
+				graph: transaction_pool.pool().clone(),
+				pool: transaction_pool,
+				// TODO: Unhardcode
+				enable_dev_signer: false,
+				filter_pool,
+				network,
+				sync: sync_service.clone(),
+				select_chain,
+				is_authority: validator,
+				// TODO: Unhardcode
+				max_past_logs: 10000,
+				block_data_cache,
+				fee_history_cache,
+				// TODO: Unhardcode
+				fee_history_limit: 2048,
+				pubsub_notification_sinks,
+			};
 
-		unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(
-			full_deps,
-			subscription_task_executor,
-		)
-		.map_err(Into::into)
+			unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(
+				full_deps,
+				subscription_task_executor,
+			)
+			.map_err(Into::into)
+		}
 	});
 
 	sc_service::spawn_tasks(sc_service::SpawnTasksParams {
@@ -555,7 +585,7 @@
 		transaction_pool: transaction_pool.clone(),
 		task_manager: &mut task_manager,
 		config: parachain_config,
-		keystore: params.keystore_container.sync_keystore(),
+		keystore: params.keystore_container.keystore(),
 		backend: backend.clone(),
 		network: network.clone(),
 		sync_service: sync_service.clone(),
@@ -600,7 +630,7 @@
 			relay_chain_interface.clone(),
 			transaction_pool,
 			sync_service.clone(),
-			params.keystore_container.sync_keystore(),
+			params.keystore_container.keystore(),
 			force_authoring,
 		)?;
 
@@ -619,6 +649,7 @@
 			relay_chain_interface,
 			relay_chain_slot_duration,
 			recovery_handle: Box::new(overseer_handle),
+			sync_service,
 		};
 
 		start_collator(params).await?;
@@ -632,6 +663,7 @@
 			relay_chain_interface,
 			relay_chain_slot_duration,
 			recovery_handle: Box::new(overseer_handle),
+			sync_service,
 		};
 
 		start_full_node(params)?;
@@ -897,6 +929,11 @@
 		prometheus_registry.clone(),
 	));
 
+	let pubsub_notification_sinks: fc_mapping_sync::EthereumBlockNotificationSinks<
+		fc_mapping_sync::EthereumBlockNotification<Block>,
+	> = Default::default();
+	let pubsub_notification_sinks = Arc::new(pubsub_notification_sinks);
+
 	let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
 		sc_service::build_network(sc_service::BuildNetworkParams {
 			config: &config,
@@ -1026,67 +1063,88 @@
 			3,
 			0,
 			SyncStrategy::Normal,
+			sync_service.clone(),
+			pubsub_notification_sinks.clone(),
 		)
 		.for_each(|()| futures::future::ready(())),
 	);
-
-	let rpc_client = client.clone();
-	let rpc_pool = transaction_pool.clone();
-	let rpc_network = network.clone();
-	let rpc_sync_service = sync_service.clone();
-	let rpc_frontier_backend = frontier_backend.clone();
 
 	#[cfg(feature = "pov-estimate")]
 	let rpc_backend = backend.clone();
 
 	let runtime_id = config.chain_spec.runtime_id();
 
-	let rpc_builder = Box::new(move |deny_unsafe, subscription_executor| {
-		let full_deps = unique_rpc::FullDeps {
-			runtime_id: runtime_id.clone(),
+	let rpc_builder = Box::new({
+		clone!(
+			backend,
+			client,
+			sync_service,
+			frontier_backend,
+			network,
+			transaction_pool,
+			pubsub_notification_sinks
+		);
+		move |deny_unsafe, subscription_executor| {
+			clone!(
+				backend,
+				block_data_cache,
+				client,
+				fee_history_cache,
+				filter_pool,
+				network,
+				pubsub_notification_sinks,
+			);
+
+			#[cfg(not(feature = "pov-estimate"))]
+			let _ = backend;
+
+			let full_deps = unique_rpc::FullDeps {
+				runtime_id: runtime_id.clone(),
 
-			#[cfg(feature = "pov-estimate")]
-			exec_params: uc_rpc::pov_estimate::ExecutorParams {
-				wasm_method: config.wasm_method,
-				default_heap_pages: config.default_heap_pages,
-				max_runtime_instances: config.max_runtime_instances,
-				runtime_cache_size: config.runtime_cache_size,
-			},
+				#[cfg(feature = "pov-estimate")]
+				exec_params: uc_rpc::pov_estimate::ExecutorParams {
+					wasm_method: config.wasm_method,
+					default_heap_pages: config.default_heap_pages,
+					max_runtime_instances: config.max_runtime_instances,
+					runtime_cache_size: config.runtime_cache_size,
+				},
 
-			#[cfg(feature = "pov-estimate")]
-			backend: rpc_backend.clone(),
-			eth_backend: rpc_frontier_backend.clone(),
-			deny_unsafe,
-			client: rpc_client.clone(),
-			pool: rpc_pool.clone(),
-			graph: rpc_pool.pool().clone(),
-			// TODO: Unhardcode
-			enable_dev_signer: false,
-			filter_pool: filter_pool.clone(),
-			network: rpc_network.clone(),
-			sync: rpc_sync_service.clone(),
-			select_chain: select_chain.clone(),
-			is_authority: collator,
-			// TODO: Unhardcode
-			max_past_logs: 10000,
-			block_data_cache: block_data_cache.clone(),
-			fee_history_cache: fee_history_cache.clone(),
-			// TODO: Unhardcode
-			fee_history_limit: 2048,
-		};
+				#[cfg(feature = "pov-estimate")]
+				backend,
+				eth_backend: frontier_backend.clone(),
+				deny_unsafe,
+				client,
+				pool: transaction_pool.clone(),
+				graph: transaction_pool.pool().clone(),
+				// TODO: Unhardcode
+				enable_dev_signer: false,
+				filter_pool,
+				network,
+				sync: sync_service.clone(),
+				select_chain: select_chain.clone(),
+				is_authority: collator,
+				// TODO: Unhardcode
+				max_past_logs: 10000,
+				block_data_cache,
+				fee_history_cache,
+				// TODO: Unhardcode
+				fee_history_limit: 2048,
+				pubsub_notification_sinks,
+			};
 
-		unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(
-			full_deps,
-			subscription_executor,
-		)
-		.map_err(Into::into)
+			unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(
+				full_deps,
+				subscription_executor,
+			)
+			.map_err(Into::into)
+		}
 	});
 
 	sc_service::spawn_tasks(sc_service::SpawnTasksParams {
 		network,
 		sync_service,
 		client,
-		keystore: keystore_container.sync_keystore(),
+		keystore: keystore_container.keystore(),
 		task_manager: &mut task_manager,
 		transaction_pool,
 		rpc_builder,
modifiednode/rpc/Cargo.tomldiffbeforeafterboth
--- a/node/rpc/Cargo.toml
+++ b/node/rpc/Cargo.toml
@@ -30,6 +30,7 @@
 fc-db = { workspace = true }
 fc-rpc = { workspace = true }
 fc-rpc-core = { workspace = true }
+fc-mapping-sync = { workspace = true }
 fp-rpc = { workspace = true }
 fp-storage = { workspace = true }
 
modifiednode/rpc/src/lib.rsdiffbeforeafterboth
--- a/node/rpc/src/lib.rs
+++ b/node/rpc/src/lib.rs
@@ -102,6 +102,12 @@
 	pub fee_history_cache: FeeHistoryCache,
 	/// Cache for Ethereum block data.
 	pub block_data_cache: Arc<EthBlockDataCacheTask<Block>>,
+
+	pub pubsub_notification_sinks: Arc<
+		fc_mapping_sync::EthereumBlockNotificationSinks<
+			fc_mapping_sync::EthereumBlockNotification<Block>,
+		>,
+	>,
 }
 
 pub fn overrides_handle<C, BE, R>(client: Arc<C>) -> Arc<OverrideHandle<Block>>
@@ -214,6 +220,7 @@
 
 		eth_backend,
 		max_past_logs,
+		pubsub_notification_sinks,
 	} = deps;
 
 	io.merge(System::new(Arc::clone(&client), Arc::clone(&pool), deny_unsafe).into_rpc())?;
@@ -244,6 +251,7 @@
 			fee_history_cache,
 			fee_history_limit,
 			execute_gas_limit_multiplier,
+			None,
 		)
 		.into_rpc(),
 	)?;
@@ -290,7 +298,17 @@
 
 	io.merge(Web3::new(client.clone()).into_rpc())?;
 
-	io.merge(EthPubSub::new(pool, client, sync, subscription_task_executor, overrides).into_rpc())?;
+	io.merge(
+		EthPubSub::new(
+			pool,
+			client,
+			sync,
+			subscription_task_executor,
+			overrides,
+			pubsub_notification_sinks,
+		)
+		.into_rpc(),
+	)?;
 
 	Ok(io)
 }