git.delta.rocks / unique-network / refs/commits / 5189324f5050

difftreelog

Adjust node and rpc to work with different runtimes

Daniel Shiposha2022-03-14parent: #ea9e87e.patch.diff
in: master

7 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -11942,6 +11942,7 @@
  "opal-runtime",
  "pallet-ethereum",
  "pallet-transaction-payment-rpc",
+ "pallet-transaction-payment-rpc-runtime-api",
  "parity-scale-codec",
  "parking_lot 0.11.2",
  "polkadot-cli",
@@ -11988,7 +11989,9 @@
  "substrate-prometheus-endpoint",
  "unique-rpc",
  "unique-runtime",
+ "unique-runtime-common",
  "up-data-structs",
+ "up-rpc",
 ]
 
 [[package]]
@@ -12003,12 +12006,11 @@
  "futures 0.3.21",
  "jsonrpc-core",
  "jsonrpc-pubsub",
- "opal-runtime",
+ "pallet-common",
  "pallet-ethereum",
  "pallet-transaction-payment-rpc",
  "pallet-transaction-payment-rpc-runtime-api",
  "pallet-unique",
- "quartz-runtime",
  "sc-client-api",
  "sc-consensus-aura",
  "sc-consensus-epochs",
@@ -12020,6 +12022,7 @@
  "sc-rpc-api",
  "sc-service",
  "sc-transaction-pool",
+ "serde",
  "sp-api",
  "sp-block-builder",
  "sp-blockchain",
@@ -12034,7 +12037,7 @@
  "substrate-frame-rpc-system",
  "tokio 0.2.25",
  "uc-rpc",
- "unique-runtime",
+ "unique-runtime-common",
  "up-rpc",
 ]
 
@@ -12118,10 +12121,13 @@
 name = "unique-runtime-common"
 version = "0.1.0"
 dependencies = [
+ "fp-rpc",
  "frame-support",
  "frame-system",
+ "pallet-common",
  "parity-scale-codec",
  "scale-info",
+ "sp-consensus-aura",
  "sp-core",
  "sp-runtime",
 ]
modifiednode/cli/Cargo.tomldiffbeforeafterboth
--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -238,6 +238,10 @@
 ################################################################################
 # Local dependencies
 
+[dependencies.unique-runtime-common]
+default-features = false
+path = "../../runtime/common"
+
 [dependencies.unique-runtime]
 path = '../../runtime/unique'
 optional = true
@@ -254,6 +258,13 @@
 path = "../../primitives/data-structs"
 default-features = false
 
+[dependencies.up-rpc]
+path = "../../primitives/rpc"
+
+[dependencies.pallet-transaction-payment-rpc-runtime-api]
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
 ################################################################################
 # Package
 
@@ -295,7 +306,7 @@
 unique-rpc = { default-features = false, path = "../rpc" }
 
 [features]
