git.delta.rocks / unique-network / refs/commits / 4657e257e343

difftreelog

Adjust node to new runtimes

Daniel Shiposha2022-03-05parent: #1f97da5.patch.diff
in: master

6 files changed

modifiednode/cli/Cargo.tomldiffbeforeafterboth
--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -239,8 +239,17 @@
 # Local dependencies
 
 [dependencies.unique-runtime]
-path = '../../runtime'
+path = '../../runtime/unique'
+optional = true
+
+[dependencies.quartz-runtime]
+path = '../../runtime/quartz'
+optional = true
 
+[dependencies.opal-runtime]
+path = '../../runtime/opal'
+optional = true
+
 [dependencies.up-data-structs]
 path = "../../primitives/data-structs"
 default-features = false
@@ -283,10 +292,10 @@
 fp-rpc = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
 pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
 
-unique-rpc = { path = "../rpc" }
+unique-rpc = { default-features = false, path = "../rpc" }
 
 [features]
-default = []
+default = ["unique-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 unique_runtime::*;19use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};20use sc_service::ChainType;21use sp_core::{sr25519, Pair, Public};22use sp_runtime::traits::{IdentifyAccount, Verify};23use std::collections::BTreeMap;2425use serde::{Deserialize, Serialize};26use serde_json::map::Map;2728/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.29pub type ChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;3031/// Helper function to generate a crypto pair from seed32pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {33	TPublic::Pair::from_string(&format!("//{}", seed), None)34		.expect("static values are valid; qed")35		.public()36}3738/// The extensions for the [`ChainSpec`].39#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]40#[serde(deny_unknown_fields)]41pub struct Extensions {42	/// The relay chain of the Parachain.43	pub relay_chain: String,44	/// The id of the Parachain.45	pub para_id: u32,46}4748impl Extensions {49	/// Try to get the extension from the given `ChainSpec`.50	pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {51		sc_chain_spec::get_extension(chain_spec.extensions())52	}53}5455type AccountPublic = <Signature as Verify>::Signer;5657/// Helper function to generate an account ID from seed58pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId59where60	AccountPublic: From<<TPublic::Pair as Pair>::Public>,61{62	AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()63}6465pub fn development_config() -> ChainSpec {66	let mut properties = Map::new();67	properties.insert("tokenSymbol".into(), "OPL".into());68	properties.insert("tokenDecimals".into(), 15.into());69	properties.insert("ss58Format".into(), 42.into());7071	ChainSpec::from_genesis(72		// Name73		"Development",74		// ID75		"dev",76		ChainType::Local,77		move || {78			testnet_genesis(79				// Sudo account80				get_account_id_from_seed::<sr25519::Public>("Alice"),81				vec![82					get_from_seed::<AuraId>("Alice"),83					get_from_seed::<AuraId>("Bob"),84				],85				// Pre-funded accounts86				vec![87					get_account_id_from_seed::<sr25519::Public>("Alice"),88					get_account_id_from_seed::<sr25519::Public>("Bob"),89				],90				1000.into(),91			)92		},93		// Bootnodes94		vec![],95		// Telemetry96		None,97		// Protocol ID98		None,99		None,100		// Properties101		Some(properties),102		// Extensions103		Extensions {104			relay_chain: "rococo-dev".into(),105			para_id: 1000,106		},107	)108}109110pub fn local_testnet_rococo_config() -> ChainSpec {111	ChainSpec::from_genesis(112		// Name113		"Local Testnet",114		// ID115		"local_testnet",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					get_account_id_from_seed::<sr25519::Public>("Charlie"),130					get_account_id_from_seed::<sr25519::Public>("Dave"),131					get_account_id_from_seed::<sr25519::Public>("Eve"),132					get_account_id_from_seed::<sr25519::Public>("Ferdie"),133					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),134					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),135					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),136					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),137					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),138					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),139				],140				1000.into(),141			)142		},143		// Bootnodes144		vec![],145		// Telemetry146		None,147		// Protocol ID148		None,149		None,150		// Properties151		None,152		// Extensions153		Extensions {154			relay_chain: "rococo-local".into(),155			para_id: 1000,156		},157	)158}159160pub fn local_testnet_westend_config() -> ChainSpec {161	ChainSpec::from_genesis(162		// Name163		"Local Testnet",164		// ID165		"local_testnet",166		ChainType::Local,167		move || {168			testnet_genesis(169				// Sudo account170				get_account_id_from_seed::<sr25519::Public>("Alice"),171				vec![172					get_from_seed::<AuraId>("Alice"),173					get_from_seed::<AuraId>("Bob"),174					get_from_seed::<AuraId>("Charlie"),175					get_from_seed::<AuraId>("Dave"),176					get_from_seed::<AuraId>("Eve"),177				],178				// Pre-funded accounts179				vec![180					get_account_id_from_seed::<sr25519::Public>("Alice"),181					get_account_id_from_seed::<sr25519::Public>("Bob"),182					get_account_id_from_seed::<sr25519::Public>("Charlie"),183					get_account_id_from_seed::<sr25519::Public>("Dave"),184					get_account_id_from_seed::<sr25519::Public>("Eve"),185					get_account_id_from_seed::<sr25519::Public>("Ferdie"),186					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),187					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),188					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),189					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),190					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),191					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),192				],193				1000.into(),194			)195		},196		// Bootnodes197		vec![],198		// Telemetry199		None,200		// Protocol ID201		None,202		None,203		// Properties204		None,205		// Extensions206		Extensions {207			relay_chain: "westend-local".into(),208			para_id: 1000,209		},210	)211}212213fn testnet_genesis(214	root_key: AccountId,215	initial_authorities: Vec<AuraId>,216	endowed_accounts: Vec<AccountId>,217	id: ParaId,218) -> GenesisConfig {219	GenesisConfig {220		system: unique_runtime::SystemConfig {221			code: unique_runtime::WASM_BINARY222				.expect("WASM binary was not build, please build it!")223				.to_vec(),224		},225		balances: BalancesConfig {226			balances: endowed_accounts227				.iter()228				.cloned()229				// 1e13 UNQ230				.map(|k| (k, 1 << 100))231				.collect(),232		},233		treasury: Default::default(),234		sudo: SudoConfig {235			key: Some(root_key),236		},237		vesting: VestingConfig { vesting: vec![] },238		parachain_info: unique_runtime::ParachainInfoConfig { parachain_id: id },239		parachain_system: Default::default(),240		aura: unique_runtime::AuraConfig {241			authorities: initial_authorities,242		},243		aura_ext: Default::default(),244		evm: EVMConfig {245			accounts: BTreeMap::new(),246		},247		ethereum: EthereumConfig {},248	}249}
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;2627#[cfg(feature = "unique-runtime")]28use unique_runtime as runtime;2930#[cfg(feature = "quartz-runtime")]31use quartz_runtime as runtime;3233#[cfg(feature = "opal-runtime")]34use opal_runtime as runtime;3536use runtime::{*, opaque::*};3738/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.39pub type ChainSpec = sc_service::GenericChainSpec<runtime::GenesisConfig, Extensions>;4041/// Helper function to generate a crypto pair from seed42pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {43	TPublic::Pair::from_string(&format!("//{}", seed), None)44		.expect("static values are valid; qed")45		.public()46}4748/// The extensions for the [`ChainSpec`].49#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]50#[serde(deny_unknown_fields)]51pub struct Extensions {52	/// The relay chain of the Parachain.53	pub relay_chain: String,54	/// The id of the Parachain.55	pub para_id: u32,56}5758impl Extensions {59	/// Try to get the extension from the given `ChainSpec`.60	pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {61		sc_chain_spec::get_extension(chain_spec.extensions())62	}63}6465type AccountPublic = <Signature as Verify>::Signer;6667/// Helper function to generate an account ID from seed68pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId69where70	AccountPublic: From<<TPublic::Pair as Pair>::Public>,71{72	AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()73}7475pub fn development_config() -> ChainSpec {76	let mut properties = Map::new();77	properties.insert("tokenSymbol".into(), "OPL".into());78	properties.insert("tokenDecimals".into(), 15.into());79	properties.insert("ss58Format".into(), 42.into());8081	ChainSpec::from_genesis(82		// Name83		"Development",84		// ID85		"dev",86		ChainType::Local,87		move || {88			testnet_genesis(89				// Sudo account90				get_account_id_from_seed::<sr25519::Public>("Alice"),91				vec![92					get_from_seed::<AuraId>("Alice"),93					get_from_seed::<AuraId>("Bob"),94				],95				// Pre-funded accounts96				vec![97					get_account_id_from_seed::<sr25519::Public>("Alice"),98					get_account_id_from_seed::<sr25519::Public>("Bob"),99				],100				1000.into(),101			)102		},103		// Bootnodes104		vec![],105		// Telemetry106		None,107		// Protocol ID108		None,109		None,110		// Properties111		Some(properties),112		// Extensions113		Extensions {114			relay_chain: "rococo-dev".into(),115			para_id: 1000,116		},117	)118}119120pub fn local_testnet_rococo_config() -> ChainSpec {121	ChainSpec::from_genesis(122		// Name123		"Local Testnet",124		// ID125		"local_testnet",126		ChainType::Local,127		move || {128			testnet_genesis(129				// Sudo account130				get_account_id_from_seed::<sr25519::Public>("Alice"),131				vec![132					get_from_seed::<AuraId>("Alice"),133					get_from_seed::<AuraId>("Bob"),134				],135				// Pre-funded accounts136				vec![137					get_account_id_from_seed::<sr25519::Public>("Alice"),138					get_account_id_from_seed::<sr25519::Public>("Bob"),139					get_account_id_from_seed::<sr25519::Public>("Charlie"),140					get_account_id_from_seed::<sr25519::Public>("Dave"),141					get_account_id_from_seed::<sr25519::Public>("Eve"),142					get_account_id_from_seed::<sr25519::Public>("Ferdie"),143					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),144					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),145					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),146					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),147					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),148					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),149				],150				1000.into(),151			)152		},153		// Bootnodes154		vec![],155		// Telemetry156		None,157		// Protocol ID158		None,159		None,160		// Properties161		None,162		// Extensions163		Extensions {164			relay_chain: "rococo-local".into(),165			para_id: 1000,166		},167	)168}169170pub fn local_testnet_westend_config() -> ChainSpec {171	ChainSpec::from_genesis(172		// Name173		"Local Testnet",174		// ID175		"local_testnet",176		ChainType::Local,177		move || {178			testnet_genesis(179				// Sudo account180				get_account_id_from_seed::<sr25519::Public>("Alice"),181				vec![182					get_from_seed::<AuraId>("Alice"),183					get_from_seed::<AuraId>("Bob"),184					get_from_seed::<AuraId>("Charlie"),185					get_from_seed::<AuraId>("Dave"),186					get_from_seed::<AuraId>("Eve"),187				],188				// Pre-funded accounts189				vec![190					get_account_id_from_seed::<sr25519::Public>("Alice"),191					get_account_id_from_seed::<sr25519::Public>("Bob"),192					get_account_id_from_seed::<sr25519::Public>("Charlie"),193					get_account_id_from_seed::<sr25519::Public>("Dave"),194					get_account_id_from_seed::<sr25519::Public>("Eve"),195					get_account_id_from_seed::<sr25519::Public>("Ferdie"),196					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),197					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),198					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),199					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),200					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),201					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),202				],203				1000.into(),204			)205		},206		// Bootnodes207		vec![],208		// Telemetry209		None,210		// Protocol ID211		None,212		None,213		// Properties214		None,215		// Extensions216		Extensions {217			relay_chain: "westend-local".into(),218			para_id: 1000,219		},220	)221}222223fn testnet_genesis(224	root_key: AccountId,225	initial_authorities: Vec<AuraId>,226	endowed_accounts: Vec<AccountId>,227	id: ParaId,228) -> GenesisConfig {229	GenesisConfig {230		system: runtime::SystemConfig {231			code: runtime::WASM_BINARY232				.expect("WASM binary was not build, please build it!")233				.to_vec(),234		},235		balances: BalancesConfig {236			balances: endowed_accounts237				.iter()238				.cloned()239				// 1e13 UNQ240				.map(|k| (k, 1 << 100))241				.collect(),242		},243		treasury: Default::default(),244		sudo: SudoConfig {245			key: Some(root_key),246		},247		vesting: VestingConfig { vesting: vec![] },248		parachain_info: runtime::ParachainInfoConfig { parachain_id: id },249		parachain_system: Default::default(),250		aura: runtime::AuraConfig {251			authorities: initial_authorities,252		},253		aura_ext: Default::default(),254		evm: EVMConfig {255			accounts: BTreeMap::new(),256		},257		ethereum: EthereumConfig {},258	}259}
modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -41,7 +41,6 @@
 use cumulus_primitives_core::ParaId;
 use cumulus_client_service::genesis::generate_genesis_block;
 use log::info;
-use unique_runtime::Block;
 use polkadot_parachain::primitives::AccountIdConversion;
 use sc_cli::{
 	ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
@@ -54,6 +53,17 @@
 use sp_runtime::traits::Block as BlockT;
 use std::{io::Write, net::SocketAddr};
 
+#[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::Block;
+
 fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
 	Ok(match id {
 		"westend-local" => Box::new(chain_spec::local_testnet_westend_config()),
@@ -104,7 +114,7 @@
 	}
 
 	fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
-		&unique_runtime::VERSION
+		&runtime::VERSION
 	}
 }
 
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -26,8 +26,17 @@
 
 use unique_rpc::overrides_handle;
 // Local Runtime Types
-use unique_runtime::RuntimeApi;
+#[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;
+
 // Cumulus Imports
 use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};
 use cumulus_client_consensus_common::ParachainConsensus;
