From 301684bf7092d557ddb49eb3ae21749f42ec1a3e Mon Sep 17 00:00:00 2001 From: Seun Date: Fri, 31 Jul 2020 16:54:18 +0100 Subject: [PATCH] substrate test runner --- .gitignore | 2 + Cargo.toml | 20 ++-- client/Cargo.toml | 6 +- client/src/lib.rs | 21 +++- src/lib.rs | 12 +- test-node/Cargo.toml | 34 +++--- test-node/runtime/Cargo.toml | 46 ++++---- test-node/src/command.rs | 60 +++++----- test-node/src/service.rs | 211 +++++++++++++---------------------- 9 files changed, 195 insertions(+), 217 deletions(-) diff --git a/.gitignore b/.gitignore index 693699042b..fc64db3139 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target **/*.rs.bk Cargo.lock +.vscode/ +.idea/ \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index ea222904f8..aab79734c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,24 +31,24 @@ url = "2.1.1" codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive", "full"] } frame-metadata = { version = "11.0.0-rc5", package = "frame-metadata" } -frame-support = { version = "2.0.0-rc5", package = "frame-support" } -sp-runtime = { version = "2.0.0-rc5", package = "sp-runtime" } -sp-version = { version = "2.0.0-rc5", package = "sp-version" } -pallet-indices = { version = "2.0.0-rc5", package = "pallet-indices" } +frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "frame-support" } +sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "sp-runtime" } +sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "sp-version" } +pallet-indices = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "pallet-indices" } hex = "0.4.2" -sp-rpc = { version = "2.0.0-rc5", package = "sp-rpc" } -sp-core = { version = "2.0.0-rc5", package = "sp-core" } +sp-rpc = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "sp-rpc" } +sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "sp-core" } sc-rpc-api = { version = "0.8.0-rc5", package = "sc-rpc-api" } -sp-transaction-pool = { version = "2.0.0-rc5", package = "sp-transaction-pool" } +sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "sp-transaction-pool" } substrate-subxt-client = { version = "0.3.0", path = "client", optional = true } substrate-subxt-proc-macro = { version = "0.11.0", path = "proc-macro" } [dev-dependencies] async-std = { version = "1.6.2", features = ["attributes"] } env_logger = "0.7.1" -frame-system = { version = "2.0.0-rc5", package = "frame-system" } -pallet-balances = { version = "2.0.0-rc5", package = "pallet-balances" } -sp-keyring = { version = "2.0.0-rc5", package = "sp-keyring" } +frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "frame-system" } +pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "pallet-balances" } +sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "sp-keyring" } substrate-subxt-client = { version = "0.3.0", path = "client" } tempdir = "0.3.7" test-node = { path = "test-node" } diff --git a/client/Cargo.toml b/client/Cargo.toml index a9a31bab3d..e2c66a2573 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -17,10 +17,10 @@ futures = { version = "0.3.5", features = ["compat"] } futures01 = { package = "futures", version = "0.1.29" } jsonrpsee = "0.1.0" log = "0.4.11" -sc-network = { version = "0.8.0-rc5", default-features = false } -sc-service = { version = "0.8.0-rc5", default-features = false } +sc-network = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +sc-service = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } serde_json = "1.0.56" -sp-keyring = "2.0.0-rc5" +sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } thiserror = "1.0.20" [dev-dependencies] diff --git a/client/src/lib.rs b/client/src/lib.rs index a335b11c48..f572bdcaa4 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -314,7 +314,8 @@ mod tests { ClientBuilder, KusamaRuntime as NodeTemplateRuntime, PairSigner, - }; + }; + use std::sync::Arc; use tempdir::TempDir; #[async_std::test] @@ -360,7 +361,14 @@ mod tests { }; let client = ClientBuilder::::new() .set_client( - SubxtClient::from_config(config, test_node::service::new_light).unwrap(), + SubxtClient::from_config( + config, + |config| { + test_node::service::new_light(config) + .map(|(task, rpc)| (task, Arc::new(rpc))) + }, + ) + .expect("Error creating subxt client"), ) .build() .await @@ -393,7 +401,14 @@ mod tests { }; let client = ClientBuilder::::new() .set_client( - SubxtClient::from_config(config, test_node::service::new_full).unwrap(), + SubxtClient::from_config( + config, + |config| { + test_node::service::new_full(config) + .map(|(task, rpc)| (task, Arc::new(rpc))) + }, + ) + .expect("Error creating subxt client"), ) .build() .await diff --git a/src/lib.rs b/src/lib.rs index 5d8148e353..3645817339 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -468,7 +468,9 @@ mod tests { SubxtClient, SubxtClientConfig, }; - use tempdir::TempDir; + use tempdir::TempDir; + use std::sync::Arc; + pub(crate) type TestRuntime = crate::NodeTemplateRuntime; @@ -496,7 +498,13 @@ mod tests { }; let client = ClientBuilder::new() .set_client( - SubxtClient::from_config(config, test_node::service::new_full) + SubxtClient::from_config( + config, + |config| { + test_node::service::new_full(config) + .map(|(task, rpc)| (task, Arc::new(rpc))) + }, + ) .expect("Error creating subxt client"), ) .build() diff --git a/test-node/Cargo.toml b/test-node/Cargo.toml index 82a9c9a20f..e22923a876 100644 --- a/test-node/Cargo.toml +++ b/test-node/Cargo.toml @@ -18,23 +18,23 @@ log = "0.4.11" structopt = "0.3.15" parking_lot = "0.11.0" -sc-cli = { version = "0.8.0-rc5", features = ["wasmtime"] } -sp-core = "2.0.0-rc5" -sc-executor = { version = "0.8.0-rc5", features = ["wasmtime"] } -sc-service = { version = "0.8.0-rc5", features = ["wasmtime"] } -sp-inherents = "2.0.0-rc5" -sc-transaction-pool = "2.0.0-rc5" -sp-transaction-pool = "2.0.0-rc5" -sc-network = "0.8.0-rc5" -sc-consensus-aura = "0.8.0-rc5" -sp-consensus-aura = "0.8.0-rc5" -sp-consensus = "0.8.0-rc5" -sc-consensus = "0.8.0-rc5" -sc-finality-grandpa = "0.8.0-rc5" -sp-finality-grandpa = "2.0.0-rc5" -sc-client-api = "2.0.0-rc5" -sp-runtime = "2.0.0-rc5" -sc-basic-authorship = "0.8.0-rc5" +sc-cli = {git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", features = ["wasmtime"] } +sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } +sc-executor = {git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", features = ["wasmtime"] } +sc-service = {git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", features = ["wasmtime"] } +sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } +sc-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } +sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } +sc-network = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } +sc-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } +sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } +sp-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } +sc-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } +sc-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } +sp-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } +sc-client-api = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } +sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } +sc-basic-authorship = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" } test-node-runtime = { version = "2.0.0-rc5", path = "runtime" } diff --git a/test-node/runtime/Cargo.toml b/test-node/runtime/Cargo.toml index 2a27d3ea3a..f40bb20476 100644 --- a/test-node/runtime/Cargo.toml +++ b/test-node/runtime/Cargo.toml @@ -12,30 +12,30 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] } - -aura = { version = "2.0.0-rc5", default-features = false, package = "pallet-aura" } -balances = { version = "2.0.0-rc5", default-features = false, package = "pallet-balances" } -frame-support = { version = "2.0.0-rc5", default-features = false } -grandpa = { version = "2.0.0-rc5", default-features = false, package = "pallet-grandpa" } -randomness-collective-flip = { version = "2.0.0-rc5", default-features = false, package = "pallet-randomness-collective-flip" } -sudo = { version = "2.0.0-rc5", default-features = false, package = "pallet-sudo" } -system = { version = "2.0.0-rc5", default-features = false, package = "frame-system" } -timestamp = { version = "2.0.0-rc5", default-features = false, package = "pallet-timestamp" } -transaction-payment = { version = "2.0.0-rc5", default-features = false, package = "pallet-transaction-payment" } -frame-executive = { version = "2.0.0-rc5", default-features = false } serde = { version = "1.0.114", optional = true, features = ["derive"] } -sp-api = { version = "2.0.0-rc5", default-features = false } -sp-block-builder = { version = "2.0.0-rc5", default-features = false } -sp-consensus-aura = { version = "0.8.0-rc5", default-features = false } -sp-core = { version = "2.0.0-rc5", default-features = false } -sp-inherents = { version = "2.0.0-rc5", default-features = false } -sp-io = { version = "2.0.0-rc5", default-features = false } -sp-offchain = { version = "2.0.0-rc5", default-features = false } -sp-runtime = { version = "2.0.0-rc5", default-features = false } -sp-session = { version = "2.0.0-rc5", default-features = false } -sp-std = { version = "2.0.0-rc5", default-features = false } -sp-transaction-pool = { version = "2.0.0-rc5", default-features = false } -sp-version = { version = "2.0.0-rc5", default-features = false } + +aura = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-aura" } +balances = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-balances" } +frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-grandpa" } +randomness-collective-flip = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-randomness-collective-flip" } +sudo = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-sudo" } +system = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "frame-system" } +timestamp = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-timestamp" } +transaction-payment = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-transaction-payment" } +frame-executive = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +sp-block-builder = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +sp-offchain = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +sp-session = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } +sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false } [build-dependencies] wasm-builder-runner = { version = "1.0.5", package = "substrate-wasm-builder-runner" } diff --git a/test-node/src/command.rs b/test-node/src/command.rs index c8196d2291..adffb7c5d1 100644 --- a/test-node/src/command.rs +++ b/test-node/src/command.rs @@ -14,19 +14,11 @@ // You should have received a copy of the GNU General Public License // along with substrate-subxt. If not, see . -use crate::{ - chain_spec, - cli::Cli, - service, - service::new_full_params, -}; -use sc_cli::{ - ChainSpec, - Role, - RuntimeVersion, - SubstrateCli, -}; -use sc_service::ServiceParams; +use crate::{chain_spec, cli::Cli, service::{self, Executor}}; +use sc_cli::{ChainSpec, Role, RuntimeVersion, SubstrateCli}; +use std::sync::Arc; +use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; +use test_node_runtime::{opaque::Block, RuntimeApi}; impl SubstrateCli for Cli { fn impl_name() -> String { @@ -78,18 +70,36 @@ pub fn run() -> sc_cli::Result<()> { Some(subcommand) => { let runner = cli.create_runner(subcommand)?; runner.run_subcommand(subcommand, |config| { - let ( - ServiceParams { - client, - backend, - task_manager, - import_queue, - .. - }, - .., - ) = new_full_params(config)?; - Ok((client, backend, import_queue, task_manager)) - }) + sc_service::new_full_parts::(&config) + .and_then(|(client, backend, _, task_manager)| { + let client = Arc::new(client); + let select_chain = sc_consensus::LongestChain::new(backend.clone()); + let inherent_data_providers = sp_inherents::InherentDataProviders::new(); + + let (grandpa_block_import, _) = sc_finality_grandpa::block_import( + client.clone(), + &(client.clone() as Arc<_>), + select_chain.clone(), + )?; + + let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new( + grandpa_block_import.clone(), + client.clone(), + ); + + let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _>( + sc_consensus_aura::slot_duration(&*client)?, + aura_block_import, + Some(Box::new(grandpa_block_import.clone())), + None, + client.clone(), + inherent_data_providers.clone(), + &task_manager.spawn_handle(), + config.prometheus_registry(), + )?; + Ok((client, backend, import_queue, task_manager)) + }) + }) } None => { let runner = cli.create_runner(&cli.run)?; diff --git a/test-node/src/service.rs b/test-node/src/service.rs index 601d19fdc1..eabf8f8a65 100644 --- a/test-node/src/service.rs +++ b/test-node/src/service.rs @@ -28,11 +28,8 @@ use sc_finality_grandpa::{ StorageAndProofProvider, }; use sc_service::{ - error::Error as ServiceError, - Configuration, - RpcHandlers, - ServiceComponents, - TaskManager, + error::Error as ServiceError, Configuration, RpcHandlers, + TaskManager, SpawnTasksParams, BuildNetworkParams, build_network, }; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use sp_inherents::InherentDataProviders; @@ -53,49 +50,19 @@ native_executor_instance!( test_node_runtime::native_version, ); -type FullClient = sc_service::TFullClient; -type FullBackend = sc_service::TFullBackend; -type FullSelectChain = sc_consensus::LongestChain; -pub fn new_full_params( - config: Configuration, -) -> Result< - ( - sc_service::ServiceParams< - Block, - FullClient, - sc_consensus_aura::AuraImportQueue, - sc_transaction_pool::FullPool, - (), - FullBackend, - >, - FullSelectChain, - sp_inherents::InherentDataProviders, - sc_finality_grandpa::GrandpaBlockImport< - FullBackend, - Block, - FullClient, - FullSelectChain, - >, - sc_finality_grandpa::LinkHalf, - ), - ServiceError, -> { - let inherent_data_providers = sp_inherents::InherentDataProviders::new(); +/// Builds a new service for a full client. +pub fn new_full(config: Configuration) -> Result<(TaskManager, RpcHandlers), ServiceError> { + let inherent_data_providers = sp_inherents::InherentDataProviders::new(); - let (client, backend, keystore, task_manager) = + let (client, backend, keystore, mut task_manager) = sc_service::new_full_parts::(&config)?; let client = Arc::new(client); let select_chain = sc_consensus::LongestChain::new(backend.clone()); - let pool_api = sc_transaction_pool::FullChainApi::new( - client.clone(), - config.prometheus_registry(), - ); let transaction_pool = sc_transaction_pool::BasicPool::new_full( config.transaction_pool.clone(), - std::sync::Arc::new(pool_api), config.prometheus_registry(), task_manager.spawn_handle(), client.clone(), @@ -121,81 +88,52 @@ pub fn new_full_params( inherent_data_providers.clone(), &task_manager.spawn_handle(), config.prometheus_registry(), - )?; - - let provider = client.clone() as Arc>; - let finality_proof_provider = - Arc::new(GrandpaFinalityProofProvider::new(backend.clone(), provider)); - - let params = sc_service::ServiceParams { - backend, - client, - import_queue, - keystore, - task_manager, - transaction_pool, - config, - block_announce_validator_builder: None, - finality_proof_request_builder: None, - finality_proof_provider: Some(finality_proof_provider), - on_demand: None, - remote_blockchain: None, - rpc_extensions_builder: Box::new(|_| ()), - }; - - Ok(( - params, - select_chain, - inherent_data_providers, - grandpa_block_import, - grandpa_link, - )) -} - -/// Builds a new service for a full client. -pub fn new_full( - config: Configuration, -) -> Result<(TaskManager, Arc), ServiceError> { - let (params, select_chain, inherent_data_providers, block_import, grandpa_link) = - new_full_params(config)?; - + )?; let ( role, force_authoring, name, enable_grandpa, prometheus_registry, - client, - transaction_pool, - keystore, - ) = { - let sc_service::ServiceParams { - config, - client, - transaction_pool, - keystore, - .. - } = ¶ms; + ) = ( + config.role.clone(), + config.force_authoring, + config.network.node_name.clone(), + !config.disable_grandpa, + config.prometheus_registry().cloned(), + ); - ( - config.role.clone(), - config.force_authoring, - config.network.node_name.clone(), - !config.disable_grandpa, - config.prometheus_registry().cloned(), - client.clone(), - transaction_pool.clone(), - keystore.clone(), - ) - }; + let provider = client.clone() as Arc>; + let finality_proof_provider = + Arc::new(GrandpaFinalityProofProvider::new(backend.clone(), provider)); + let (network, network_status_sinks, system_rpc_tx) = build_network(BuildNetworkParams { + config: &config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue, + on_demand: None, + block_announce_validator_builder: None, + finality_proof_request_builder: None, + finality_proof_provider: Some(finality_proof_provider), + })?; + let params = SpawnTasksParams { + config, + client: client.clone(), + backend: backend.clone(), + task_manager: &mut task_manager, + keystore: keystore.clone(), + on_demand: None, + transaction_pool: transaction_pool.clone(), + rpc_extensions_builder: Box::new(|_| {}), + remote_blockchain: None, + network: network.clone(), + network_status_sinks, + system_rpc_tx, + telemetry_connection_sinks: Default::default() + }; - let ServiceComponents { - task_manager, - rpc_handlers, - network, - telemetry_on_connect_sinks, - .. - } = sc_service::build(params)?; + let rpc_handlers = sc_service::spawn_tasks(params)?; if role.is_authority() { let proposer = sc_basic_authorship::ProposerFactory::new( @@ -211,7 +149,7 @@ pub fn new_full( sc_consensus_aura::slot_duration(&*client)?, client.clone(), select_chain, - block_import, + grandpa_block_import, proposer, network.clone(), inherent_data_providers.clone(), @@ -256,7 +194,7 @@ pub fn new_full( link: grandpa_link, network, inherent_data_providers, - telemetry_on_connect: Some(telemetry_on_connect_sinks.on_connect_stream()), + telemetry_on_connect: None, voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(), prometheus_registry, shared_voter_state: SharedVoterState::empty(), @@ -282,20 +220,17 @@ pub fn new_full( /// Builds a new service for a light client. pub fn new_light( config: Configuration, -) -> Result<(TaskManager, Arc), ServiceError> { - let (client, backend, keystore, task_manager, on_demand) = +) -> Result<(TaskManager, RpcHandlers), ServiceError> { + let (client, backend, keystore, mut task_manager, on_demand) = sc_service::new_light_parts::(&config)?; - let transaction_pool_api = Arc::new(sc_transaction_pool::LightChainApi::new( - client.clone(), - on_demand.clone(), - )); - let transaction_pool = sc_transaction_pool::BasicPool::new_light( + let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light( config.transaction_pool.clone(), - transaction_pool_api, config.prometheus_registry(), - task_manager.spawn_handle(), - ); + task_manager.spawn_handle(), + client.clone(), + on_demand.clone(), + )); let grandpa_block_import = sc_finality_grandpa::light_block_import( client.clone(), @@ -321,28 +256,36 @@ pub fn new_light( let finality_proof_provider = Arc::new(GrandpaFinalityProofProvider::new( backend.clone(), client.clone() as Arc<_>, - )); - - sc_service::build(sc_service::ServiceParams { + )); + + let (network, network_status_sinks, system_rpc_tx) = build_network(BuildNetworkParams { + config: &config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue, + on_demand: Some(on_demand.clone()), block_announce_validator_builder: None, finality_proof_request_builder: Some(finality_proof_request_builder), finality_proof_provider: Some(finality_proof_provider), + })?; + + let params = SpawnTasksParams { on_demand: Some(on_demand), + network, + client, + backend: backend.clone(), + network_status_sinks, + system_rpc_tx, + telemetry_connection_sinks: Default::default(), remote_blockchain: Some(backend.remote_blockchain()), rpc_extensions_builder: Box::new(|_| ()), - transaction_pool: Arc::new(transaction_pool), + transaction_pool, config, - client, - import_queue, keystore, - backend, - task_manager, - }) - .map( - |ServiceComponents { - task_manager, - rpc_handlers, - .. - }| (task_manager, rpc_handlers), - ) + task_manager: &mut task_manager, + }; + + sc_service::spawn_tasks(params) + .map(|rpc_handlers| (task_manager, rpc_handlers)) }