-default = ["unique-runtime"]
+default = ["unique-runtime", "quartz-runtime", "opal-runtime"]
 runtime-benchmarks = [
     'unique-runtime/runtime-benchmarks',
     'polkadot-service/runtime-benchmarks',
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -24,20 +24,33 @@
 use serde::{Deserialize, Serialize};
 use serde_json::map::Map;
 
-#[cfg(feature = "unique-runtime")]
-use unique_runtime as runtime;
+use unique_runtime_common::types::*;
 
-#[cfg(feature = "quartz-runtime")]
-use quartz_runtime as runtime;
+/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
+pub type ChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;
 
-#[cfg(feature = "opal-runtime")]
-use opal_runtime as runtime;
+pub trait RuntimeIdentification {
+	fn is_unique(&self) -> bool;
+
+	fn is_quartz(&self) -> bool;
 
-use runtime::{*, opaque::*};
+	fn is_opal(&self) -> bool;
+}
 
-/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
-pub type ChainSpec = sc_service::GenericChainSpec<runtime::GenesisConfig, Extensions>;
+impl RuntimeIdentification for Box<dyn sc_service::ChainSpec> {
+	fn is_unique(&self) -> bool {
+		self.id().starts_with("unique")
+	}
 
+	fn is_quartz(&self) -> bool {
+		self.id().starts_with("quartz")
+	}
+
+	fn is_opal(&self) -> bool {
+		self.id().starts_with("opal")
+	}
+}
+
 /// Helper function to generate a crypto pair from seed
 pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
 	TPublic::Pair::from_string(&format!("//{}", seed), None)
@@ -225,10 +238,12 @@
 	initial_authorities: Vec<AuraId>,
 	endowed_accounts: Vec<AccountId>,
 	id: ParaId,
-) -> GenesisConfig {
+) -> unique_runtime::GenesisConfig {
+	use unique_runtime::*;
+
 	GenesisConfig {
-		system: runtime::SystemConfig {
-			code: runtime::WASM_BINARY
+		system: SystemConfig {
+			code: WASM_BINARY
 				.expect("WASM binary was not build, please build it!")
 				.to_vec(),
 		},
@@ -245,9 +260,9 @@
 			key: Some(root_key),
 		},
 		vesting: VestingConfig { vesting: vec![] },
-		parachain_info: runtime::ParachainInfoConfig { parachain_id: id },
+		parachain_info: ParachainInfoConfig { parachain_id: id },
 		parachain_system: Default::default(),
-		aura: runtime::AuraConfig {
+		aura: AuraConfig {
 			authorities: initial_authorities,
 		},
 		aura_ext: Default::default(),
modifiednode/cli/src/command.rsdiffbeforeafterboth
33// limitations under the License.33// limitations under the License.
3434
35use crate::{35use crate::{
36 chain_spec,36 chain_spec::{self, RuntimeIdentification},
37 cli::{Cli, RelayChainCli, Subcommand},37 cli::{Cli, RelayChainCli, Subcommand},
38 service::{new_partial, ParachainRuntimeExecutor},38 service::new_partial,
39};39};
40
41#[cfg(feature = "unique-runtime")]
42use crate::service::UniqueRuntimeExecutor;
43
44#[cfg(feature = "quartz-runtime")]
45use crate::service::QuartzRuntimeExecutor;
46
47#[cfg(feature = "opal-runtime")]
48use crate::service::OpalRuntimeExecutor;
49
40use codec::Encode;50use codec::Encode;
41use cumulus_primitives_core::ParaId;51use cumulus_primitives_core::ParaId;
53use sp_runtime::traits::Block as BlockT;63use sp_runtime::traits::Block as BlockT;
54use std::{io::Write, net::SocketAddr};64use std::{io::Write, net::SocketAddr};
5565
56#[cfg(feature = "unique-runtime")]
57use unique_runtime as runtime;66use unique_runtime_common::types::Block;
5867
59#[cfg(feature = "quartz-runtime")]68macro_rules! no_runtime_err {
60use quartz_runtime as runtime;69 ($chain_spec:expr) => {
61
62#[cfg(feature = "opal-runtime")]70 format!("No runtime valid runtime was found, chain id: {}",
71 $chain_spec.id())
63use opal_runtime as runtime;72 };
6473}
65use runtime::Block;
6674
67fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {75fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
68 Ok(match id {76 Ok(match id {
79impl SubstrateCli for Cli {87impl SubstrateCli for Cli {
80 // TODO use args88 // TODO use args
81 fn impl_name() -> String {89 fn impl_name() -> String {
82 format!("{} Node", runtime::RUNTIME_NAME)90 "Unique Node".into()
83 }91 }
8492
85 fn impl_version() -> String {93 fn impl_version() -> String {
88 // TODO use args96 // TODO use args
89 fn description() -> String {97 fn description() -> String {
90 format!(98 format!(
91 "{} Node\n\nThe command-line arguments provided first will be \99 "Unique Node\n\nThe command-line arguments provided first will be \
92 passed to the parachain node, while the arguments provided after -- will be passed \100 passed to the parachain node, while the arguments provided after -- will be passed \
93 to the relaychain node.\n\n\101 to the relaychain node.\n\n\
94 {} [parachain-args] -- [relaychain-args]",102 {} [parachain-args] -- [relaychain-args]",
95 runtime::RUNTIME_NAME,
96 Self::executable_name()103 Self::executable_name()
97 )104 )
98 }105 }
114 load_spec(id)121 load_spec(id)
115 }122 }
116123
117 fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {124 fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
125 #[cfg(feature = "unique-runtime")]
126 if chain_spec.is_unique() {
127 return &unique_runtime::VERSION;
128 }
129
130 #[cfg(feature = "quartz-runtime")]
131 if chain_spec.is_quartz() {
132 return &quartz_runtime::VERSION;
133 }
134
135 #[cfg(feature = "opal-runtime")]
136 if chain_spec.is_opal() {
118 &runtime::VERSION137 return &opal_runtime::VERSION;
138 }
139
140 panic!("{}", no_runtime_err!(chain_spec));
119 }141 }
120}142}
121143
122impl SubstrateCli for RelayChainCli {144impl SubstrateCli for RelayChainCli {
123 // TODO use args145 // TODO use args
124 fn impl_name() -> String {146 fn impl_name() -> String {
125 format!("{} Node", runtime::RUNTIME_NAME)147 "Unique Node".into()
126 }148 }
127149
128 fn impl_version() -> String {150 fn impl_version() -> String {
129 env!("SUBSTRATE_CLI_IMPL_VERSION").into()151 env!("SUBSTRATE_CLI_IMPL_VERSION").into()
130 }152 }
131 // TODO use args153 // TODO use args
132 fn description() -> String {154 fn description() -> String {
155 "Unique Node\n\nThe command-line arguments provided first will be \
156 passed to the parachain node, while the arguments provided after -- will be passed \
157 to the relaychain node.\n\n\
158 parachain-collator [parachain-args] -- [relaychain-args]"
133 format!(159 .into()
134 "{} Node\n\nThe command-line arguments provided first will be \
135 passed to the parachain node, while the arguments provided after -- will be passed \
136 to the relaychain node.\n\n\
137 parachain-collator [parachain-args] -- [relaychain-args]",
138 runtime::RUNTIME_NAME
139 )
140 }160 }
141161
174 (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{194 (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{
175 let runner = $cli.create_runner($cmd)?;195 let runner = $cli.create_runner($cmd)?;
196
197 #[cfg(feature = "unique-runtime")]
176 runner.async_run(|$config| {198 if runner.config().chain_spec.is_unique() {
199 return runner.async_run(|$config| {
177 let $components = new_partial::<200 let $components = new_partial::<
178 _201 unique_runtime::RuntimeApi, UniqueRuntimeExecutor, _
179 >(202 >(
180 &$config,203 &$config,
181 crate::service::parachain_build_import_queue,204 crate::service::parachain_build_import_queue,
182 )?;205 )?;
183 let task_manager = $components.task_manager;206 let task_manager = $components.task_manager;
184 { $( $code )* }.map(|v| (v, task_manager))207 { $( $code )* }.map(|v| (v, task_manager))
185 })208 });
209 }
210
211 #[cfg(feature = "quartz-runtime")]
212 if runner.config().chain_spec.is_quartz() {
213 return runner.async_run(|$config| {
214 let $components = new_partial::<
215 quartz_runtime::RuntimeApi, QuartzRuntimeExecutor, _
216 >(
217 &$config,
218 crate::service::parachain_build_import_queue,
219 )?;
220 let task_manager = $components.task_manager;
221 { $( $code )* }.map(|v| (v, task_manager))
222 });
223 }
224
225 #[cfg(feature = "opal-runtime")]
226 if runner.config().chain_spec.is_opal() {
227 return runner.async_run(|$config| {
228 let $components = new_partial::<
229 opal_runtime::RuntimeApi, OpalRuntimeExecutor, _
230 >(
231 &$config,
232 crate::service::parachain_build_import_queue,
233 )?;
234 let task_manager = $components.task_manager;
235 { $( $code )* }.map(|v| (v, task_manager))
236 });
237 }
238
239 Err(no_runtime_err!(runner.config().chain_spec).into())
186 }}240 }}
187}241}
188242
287 if cfg!(feature = "runtime-benchmarks") {341 if cfg!(feature = "runtime-benchmarks") {
288 let runner = cli.create_runner(cmd)?;342 let runner = cli.create_runner(cmd)?;
289
290 runner.sync_run(|config| cmd.run::<Block, ParachainRuntimeExecutor>(config))343 runner.sync_run(|config| {
344 #[cfg(feature = "unique-runtime")]
345 if config.chain_spec.is_unique() {
346 return cmd.run::<Block, UniqueRuntimeExecutor>(config);
347 }
348
349 #[cfg(feature = "quartz-runtime")]
350 if config.chain_spec.is_quartz() {
351 return cmd.run::<Block, QuartzRuntimeExecutor>(config);
352 }
353
354 #[cfg(feature = "opal-runtime")]
355 if config.chain_spec.is_opal() {
356 return cmd.run::<Block, OpalRuntimeExecutor>(config);
357 }
358
359 Err(no_runtime_err!(config.chain_spec).into())
360 })
291 } else {361 } else {
292 Err("Benchmarking wasn't enabled when building the node. \362 Err("Benchmarking wasn't enabled when building the node. \
293 You can enable it with `--features runtime-benchmarks`."363 You can enable it with `--features runtime-benchmarks`."
341 }411 }
342 );412 );
343413
414 #[cfg(feature = "unique-runtime")]
415 if config.chain_spec.is_unique() {
416 return crate::service::start_node::<
417 unique_runtime::Runtime,
418 unique_runtime::RuntimeApi,
419 UniqueRuntimeExecutor,
420 >(config, polkadot_config, id)
421 .await
422 .map(|r| r.0)
423 .map_err(Into::into);
424 }
425
426 #[cfg(feature = "quartz-runtime")]
427 if config.chain_spec.is_quartz() {
428 return crate::service::start_node::<
429 quartz_runtime::Runtime,
430 quartz_runtime::RuntimeApi,
431 QuartzRuntimeExecutor,
432 >(config, polkadot_config, id)
433 .await
434 .map(|r| r.0)
435 .map_err(Into::into);
436 }
437
438 #[cfg(feature = "opal-runtime")]
439 if config.chain_spec.is_opal() {
344 crate::service::start_node(config, polkadot_config, id)440 return crate::service::start_node::<
441 opal_runtime::Runtime,
442 opal_runtime::RuntimeApi,
443 OpalRuntimeExecutor,
444 >(config, polkadot_config, id)
445 .await
446 .map(|r| r.0)
345 .await447 .map_err(Into::into);
346 .map(|r| r.0)448 }
347 .map_err(Into::into)449
450 Err(no_runtime_err!(config.chain_spec).into())
348 })451 })
349 }452 }
350 }453 }
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -25,17 +25,8 @@
 use futures::StreamExt;
 
 use unique_rpc::overrides_handle;
