Split the Roles in three types (#5520)

* Split the Roles bitfield in three

* Forgot to include some changes

* Fix cli test

* More test fixes

* Oh God, merging master broke other tests

* Didn't run the doctests

* Address review

* I'm trying to fix the build blindly because it's taking a good hour to compile on my machine

* Address some review

* Also update the peerset's API to make sense

* Fix peerset tests

* Fix browser node

* client: distinguish between local and network authority

Co-authored-by: André Silva <andre.beat@gmail.com>
This commit is contained in:
Pierre Krieger
2020-04-03 19:08:14 +02:00
committed by GitHub
parent 9dbcb11f66
commit 8c03a4fcef
44 changed files with 591 additions and 432 deletions
+6 -17
View File
@@ -18,7 +18,7 @@
pub use sc_client::ExecutionStrategies;
pub use sc_client_db::{kvdb::KeyValueDB, PruningMode};
pub use sc_network::config::{ExtTransport, NetworkConfiguration, Roles};
pub use sc_network::{Multiaddr, config::{MultiaddrWithPeerId, ExtTransport, NetworkConfiguration, Role}};
pub use sc_executor::WasmExecutionMethod;
use std::{future::Future, path::{PathBuf, Path}, pin::Pin, net::SocketAddr, sync::Arc};
@@ -58,8 +58,8 @@ pub struct Configuration {
pub impl_version: &'static str,
/// Git commit if any.
pub impl_commit: &'static str,
/// Node roles.
pub roles: Roles,
/// Node role.
pub role: Role,
/// How to spawn background tasks. Mandatory, otherwise creating a `Service` will error.
pub task_executor: Option<Arc<dyn Fn(Pin<Box<dyn Future<Output = ()> + Send>>) + Send + Sync>>,
/// Extrinsic pool configuration.
@@ -105,10 +105,6 @@ pub struct Configuration {
pub default_heap_pages: Option<u64>,
/// Should offchain workers be executed.
pub offchain_worker: bool,
/// Sentry mode is enabled, the node's role is AUTHORITY but it should not
/// actively participate in consensus (i.e. no keystores should be passed to
/// consensus modules).
pub sentry_mode: bool,
/// Enable authoring even when offline.
pub force_authoring: bool,
/// Disable GRANDPA when running in validator mode
@@ -204,7 +200,7 @@ impl Default for Configuration {
chain_spec: None,
config_dir: None,
name: Default::default(),
roles: Roles::FULL,
role: Role::Full,
task_executor: None,
transaction_pool: Default::default(),
network: Default::default(),
@@ -224,7 +220,6 @@ impl Default for Configuration {
telemetry_external_transport: None,
default_heap_pages: None,
offchain_worker: Default::default(),
sentry_mode: false,
force_authoring: false,
disable_grandpa: false,
dev_key_seed: None,
@@ -286,15 +281,9 @@ impl Configuration {
self.database.as_ref().expect("database must be specified")
}
/// Returns a string displaying the node role, special casing the sentry mode
/// (returning `SENTRY`), since the node technically has an `AUTHORITY` role but
/// doesn't participate.
/// Returns a string displaying the node role.
pub fn display_role(&self) -> String {
if self.sentry_mode {
"SENTRY".to_string()
} else {
self.roles.to_string()
}
self.role.to_string()
}
/// Use in memory keystore config when it is not required at all.