grandpa: enable observer for light client (#3019)

* grandpa: enable observer for light client

* update Substrate

* service: fix missing import

* runtime: bump spec versions

Co-authored-by: parity-processbot <>
This commit is contained in:
André Silva
2021-05-26 18:22:15 +01:00
committed by GitHub
parent 44704a57e1
commit e3edb71ed7
6 changed files with 182 additions and 159 deletions
+153 -152
View File
File diff suppressed because it is too large Load Diff
+25 -3
View File
@@ -25,7 +25,6 @@ mod parachains_db;
#[cfg(feature = "full-node")] #[cfg(feature = "full-node")]
use { use {
std::time::Duration,
tracing::info, tracing::info,
polkadot_network_bridge::RequestMultiplexer, polkadot_network_bridge::RequestMultiplexer,
polkadot_node_core_av_store::Config as AvailabilityConfig, polkadot_node_core_av_store::Config as AvailabilityConfig,
@@ -51,6 +50,7 @@ use sp_core::traits::SpawnNamed;
use polkadot_subsystem::jaeger; use polkadot_subsystem::jaeger;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration;
use prometheus_endpoint::Registry; use prometheus_endpoint::Registry;
use sc_executor::native_executor_instance; use sc_executor::native_executor_instance;
@@ -1004,7 +1004,7 @@ pub fn new_full<RuntimeApi, Executor>(
name: Some(name), name: Some(name),
observer_enabled: false, observer_enabled: false,
keystore: keystore_opt, keystore: keystore_opt,
is_authority: role.is_authority(), local_role: role,
telemetry: telemetry.as_ref().map(|x| x.handle()), telemetry: telemetry.as_ref().map(|x| x.handle()),
}; };
@@ -1112,6 +1112,8 @@ fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(
telemetry telemetry
}); });
config.network.extra_sets.push(grandpa::grandpa_peers_set_config());
let select_chain = sc_consensus::LongestChain::new(backend.clone()); let select_chain = sc_consensus::LongestChain::new(backend.clone());
let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light( let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
@@ -1122,7 +1124,7 @@ fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(
on_demand.clone(), on_demand.clone(),
)); ));
let (grandpa_block_import, _) = grandpa::block_import( let (grandpa_block_import, grandpa_link) = grandpa::block_import(
client.clone(), client.clone(),
&(client.clone() as Arc<_>), &(client.clone() as Arc<_>),
select_chain.clone(), select_chain.clone(),
@@ -1172,6 +1174,26 @@ fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(
block_announce_validator_builder: None, block_announce_validator_builder: None,
})?; })?;
let enable_grandpa = !config.disable_grandpa;
if enable_grandpa {
let name = config.network.node_name.clone();
let config = grandpa::Config {
gossip_duration: Duration::from_millis(1000),
justification_period: 512,
name: Some(name),
observer_enabled: false,
keystore: None,
local_role: config.role.clone(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
};
task_manager.spawn_handle().spawn_blocking(
"grandpa-observer",
grandpa::run_grandpa_observer(config, grandpa_link, network.clone())?,
);
}
if config.offchain_worker.enabled { if config.offchain_worker.enabled {
let _ = service::build_offchain_workers( let _ = service::build_offchain_workers(
&config, &config,
+1 -1
View File
@@ -120,7 +120,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("kusama"), spec_name: create_runtime_str!("kusama"),
impl_name: create_runtime_str!("parity-kusama"), impl_name: create_runtime_str!("parity-kusama"),
authoring_version: 2, authoring_version: 2,
spec_version: 9030, spec_version: 9031,
impl_version: 0, impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))] #[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS, apis: RUNTIME_API_VERSIONS,
+1 -1
View File
@@ -95,7 +95,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polkadot"), spec_name: create_runtime_str!("polkadot"),
impl_name: create_runtime_str!("parity-polkadot"), impl_name: create_runtime_str!("parity-polkadot"),
authoring_version: 0, authoring_version: 0,
spec_version: 9030, spec_version: 9031,
impl_version: 0, impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))] #[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS, apis: RUNTIME_API_VERSIONS,
+1 -1
View File
@@ -110,7 +110,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("rococo"), spec_name: create_runtime_str!("rococo"),
impl_name: create_runtime_str!("parity-rococo-v1.6"), impl_name: create_runtime_str!("parity-rococo-v1.6"),
authoring_version: 0, authoring_version: 0,
spec_version: 9003, spec_version: 9004,
impl_version: 0, impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))] #[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS, apis: RUNTIME_API_VERSIONS,
+1 -1
View File
@@ -118,7 +118,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("westend"), spec_name: create_runtime_str!("westend"),
impl_name: create_runtime_str!("parity-westend"), impl_name: create_runtime_str!("parity-westend"),
authoring_version: 2, authoring_version: 2,
spec_version: 9030, spec_version: 9031,
impl_version: 0, impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))] #[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS, apis: RUNTIME_API_VERSIONS,