@@ -69,11 +78,11 @@
 	type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
 
 	fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
-		unique_runtime::api::dispatch(method, data)
+		runtime::api::dispatch(method, data)
 	}
 
 	fn native_version() -> sc_executor::NativeVersion {
-		unique_runtime::native_version()
+		runtime::native_version()
 	}
 }
 
modifiednode/rpc/Cargo.tomldiffbeforeafterboth
--- a/node/rpc/Cargo.toml
+++ b/node/rpc/Cargo.toml
@@ -51,7 +51,10 @@
 pallet-unique = { path = "../../pallets/unique" }
 uc-rpc = { path = "../../client/rpc" }
 up-rpc = { path = "../../primitives/rpc" }
-unique-runtime = { path = "../../runtime" }
+unique-runtime = { path = "../../runtime/unique", optional = true }
+quartz-runtime = { path = "../../runtime/quartz", optional = true }
+opal-runtime = { path = "../../runtime/opal", optional = true }
 
 [features]
+default = ["unique-runtime"]
 std = []
modifiednode/rpc/src/lib.rsdiffbeforeafterboth
--- a/node/rpc/src/lib.rs
+++ b/node/rpc/src/lib.rs
@@ -15,7 +15,6 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use sp_runtime::traits::BlakeTwo256;
-use unique_runtime::{Hash, AccountId, CrossAccountId, Index, opaque::Block, BlockNumber, Balance};
 use fc_rpc::{
 	EthBlockDataCache, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override,
 	StorageOverride, SchemaV2Override, SchemaV3Override,
@@ -41,6 +40,17 @@
 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>;
 
@@ -231,7 +241,7 @@
 		client.clone(),
 		pool.clone(),
 		graph,
-		unique_runtime::TransactionConverter,
+		runtime::TransactionConverter,
 		network.clone(),
 		signers,
 		overrides.clone(),