-// Local Runtime Types
-#[cfg(feature = "unique-runtime")]
-use unique_runtime as runtime;
-
-#[cfg(feature = "quartz-runtime")]
-use quartz_runtime as runtime;
 
-#[cfg(feature = "opal-runtime")]
-use opal_runtime as runtime;
-
-use runtime::RuntimeApi;
+use serde::{Serialize, Deserialize};
 
 // Cumulus Imports
 use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};
@@ -71,18 +62,46 @@
 pub type Block = sp_runtime::generic::Block<Header, sp_runtime::OpaqueExtrinsic>;
 type Hash = sp_core::H256;
 
+use unique_runtime_common::types::{AuraId, RuntimeInstance, AccountId, Balance, Index};
+
 /// Native executor instance.
-pub struct ParachainRuntimeExecutor;
+pub struct UniqueRuntimeExecutor;
+pub struct QuartzRuntimeExecutor;
+pub struct OpalRuntimeExecutor;
+
+impl NativeExecutionDispatch for UniqueRuntimeExecutor {
+	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
+
+	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
+		unique_runtime::api::dispatch(method, data)
+	}
+
+	fn native_version() -> sc_executor::NativeVersion {
+		unique_runtime::native_version()
+	}
+}
+
+impl NativeExecutionDispatch for QuartzRuntimeExecutor {
+	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
 
-impl NativeExecutionDispatch for ParachainRuntimeExecutor {
+	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
+		unique_runtime::api::dispatch(method, data)
+	}
+
+	fn native_version() -> sc_executor::NativeVersion {
+		unique_runtime::native_version()
+	}
+}
+
+impl NativeExecutionDispatch for OpalRuntimeExecutor {
 	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
 
 	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
-		runtime::api::dispatch(method, data)
+		unique_runtime::api::dispatch(method, data)
 	}
 
 	fn native_version() -> sc_executor::NativeVersion {
-		runtime::native_version()
+		unique_runtime::native_version()
 	}
 }
 
