Companion PR to splitting Roles (#960)

* Companion PR to splitting Roles

* Fix network tests

* Fix service build

* Even more fixing

* Oops, quick fix

* use is_network_authority in grandpa service config

Co-authored-by: André Silva <andre.beat@gmail.com>
This commit is contained in:
Pierre Krieger
2020-04-03 19:08:46 +02:00
committed by GitHub
parent a26d919d8b
commit 8ce7154111
7 changed files with 41 additions and 51 deletions
+7 -12
View File
@@ -31,7 +31,7 @@ use inherents::InherentDataProviders;
use sc_executor::native_executor_instance;
use log::info;
pub use service::{
AbstractService, Roles, PruningMode, TransactionPoolOptions, Error, RuntimeGenesis, ServiceBuilderCommand,
AbstractService, Role, PruningMode, TransactionPoolOptions, Error, RuntimeGenesis, ServiceBuilderCommand,
TFullClient, TLightClient, TFullBackend, TLightBackend, TFullCallExecutor, TLightCallExecutor,
Configuration, ChainSpec,
};
@@ -314,7 +314,8 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(
use futures::stream::StreamExt;
let is_collator = collating_for.is_some();
let is_authority = config.roles.is_authority() && !is_collator;
let role = config.role.clone();
let is_authority = role.is_authority() && !is_collator;
let force_authoring = config.force_authoring;
let max_block_data_size = max_block_data_size;
let db_path = if let DatabaseConfig::Path { ref path, .. } = config.expect_database() {
@@ -325,14 +326,8 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(
let disable_grandpa = config.disable_grandpa;
let name = config.name.clone();
let authority_discovery_enabled = authority_discovery_enabled;
let sentry_nodes = config.network.sentry_nodes.clone();
let slot_duration = slot_duration;
// sentry nodes announce themselves as authorities to the network
// and should run the same protocols authorities do, but it should
// never actively participate in any consensus process.
let participates_in_consensus = is_authority && !config.sentry_mode;
let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config, Runtime, Dispatch);
let backend = builder.backend().clone();
@@ -388,7 +383,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(
service.spawn_task_handle(),
).map_err(|e| format!("Could not spawn network worker: {:?}", e))?;
if participates_in_consensus {
if let Role::Authority { sentry_nodes } = &role {
let availability_store = {
use std::path::PathBuf;
@@ -470,7 +465,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(
let authority_discovery = authority_discovery::AuthorityDiscovery::new(
service.client(),
network,
sentry_nodes,
sentry_nodes.clone(),
service.keystore(),
dht_event_stream,
service.prometheus_registry(),
@@ -481,7 +476,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(
// 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 participates_in_consensus {
let keystore = if is_authority {
Some(service.keystore())
} else {
None
@@ -494,7 +489,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(
name: Some(name),
observer_enabled: false,
keystore,
is_authority,
is_authority: role.is_network_authority(),
};
let enable_grandpa = !disable_grandpa;