difftreelog
Make opal runtime mandatory
in: master
5 files changed
node/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',
node/cli/src/chain_spec.rsdiffbeforeafterboth--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -35,7 +35,6 @@
pub type QuartzChainSpec = sc_service::GenericChainSpec<quartz_runtime::GenesisConfig, Extensions>;
/// The `ChainSpec` parameterized for the opal runtime.
-#[cfg(feature = "opal-runtime")]
pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;
pub enum RuntimeId {
@@ -61,7 +60,6 @@
return RuntimeId::Quartz;
}
- #[cfg(feature = "opal-runtime")]
if self.id().starts_with("opal") {
return RuntimeId::Opal;
}
node/cli/src/command.rsdiffbeforeafterboth1// 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/>.1617// Original license18// This file is part of Substrate.1920// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.21// SPDX-License-Identifier: Apache-2.02223// Licensed under the Apache License, Version 2.0 (the "License");24// you may not use this file except in compliance with the License.25// You may obtain a copy of the License at26//27// http://www.apache.org/licenses/LICENSE-2.028//29// Unless required by applicable law or agreed to in writing, software30// distributed under the License is distributed on an "AS IS" BASIS,31// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.32// See the License for the specific language governing permissions and33// limitations under the License.3435use crate::{36 chain_spec::{self, RuntimeId, RuntimeIdentification},37 cli::{Cli, RelayChainCli, Subcommand},38 service::new_partial,39};4041#[cfg(feature = "unique-runtime")]42use crate::service::UniqueRuntimeExecutor;4344#[cfg(feature = "quartz-runtime")]45use crate::service::QuartzRuntimeExecutor;4647#[cfg(feature = "opal-runtime")]48use crate::service::OpalRuntimeExecutor;4950use codec::Encode;51use cumulus_primitives_core::ParaId;52use cumulus_client_service::genesis::generate_genesis_block;53use log::info;54use polkadot_parachain::primitives::AccountIdConversion;55use sc_cli::{56 ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,57 NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,58};59use sc_service::{60 config::{BasePath, PrometheusConfig},61};62use sp_core::hexdisplay::HexDisplay;63use sp_runtime::traits::Block as BlockT;64use std::{io::Write, net::SocketAddr};6566use unique_runtime_common::types::Block;6768macro_rules! no_runtime_err {69 ($chain_name:expr) => {70 format!(71 "No runtime valid runtime was found for chain {}",72 $chain_name73 )74 };75}7677fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {78 Ok(match id {79 "westend-local" => Box::new(chain_spec::local_testnet_westend_config()),80 "rococo-local" => Box::new(chain_spec::local_testnet_rococo_config()),81 "dev" => Box::new(chain_spec::development_config()),82 "" | "local" => Box::new(chain_spec::local_testnet_rococo_config()),83 path => {84 let path = std::path::PathBuf::from(path);85 let chain_spec = Box::new(sc_service::GenericChainSpec::<()>::from_json_file(86 path.clone(),87 )?) as Box<dyn sc_service::ChainSpec>;8889 match chain_spec.runtime_id() {90 #[cfg(feature = "unique-runtime")]91 RuntimeId::Unique => Box::new(chain_spec::UniqueChainSpec::from_json_file(path)?),9293 #[cfg(feature = "quartz-runtime")]94 RuntimeId::Quartz => Box::new(chain_spec::QuartzChainSpec::from_json_file(path)?),9596 #[cfg(feature = "opal-runtime")]97 RuntimeId::Opal => Box::new(chain_spec::OpalChainSpec::from_json_file(path)?),9899 RuntimeId::Unknown(chain) => return Err(no_runtime_err!(chain)),100 }101 }102 })103}104105impl SubstrateCli for Cli {106 // TODO use args107 fn impl_name() -> String {108 "Unique Node".into()109 }110111 fn impl_version() -> String {112 env!("SUBSTRATE_CLI_IMPL_VERSION").into()113 }114 // TODO use args115 fn description() -> String {116 format!(117 "Unique Node\n\nThe command-line arguments provided first will be \118 passed to the parachain node, while the arguments provided after -- will be passed \119 to the relaychain node.\n\n\120 {} [parachain-args] -- [relaychain-args]",121 Self::executable_name()122 )123 }124125 fn author() -> String {126 env!("CARGO_PKG_AUTHORS").into()127 }128129 //TODO use args130 fn support_url() -> String {131 "support@unique.network".into()132 }133134 fn copyright_start_year() -> i32 {135 2019136 }137138 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {139 load_spec(id)140 }141142 fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {143 match chain_spec.runtime_id() {144 #[cfg(feature = "unique-runtime")]145 RuntimeId::Unique => &unique_runtime::VERSION,146147 #[cfg(feature = "quartz-runtime")]148 RuntimeId::Quartz => &quartz_runtime::VERSION,149150 #[cfg(feature = "opal-runtime")]151 RuntimeId::Opal => &opal_runtime::VERSION,152153 RuntimeId::Unknown(chain) => panic!("{}", no_runtime_err!(chain)),154 }155 }156}157158impl SubstrateCli for RelayChainCli {159 // TODO use args160 fn impl_name() -> String {161 "Unique Node".into()162 }163164 fn impl_version() -> String {165 env!("SUBSTRATE_CLI_IMPL_VERSION").into()166 }167 // TODO use args168 fn description() -> String {169 "Unique Node\n\nThe command-line arguments provided first will be \170 passed to the parachain node, while the arguments provided after -- will be passed \171 to the relaychain node.\n\n\172 parachain-collator [parachain-args] -- [relaychain-args]"173 .into()174 }175176 fn author() -> String {177 env!("CARGO_PKG_AUTHORS").into()178 }179 // TODO use args180 fn support_url() -> String {181 "support@unique.network".into()182 }183184 fn copyright_start_year() -> i32 {185 2019186 }187188 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {189 polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)190 }191192 fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {193 polkadot_cli::Cli::native_runtime_version(chain_spec)194 }195}196197#[allow(clippy::borrowed_box)]198fn extract_genesis_wasm(chain_spec: &Box<dyn sc_service::ChainSpec>) -> Result<Vec<u8>> {199 let mut storage = chain_spec.build_storage()?;200201 storage202 .top203 .remove(sp_core::storage::well_known_keys::CODE)204 .ok_or_else(|| "Could not find wasm file in genesis state!".into())205}206207macro_rules! async_run_with_runtime {208 (209 $runtime_api:path, $executor:path,210 $runner:ident, $components:ident, $cli:ident, $cmd:ident, $config:ident,211 $( $code:tt )*212 ) => {213 $runner.async_run(|$config| {214 let $components = new_partial::<215 $runtime_api, $executor, _216 >(217 &$config,218 crate::service::parachain_build_import_queue,219 )?;220 let task_manager = $components.task_manager;221222 { $( $code )* }.map(|v| (v, task_manager))223 })224 };225}226227macro_rules! construct_async_run {228 (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{229 let runner = $cli.create_runner($cmd)?;230231 match runner.config().chain_spec.runtime_id() {232 #[cfg(feature = "unique-runtime")]233 RuntimeId::Unique => async_run_with_runtime!(234 unique_runtime::RuntimeApi, UniqueRuntimeExecutor,235 runner, $components, $cli, $cmd, $config, $( $code )*236 ),237238 #[cfg(feature = "quartz-runtime")]239 RuntimeId::Quartz => async_run_with_runtime!(240 quartz_runtime::RuntimeApi, QuartzRuntimeExecutor,241 runner, $components, $cli, $cmd, $config, $( $code )*242 ),243244 #[cfg(feature = "opal-runtime")]245 RuntimeId::Opal => async_run_with_runtime!(246 opal_runtime::RuntimeApi, OpalRuntimeExecutor,247 runner, $components, $cli, $cmd, $config, $( $code )*248 ),249250 RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into())251 }252 }}253}254255/// Parse command line arguments into service configuration.256pub fn run() -> Result<()> {257 let cli = Cli::from_args();258259 match &cli.subcommand {260 Some(Subcommand::BuildSpec(cmd)) => {261 let runner = cli.create_runner(cmd)?;262 runner.sync_run(|config| cmd.run(config.chain_spec, config.network))263 }264 Some(Subcommand::CheckBlock(cmd)) => {265 construct_async_run!(|components, cli, cmd, config| {266 Ok(cmd.run(components.client, components.import_queue))267 })268 }269 Some(Subcommand::ExportBlocks(cmd)) => {270 construct_async_run!(|components, cli, cmd, config| {271 Ok(cmd.run(components.client, config.database))272 })273 }274 Some(Subcommand::ExportState(cmd)) => {275 construct_async_run!(|components, cli, cmd, config| {276 Ok(cmd.run(components.client, config.chain_spec))277 })278 }279 Some(Subcommand::ImportBlocks(cmd)) => {280 construct_async_run!(|components, cli, cmd, config| {281 Ok(cmd.run(components.client, components.import_queue))282 })283 }284 Some(Subcommand::PurgeChain(cmd)) => {285 let runner = cli.create_runner(cmd)?;286287 runner.sync_run(|config| {288 let polkadot_cli = RelayChainCli::new(289 &config,290 [RelayChainCli::executable_name()]291 .iter()292 .chain(cli.relaychain_args.iter()),293 );294295 let polkadot_config = SubstrateCli::create_configuration(296 &polkadot_cli,297 &polkadot_cli,298 config.tokio_handle.clone(),299 )300 .map_err(|err| format!("Relay chain argument error: {}", err))?;301302 cmd.run(config, polkadot_config)303 })304 }305 Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| {306 Ok(cmd.run(components.client, components.backend))307 }),308 Some(Subcommand::ExportGenesisState(params)) => {309 let mut builder = sc_cli::LoggerBuilder::new("");310 builder.with_profiling(sc_tracing::TracingReceiver::Log, "");311 let _ = builder.init();312313 let spec = load_spec(¶ms.chain.clone().unwrap_or_default())?;314 let state_version = Cli::native_runtime_version(&spec).state_version();315 let block: Block = generate_genesis_block(&spec, state_version)?;316 let raw_header = block.header().encode();317 let output_buf = if params.raw {318 raw_header319 } else {320 format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes()321 };322323 if let Some(output) = ¶ms.output {324 std::fs::write(output, output_buf)?;325 } else {326 std::io::stdout().write_all(&output_buf)?;327 }328329 Ok(())330 }331 Some(Subcommand::ExportGenesisWasm(params)) => {332 let mut builder = sc_cli::LoggerBuilder::new("");333 builder.with_profiling(sc_tracing::TracingReceiver::Log, "");334 let _ = builder.init();335336 let raw_wasm_blob =337 extract_genesis_wasm(&cli.load_spec(¶ms.chain.clone().unwrap_or_default())?)?;338 let output_buf = if params.raw {339 raw_wasm_blob340 } else {341 format!("0x{:?}", HexDisplay::from(&raw_wasm_blob)).into_bytes()342 };343344 if let Some(output) = ¶ms.output {345 std::fs::write(output, output_buf)?;346 } else {347 std::io::stdout().write_all(&output_buf)?;348 }349350 Ok(())351 }352 Some(Subcommand::Benchmark(cmd)) => {353 if cfg!(feature = "runtime-benchmarks") {354 let runner = cli.create_runner(cmd)?;355 runner.sync_run(|config| match config.chain_spec.runtime_id() {356 #[cfg(feature = "unique-runtime")]357 RuntimeId::Unique => cmd.run::<Block, UniqueRuntimeExecutor>(config),358359 #[cfg(feature = "quartz-runtime")]360 RuntimeId::Quartz => cmd.run::<Block, QuartzRuntimeExecutor>(config),361362 #[cfg(feature = "opal-runtime")]363 RuntimeId::Opal => cmd.run::<Block, OpalRuntimeExecutor>(config),364365 RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into()),366 })367 } else {368 Err("Benchmarking wasn't enabled when building the node. \369 You can enable it with `--features runtime-benchmarks`."370 .into())371 }372 }373 None => {374 let runner = cli.create_runner(&cli.run.normalize())?;375376 runner.run_node_until_exit(|config| async move {377 let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)378 .map(|e| e.para_id)379 .ok_or("Could not find parachain ID in chain-spec.")?;380381 let polkadot_cli = RelayChainCli::new(382 &config,383 [RelayChainCli::executable_name()]384 .iter()385 .chain(cli.relaychain_args.iter()),386 );387388 let id = ParaId::from(para_id);389390 let parachain_account =391 AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);392393 let state_version =394 RelayChainCli::native_runtime_version(&config.chain_spec).state_version();395 let block: Block = generate_genesis_block(&config.chain_spec, state_version)396 .map_err(|e| format!("{:?}", e))?;397 let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));398 let genesis_hash = format!("0x{:?}", HexDisplay::from(&block.header().hash().0));399400 let polkadot_config = SubstrateCli::create_configuration(401 &polkadot_cli,402 &polkadot_cli,403 config.tokio_handle.clone(),404 )405 .map_err(|err| format!("Relay chain argument error: {}", err))?;406407 info!("Parachain id: {:?}", id);408 info!("Parachain Account: {}", parachain_account);409 info!("Parachain genesis state: {}", genesis_state);410 info!("Parachain genesis hash: {}", genesis_hash);411 info!(412 "Is collating: {}",413 if config.role.is_authority() {414 "yes"415 } else {416 "no"417 }418 );419420 match config.chain_spec.runtime_id() {421 #[cfg(feature = "unique-runtime")]422 RuntimeId::Unique => crate::service::start_node::<423 unique_runtime::Runtime,424 unique_runtime::RuntimeApi,425 UniqueRuntimeExecutor,426 >(config, polkadot_config, id)427 .await428 .map(|r| r.0)429 .map_err(Into::into),430431 #[cfg(feature = "quartz-runtime")]432 RuntimeId::Quartz => crate::service::start_node::<433 quartz_runtime::Runtime,434 quartz_runtime::RuntimeApi,435 QuartzRuntimeExecutor,436 >(config, polkadot_config, id)437 .await438 .map(|r| r.0)439 .map_err(Into::into),440441 #[cfg(feature = "opal-runtime")]442 RuntimeId::Opal => crate::service::start_node::<443 opal_runtime::Runtime,444 opal_runtime::RuntimeApi,445 OpalRuntimeExecutor,446 >(config, polkadot_config, id)447 .await448 .map(|r| r.0)449 .map_err(Into::into),450451 RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into()),452 }453 })454 }455 }456}457458impl DefaultConfigurationValues for RelayChainCli {459 fn p2p_listen_port() -> u16 {460 30334461 }462463 fn rpc_ws_listen_port() -> u16 {464 9945465 }466467 fn rpc_http_listen_port() -> u16 {468 9934469 }470471 fn prometheus_listen_port() -> u16 {472 9616473 }474}475476impl CliConfiguration<Self> for RelayChainCli {477 fn shared_params(&self) -> &SharedParams {478 self.base.base.shared_params()479 }480481 fn import_params(&self) -> Option<&ImportParams> {482 self.base.base.import_params()483 }484485 fn network_params(&self) -> Option<&NetworkParams> {486 self.base.base.network_params()487 }488489 fn keystore_params(&self) -> Option<&KeystoreParams> {490 self.base.base.keystore_params()491 }492493 fn base_path(&self) -> Result<Option<BasePath>> {494 Ok(self495 .shared_params()496 .base_path()497 .or_else(|| self.base_path.clone().map(Into::into)))498 }499500 fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {501 self.base.base.rpc_http(default_listen_port)502 }503504 fn rpc_ipc(&self) -> Result<Option<String>> {505 self.base.base.rpc_ipc()506 }507508 fn rpc_ws(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {509 self.base.base.rpc_ws(default_listen_port)510 }511512 fn prometheus_config(513 &self,514 default_listen_port: u16,515 chain_spec: &Box<dyn ChainSpec>,516 ) -> Result<Option<PrometheusConfig>> {517 self.base518 .base519 .prometheus_config(default_listen_port, chain_spec)520 }521522 fn init<F>(523 &self,524 _support_url: &String,525 _impl_version: &String,526 _logger_hook: F,527 _config: &sc_service::Configuration,528 ) -> Result<()> {529 unreachable!("PolkadotCli is never initialized; qed");530 }531532 fn chain_id(&self, is_dev: bool) -> Result<String> {533 let chain_id = self.base.base.chain_id(is_dev)?;534535 Ok(if chain_id.is_empty() {536 self.chain_id.clone().unwrap_or_default()537 } else {538 chain_id539 })540 }541542 fn role(&self, is_dev: bool) -> Result<sc_service::Role> {543 self.base.base.role(is_dev)544 }545546 fn transaction_pool(&self) -> Result<sc_service::config::TransactionPoolOptions> {547 self.base.base.transaction_pool()548 }549550 fn state_cache_child_ratio(&self) -> Result<Option<usize>> {551 self.base.base.state_cache_child_ratio()552 }553554 fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {555 self.base.base.rpc_methods()556 }557558 fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {559 self.base.base.rpc_ws_max_connections()560 }561562 fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {563 self.base.base.rpc_cors(is_dev)564 }565566 fn default_heap_pages(&self) -> Result<Option<u64>> {567 self.base.base.default_heap_pages()568 }569570 fn force_authoring(&self) -> Result<bool> {571 self.base.base.force_authoring()572 }573574 fn disable_grandpa(&self) -> Result<bool> {575 self.base.base.disable_grandpa()576 }577578 fn max_runtime_instances(&self) -> Result<Option<usize>> {579 self.base.base.max_runtime_instances()580 }581582 fn announce_block(&self) -> Result<bool> {583 self.base.base.announce_block()584 }585586 fn telemetry_endpoints(587 &self,588 chain_spec: &Box<dyn ChainSpec>,589 ) -> Result<Option<sc_telemetry::TelemetryEndpoints>> {590 self.base.base.telemetry_endpoints(chain_spec)591 }592}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/>.1617// Original license18// This file is part of Substrate.1920// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.21// SPDX-License-Identifier: Apache-2.02223// Licensed under the Apache License, Version 2.0 (the "License");24// you may not use this file except in compliance with the License.25// You may obtain a copy of the License at26//27// http://www.apache.org/licenses/LICENSE-2.028//29// Unless required by applicable law or agreed to in writing, software30// distributed under the License is distributed on an "AS IS" BASIS,31// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.32// See the License for the specific language governing permissions and33// limitations under the License.3435use crate::{36 chain_spec::{self, RuntimeId, RuntimeIdentification},37 cli::{Cli, RelayChainCli, Subcommand},38 service::new_partial,39};4041#[cfg(feature = "unique-runtime")]42use crate::service::UniqueRuntimeExecutor;4344#[cfg(feature = "quartz-runtime")]45use crate::service::QuartzRuntimeExecutor;4647use crate::service::OpalRuntimeExecutor;4849use codec::Encode;50use cumulus_primitives_core::ParaId;51use cumulus_client_service::genesis::generate_genesis_block;52use log::info;53use polkadot_parachain::primitives::AccountIdConversion;54use sc_cli::{55 ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,56 NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,57};58use sc_service::{59 config::{BasePath, PrometheusConfig},60};61use sp_core::hexdisplay::HexDisplay;62use sp_runtime::traits::Block as BlockT;63use std::{io::Write, net::SocketAddr};6465use unique_runtime_common::types::Block;6667macro_rules! no_runtime_err {68 ($chain_name:expr) => {69 format!(70 "No runtime valid runtime was found for chain {}",71 $chain_name72 )73 };74}7576fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {77 Ok(match id {78 "westend-local" => Box::new(chain_spec::local_testnet_westend_config()),79 "rococo-local" => Box::new(chain_spec::local_testnet_rococo_config()),80 "dev" => Box::new(chain_spec::development_config()),81 "" | "local" => Box::new(chain_spec::local_testnet_rococo_config()),82 path => {83 let path = std::path::PathBuf::from(path);84 let chain_spec = Box::new(chain_spec::OpalChainSpec::from_json_file(85 path.clone(),86 )?) as Box<dyn sc_service::ChainSpec>;8788 match chain_spec.runtime_id() {89 #[cfg(feature = "unique-runtime")]90 RuntimeId::Unique => Box::new(chain_spec::UniqueChainSpec::from_json_file(path)?),9192 #[cfg(feature = "quartz-runtime")]93 RuntimeId::Quartz => Box::new(chain_spec::QuartzChainSpec::from_json_file(path)?),9495 RuntimeId::Opal => Box::new(chain_spec::OpalChainSpec::from_json_file(path)?),96 RuntimeId::Unknown(chain) => return Err(no_runtime_err!(chain)),97 }98 }99 })100}101102impl SubstrateCli for Cli {103 // TODO use args104 fn impl_name() -> String {105 "Unique Node".into()106 }107108 fn impl_version() -> String {109 env!("SUBSTRATE_CLI_IMPL_VERSION").into()110 }111 // TODO use args112 fn description() -> String {113 format!(114 "Unique Node\n\nThe command-line arguments provided first will be \115 passed to the parachain node, while the arguments provided after -- will be passed \116 to the relaychain node.\n\n\117 {} [parachain-args] -- [relaychain-args]",118 Self::executable_name()119 )120 }121122 fn author() -> String {123 env!("CARGO_PKG_AUTHORS").into()124 }125126 //TODO use args127 fn support_url() -> String {128 "support@unique.network".into()129 }130131 fn copyright_start_year() -> i32 {132 2019133 }134135 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {136 load_spec(id)137 }138139 fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {140 match chain_spec.runtime_id() {141 #[cfg(feature = "unique-runtime")]142 RuntimeId::Unique => &unique_runtime::VERSION,143144 #[cfg(feature = "quartz-runtime")]145 RuntimeId::Quartz => &quartz_runtime::VERSION,146147 RuntimeId::Opal => &opal_runtime::VERSION,148 RuntimeId::Unknown(chain) => panic!("{}", no_runtime_err!(chain)),149 }150 }151}152153impl SubstrateCli for RelayChainCli {154 // TODO use args155 fn impl_name() -> String {156 "Unique Node".into()157 }158159 fn impl_version() -> String {160 env!("SUBSTRATE_CLI_IMPL_VERSION").into()161 }162 // TODO use args163 fn description() -> String {164 "Unique Node\n\nThe command-line arguments provided first will be \165 passed to the parachain node, while the arguments provided after -- will be passed \166 to the relaychain node.\n\n\167 parachain-collator [parachain-args] -- [relaychain-args]"168 .into()169 }170171 fn author() -> String {172 env!("CARGO_PKG_AUTHORS").into()173 }174 // TODO use args175 fn support_url() -> String {176 "support@unique.network".into()177 }178179 fn copyright_start_year() -> i32 {180 2019181 }182183 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {184 polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)185 }186187 fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {188 polkadot_cli::Cli::native_runtime_version(chain_spec)189 }190}191192#[allow(clippy::borrowed_box)]193fn extract_genesis_wasm(chain_spec: &Box<dyn sc_service::ChainSpec>) -> Result<Vec<u8>> {194 let mut storage = chain_spec.build_storage()?;195196 storage197 .top198 .remove(sp_core::storage::well_known_keys::CODE)199 .ok_or_else(|| "Could not find wasm file in genesis state!".into())200}201202macro_rules! async_run_with_runtime {203 (204 $runtime_api:path, $executor:path,205 $runner:ident, $components:ident, $cli:ident, $cmd:ident, $config:ident,206 $( $code:tt )*207 ) => {208 $runner.async_run(|$config| {209 let $components = new_partial::<210 $runtime_api, $executor, _211 >(212 &$config,213 crate::service::parachain_build_import_queue,214 )?;215 let task_manager = $components.task_manager;216217 { $( $code )* }.map(|v| (v, task_manager))218 })219 };220}221222macro_rules! construct_async_run {223 (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{224 let runner = $cli.create_runner($cmd)?;225226 match runner.config().chain_spec.runtime_id() {227 #[cfg(feature = "unique-runtime")]228 RuntimeId::Unique => async_run_with_runtime!(229 unique_runtime::RuntimeApi, UniqueRuntimeExecutor,230 runner, $components, $cli, $cmd, $config, $( $code )*231 ),232233 #[cfg(feature = "quartz-runtime")]234 RuntimeId::Quartz => async_run_with_runtime!(235 quartz_runtime::RuntimeApi, QuartzRuntimeExecutor,236 runner, $components, $cli, $cmd, $config, $( $code )*237 ),238239 RuntimeId::Opal => async_run_with_runtime!(240 opal_runtime::RuntimeApi, OpalRuntimeExecutor,241 runner, $components, $cli, $cmd, $config, $( $code )*242 ),243244 RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into())245 }246 }}247}248249/// Parse command line arguments into service configuration.250pub fn run() -> Result<()> {251 let cli = Cli::from_args();252253 match &cli.subcommand {254 Some(Subcommand::BuildSpec(cmd)) => {255 let runner = cli.create_runner(cmd)?;256 runner.sync_run(|config| cmd.run(config.chain_spec, config.network))257 }258 Some(Subcommand::CheckBlock(cmd)) => {259 construct_async_run!(|components, cli, cmd, config| {260 Ok(cmd.run(components.client, components.import_queue))261 })262 }263 Some(Subcommand::ExportBlocks(cmd)) => {264 construct_async_run!(|components, cli, cmd, config| {265 Ok(cmd.run(components.client, config.database))266 })267 }268 Some(Subcommand::ExportState(cmd)) => {269 construct_async_run!(|components, cli, cmd, config| {270 Ok(cmd.run(components.client, config.chain_spec))271 })272 }273 Some(Subcommand::ImportBlocks(cmd)) => {274 construct_async_run!(|components, cli, cmd, config| {275 Ok(cmd.run(components.client, components.import_queue))276 })277 }278 Some(Subcommand::PurgeChain(cmd)) => {279 let runner = cli.create_runner(cmd)?;280281 runner.sync_run(|config| {282 let polkadot_cli = RelayChainCli::new(283 &config,284 [RelayChainCli::executable_name()]285 .iter()286 .chain(cli.relaychain_args.iter()),287 );288289 let polkadot_config = SubstrateCli::create_configuration(290 &polkadot_cli,291 &polkadot_cli,292 config.tokio_handle.clone(),293 )294 .map_err(|err| format!("Relay chain argument error: {}", err))?;295296 cmd.run(config, polkadot_config)297 })298 }299 Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| {300 Ok(cmd.run(components.client, components.backend))301 }),302 Some(Subcommand::ExportGenesisState(params)) => {303 let mut builder = sc_cli::LoggerBuilder::new("");304 builder.with_profiling(sc_tracing::TracingReceiver::Log, "");305 let _ = builder.init();306307 let spec = load_spec(¶ms.chain.clone().unwrap_or_default())?;308 let state_version = Cli::native_runtime_version(&spec).state_version();309 let block: Block = generate_genesis_block(&spec, state_version)?;310 let raw_header = block.header().encode();311 let output_buf = if params.raw {312 raw_header313 } else {314 format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes()315 };316317 if let Some(output) = ¶ms.output {318 std::fs::write(output, output_buf)?;319 } else {320 std::io::stdout().write_all(&output_buf)?;321 }322323 Ok(())324 }325 Some(Subcommand::ExportGenesisWasm(params)) => {326 let mut builder = sc_cli::LoggerBuilder::new("");327 builder.with_profiling(sc_tracing::TracingReceiver::Log, "");328 let _ = builder.init();329330 let raw_wasm_blob =331 extract_genesis_wasm(&cli.load_spec(¶ms.chain.clone().unwrap_or_default())?)?;332 let output_buf = if params.raw {333 raw_wasm_blob334 } else {335 format!("0x{:?}", HexDisplay::from(&raw_wasm_blob)).into_bytes()336 };337338 if let Some(output) = ¶ms.output {339 std::fs::write(output, output_buf)?;340 } else {341 std::io::stdout().write_all(&output_buf)?;342 }343344 Ok(())345 }346 Some(Subcommand::Benchmark(cmd)) => {347 if cfg!(feature = "runtime-benchmarks") {348 let runner = cli.create_runner(cmd)?;349 runner.sync_run(|config| match config.chain_spec.runtime_id() {350 #[cfg(feature = "unique-runtime")]351 RuntimeId::Unique => cmd.run::<Block, UniqueRuntimeExecutor>(config),352353 #[cfg(feature = "quartz-runtime")]354 RuntimeId::Quartz => cmd.run::<Block, QuartzRuntimeExecutor>(config),355356 RuntimeId::Opal => cmd.run::<Block, OpalRuntimeExecutor>(config),357 RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into()),358 })359 } else {360 Err("Benchmarking wasn't enabled when building the node. \361 You can enable it with `--features runtime-benchmarks`."362 .into())363 }364 }365 None => {366 let runner = cli.create_runner(&cli.run.normalize())?;367368 runner.run_node_until_exit(|config| async move {369 let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)370 .map(|e| e.para_id)371 .ok_or("Could not find parachain ID in chain-spec.")?;372373 let polkadot_cli = RelayChainCli::new(374 &config,375 [RelayChainCli::executable_name()]376 .iter()377 .chain(cli.relaychain_args.iter()),378 );379380 let id = ParaId::from(para_id);381382 let parachain_account =383 AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);384385 let state_version =386 RelayChainCli::native_runtime_version(&config.chain_spec).state_version();387 let block: Block = generate_genesis_block(&config.chain_spec, state_version)388 .map_err(|e| format!("{:?}", e))?;389 let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));390 let genesis_hash = format!("0x{:?}", HexDisplay::from(&block.header().hash().0));391392 let polkadot_config = SubstrateCli::create_configuration(393 &polkadot_cli,394 &polkadot_cli,395 config.tokio_handle.clone(),396 )397 .map_err(|err| format!("Relay chain argument error: {}", err))?;398399 info!("Parachain id: {:?}", id);400 info!("Parachain Account: {}", parachain_account);401 info!("Parachain genesis state: {}", genesis_state);402 info!("Parachain genesis hash: {}", genesis_hash);403 info!(404 "Is collating: {}",405 if config.role.is_authority() {406 "yes"407 } else {408 "no"409 }410 );411412 match config.chain_spec.runtime_id() {413 #[cfg(feature = "unique-runtime")]414 RuntimeId::Unique => crate::service::start_node::<415 unique_runtime::Runtime,416 unique_runtime::RuntimeApi,417 UniqueRuntimeExecutor,418 >(config, polkadot_config, id)419 .await420 .map(|r| r.0)421 .map_err(Into::into),422423 #[cfg(feature = "quartz-runtime")]424 RuntimeId::Quartz => crate::service::start_node::<425 quartz_runtime::Runtime,426 quartz_runtime::RuntimeApi,427 QuartzRuntimeExecutor,428 >(config, polkadot_config, id)429 .await430 .map(|r| r.0)431 .map_err(Into::into),432433 RuntimeId::Opal => crate::service::start_node::<434 opal_runtime::Runtime,435 opal_runtime::RuntimeApi,436 OpalRuntimeExecutor,437 >(config, polkadot_config, id)438 .await439 .map(|r| r.0)440 .map_err(Into::into),441442 RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into()),443 }444 })445 }446 }447}448449impl DefaultConfigurationValues for RelayChainCli {450 fn p2p_listen_port() -> u16 {451 30334452 }453454 fn rpc_ws_listen_port() -> u16 {455 9945456 }457458 fn rpc_http_listen_port() -> u16 {459 9934460 }461462 fn prometheus_listen_port() -> u16 {463 9616464 }465}466467impl CliConfiguration<Self> for RelayChainCli {468 fn shared_params(&self) -> &SharedParams {469 self.base.base.shared_params()470 }471472 fn import_params(&self) -> Option<&ImportParams> {473 self.base.base.import_params()474 }475476 fn network_params(&self) -> Option<&NetworkParams> {477 self.base.base.network_params()478 }479480 fn keystore_params(&self) -> Option<&KeystoreParams> {481 self.base.base.keystore_params()482 }483484 fn base_path(&self) -> Result<Option<BasePath>> {485 Ok(self486 .shared_params()487 .base_path()488 .or_else(|| self.base_path.clone().map(Into::into)))489 }490491 fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {492 self.base.base.rpc_http(default_listen_port)493 }494495 fn rpc_ipc(&self) -> Result<Option<String>> {496 self.base.base.rpc_ipc()497 }498499 fn rpc_ws(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {500 self.base.base.rpc_ws(default_listen_port)501 }502503 fn prometheus_config(504 &self,505 default_listen_port: u16,506 chain_spec: &Box<dyn ChainSpec>,507 ) -> Result<Option<PrometheusConfig>> {508 self.base509 .base510 .prometheus_config(default_listen_port, chain_spec)511 }512513 fn init<F>(514 &self,515 _support_url: &String,516 _impl_version: &String,517 _logger_hook: F,518 _config: &sc_service::Configuration,519 ) -> Result<()> {520 unreachable!("PolkadotCli is never initialized; qed");521 }522523 fn chain_id(&self, is_dev: bool) -> Result<String> {524 let chain_id = self.base.base.chain_id(is_dev)?;525526 Ok(if chain_id.is_empty() {527 self.chain_id.clone().unwrap_or_default()528 } else {529 chain_id530 })531 }532533 fn role(&self, is_dev: bool) -> Result<sc_service::Role> {534 self.base.base.role(is_dev)535 }536537 fn transaction_pool(&self) -> Result<sc_service::config::TransactionPoolOptions> {538 self.base.base.transaction_pool()539 }540541 fn state_cache_child_ratio(&self) -> Result<Option<usize>> {542 self.base.base.state_cache_child_ratio()543 }544545 fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {546 self.base.base.rpc_methods()547 }548549 fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {550 self.base.base.rpc_ws_max_connections()551 }552553 fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {554 self.base.base.rpc_cors(is_dev)555 }556557 fn default_heap_pages(&self) -> Result<Option<u64>> {558 self.base.base.default_heap_pages()559 }560561 fn force_authoring(&self) -> Result<bool> {562 self.base.base.force_authoring()563 }564565 fn disable_grandpa(&self) -> Result<bool> {566 self.base.base.disable_grandpa()567 }568569 fn max_runtime_instances(&self) -> Result<Option<usize>> {570 self.base.base.max_runtime_instances()571 }572573 fn announce_block(&self) -> Result<bool> {574 self.base.base.announce_block()575 }576577 fn telemetry_endpoints(578 &self,579 chain_spec: &Box<dyn ChainSpec>,580 ) -> Result<Option<sc_telemetry::TelemetryEndpoints>> {581 self.base.base.telemetry_endpoints(chain_spec)582 }583}node/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;
node/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
+}