@@ -106,9 +125,7 @@
 	)?))
 }
 
-type ExecutorDispatch = ParachainRuntimeExecutor;
-
-type FullClient =
+type FullClient<RuntimeApi, ExecutorDispatch> =
 	sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;
 type FullBackend = sc_service::TFullBackend<Block>;
 type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
@@ -118,16 +135,16 @@
 /// Use this macro if you don't actually need the full service, but just the builder in order to
 /// be able to perform chain operations.
 #[allow(clippy::type_complexity)]
-pub fn new_partial<BIQ>(
+pub fn new_partial<RuntimeApi, ExecutorDispatch, BIQ>(
 	config: &Configuration,
 	build_import_queue: BIQ,
 ) -> Result<
 	PartialComponents<
-		FullClient,
+		FullClient<RuntimeApi, ExecutorDispatch>,
 		FullBackend,
 		FullSelectChain,
-		sc_consensus::DefaultImportQueue<Block, FullClient>,
-		sc_transaction_pool::FullPool<Block, FullClient>,
+		sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
+		sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
 		(
 			Option<Telemetry>,
 			Option<FilterPool>,
@@ -140,13 +157,21 @@
 >
 where
 	sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
+	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+		+ Send
+		+ Sync
+		+ 'static,
+	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,
 	ExecutorDispatch: NativeExecutionDispatch + 'static,
 	BIQ: FnOnce(
-		Arc<FullClient>,
+		Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
 		&Configuration,
 		Option<TelemetryHandle>,
 		&TaskManager,
-	) -> Result<sc_consensus::DefaultImportQueue<Block, FullClient>, sc_service::Error>,
+	) -> Result<
+		sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
+		sc_service::Error,
+	>,
 {
 	let _telemetry = config
 		.telemetry_endpoints
@@ -240,29 +265,50 @@
 ///
 /// This is the actual implementation that is abstract over the executor and the runtime api.
 #[sc_tracing::logging::prefix_logs_with("Parachain")]
-async fn start_node_impl<BIQ, BIC>(
+async fn start_node_impl<Runtime, RuntimeApi, ExecutorDispatch, BIQ, BIC>(
 	parachain_config: Configuration,
 	polkadot_config: Configuration,
 	id: ParaId,
 	build_import_queue: BIQ,
 	build_consensus: BIC,
-) -> sc_service::error::Result<(TaskManager, Arc<FullClient>)>
+) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>
 where
 	sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
+	Runtime: RuntimeInstance + Send + Sync + 'static,
+	<Runtime as RuntimeInstance>::CrossAccountId: Serialize,
+	for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,
+	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+		+ Send
+		+ Sync
+		+ 'static,
+	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+		+ fp_rpc::EthereumRuntimeRPCApi<Block>
+		+ sp_session::SessionKeys<Block>
+		+ sp_block_builder::BlockBuilder<Block>
+		+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
+		+ up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>
+		+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
+		+ sp_api::Metadata<Block>
+		+ sp_offchain::OffchainWorkerApi<Block>
+		+ cumulus_primitives_core::CollectCollationInfo<Block>,
 	ExecutorDispatch: NativeExecutionDispatch + 'static,
 	BIQ: FnOnce(
-		Arc<FullClient>,
+		Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
 		&Configuration,
 		Option<TelemetryHandle>,
 		&TaskManager,
-	) -> Result<sc_consensus::DefaultImportQueue<Block, FullClient>, sc_service::Error>,
+	) -> Result<
+		sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
+		sc_service::Error,
+	>,
 	BIC: FnOnce(
-		Arc<FullClient>,
+		Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
 		Option<&Registry>,
 		Option<TelemetryHandle>,
 		&TaskManager,
 		Arc<dyn RelayChainInterface>,
-		Arc<sc_transaction_pool::FullPool<Block, FullClient>>,
+		Arc<sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>>,
 		Arc<NetworkService<Block, Hash>>,
 		SyncCryptoStorePtr,
 		bool,
@@ -274,7 +320,8 @@
 
 	let parachain_config = prepare_node_config(parachain_config);
 
-	let params = new_partial::<BIQ>(&parachain_config, build_import_queue)?;
+	let params =
+		new_partial::<RuntimeApi, ExecutorDispatch, BIQ>(&parachain_config, build_import_queue)?;
 	let (mut telemetry, filter_pool, frontier_backend, telemetry_worker_handle, fee_history_cache) =
 		params.other;
 
@@ -320,7 +367,7 @@
 
 	let block_data_cache = Arc::new(fc_rpc::EthBlockDataCache::new(
 		task_manager.spawn_handle(),
-		overrides_handle(client.clone()),
+		overrides_handle::<_, _, Runtime>(client.clone()),
 		50,
 		50,
 	));
@@ -346,10 +393,12 @@
 			fee_history_limit: 2048,
 		};
 
-		Ok(unique_rpc::create_full::<_, _, _, _, RuntimeApi, _>(
-			full_deps,
-			subscription_executor.clone(),
-		))
+		Ok(
+			unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(
+				full_deps,
+				subscription_executor.clone(),
+			),
+		)
 	});
 
 	task_manager.spawn_essential_handle().spawn(
@@ -436,12 +485,26 @@
 }
 
 /// Build the import queue for the the parachain runtime.
