From 4657e257e343c685cce0259e3a4670acccdcae1e Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Sat, 05 Mar 2022 18:23:51 +0000 Subject: [PATCH] Adjust node to new runtimes --- --- 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', --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -15,7 +15,6 @@ // along with Unique Network. If not, see . use cumulus_primitives_core::ParaId; -use unique_runtime::*; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sc_service::ChainType; use sp_core::{sr25519, Pair, Public}; @@ -25,8 +24,19 @@ use serde::{Deserialize, Serialize}; use serde_json::map::Map; +#[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::*}; + /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. -pub type ChainSpec = sc_service::GenericChainSpec; +pub type ChainSpec = sc_service::GenericChainSpec; /// Helper function to generate a crypto pair from seed pub fn get_from_seed(seed: &str) -> ::Public { @@ -217,8 +227,8 @@ id: ParaId, ) -> GenesisConfig { GenesisConfig { - system: unique_runtime::SystemConfig { - code: unique_runtime::WASM_BINARY + system: runtime::SystemConfig { + code: runtime::WASM_BINARY .expect("WASM binary was not build, please build it!") .to_vec(), }, @@ -235,9 +245,9 @@ key: Some(root_key), }, vesting: VestingConfig { vesting: vec![] }, - parachain_info: unique_runtime::ParachainInfoConfig { parachain_id: id }, + parachain_info: runtime::ParachainInfoConfig { parachain_id: id }, parachain_system: Default::default(), - aura: unique_runtime::AuraConfig { + aura: runtime::AuraConfig { authorities: initial_authorities, }, aura_ext: Default::default(), --- 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, String> { Ok(match id { "westend-local" => Box::new(chain_spec::local_testnet_westend_config()), @@ -104,7 +114,7 @@ } fn native_runtime_version(_: &Box) -> &'static RuntimeVersion { - &unique_runtime::VERSION + &runtime::VERSION } } --- 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> { - unique_runtime::api::dispatch(method, data) + runtime::api::dispatch(method, data) } fn native_version() -> sc_executor::NativeVersion { - unique_runtime::native_version() + runtime::native_version() } } --- 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 = [] --- a/node/rpc/src/lib.rs +++ b/node/rpc/src/lib.rs @@ -15,7 +15,6 @@ // along with Unique Network. If not, see . 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; @@ -231,7 +241,7 @@ client.clone(), pool.clone(), graph, - unique_runtime::TransactionConverter, + runtime::TransactionConverter, network.clone(), signers, overrides.clone(), -- gitstuff