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

difftreelog

Make opal runtime mandatory

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

5 files changed

modifiednode/cli/Cargo.tomldiffbeforeafterboth
--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -252,7 +252,6 @@
 
 [dependencies.opal-runtime]
 path = '../../runtime/opal'
-optional = true
 
 [dependencies.up-data-structs]
 path = "../../primitives/data-structs"
@@ -306,7 +305,7 @@
 unique-rpc = { default-features = false, path = "../rpc" }
 
 [features]
-default = ["unique-runtime", "quartz-runtime", "opal-runtime"]
+default = ["unique-runtime", "quartz-runtime"]
 runtime-benchmarks = [
     'unique-runtime/runtime-benchmarks',
     'polkadot-service/runtime-benchmarks',
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
before · node/cli/src/chain_spec.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use cumulus_primitives_core::ParaId;18use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};19use sc_service::ChainType;20use sp_core::{sr25519, Pair, Public};21use sp_runtime::traits::{IdentifyAccount, Verify};22use std::collections::BTreeMap;2324use serde::{Deserialize, Serialize};25use serde_json::map::Map;2627use unique_runtime_common::types::*;2829/// The `ChainSpec` parameterized for the unique runtime.30#[cfg(feature = "unique-runtime")]31pub type UniqueChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;3233/// The `ChainSpec` parameterized for the quartz runtime.34#[cfg(feature = "quartz-runtime")]35pub type QuartzChainSpec = sc_service::GenericChainSpec<quartz_runtime::GenesisConfig, Extensions>;3637/// The `ChainSpec` parameterized for the opal runtime.38#[cfg(feature = "opal-runtime")]39pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;4041pub enum RuntimeId {42	Unique,43	Quartz,44	Opal,45	Unknown(String),46}4748pub trait RuntimeIdentification {49	fn runtime_id(&self) -> RuntimeId;50}5152impl RuntimeIdentification for Box<dyn sc_service::ChainSpec> {53	fn runtime_id(&self) -> RuntimeId {54		#[cfg(feature = "unique-runtime")]55		if self.id().starts_with("unique") {56			return RuntimeId::Unique;57		}5859		#[cfg(feature = "quartz-runtime")]60		if self.id().starts_with("quartz") {61			return RuntimeId::Quartz;62		}6364		#[cfg(feature = "opal-runtime")]65		if self.id().starts_with("opal") {66			return RuntimeId::Opal;67		}6869		RuntimeId::Unknown(self.id().into())70	}71}7273/// Helper function to generate a crypto pair from seed74pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {75	TPublic::Pair::from_string(&format!("//{}", seed), None)76		.expect("static values are valid; qed")77		.public()78}7980/// The extensions for the [`ChainSpec`].81#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]82#[serde(deny_unknown_fields)]83pub struct Extensions {84	/// The relay chain of the Parachain.85	pub relay_chain: String,86	/// The id of the Parachain.87	pub para_id: u32,88}8990impl Extensions {91	/// Try to get the extension from the given `ChainSpec`.92	pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {93		sc_chain_spec::get_extension(chain_spec.extensions())94	}95}9697type AccountPublic = <Signature as Verify>::Signer;9899/// Helper function to generate an account ID from seed100pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId101where102	AccountPublic: From<<TPublic::Pair as Pair>::Public>,103{104	AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()105}106107pub fn development_config() -> OpalChainSpec {108	let mut properties = Map::new();109	properties.insert("tokenSymbol".into(), "OPL".into());110	properties.insert("tokenDecimals".into(), 15.into());111	properties.insert("ss58Format".into(), 42.into());112113	OpalChainSpec::from_genesis(114		// Name115		"Development",116		// ID117		"dev",118		ChainType::Local,119		move || {120			testnet_genesis(121				// Sudo account122				get_account_id_from_seed::<sr25519::Public>("Alice"),123				vec![124					get_from_seed::<AuraId>("Alice"),125					get_from_seed::<AuraId>("Bob"),126				],127				// Pre-funded accounts128				vec![129					get_account_id_from_seed::<sr25519::Public>("Alice"),130					get_account_id_from_seed::<sr25519::Public>("Bob"),131				],132				1000.into(),133			)134		},135		// Bootnodes136		vec![],137		// Telemetry138		None,139		// Protocol ID140		None,141		None,142		// Properties143		Some(properties),144		// Extensions145		Extensions {146			relay_chain: "rococo-dev".into(),147			para_id: 1000,148		},149	)150}151152pub fn local_testnet_rococo_config() -> OpalChainSpec {153	OpalChainSpec::from_genesis(154		// Name155		"Local Testnet",156		// ID157		"local_testnet",158		ChainType::Local,159		move || {160			testnet_genesis(161				// Sudo account162				get_account_id_from_seed::<sr25519::Public>("Alice"),163				vec![164					get_from_seed::<AuraId>("Alice"),165					get_from_seed::<AuraId>("Bob"),166				],167				// Pre-funded accounts168				vec![169					get_account_id_from_seed::<sr25519::Public>("Alice"),170					get_account_id_from_seed::<sr25519::Public>("Bob"),171					get_account_id_from_seed::<sr25519::Public>("Charlie"),172					get_account_id_from_seed::<sr25519::Public>("Dave"),173					get_account_id_from_seed::<sr25519::Public>("Eve"),174					get_account_id_from_seed::<sr25519::Public>("Ferdie"),175					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),176					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),177					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),178					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),179					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),180					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),181				],182				1000.into(),183			)184		},185		// Bootnodes186		vec![],187		// Telemetry188		None,189		// Protocol ID190		None,191		None,192		// Properties193		None,194		// Extensions195		Extensions {196			relay_chain: "rococo-local".into(),197			para_id: 1000,198		},199	)200}201202pub fn local_testnet_westend_config() -> OpalChainSpec {203	OpalChainSpec::from_genesis(204		// Name205		"Local Testnet",206		// ID207		"local_testnet",208		ChainType::Local,209		move || {210			testnet_genesis(211				// Sudo account212				get_account_id_from_seed::<sr25519::Public>("Alice"),213				vec![214					get_from_seed::<AuraId>("Alice"),215					get_from_seed::<AuraId>("Bob"),216					get_from_seed::<AuraId>("Charlie"),217					get_from_seed::<AuraId>("Dave"),218					get_from_seed::<AuraId>("Eve"),219				],220				// Pre-funded accounts221				vec![222					get_account_id_from_seed::<sr25519::Public>("Alice"),223					get_account_id_from_seed::<sr25519::Public>("Bob"),224					get_account_id_from_seed::<sr25519::Public>("Charlie"),225					get_account_id_from_seed::<sr25519::Public>("Dave"),226					get_account_id_from_seed::<sr25519::Public>("Eve"),227					get_account_id_from_seed::<sr25519::Public>("Ferdie"),228					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),229					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),230					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),231					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),232					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),233					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),234				],235				1000.into(),236			)237		},238		// Bootnodes239		vec![],240		// Telemetry241		None,242		// Protocol ID243		None,244		None,245		// Properties246		None,247		// Extensions248		Extensions {249			relay_chain: "westend-local".into(),250			para_id: 1000,251		},252	)253}254255fn testnet_genesis(256	root_key: AccountId,257	initial_authorities: Vec<AuraId>,258	endowed_accounts: Vec<AccountId>,259	id: ParaId,260) -> opal_runtime::GenesisConfig {261	use opal_runtime::*;262263	GenesisConfig {264		system: SystemConfig {265			code: WASM_BINARY266				.expect("WASM binary was not build, please build it!")267				.to_vec(),268		},269		balances: BalancesConfig {270			balances: endowed_accounts271				.iter()272				.cloned()273				// 1e13 UNQ274				.map(|k| (k, 1 << 100))275				.collect(),276		},277		treasury: Default::default(),278		sudo: SudoConfig {279			key: Some(root_key),280		},281		vesting: VestingConfig { vesting: vec![] },282		parachain_info: ParachainInfoConfig { parachain_id: id },283		parachain_system: Default::default(),284		aura: AuraConfig {285			authorities: initial_authorities,286		},287		aura_ext: Default::default(),288		evm: EVMConfig {289			accounts: BTreeMap::new(),290		},291		ethereum: EthereumConfig {},292	}293}
after · node/cli/src/chain_spec.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use cumulus_primitives_core::ParaId;18use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};19use sc_service::ChainType;20use sp_core::{sr25519, Pair, Public};21use sp_runtime::traits::{IdentifyAccount, Verify};22use std::collections::BTreeMap;2324use serde::{Deserialize, Serialize};25use serde_json::map::Map;2627use unique_runtime_common::types::*;2829/// The `ChainSpec` parameterized for the unique runtime.30#[cfg(feature = "unique-runtime")]31pub type UniqueChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;3233/// The `ChainSpec` parameterized for the quartz runtime.34#[cfg(feature = "quartz-runtime")]35pub type QuartzChainSpec = sc_service::GenericChainSpec<quartz_runtime::GenesisConfig, Extensions>;3637/// The `ChainSpec` parameterized for the opal runtime.38pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;3940pub enum RuntimeId {41	Unique,42	Quartz,43	Opal,44	Unknown(String),45}4647pub trait RuntimeIdentification {48	fn runtime_id(&self) -> RuntimeId;49}5051impl RuntimeIdentification for Box<dyn sc_service::ChainSpec> {52	fn runtime_id(&self) -> RuntimeId {53		#[cfg(feature = "unique-runtime")]54		if self.id().starts_with("unique") {55			return RuntimeId::Unique;56		}5758		#[cfg(feature = "quartz-runtime")]59		if self.id().starts_with("quartz") {60			return RuntimeId::Quartz;61		}6263		if self.id().starts_with("opal") {64			return RuntimeId::Opal;65		}6667		RuntimeId::Unknown(self.id().into())68	}69}7071/// Helper function to generate a crypto pair from seed72pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {73	TPublic::Pair::from_string(&format!("//{}", seed), None)74		.expect("static values are valid; qed")75		.public()76}7778/// The extensions for the [`ChainSpec`].79#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]80#[serde(deny_unknown_fields)]81pub struct Extensions {82	/// The relay chain of the Parachain.83	pub relay_chain: String,84	/// The id of the Parachain.85	pub para_id: u32,86}8788impl Extensions {89	/// Try to get the extension from the given `ChainSpec`.90	pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {91		sc_chain_spec::get_extension(chain_spec.extensions())92	}93}9495type AccountPublic = <Signature as Verify>::Signer;9697/// Helper function to generate an account ID from seed98pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId99where100	AccountPublic: From<<TPublic::Pair as Pair>::Public>,101{102	AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()103}104105pub fn development_config() -> OpalChainSpec {106	let mut properties = Map::new();107	properties.insert("tokenSymbol".into(), "OPL".into());108	properties.insert("tokenDecimals".into(), 15.into());109	properties.insert("ss58Format".into(), 42.into());110111	OpalChainSpec::from_genesis(112		// Name113		"Development",114		// ID115		"dev",116		ChainType::Local,117		move || {118			testnet_genesis(119				// Sudo account120				get_account_id_from_seed::<sr25519::Public>("Alice"),121				vec![122					get_from_seed::<AuraId>("Alice"),123					get_from_seed::<AuraId>("Bob"),124				],125				// Pre-funded accounts126				vec![127					get_account_id_from_seed::<sr25519::Public>("Alice"),128					get_account_id_from_seed::<sr25519::Public>("Bob"),129				],130				1000.into(),131			)132		},133		// Bootnodes134		vec![],135		// Telemetry136		None,137		// Protocol ID138		None,139		None,140		// Properties141		Some(properties),142		// Extensions143		Extensions {144			relay_chain: "rococo-dev".into(),145			para_id: 1000,146		},147	)148}149150pub fn local_testnet_rococo_config() -> OpalChainSpec {151	OpalChainSpec::from_genesis(152		// Name153		"Local Testnet",154		// ID155		"local_testnet",156		ChainType::Local,157		move || {158			testnet_genesis(159				// Sudo account160				get_account_id_from_seed::<sr25519::Public>("Alice"),161				vec![162					get_from_seed::<AuraId>("Alice"),163					get_from_seed::<AuraId>("Bob"),164				],165				// Pre-funded accounts166				vec![167					get_account_id_from_seed::<sr25519::Public>("Alice"),168					get_account_id_from_seed::<sr25519::Public>("Bob"),169					get_account_id_from_seed::<sr25519::Public>("Charlie"),170					get_account_id_from_seed::<sr25519::Public>("Dave"),171					get_account_id_from_seed::<sr25519::Public>("Eve"),172					get_account_id_from_seed::<sr25519::Public>("Ferdie"),173					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),174					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),175					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),176					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),177					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),178					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),179				],180				1000.into(),181			)182		},183		// Bootnodes184		vec![],185		// Telemetry186		None,187		// Protocol ID188		None,189		None,190		// Properties191		None,192		// Extensions193		Extensions {194			relay_chain: "rococo-local".into(),195			para_id: 1000,196		},197	)198}199200pub fn local_testnet_westend_config() -> OpalChainSpec {201	OpalChainSpec::from_genesis(202		// Name203		"Local Testnet",204		// ID205		"local_testnet",206		ChainType::Local,207		move || {208			testnet_genesis(209				// Sudo account210				get_account_id_from_seed::<sr25519::Public>("Alice"),211				vec![212					get_from_seed::<AuraId>("Alice"),213					get_from_seed::<AuraId>("Bob"),214					get_from_seed::<AuraId>("Charlie"),215					get_from_seed::<AuraId>("Dave"),216					get_from_seed::<AuraId>("Eve"),217				],218				// Pre-funded accounts219				vec![220					get_account_id_from_seed::<sr25519::Public>("Alice"),221					get_account_id_from_seed::<sr25519::Public>("Bob"),222					get_account_id_from_seed::<sr25519::Public>("Charlie"),223					get_account_id_from_seed::<sr25519::Public>("Dave"),224					get_account_id_from_seed::<sr25519::Public>("Eve"),225					get_account_id_from_seed::<sr25519::Public>("Ferdie"),226					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),227					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),228					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),229					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),230					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),231					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),232				],233				1000.into(),234			)235		},236		// Bootnodes237		vec![],238		// Telemetry239		None,240		// Protocol ID241		None,242		None,243		// Properties244		None,245		// Extensions246		Extensions {247			relay_chain: "westend-local".into(),248			para_id: 1000,249		},250	)251}252253fn testnet_genesis(254	root_key: AccountId,255	initial_authorities: Vec<AuraId>,256	endowed_accounts: Vec<AccountId>,257	id: ParaId,258) -> opal_runtime::GenesisConfig {259	use opal_runtime::*;260261	GenesisConfig {262		system: SystemConfig {263			code: WASM_BINARY264				.expect("WASM binary was not build, please build it!")265				.to_vec(),266		},267		balances: BalancesConfig {268			balances: endowed_accounts269				.iter()270				.cloned()271				// 1e13 UNQ272				.map(|k| (k, 1 << 100))273				.collect(),274		},275		treasury: Default::default(),276		sudo: SudoConfig {277			key: Some(root_key),278		},279		vesting: VestingConfig { vesting: vec![] },280		parachain_info: ParachainInfoConfig { parachain_id: id },281		parachain_system: Default::default(),282		aura: AuraConfig {283			authorities: initial_authorities,284		},285		aura_ext: Default::default(),286		evm: EVMConfig {287			accounts: BTreeMap::new(),288		},289		ethereum: EthereumConfig {},290	}291}
modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -44,7 +44,6 @@
 #[cfg(feature = "quartz-runtime")]
 use crate::service::QuartzRuntimeExecutor;
 
