@@ -9,7 +9,6 @@ use sc_service::{error::{Error as ServiceError}, AbstractService, Configuration,
99use sp_inherents:: InherentDataProviders ;
1010use sc_executor:: native_executor_instance;
1111pub use sc_executor:: NativeExecutor ;
12- use sp_consensus_aura:: sr25519:: { AuthorityPair as AuraPair } ;
1312use sc_finality_grandpa:: {
1413 FinalityProofProvider as GrandpaFinalityProofProvider , StorageAndProofProvider , SharedVoterState ,
1514} ;
@@ -28,7 +27,6 @@ native_executor_instance!(
2827macro_rules! new_full_start {
2928 ( $config: expr) => { {
3029 use std:: sync:: Arc ;
31- use sp_consensus_aura:: sr25519:: AuthorityPair as AuraPair ;
3230
3331 let mut import_setup = None ;
3432 let inherent_data_providers = sp_inherents:: InherentDataProviders :: new( ) ;
@@ -68,22 +66,25 @@ macro_rules! new_full_start {
6866 select_chain,
6967 ) ?;
7068
71- let aura_block_import = sc_consensus_aura:: AuraBlockImport :: <_, _, _, AuraPair >:: new(
72- grandpa_block_import. clone( ) , client. clone( ) ,
73- ) ;
69+ let ( block_import, babe_link) = sc_consensus_babe:: block_import(
70+ sc_consensus_babe:: Config :: get_or_compute( & * client) ?,
71+ grandpa_block_import. clone( ) ,
72+ client. clone( ) ,
73+ ) ?;
7474
75- let import_queue = sc_consensus_aura:: import_queue:: <_, _, _, AuraPair , _>(
76- sc_consensus_aura:: slot_duration( & * client) ?,
77- aura_block_import,
78- Some ( Box :: new( grandpa_block_import. clone( ) ) ) ,
75+ let justification_import = grandpa_block_import. clone( ) ;
76+ let import_queue = sc_consensus_babe:: import_queue(
77+ babe_link. clone( ) ,
78+ block_import. clone( ) ,
79+ Some ( Box :: new( justification_import) ) ,
7980 None ,
8081 client,
8182 inherent_data_providers. clone( ) ,
8283 spawn_task_handle,
8384 registry,
8485 ) ?;
8586
86- import_setup = Some ( ( grandpa_block_import , grandpa_link) ) ;
87+ import_setup = Some ( ( block_import , grandpa_link, babe_link ) ) ;
8788
8889 Ok ( import_queue)
8990 } ) ?;
@@ -101,7 +102,7 @@ pub fn new_full(config: Configuration) -> Result<impl AbstractService, ServiceEr
101102
102103 let ( builder, mut import_setup, inherent_data_providers) = new_full_start ! ( config) ;
103104
104- let ( block_import, grandpa_link) =
105+ let ( block_import, grandpa_link, babe_link ) =
105106 import_setup. take ( )
106107 . expect ( "Link Half and Block Import are present for Full Services or setup failed before. qed" ) ;
107108
@@ -127,22 +128,23 @@ pub fn new_full(config: Configuration) -> Result<impl AbstractService, ServiceEr
127128 let can_author_with =
128129 sp_consensus:: CanAuthorWithNativeVersion :: new ( client. executor ( ) . clone ( ) ) ;
129130
130- let aura = sc_consensus_aura :: start_aura :: < _ , _ , _ , _ , _ , AuraPair , _ , _ , _ > (
131- sc_consensus_aura :: slot_duration ( & * client ) ? ,
131+ let babe_config = sc_consensus_babe :: BabeParams {
132+ keystore : service . keystore ( ) ,
132133 client,
133134 select_chain,
135+ env : proposer,
134136 block_import,
135- proposer,
136- service. network ( ) ,
137- inherent_data_providers. clone ( ) ,
137+ sync_oracle : service. network ( ) ,
138+ inherent_data_providers : inherent_data_providers. clone ( ) ,
138139 force_authoring,
139- service . keystore ( ) ,
140+ babe_link ,
140141 can_author_with,
141- ) ? ;
142+ } ;
142143
143- // the AURA authoring task is considered essential, i.e. if it
144+ let babe = sc_consensus_babe:: start_babe ( babe_config) ?;
145+ // the BABE authoring task is considered infallible, i.e. if it
144146 // fails we take down the service with it.
145- service. spawn_essential_task ( "aura " , aura ) ;
147+ service. spawn_essential_task ( "babe-proposer " , babe ) ;
146148 }
147149
148150 // if the node isn't actively participating in consensus then it doesn't
@@ -246,12 +248,18 @@ pub fn new_light(config: Configuration) -> Result<impl AbstractService, ServiceE
246248 let finality_proof_request_builder =
247249 finality_proof_import. create_finality_proof_request_builder( ) ;
248250
249- let import_queue = sc_consensus_aura :: import_queue :: < _ , _ , _ , AuraPair , _ > (
250- sc_consensus_aura :: slot_duration ( & * client) ?,
251+ let ( babe_block_import , babe_link ) = sc_consensus_babe :: block_import (
252+ sc_consensus_babe :: Config :: get_or_compute ( & * client) ?,
251253 grandpa_block_import,
254+ client. clone( ) ,
255+ ) ?;
256+
257+ let import_queue = sc_consensus_babe:: import_queue(
258+ babe_link,
259+ babe_block_import,
252260 None ,
253261 Some ( Box :: new( finality_proof_import) ) ,
254- client,
262+ client. clone ( ) ,
255263 inherent_data_providers. clone( ) ,
256264 spawn_task_handle,
257265 prometheus_registry,
0 commit comments