-pub fn parachain_build_import_queue(
-	client: Arc<FullClient>,
+pub fn parachain_build_import_queue<RuntimeApi, ExecutorDispatch>(
+	client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
 	config: &Configuration,
 	telemetry: Option<TelemetryHandle>,
 	task_manager: &TaskManager,
-) -> Result<sc_consensus::DefaultImportQueue<Block, FullClient>, sc_service::Error> {
+) -> Result<
+	sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
+	sc_service::Error,
+>
+where
+	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+		+ Send
+		+ Sync
+		+ 'static,
+	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+		+ sp_block_builder::BlockBuilder<Block>
+		+ sp_consensus_aura::AuraApi<Block, AuraId>
+		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
+	ExecutorDispatch: NativeExecutionDispatch + 'static,
+{
 	let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
 
 	cumulus_client_consensus_aura::import_queue::<
@@ -475,12 +538,34 @@
 }
 
 /// Start a normal parachain node.
-pub async fn start_node(
+pub async fn start_node<Runtime, RuntimeApi, ExecutorDispatch>(
 	parachain_config: Configuration,
 	polkadot_config: Configuration,
 	id: ParaId,
-) -> sc_service::error::Result<(TaskManager, Arc<FullClient>)> {
-	start_node_impl::<_, _>(
+) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>
+where
+	Runtime: RuntimeInstance + Send + Sync + 'static,
+	<Runtime as RuntimeInstance>::CrossAccountId: Serialize,
+	for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,
+	RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+		+ Send
+		+ Sync
+		+ 'static,
+	RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+		+ fp_rpc::EthereumRuntimeRPCApi<Block>
+		+ sp_session::SessionKeys<Block>
+		+ sp_block_builder::BlockBuilder<Block>
+		+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
+		+ up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>
+		+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
+		+ sp_api::Metadata<Block>
+		+ sp_offchain::OffchainWorkerApi<Block>
+		+ cumulus_primitives_core::CollectCollationInfo<Block>
+		+ sp_consensus_aura::AuraApi<Block, AuraId>,
+	ExecutorDispatch: NativeExecutionDispatch + 'static,
+{
+	start_node_impl::<Runtime, RuntimeApi, ExecutorDispatch, _, _>(
 		parachain_config,
 		polkadot_config,
 		id,
modifiednode/rpc/Cargo.tomldiffbeforeafterboth
--- a/node/rpc/Cargo.toml
+++ b/node/rpc/Cargo.toml
@@ -48,13 +48,16 @@
 fc-db = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
 fc-mapping-sync = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
 
+pallet-common = { default-features = false, path = "../../pallets/common" }
+unique-runtime-common = { default-features = false, path = "../../runtime/common" }
 pallet-unique = { path = "../../pallets/unique" }
 uc-rpc = { path = "../../client/rpc" }
 up-rpc = { path = "../../primitives/rpc" }
-unique-runtime = { path = "../../runtime/unique", optional = true }
-quartz-runtime = { path = "../../runtime/quartz", optional = true }
-opal-runtime = { path = "../../runtime/opal", optional = true }
 
+[dependencies.serde]
+features = ['derive']
+version = '1.0.130'
+
 [features]
-default = ["unique-runtime"]
+default = []
 std = []
modifiednode/rpc/src/lib.rsdiffbeforeafterboth
--- a/node/rpc/src/lib.rs
+++ b/node/rpc/src/lib.rs
@@ -40,16 +40,9 @@
 use sc_service::TransactionPool;
 use std::{collections::BTreeMap, marker::PhantomData, sync::Arc};
 
-#[cfg(feature = "unique-runtime")]
-use unique_runtime as runtime;
-
-#[cfg(feature = "quartz-runtime")]
-use quartz_runtime as runtime;
-
-#[cfg(feature = "opal-runtime")]
-use opal_runtime as runtime;
-
-use runtime::opaque::{Hash, AccountId, CrossAccountId, Index, Block, BlockNumber, Balance};
+use unique_runtime_common::types::{
+	Hash, AccountId, RuntimeInstance, Index, Block, BlockNumber, Balance,
+};
 
 /// Public io handler for exporting into other modules
 pub type IoHandler = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
@@ -100,29 +93,33 @@
 	pub block_data_cache: Arc<EthBlockDataCache<Block>>,
 }
 
-struct AccountCodes<C, B> {
+struct AccountCodes<C, B, R> {
 	client: Arc<C>,
-	_marker: PhantomData<B>,
+	_blk_marker: PhantomData<B>,
+	_runtime_marker: PhantomData<R>,
 }
 
-impl<C, Block> AccountCodes<C, Block>
+impl<C, Block, R> AccountCodes<C, Block, R>
 where
 	Block: sp_api::BlockT,
 	C: ProvideRuntimeApi<Block>,
+	R: RuntimeInstance,
 {
 	fn new(client: Arc<C>) -> Self {
 		Self {
 			client,
-			_marker: PhantomData,
+			_blk_marker: PhantomData,
+			_runtime_marker: PhantomData,
 		}
 	}
 }
 
-impl<C, Block> fc_rpc::AccountCodeProvider<Block> for AccountCodes<C, Block>
+impl<C, Block, Runtime> fc_rpc::AccountCodeProvider<Block> for AccountCodes<C, Block, Runtime>
 where
 	Block: sp_api::BlockT,
 	C: ProvideRuntimeApi<Block>,
-	C::Api: up_rpc::UniqueApi<Block, CrossAccountId, AccountId>,
+	C::Api: up_rpc::UniqueApi<Block, <Runtime as RuntimeInstance>::CrossAccountId, AccountId>,
+	Runtime: RuntimeInstance,
 {
 	fn code(&self, block: &sp_api::BlockId<Block>, account: sp_core::H160) -> Option<Vec<u8>> {
 		use up_rpc::UniqueApi;
@@ -134,22 +131,23 @@
 	}
 }
 
-pub fn overrides_handle<C, BE>(client: Arc<C>) -> Arc<OverrideHandle<Block>>
+pub fn overrides_handle<C, BE, R>(client: Arc<C>) -> Arc<OverrideHandle<Block>>
 where
 	C: ProvideRuntimeApi<Block> + StorageProvider<Block, BE> + AuxStore,
 	C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError>,
 	C: Send + Sync + 'static,
 	C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,
-	C::Api: up_rpc::UniqueApi<Block, CrossAccountId, AccountId>,
+	C::Api: up_rpc::UniqueApi<Block, <R as RuntimeInstance>::CrossAccountId, AccountId>,
 	BE: Backend<Block> + 'static,
 	BE::State: StateBackend<BlakeTwo256>,
+	R: RuntimeInstance + Send + Sync + 'static,
 {
 	let mut overrides_map = BTreeMap::new();
 	overrides_map.insert(
 		EthereumStorageSchema::V1,
 		Box::new(SchemaV1Override::new_with_code_provider(
 			client.clone(),
-			Arc::new(AccountCodes::<C, Block>::new(client.clone())),
+			Arc::new(AccountCodes::<C, Block, R>::new(client.clone())),
 		)) as Box<dyn StorageOverride<_> + Send + Sync>,
 	);
 	overrides_map.insert(
@@ -170,7 +168,7 @@
 }
 
 /// Instantiate all Full RPC extensions.
-pub fn create_full<C, P, SC, CA, A, B>(
+pub fn create_full<C, P, SC, CA, R, A, B>(
 	deps: FullDeps<C, P, SC, CA>,
 	subscription_task_executor: SubscriptionTaskExecutor,
 ) -> jsonrpc_core::IoHandler<sc_rpc_api::Metadata>
@@ -184,11 +182,14 @@
 	// C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,
 	C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
 	C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,
-	C::Api: up_rpc::UniqueApi<Block, CrossAccountId, AccountId>,
+	C::Api: up_rpc::UniqueApi<Block, <R as RuntimeInstance>::CrossAccountId, AccountId>,
 	B: sc_client_api::Backend<Block> + Send + Sync + 'static,
 	B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
 	P: TransactionPool<Block = Block> + 'static,
 	CA: ChainApi<Block = Block> + 'static,
+	R: RuntimeInstance + Send + Sync + 'static,
+	<R as RuntimeInstance>::CrossAccountId: serde::Serialize,
+	for<'de> <R as RuntimeInstance>::CrossAccountId: serde::Deserialize<'de>,
 {
 	use fc_rpc::{
 		EthApi, EthApiServer, EthDevSigner, EthFilterApi, EthFilterApiServer, EthPubSubApi,
@@ -235,13 +236,13 @@
 		signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);
 	}
 
-	let overrides = overrides_handle(client.clone());
+	let overrides = overrides_handle::<_, _, R>(client.clone());
 
 	io.extend_with(EthApiServer::to_delegate(EthApi::new(
 		client.clone(),
 		pool.clone(),
 		graph,
-		runtime::TransactionConverter,
+		<R as RuntimeInstance>::get_transaction_converter(),
 		network.clone(),
 		signers,
 		overrides.clone(),