Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge branch 'master' into fs-alternate-service
  • Loading branch information
montekki committed Jun 11, 2020
commit 1a13b9cd2fe643b1ed7bb476c3813606eed93316
49 changes: 4 additions & 45 deletions collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,51 +383,10 @@ where
P::ParachainContext: Send + 'static,
<P::ParachainContext as ParachainContext>::ProduceCandidate: Send,
{
let is_kusama = config.chain_spec.is_kusama();
match (is_kusama, &config.role) {
(_, Role::Light) => Err(
ServiceError::Other("light nodes are unsupported as collator".into())
).into(),
(true, _) => {
let (service, client, handlers) = service::kusama_new_full(
config,
Some((key.public(), para_id)),
None,
false,
6000,
None
)?;
let spawn_handle = service.spawn_task_handle();
build_collator_service(
spawn_handle,
handlers,
client,
para_id,
key,
build_parachain_context
)?.await;
Ok(())
},
(false, _) => {
let (service, client, handles) = service::polkadot_new_full(
config,
Some((key.public(), para_id)),
None,
false,
6000,
None
)?;
let spawn_handle = service.spawn_task_handle();
build_collator_service(
spawn_handle,
handles,
client,
para_id,
key,
build_parachain_context,
)?.await;
Ok(())
}
if matches!(config.role, Role::Light) {
return Err(
polkadot_service::Error::Other("light nodes are unsupported as collator".into())
.into());
}

if config.chain_spec.is_kusama() {
Expand Down
29 changes: 19 additions & 10 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fn set_prometheus_registry(config: &mut Configuration) -> Result<(), ServiceErro
/// Use this macro if you don't actually need the full service, but just the builder in order to
/// be able to perform chain operations.
macro_rules! new_full_start {
($config:expr, $runtime:ty, $executor:ty) => {{
($config:expr, $runtime:ty, $executor:ty, $informant_prefix:expr $(,)?) => {{
set_prometheus_registry(&mut $config)?;

let mut import_setup = None;
Expand All @@ -162,6 +162,7 @@ macro_rules! new_full_start {
let builder = service::ServiceBuilder::new_full::<
Block, $runtime, $executor
>($config)?
.with_informant_prefix($informant_prefix.unwrap_or_default())?
.with_select_chain(|_, backend| {
Ok(sc_consensus::LongestChain::new(backend.clone()))
})?
Expand Down Expand Up @@ -306,9 +307,11 @@ macro_rules! new_full {
$authority_discovery_enabled:expr,
$grandpa_pause:expr,
$runtime:ty,
$dispatch:ty
$dispatch:ty,
$informant_prefix:expr $(,)?
) => {{
use sc_client_api::ExecutorProvider;
use sp_core::traits::BareCryptoStorePtr;

let is_collator = $collating_for.is_some();
let role = $config.role.clone();
Expand All @@ -318,14 +321,14 @@ macro_rules! new_full {
let name = $config.network.node_name.clone();

let (builder, mut import_setup, inherent_data_providers, mut rpc_setup) =
new_full_start!($config, $runtime, $dispatch);
new_full_start!($config, $runtime, $dispatch, $informant_prefix);

let service = builder
.with_finality_proof_provider(|client, backend| {
let provider = client as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
})?
.build()?;
.build_full()?;

let (block_import, link_half, babe_link) = import_setup.take()
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
Expand Down Expand Up @@ -406,7 +409,7 @@ macro_rules! new_full {
// if the node isn't actively participating in consensus then it doesn't
// need a keystore, regardless of which protocol we use below.
let keystore = if is_authority {
Some(service.keystore())
Some(service.keystore() as BareCryptoStorePtr)
} else {
None
};
Expand Down Expand Up @@ -563,7 +566,7 @@ macro_rules! new_light {
};
Ok(polkadot_rpc::create_light(light_deps))
})?
.build()
.build_light()
}}
}

Expand All @@ -579,7 +582,7 @@ where
<Runtime::RuntimeApi as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{
config.keystore = service::config::KeystoreConfig::InMemory;
Ok(new_full_start!(config, Runtime, Dispatch).0)
Ok(new_full_start!(config, Runtime, Dispatch, None).0)
}

/// Create a new Polkadot service for a full node.
Expand All @@ -591,6 +594,7 @@ pub fn polkadot_new_full(
_authority_discovery_enabled: bool,
_slot_duration: u64,
grandpa_pause: Option<(u32, u32)>,
informant_prefix: Option<String>,
)
-> Result<(
impl AbstractService,
Expand All @@ -608,7 +612,8 @@ pub fn polkadot_new_full(
authority_discovery_enabled,
grandpa_pause,
polkadot_runtime::RuntimeApi,
PolkadotExecutor
PolkadotExecutor,
informant_prefix,
);

Ok((service, client, FullNodeHandles))
Expand All @@ -623,6 +628,7 @@ pub fn kusama_new_full(
_authority_discovery_enabled: bool,
_slot_duration: u64,
grandpa_pause: Option<(u32, u32)>,
informant_prefix: Option<String>,
) -> Result<(
impl AbstractService,
Arc<impl PolkadotClient<
Expand All @@ -640,7 +646,8 @@ pub fn kusama_new_full(
authority_discovery_enabled,
grandpa_pause,
kusama_runtime::RuntimeApi,
KusamaExecutor
KusamaExecutor,
informant_prefix,
);

Ok((service, client, FullNodeHandles))
Expand All @@ -655,6 +662,7 @@ pub fn westend_new_full(
_authority_discovery_enabled: bool,
_slot_duration: u64,
grandpa_pause: Option<(u32, u32)>,
informant_prefix: Option<String>,
)
-> Result<(
impl AbstractService,
Expand All @@ -672,7 +680,8 @@ pub fn westend_new_full(
authority_discovery_enabled,
grandpa_pause,
westend_runtime::RuntimeApi,
WestendExecutor
WestendExecutor,
informant_prefix,
);

Ok((service, client, FullNodeHandles))
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.