-#[cfg(feature = "opal-runtime")]
 use crate::service::OpalRuntimeExecutor;
 
 use codec::Encode;
@@ -82,7 +81,7 @@
 		"" | "local" => Box::new(chain_spec::local_testnet_rococo_config()),
 		path => {
 			let path = std::path::PathBuf::from(path);
-			let chain_spec = Box::new(sc_service::GenericChainSpec::<()>::from_json_file(
+			let chain_spec = Box::new(chain_spec::OpalChainSpec::from_json_file(
 				path.clone(),
 			)?) as Box<dyn sc_service::ChainSpec>;
 
@@ -93,9 +92,7 @@
 				#[cfg(feature = "quartz-runtime")]
 				RuntimeId::Quartz => Box::new(chain_spec::QuartzChainSpec::from_json_file(path)?),
 
-				#[cfg(feature = "opal-runtime")]
 				RuntimeId::Opal => Box::new(chain_spec::OpalChainSpec::from_json_file(path)?),
-
 				RuntimeId::Unknown(chain) => return Err(no_runtime_err!(chain)),
 			}
 		}
@@ -147,9 +144,7 @@
 			#[cfg(feature = "quartz-runtime")]
 			RuntimeId::Quartz => &quartz_runtime::VERSION,
 
-			#[cfg(feature = "opal-runtime")]
 			RuntimeId::Opal => &opal_runtime::VERSION,
-
 			RuntimeId::Unknown(chain) => panic!("{}", no_runtime_err!(chain)),
 		}
 	}
