mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 12:17:58 +00:00
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:
@@ -45,7 +45,7 @@ async fn start_inner(chain_spec: String, log_level: String) -> Result<Client, Bo
|
||||
info!("❤️ by Parity Technologies, 2017-2020");
|
||||
info!("📋 Chain specification: {}", config.expect_chain_spec().name());
|
||||
info!("🏷 Node name: {}", config.name);
|
||||
info!("👤 Roles: {:?}", config.roles);
|
||||
info!("👤 Role: {:?}", config.role);
|
||||
|
||||
// Create the service. This is the most heavy initialization step.
|
||||
let service = crate::service::new_light(config)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use sc_cli::VersionInfo;
|
||||
use sc_service::{Roles as ServiceRoles};
|
||||
use sc_service::{Role as ServiceRole};
|
||||
use node_transaction_factory::RuntimeAdapter;
|
||||
use crate::{Cli, service, ChainSpec, load_spec, Subcommand, factory_impl::FactoryState};
|
||||
|
||||
@@ -65,7 +65,7 @@ where
|
||||
cli_args.shared_params.update_config(&mut config, load_spec, &version)?;
|
||||
cli_args.import_params.update_config(
|
||||
&mut config,
|
||||
ServiceRoles::FULL,
|
||||
&ServiceRole::Full,
|
||||
cli_args.shared_params.dev,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -120,24 +120,17 @@ macro_rules! new_full {
|
||||
use sc_client_api::ExecutorProvider;
|
||||
|
||||
let (
|
||||
is_authority,
|
||||
role,
|
||||
force_authoring,
|
||||
name,
|
||||
disable_grandpa,
|
||||
sentry_nodes,
|
||||
) = (
|
||||
$config.roles.is_authority(),
|
||||
$config.role.clone(),
|
||||
$config.force_authoring,
|
||||
$config.name.clone(),
|
||||
$config.disable_grandpa,
|
||||
$config.network.sentry_nodes.clone(),
|
||||
);
|
||||
|
||||
// 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);
|
||||
|
||||
let service = builder
|
||||
@@ -153,7 +146,7 @@ macro_rules! new_full {
|
||||
|
||||
($with_startup_data)(&block_import, &babe_link);
|
||||
|
||||
if participates_in_consensus {
|
||||
if let sc_service::config::Role::Authority { sentry_nodes } = &role {
|
||||
let proposer = sc_basic_authorship::ProposerFactory::new(
|
||||
service.client(),
|
||||
service.transaction_pool()
|
||||
@@ -190,7 +183,7 @@ macro_rules! new_full {
|
||||
let authority_discovery = sc_authority_discovery::AuthorityDiscovery::new(
|
||||
service.client(),
|
||||
network,
|
||||
sentry_nodes,
|
||||
sentry_nodes.clone(),
|
||||
service.keystore(),
|
||||
dht_event_stream,
|
||||
service.prometheus_registry(),
|
||||
@@ -201,7 +194,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 participates_in_consensus {
|
||||
let keystore = if role.is_authority() {
|
||||
Some(service.keystore())
|
||||
} else {
|
||||
None
|
||||
@@ -214,7 +207,7 @@ macro_rules! new_full {
|
||||
name: Some(name),
|
||||
observer_enabled: false,
|
||||
keystore,
|
||||
is_authority,
|
||||
is_authority: role.is_network_authority(),
|
||||
};
|
||||
|
||||
let enable_grandpa = !disable_grandpa;
|
||||
|
||||
Reference in New Issue
Block a user