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 -8
View File
@@ -34,7 +34,7 @@ use sc_service::{
Configuration,
config::{DatabaseConfig, KeystoreConfig},
RuntimeGenesis,
Roles,
Role,
Error,
};
use sc_network::{multiaddr, Multiaddr, NetworkStateInfo};
@@ -134,7 +134,7 @@ where F: Send + 'static, L: Send +'static, U: Clone + Send + 'static
fn node_config<G: RuntimeGenesis + 'static, E: ChainSpecExtension + Clone + 'static + Send> (
index: usize,
spec: &GenericChainSpec<G, E>,
role: Roles,
role: Role,
task_executor: Arc<dyn Fn(Pin<Box<dyn futures::Future<Output = ()> + Send>>) + Send + Sync>,
key_seed: Option<String>,
base_port: u16,
@@ -161,7 +161,6 @@ fn node_config<G: RuntimeGenesis + 'static, E: ChainSpecExtension + Clone + 'sta
out_peers: 450,
reserved_nodes: vec![],
non_reserved_mode: NonReservedPeerMode::Accept,
sentry_nodes: vec![],
client_version: "network/test/0.1".to_owned(),
node_name: "unknown".to_owned(),
transport: TransportConfig::Normal {
@@ -177,7 +176,7 @@ fn node_config<G: RuntimeGenesis + 'static, E: ChainSpecExtension + Clone + 'sta
impl_name: "network-test-impl",
impl_version: "0.1",
impl_commit: "",
roles: role,
role,
task_executor: Some(task_executor),
transaction_pool: Default::default(),
network: network_config,
@@ -206,7 +205,6 @@ fn node_config<G: RuntimeGenesis + 'static, E: ChainSpecExtension + Clone + 'sta
telemetry_external_transport: None,
default_heap_pages: None,
offchain_worker: false,
sentry_mode: false,
force_authoring: false,
disable_grandpa: false,
dev_key_seed: key_seed,
@@ -267,7 +265,7 @@ impl<G, E, F, L, U> TestNet<G, E, F, L, U> where
let node_config = node_config(
self.nodes,
&self.chain_spec,
Roles::AUTHORITY,
Role::Authority { sentry_nodes: Vec::new() },
task_executor,
Some(key),
self.base_port,
@@ -288,7 +286,7 @@ impl<G, E, F, L, U> TestNet<G, E, F, L, U> where
let executor = executor.clone();
Arc::new(move |fut: Pin<Box<dyn futures::Future<Output = ()> + Send>>| executor.spawn(fut.unit_error().compat()))
};
let node_config = node_config(self.nodes, &self.chain_spec, Roles::FULL, task_executor, None, self.base_port, &temp);
let node_config = node_config(self.nodes, &self.chain_spec, Role::Full, task_executor, None, self.base_port, &temp);
let addr = node_config.network.listen_addresses.iter().next().unwrap().clone();
let (service, user_data) = full(node_config).expect("Error creating test node service");
let service = SyncService::from(service);
@@ -304,7 +302,7 @@ impl<G, E, F, L, U> TestNet<G, E, F, L, U> where
let executor = executor.clone();
Arc::new(move |fut: Pin<Box<dyn futures::Future<Output = ()> + Send>>| executor.spawn(fut.unit_error().compat()))
};
let node_config = node_config(self.nodes, &self.chain_spec, Roles::LIGHT, task_executor, None, self.base_port, &temp);
let node_config = node_config(self.nodes, &self.chain_spec, Role::Light, task_executor, None, self.base_port, &temp);
let addr = node_config.network.listen_addresses.iter().next().unwrap().clone();
let service = SyncService::from(light(node_config).expect("Error creating test node service"));