@@ -241,7 +236,6 @@
 				runner, $components, $cli, $cmd, $config, $( $code )*
 			),
 
-			#[cfg(feature = "opal-runtime")]
 			RuntimeId::Opal => async_run_with_runtime!(
 				opal_runtime::RuntimeApi, OpalRuntimeExecutor,
 				runner, $components, $cli, $cmd, $config, $( $code )*
@@ -359,9 +353,7 @@
 					#[cfg(feature = "quartz-runtime")]
 					RuntimeId::Quartz => cmd.run::<Block, QuartzRuntimeExecutor>(config),
 
-					#[cfg(feature = "opal-runtime")]
 					RuntimeId::Opal => cmd.run::<Block, OpalRuntimeExecutor>(config),
-
 					RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into()),
 				})
 			} else {
@@ -438,7 +430,6 @@
 					.map(|r| r.0)
 					.map_err(Into::into),
 
-					#[cfg(feature = "opal-runtime")]
 					RuntimeId::Opal => crate::service::start_node::<
 						opal_runtime::Runtime,
 						opal_runtime::RuntimeApi,
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -95,7 +95,6 @@
 	}
 }
 
-#[cfg(feature = "opal-runtime")]
 impl NativeExecutionDispatch for OpalRuntimeExecutor {
 	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
 
addednode/rpc/src/lib.rs.expdiffbeforeafterboth
--- /dev/null
+++ b/node/rpc/src/lib.rs.exp
@@ -0,0 +1,294 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+use sp_runtime::traits::BlakeTwo256;
+use fc_rpc::{
+	EthBlockDataCache, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override,
+	StorageOverride, SchemaV2Override, SchemaV3Override,
+};
+use fc_rpc_core::types::{FilterPool, FeeHistoryCache};
+use jsonrpc_pubsub::manager::SubscriptionManager;
+use pallet_ethereum::EthereumStorageSchema;
+use sc_client_api::{
+	backend::{AuxStore, StorageProvider},
+	client::BlockchainEvents,
+	StateBackend, Backend,
+};
+use sc_finality_grandpa::{
+	FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
+};
+use sc_network::NetworkService;
+use sc_rpc::SubscriptionTaskExecutor;
+pub use sc_rpc_api::DenyUnsafe;
+use sc_transaction_pool::{ChainApi, Pool};
+use sp_api::ProvideRuntimeApi;
+use sp_block_builder::BlockBuilder;
+use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
+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};
+
+/// Public io handler for exporting into other modules
+pub type IoHandler = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
+
+/// Extra dependencies for GRANDPA
+pub struct GrandpaDeps<B> {
+	/// Voting round info.
+	pub shared_voter_state: SharedVoterState,
+	/// Authority set info.
+	pub shared_authority_set: SharedAuthoritySet<Hash, BlockNumber>,
+	/// Receives notifications about justification events from Grandpa.
+	pub justification_stream: GrandpaJustificationStream<Block>,
+	/// Executor to drive the subscription manager in the Grandpa RPC handler.
+	pub subscription_executor: SubscriptionTaskExecutor,
+	/// Finality proof provider.
+	pub finality_provider: Arc<FinalityProofProvider<B, Block>>,
+}
+
+/// Full client dependencies.
+pub struct FullDeps<C, P, SC, CA: ChainApi> {
+	/// The client instance to use.
+	pub client: Arc<C>,
+	/// Transaction pool instance.
+	pub pool: Arc<P>,
+	/// Graph pool instance.
+	pub graph: Arc<Pool<CA>>,
+	/// The SelectChain Strategy
+	pub select_chain: SC,
+	/// The Node authority flag
+	pub is_authority: bool,
+	/// Whether to enable dev signer
+	pub enable_dev_signer: bool,
+	/// Network service
+	pub network: Arc<NetworkService<Block, Hash>>,
+	/// Whether to deny unsafe calls
+	pub deny_unsafe: DenyUnsafe,
+	/// EthFilterApi pool.
+	pub filter_pool: Option<FilterPool>,
+	/// Backend.
+	pub backend: Arc<fc_db::Backend<Block>>,
+	/// Maximum number of logs in a query.
+	pub max_past_logs: u32,
+	/// Maximum fee history cache size.
+	pub fee_history_limit: u64,
+	/// Fee history cache.
+	pub fee_history_cache: FeeHistoryCache,
+	/// Cache for Ethereum block data.
+	pub block_data_cache: Arc<EthBlockDataCache<Block>>,
+}
+
+struct AccountCodes<C, B, CAId> {
+	client: Arc<C>,
+	_blk_marker: PhantomData<B>,
+	_caid_marker: PhantomData<CAId>,
+}
+
+impl<C, Block, CAId> AccountCodes<C, Block, CAId>
+where
+	Block: sp_api::BlockT,
+	C: ProvideRuntimeApi<Block>,
+{
+	fn new(client: Arc<C>) -> Self {
+		Self {
+			client,
+			_blk_marker: PhantomData,
+			_caid_marker: PhantomData,
+		}
+	}
+}
+
+impl<C, Block, CAId> fc_rpc::AccountCodeProvider<Block> for AccountCodes<C, Block, CAId>
+where
+	Block: sp_api::BlockT,
+	C: ProvideRuntimeApi<Block>,
+	C::Api: up_rpc::UniqueApi<Block, CAId, AccountId>,
+	CAId: pallet_common::account::CrossAccountId<sp_runtime::AccountId32>,
+{
+	fn code(&self, block: &sp_api::BlockId<Block>, account: sp_core::H160) -> Option<Vec<u8>> {
+		use up_rpc::UniqueApi;
+		self.client
+			.runtime_api()
+			.eth_contract_code(block, account)
+			.ok()
+			.flatten()
+	}
+}
+
+pub fn overrides_handle<C, BE, CAId>(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, CAId, AccountId>,
+	BE: Backend<Block> + 'static,
+	BE::State: StateBackend<BlakeTwo256>,
+	CAId: pallet_common::account::CrossAccountId<sp_runtime::AccountId32> + Sync + Send + '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, CAId>::new(client.clone())),
+		)) as Box<dyn StorageOverride<_> + Send + Sync>,
+	);
+	overrides_map.insert(
+		EthereumStorageSchema::V2,
+		Box::new(SchemaV2Override::new(client.clone()))
+			as Box<dyn StorageOverride<_> + Send + Sync>,
+	);
+	overrides_map.insert(
+		EthereumStorageSchema::V3,
+		Box::new(SchemaV3Override::new(client.clone()))
+			as Box<dyn StorageOverride<_> + Send + Sync>,
+	);
+
+	Arc::new(OverrideHandle {
+		schemas: overrides_map,
+		fallback: Box::new(RuntimeApiStorageOverride::new(client)),
+	})
+}
+
+/// Instantiate all Full RPC extensions.
+pub fn create_full<C, P, SC, CA, CAId, A, B>(
+	deps: FullDeps<C, P, SC, CA>,
+	subscription_task_executor: SubscriptionTaskExecutor,
+) -> jsonrpc_core::IoHandler<sc_rpc_api::Metadata>
+where
+	C: ProvideRuntimeApi<Block> + StorageProvider<Block, B> + AuxStore,
+	C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
+	C: Send + Sync + 'static,
+	C: BlockchainEvents<Block>,
+	C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
+	C::Api: BlockBuilder<Block>,
+	// 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, CAId, 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,
+	CAId: pallet_common::account::CrossAccountId<sp_runtime::AccountId32> + Sync + Send + 'static,
+{
+	use fc_rpc::{
+		EthApi, EthApiServer, EthDevSigner, EthFilterApi, EthFilterApiServer, EthPubSubApi,
+		EthPubSubApiServer, EthSigner, HexEncodedIdProvider, NetApi, NetApiServer, Web3Api,
+		Web3ApiServer,
+	};
+	use uc_rpc::{UniqueApi, Unique};
+	// use pallet_contracts_rpc::{Contracts, ContractsApi};
+	use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
+	use substrate_frame_rpc_system::{FullSystem, SystemApi};
+
+	let mut io = jsonrpc_core::IoHandler::default();
+	let FullDeps {
+		client,
+		pool,
+		graph,
+		select_chain: _,
+		fee_history_limit,
+		fee_history_cache,
+		block_data_cache,
+		enable_dev_signer,
+		is_authority,
+		network,
+		deny_unsafe,
+		filter_pool,
+		backend,
+		max_past_logs,
+	} = deps;
+
+	io.extend_with(SystemApi::to_delegate(FullSystem::new(
+		client.clone(),
+		pool.clone(),
+		deny_unsafe,
+	)));
+
+	io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(
+		client.clone(),
+	)));
+
+	// io.extend_with(ContractsApi::to_delegate(Contracts::new(client.clone())));
+
+	let mut signers = Vec::new();
+	if enable_dev_signer {
+		signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);
+	}
+
+	let overrides = overrides_handle::<_, _, CAId>(client.clone());
+
+	io.extend_with(EthApiServer::to_delegate(EthApi::new(
+		client.clone(),
+		pool.clone(),
+		graph,
+		runtime::TransactionConverter,
+		network.clone(),
+		signers,
+		overrides.clone(),
+		backend.clone(),
+		is_authority,
+		max_past_logs,
+		block_data_cache.clone(),
+		fee_history_limit,
+		fee_history_cache,
+	)));
+	io.extend_with(UniqueApi::to_delegate(Unique::new(client.clone())));
+
+	if let Some(filter_pool) = filter_pool {
+		io.extend_with(EthFilterApiServer::to_delegate(EthFilterApi::new(
+			client.clone(),
+			backend,
+			filter_pool,
+			500_usize, // max stored filters
+			max_past_logs,
+			block_data_cache,
+		)));
+	}
+
+	io.extend_with(NetApiServer::to_delegate(NetApi::new(
+		client.clone(),
+		network.clone(),
+		// Whether to format the `peer_count` response as Hex (default) or not.
+		true,
+	)));
+
+	io.extend_with(Web3ApiServer::to_delegate(Web3Api::new(client.clone())));
+
+	io.extend_with(EthPubSubApiServer::to_delegate(EthPubSubApi::new(
+		pool,
+		client,
+		network,
+		SubscriptionManager::<HexEncodedIdProvider>::with_id_provider(
+			HexEncodedIdProvider::default(),
+			Arc::new(subscription_task_executor),
+		),
+		overrides,
+	)));
+
+	io
+}