Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Companion PR for Remove the service, replacing it with a struct of individual chain components #1288

Merged
16 commits merged into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/src/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ async fn start_inner(chain_spec: String, log_level: String) -> Result<Client, Bo
info!("👤 Role: {}", config.display_role());

// Create the service. This is the most heavy initialization step.
let service = service::kusama_new_light(config)
let (task_manager, rpc_handlers) = service::kusama_new_light(config)
.map_err(|e| format!("{:?}", e))?;

Ok(browser_utils::start_client(service))
Ok(browser_utils::start_client(task_manager, rpc_handlers))
}
97 changes: 47 additions & 50 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ use log::info;
use service::{IdentifyVariant, self};
#[cfg(feature = "service-rewr")]
use service_new::{IdentifyVariant, self as service};
use sc_executor::NativeExecutionDispatch;
use sc_cli::{SubstrateCli, Result};
use sc_cli::{SubstrateCli, Result, RuntimeVersion, Role};
use crate::cli::{Cli, Subcommand};

fn get_exec_name() -> Option<String> {
Expand Down Expand Up @@ -75,6 +74,16 @@ impl SubstrateCli for Cli {
path => Box::new(service::PolkadotChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
}

fn native_runtime_version(spec: &Box<dyn service::ChainSpec>) -> &'static RuntimeVersion {
if spec.is_kusama() {
&service::kusama_runtime::VERSION
} else if spec.is_westend() {
&service::westend_runtime::VERSION
} else {
&service::polkadot_runtime::VERSION
}
}
}

/// Parses polkadot specific CLI arguments and run the service.
Expand Down Expand Up @@ -116,56 +125,44 @@ pub fn run() -> Result<()> {
info!(" KUSAMA FOUNDATION ");
info!("----------------------------");

runtime.run_node(
|config| {
service::kusama_new_light(config)
},
|config| {
service::kusama_new_full(
config,
None,
None,
authority_discovery_enabled,
6000,
grandpa_pause,
).map(|(s, _, _)| s)
},
service::KusamaExecutor::native_version().runtime_version
)
runtime.run_node_until_exit(|config| match config.role {
Role::Light => service::kusama_new_light(config)
.map(|(components, _)| components),
_ => service::kusama_new_full(
config,
None,
None,
authority_discovery_enabled,
6000,
grandpa_pause,
).map(|(components, _, _)| components)
})
} else if chain_spec.is_westend() {
runtime.run_node(
|config| {
service::westend_new_light(config)
},
|config| {
service::westend_new_full(
config,
None,
None,
authority_discovery_enabled,
6000,
grandpa_pause,
).map(|(s, _, _)| s)
},
service::WestendExecutor::native_version().runtime_version
)
runtime.run_node_until_exit(|config| match config.role {
Role::Light => service::westend_new_light(config)
.map(|(components, _)| components),
_ => service::westend_new_full(
config,
None,
None,
authority_discovery_enabled,
6000,
grandpa_pause,
).map(|(components, _, _)| components)
})
} else {
runtime.run_node(
|config| {
service::polkadot_new_light(config)
},
|config| {
service::polkadot_new_full(
config,
None,
None,
authority_discovery_enabled,
6000,
grandpa_pause,
).map(|(s, _, _)| s)
},
service::PolkadotExecutor::native_version().runtime_version
)
runtime.run_node_until_exit(|config| match config.role {
Role::Light => service::polkadot_new_light(config)
.map(|(components, _)| components),
_ => service::polkadot_new_full(
config,
None,
None,
authority_discovery_enabled,
6000,
grandpa_pause,
).map(|(components, _, _)| components)
})
}
},
Some(Subcommand::Base(subcommand)) => {
Expand Down
4 changes: 2 additions & 2 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ mod command;

#[cfg(not(feature = "service-rewr"))]
pub use service::{
AbstractService, ProvideRuntimeApi, CoreApi, ParachainHost, IdentifyVariant,
ProvideRuntimeApi, CoreApi, ParachainHost, IdentifyVariant,
Block, self, RuntimeApiCollection, TFullClient
};

#[cfg(feature = "service-rewr")]
pub use service_new::{
self as service,
AbstractService, ProvideRuntimeApi, CoreApi, ParachainHost, IdentifyVariant,
ProvideRuntimeApi, CoreApi, ParachainHost, IdentifyVariant,
Block, self, RuntimeApiCollection, TFullClient
};

Expand Down
14 changes: 7 additions & 7 deletions collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ use polkadot_primitives::{
}
};
use polkadot_cli::{
ProvideRuntimeApi, AbstractService, ParachainHost, IdentifyVariant,
ProvideRuntimeApi, ParachainHost, IdentifyVariant,
service::{self, Role}
};
pub use polkadot_cli::service::Configuration;
Expand Down Expand Up @@ -386,15 +386,15 @@ where
}

if config.chain_spec.is_kusama() {
let (service, client, handlers) = service::kusama_new_full(
let (task_manager, client, handlers) = service::kusama_new_full(
config,
Some((key.public(), para_id)),
None,
false,
6000,
None,
)?;
let spawn_handle = service.spawn_task_handle();
let spawn_handle = task_manager.spawn_handle();
build_collator_service(
spawn_handle,
handlers,
Expand All @@ -404,15 +404,15 @@ where
build_parachain_context
)?.await;
} else if config.chain_spec.is_westend() {
let (service, client, handlers) = service::westend_new_full(
let (task_manager, client, handlers) = service::westend_new_full(
config,
Some((key.public(), para_id)),
None,
false,
6000,
None,
)?;
let spawn_handle = service.spawn_task_handle();
let spawn_handle = task_manager.spawn_handle();
build_collator_service(
spawn_handle,
handlers,
Expand All @@ -422,15 +422,15 @@ where
build_parachain_context
)?.await;
} else {
let (service, client, handles) = service::polkadot_new_full(
let (task_manager, client, handles) = service::polkadot_new_full(
config,
Some((key.public(), para_id)),
None,
false,
6000,
None,
)?;
let spawn_handle = service.spawn_task_handle();
let spawn_handle = task_manager.spawn_handle();
build_collator_service(
spawn_handle,
handles,
Expand Down
Loading