@@ -27,7 +27,6 @@ use polkadot_runtime::GenesisConfig;
27
27
use polkadot_network:: { gossip:: { self as network_gossip, Known } , validation:: ValidationNetwork } ;
28
28
use service:: { error:: { Error as ServiceError } , Configuration , ServiceBuilder } ;
29
29
use transaction_pool:: txpool:: { Pool as TransactionPool } ;
30
- use babe:: { import_queue, start_babe} ;
31
30
use grandpa:: { self , FinalityProofProvider as GrandpaFinalityProofProvider } ;
32
31
use inherents:: InherentDataProviders ;
33
32
use log:: info;
@@ -98,20 +97,20 @@ macro_rules! new_full_start {
98
97
let justification_import = grandpa_block_import. clone( ) ;
99
98
100
99
let ( block_import, babe_link) = babe:: block_import(
101
- babe:: Config :: get_or_compute( & * client) ?,
102
- grandpa_block_import,
103
- client. clone( ) ,
104
- client. clone( ) ,
100
+ babe:: Config :: get_or_compute( & * client) ?,
101
+ grandpa_block_import,
102
+ client. clone( ) ,
103
+ client. clone( ) ,
105
104
) ?;
106
105
107
106
let import_queue = babe:: import_queue(
108
- babe_link. clone( ) ,
109
- block_import. clone( ) ,
110
- Some ( Box :: new( justification_import) ) ,
111
- None ,
112
- client. clone( ) ,
113
- client,
114
- inherent_data_providers. clone( ) ,
107
+ babe_link. clone( ) ,
108
+ block_import. clone( ) ,
109
+ Some ( Box :: new( justification_import) ) ,
110
+ None ,
111
+ client. clone( ) ,
112
+ client,
113
+ inherent_data_providers. clone( ) ,
115
114
) ?;
116
115
117
116
import_setup = Some ( ( block_import, grandpa_link, babe_link) ) ;
@@ -258,49 +257,48 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
258
257
babe_link,
259
258
} ;
260
259
261
- let babe = start_babe ( babe_config) ?;
262
- let select = babe. select ( service. on_exit ( ) ) . then ( |_| Ok ( ( ) ) ) ;
263
- service. spawn_essential_task ( Box :: new ( select) ) ;
260
+ let babe = babe:: start_babe ( babe_config) ?;
261
+ service. spawn_essential_task ( babe) ;
264
262
}
265
263
264
+ let keystore = if is_authority {
265
+ Some ( service. keystore ( ) )
266
+ } else {
267
+ None
268
+ } ;
269
+
266
270
let config = grandpa:: Config {
267
271
// FIXME substrate#1578 make this available through chainspec
268
272
gossip_duration : Duration :: from_millis ( 333 ) ,
269
273
justification_period : 512 ,
270
274
name : Some ( name) ,
271
- keystore : Some ( service . keystore ( ) ) ,
275
+ keystore,
272
276
} ;
273
277
274
- match ( is_authority, disable_grandpa) {
275
- ( false , false ) => {
276
- // start the lightweight GRANDPA observer
277
- service. spawn_task ( Box :: new ( grandpa:: run_grandpa_observer (
278
- config,
279
- link_half,
280
- service. network ( ) ,
281
- service. on_exit ( ) ,
282
- ) ?) ) ;
283
- } ,
284
- ( true , false ) => {
285
- // start the full GRANDPA voter
286
- let grandpa_config = grandpa:: GrandpaParams {
287
- config : config,
288
- link : link_half,
289
- network : service. network ( ) ,
290
- inherent_data_providers : inherent_data_providers. clone ( ) ,
291
- on_exit : service. on_exit ( ) ,
292
- telemetry_on_connect : Some ( service. telemetry_on_connect_stream ( ) ) ,
293
- voting_rule : grandpa:: VotingRulesBuilder :: default ( ) . build ( ) ,
294
- } ;
295
- service. spawn_essential_task ( Box :: new ( grandpa:: run_grandpa_voter ( grandpa_config) ?) ) ;
296
- } ,
297
- ( _, true ) => {
298
- grandpa:: setup_disabled_grandpa (
299
- service. client ( ) ,
300
- & inherent_data_providers,
301
- service. network ( ) ,
302
- ) ?;
303
- } ,
278
+ let enable_grandpa = !disable_grandpa;
279
+ if enable_grandpa {
280
+ // start the full GRANDPA voter
281
+ // NOTE: unlike in polkadot/master we are currently running the full
282
+ // GRANDPA voter protocol for all full nodes (regardless of whether
283
+ // they're validators or not). at this point the full voter should
284
+ // provide better guarantees of block and vote data availability than
285
+ // the observer.
286
+ let grandpa_config = grandpa:: GrandpaParams {
287
+ config : config,
288
+ link : link_half,
289
+ network : service. network ( ) ,
290
+ inherent_data_providers : inherent_data_providers. clone ( ) ,
291
+ on_exit : service. on_exit ( ) ,
292
+ telemetry_on_connect : Some ( service. telemetry_on_connect_stream ( ) ) ,
293
+ voting_rule : grandpa:: VotingRulesBuilder :: default ( ) . build ( ) ,
294
+ } ;
295
+ service. spawn_essential_task ( grandpa:: run_grandpa_voter ( grandpa_config) ?) ;
296
+ } else {
297
+ grandpa:: setup_disabled_grandpa (
298
+ service. client ( ) ,
299
+ & inherent_data_providers,
300
+ service. network ( ) ,
301
+ ) ?;
304
302
}
305
303
306
304
Ok ( service)
@@ -336,7 +334,6 @@ pub fn new_light(config: Configuration<CustomConfiguration, GenesisConfig>)
336
334
let finality_proof_request_builder =
337
335
finality_proof_import. create_finality_proof_request_builder ( ) ;
338
336
339
-
340
337
let ( babe_block_import, babe_link) = babe:: block_import (
341
338
babe:: Config :: get_or_compute ( & * client) ?,
342
339
grandpa_block_import,
@@ -345,7 +342,7 @@ pub fn new_light(config: Configuration<CustomConfiguration, GenesisConfig>)
345
342
) ?;
346
343
347
344
// FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`.
348
- let import_queue = import_queue (
345
+ let import_queue = babe :: import_queue (
349
346
babe_link,
350
347
babe_block_import,
351
348
None ,
0 commit comments