From 6605dbdc76f454bd0d3d51ab75b1459fca8951ea Mon Sep 17 00:00:00 2001 From: jasl Date: Sat, 19 Nov 2022 03:44:31 +0800 Subject: [PATCH] Port missing https://github.com/paritytech/cumulus/pull/1585 --- Cargo.lock | 47 ++++++++++++++++++++++++++++++++++++++- node/Cargo.toml | 1 + node/src/cli.rs | 2 +- node/src/command.rs | 5 ++++- node/src/service/mod.rs | 12 +++------- node/src/service/phala.rs | 1 - node/src/service/shell.rs | 1 - 7 files changed, 55 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df4007bc..625d9271 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1745,6 +1745,50 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cumulus-relay-chain-minimal-node" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" +dependencies = [ + "array-bytes", + "async-trait", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "cumulus-relay-chain-rpc-interface", + "futures", + "lru 0.8.0", + "polkadot-availability-distribution", + "polkadot-core-primitives", + "polkadot-network-bridge", + "polkadot-node-core-av-store", + "polkadot-node-network-protocol", + "polkadot-node-subsystem-util", + "polkadot-overseer", + "polkadot-primitives", + "polkadot-service", + "sc-authority-discovery", + "sc-client-api", + "sc-consensus", + "sc-keystore", + "sc-network", + "sc-network-common", + "sc-network-light", + "sc-network-sync", + "sc-service", + "sc-telemetry", + "sc-tracing", + "sc-transaction-pool", + "sc-transaction-pool-api", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-runtime", + "tokio", + "tracing", + "url", +] + [[package]] name = "cumulus-relay-chain-rpc-interface" version = "0.1.0" @@ -3680,6 +3724,7 @@ dependencies = [ "cumulus-primitives-parachain-inherent", "cumulus-relay-chain-inprocess-interface", "cumulus-relay-chain-interface", + "cumulus-relay-chain-minimal-node", "cumulus-relay-chain-rpc-interface", "frame-benchmarking", "frame-benchmarking-cli", @@ -12190,7 +12235,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "digest 0.10.3", "rand 0.8.5", "static_assertions", diff --git a/node/Cargo.toml b/node/Cargo.toml index bc296b99..cb70657e 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -102,6 +102,7 @@ cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/c cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.32" } cumulus-relay-chain-inprocess-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.32" } cumulus-relay-chain-rpc-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.32" } +cumulus-relay-chain-minimal-node = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.32" } # Polkadot dependencies polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.32" } diff --git a/node/src/cli.rs b/node/src/cli.rs index ead088fc..39970543 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -82,7 +82,7 @@ pub struct Cli { pub no_hardware_benchmarks: bool, /// Relay chain arguments - #[arg(raw = true, conflicts_with = "relay-chain-rpc-url")] + #[arg(raw = true)] pub relaychain_args: Vec, } diff --git a/node/src/command.rs b/node/src/command.rs index a3da1e71..90e71218 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -18,7 +18,7 @@ use codec::Encode; use cumulus_client_cli::generate_genesis_block; use cumulus_primitives_core::ParaId; use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; -use log::info; +use log::{info, warn}; use sc_cli::{ CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli, @@ -744,6 +744,9 @@ pub fn run() -> Result<()> { "no" } ); + if collator_options.relay_chain_rpc_url.is_some() && cli.relaychain_args.len() > 0 { + warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options."); + } #[cfg(feature = "phala-native")] if config.chain_spec.is_phala() { diff --git a/node/src/service/mod.rs b/node/src/service/mod.rs index b67e6c05..d462a373 100644 --- a/node/src/service/mod.rs +++ b/node/src/service/mod.rs @@ -24,7 +24,7 @@ use cumulus_client_service::{ use cumulus_primitives_core::ParaId; use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain; use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult}; -use cumulus_relay_chain_rpc_interface::{create_client_and_start_worker, RelayChainRpcInterface}; +use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node; use polkadot_service::CollatorPair; use sc_executor::WasmExecutor; @@ -82,13 +82,8 @@ async fn build_relay_chain_interface( Option, )> { match collator_options.relay_chain_rpc_url { - Some(relay_chain_url) => { - let client = create_client_and_start_worker(relay_chain_url, task_manager).await?; - Ok(( - Arc::new(RelayChainRpcInterface::new(client)) as Arc<_>, - None, - )) - } + Some(relay_chain_url) => + build_minimal_relay_chain_node(polkadot_config, task_manager, relay_chain_url).await, None => build_inprocess_relay_chain( polkadot_config, parachain_config, @@ -452,7 +447,6 @@ where relay_chain_interface, relay_chain_slot_duration, import_queue, - collator_options, }; start_full_node(params)?; diff --git a/node/src/service/phala.rs b/node/src/service/phala.rs index 67d1dff3..a1b08688 100644 --- a/node/src/service/phala.rs +++ b/node/src/service/phala.rs @@ -387,7 +387,6 @@ async fn start_node_impl( relay_chain_interface, relay_chain_slot_duration, import_queue, - collator_options, }; start_full_node(params)?; diff --git a/node/src/service/shell.rs b/node/src/service/shell.rs index 65da7aaa..0facb448 100644 --- a/node/src/service/shell.rs +++ b/node/src/service/shell.rs @@ -263,7 +263,6 @@ async fn start_node_impl( relay_chain_interface, relay_chain_slot_duration, import_queue, - collator_options, }; start_full_node(params)?;