mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +00:00
Fix service setup for non-validator nodes (#378)
* Fix service setup for non-validator nodes * Apply suggestions
This commit is contained in:
committed by
Gavin Wood
parent
2c6409a942
commit
da39da8a04
@@ -169,6 +169,16 @@ pub fn register_validator<O: KnownOracle + 'static>(
|
|||||||
RegisteredMessageValidator { inner: validator as _ }
|
RegisteredMessageValidator { inner: validator as _ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Register a gossip validator for a non-authority node.
|
||||||
|
pub fn register_non_authority_validator(service: Arc<NetworkService>) {
|
||||||
|
service.with_gossip(|gossip, ctx|
|
||||||
|
gossip.register_validator(
|
||||||
|
ctx,
|
||||||
|
POLKADOT_ENGINE_ID,
|
||||||
|
Arc::new(substrate_network::consensus_gossip::DiscardAll)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// A registered message validator.
|
/// A registered message validator.
|
||||||
///
|
///
|
||||||
/// Create this using `register_validator`.
|
/// Create this using `register_validator`.
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ use std::sync::Arc;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use polkadot_primitives::{parachain, Block, Hash, BlockId};
|
use polkadot_primitives::{parachain, Block, Hash, BlockId};
|
||||||
use polkadot_runtime::{GenesisConfig, RuntimeApi};
|
use polkadot_runtime::{GenesisConfig, RuntimeApi};
|
||||||
use polkadot_network::gossip::{self as network_gossip, Known};
|
use polkadot_network::{gossip::{self as network_gossip, Known}, validation::ValidationNetwork};
|
||||||
use service::{
|
use service::{
|
||||||
FactoryFullConfiguration, FullBackend, LightBackend, FullExecutor, LightExecutor,
|
FactoryFullConfiguration, FullBackend, LightBackend, FullExecutor, LightExecutor,
|
||||||
error::Error as ServiceError, TelemetryOnConnect
|
error::Error as ServiceError, TelemetryOnConnect
|
||||||
@@ -198,10 +198,6 @@ service::construct_service_factory! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if service.config().roles != service::Roles::AUTHORITY {
|
|
||||||
return Ok(service);
|
|
||||||
}
|
|
||||||
|
|
||||||
if service.config().custom.collating_for.is_some() {
|
if service.config().custom.collating_for.is_some() {
|
||||||
info!(
|
info!(
|
||||||
"The node cannot start as an authority because it is also configured to run as a collator."
|
"The node cannot start as an authority because it is also configured to run as a collator."
|
||||||
@@ -241,7 +237,7 @@ service::construct_service_factory! {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
use polkadot_network::validation::ValidationNetwork;
|
if service.config().roles.is_authority() {
|
||||||
let extrinsic_store = {
|
let extrinsic_store = {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
@@ -293,7 +289,10 @@ service::construct_service_factory! {
|
|||||||
|
|
||||||
let babe = start_babe(babe_config)?;
|
let babe = start_babe(babe_config)?;
|
||||||
let select = babe.select(service.on_exit()).then(|_| Ok(()));
|
let select = babe.select(service.on_exit()).then(|_| Ok(()));
|
||||||
service.spawn_task(Box::new(select));
|
service.spawn_essential_task(Box::new(select));
|
||||||
|
} else {
|
||||||
|
network_gossip::register_non_authority_validator(service.network());
|
||||||
|
}
|
||||||
|
|
||||||
let config = grandpa::Config {
|
let config = grandpa::Config {
|
||||||
// FIXME substrate#1578 make this available through chainspec
|
// FIXME substrate#1578 make this available through chainspec
|
||||||
@@ -326,7 +325,7 @@ service::construct_service_factory! {
|
|||||||
on_exit: service.on_exit(),
|
on_exit: service.on_exit(),
|
||||||
telemetry_on_connect: Some(telemetry_on_connect),
|
telemetry_on_connect: Some(telemetry_on_connect),
|
||||||
};
|
};
|
||||||
service.spawn_task(Box::new(grandpa::run_grandpa_voter(grandpa_config)?));
|
service.spawn_essential_task(Box::new(grandpa::run_grandpa_voter(grandpa_config)?));
|
||||||
},
|
},
|
||||||
(_, true) => {
|
(_, true) => {
|
||||||
grandpa::setup_disabled_grandpa(
|
grandpa::setup_disabled_grandpa(
|
||||||
@@ -336,45 +335,6 @@ service::construct_service_factory! {
|
|||||||
)?;
|
)?;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// let config = grandpa::Config {
|
|
||||||
// // FIXME #1578 make this available through chainspec
|
|
||||||
// gossip_duration: Duration::from_millis(333),
|
|
||||||
// justification_period: 4096,
|
|
||||||
// name: Some(service.config().name.clone()),
|
|
||||||
// keystore: Some(service.keystore()),
|
|
||||||
// };
|
|
||||||
|
|
||||||
// if !service.config().disable_grandpa {
|
|
||||||
// if service.config().roles.is_authority() {
|
|
||||||
// let telemetry_on_connect = TelemetryOnConnect {
|
|
||||||
// telemetry_connection_sinks: service.telemetry_on_connect_stream(),
|
|
||||||
// };
|
|
||||||
// let grandpa_config = grandpa::GrandpaParams {
|
|
||||||
// config: config,
|
|
||||||
// link: link_half,
|
|
||||||
// network: service.network(),
|
|
||||||
// inherent_data_providers: service.config().custom.inherent_data_providers.clone(),
|
|
||||||
// on_exit: service.on_exit(),
|
|
||||||
// telemetry_on_connect: Some(telemetry_on_connect),
|
|
||||||
// };
|
|
||||||
// service.spawn_task(Box::new(grandpa::run_grandpa_voter(grandpa_config)?));
|
|
||||||
// } else {
|
|
||||||
// service.spawn_task(Box::new(grandpa::run_grandpa_observer(
|
|
||||||
// config,
|
|
||||||
// link_half,
|
|
||||||
// service.network(),
|
|
||||||
// service.on_exit(),
|
|
||||||
// )?));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // regardless of whether grandpa is started or not, when
|
|
||||||
// // authoring blocks we expect inherent data regarding what our
|
|
||||||
// // last finalized block is, to be available.
|
|
||||||
// grandpa::register_finality_tracker_inherent_data_provider(
|
|
||||||
// service.client(),
|
|
||||||
// &service.config().custom.inherent_data_providers,
|
|
||||||
// )?;
|
|
||||||
|
|
||||||
Ok(service)
|
Ok(service)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user