@@ -51,6 +51,42 @@ type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
5151type FullGrandpaBlockImport < E = WasmExecutor < sp_io:: SubstrateHostFunctions > > =
5252 sc_consensus_grandpa:: GrandpaBlockImport < FullBackend , Block , FullClient < E > , FullSelectChain > ;
5353
54+ /// Inherent data provider for BABE consensus.
55+ #[ derive( Clone ) ]
56+ pub struct BabeInherentDataProvider {
57+ slot_duration : sp_consensus_babe:: SlotDuration ,
58+ }
59+
60+ impl BabeInherentDataProvider {
61+ pub fn new ( slot_duration : sp_consensus_babe:: SlotDuration ) -> Self {
62+ Self { slot_duration }
63+ }
64+ }
65+
66+ #[ async_trait:: async_trait]
67+ impl sp_inherents:: CreateInherentDataProviders < Block , ( ) > for BabeInherentDataProvider {
68+ type InherentDataProviders = (
69+ sp_consensus_babe:: inherents:: InherentDataProvider ,
70+ sp_timestamp:: InherentDataProvider ,
71+ ) ;
72+
73+ async fn create_inherent_data_providers (
74+ & self ,
75+ _parent : <Block as sp_runtime:: traits:: Block >:: Hash ,
76+ _extra_args : ( ) ,
77+ ) -> Result < Self :: InherentDataProviders , Box < dyn std:: error:: Error + Send + Sync > > {
78+ let timestamp = sp_timestamp:: InherentDataProvider :: from_system_time ( ) ;
79+ let slot = sp_consensus_babe:: inherents:: InherentDataProvider :: from_timestamp_and_slot_duration (
80+ * timestamp,
81+ self . slot_duration ,
82+ ) ;
83+ Ok ( ( slot, timestamp) )
84+ }
85+ }
86+
87+ type FullBabeBlockImport < E = WasmExecutor < sp_io:: SubstrateHostFunctions > > =
88+ sc_consensus_babe:: BabeBlockImport < Block , FullClient < E > , FullGrandpaBlockImport < E > , BabeInherentDataProvider , FullSelectChain > ;
89+
5490/// Our native executor instance.
5591pub struct ExecutorDispatch ;
5692
@@ -166,7 +202,7 @@ pub fn new_partial<E>(
166202 sc_rpc:: SubscriptionTaskExecutor ,
167203 ) -> Result < jsonrpsee:: RpcModule < ( ) > , sc_service:: Error > ,
168204 (
169- sc_consensus_babe :: BabeBlockImport < Block , FullClient < E > , FullGrandpaBlockImport < E > > ,
205+ FullBabeBlockImport < E > ,
170206 sc_consensus_grandpa:: LinkHalf < Block , FullClient < E > , FullSelectChain > ,
171207 sc_consensus_babe:: BabeLink < Block > ,
172208 ) ,
@@ -226,35 +262,27 @@ where
226262
227263 let justification_import = grandpa_block_import. clone ( ) ;
228264
265+ let slot_duration = sc_consensus_babe:: configuration ( & * client) ?. slot_duration ( ) ;
266+ let inherent_data_provider = BabeInherentDataProvider :: new ( slot_duration) ;
229267 let ( block_import, babe_link) = sc_consensus_babe:: block_import (
230268 sc_consensus_babe:: configuration ( & * client) ?,
231269 grandpa_block_import,
232270 client. clone ( ) ,
271+ inherent_data_provider,
272+ select_chain. clone ( ) ,
273+ OffchainTransactionPoolFactory :: new ( transaction_pool. clone ( ) ) ,
233274 ) ?;
234275
235- let slot_duration = babe_link. config ( ) . slot_duration ( ) ;
236276 let ( import_queue, babe_worker_handle) =
237277 sc_consensus_babe:: import_queue ( sc_consensus_babe:: ImportQueueParams {
238278 link : babe_link. clone ( ) ,
239279 block_import : block_import. clone ( ) ,
240280 justification_import : Some ( Box :: new ( justification_import) ) ,
241281 client : client. clone ( ) ,
242- select_chain : select_chain. clone ( ) ,
243- create_inherent_data_providers : move |_, ( ) | async move {
244- let timestamp = sp_timestamp:: InherentDataProvider :: from_system_time ( ) ;
245-
246- let slot =
247- sp_consensus_babe:: inherents:: InherentDataProvider :: from_timestamp_and_slot_duration (
248- * timestamp,
249- slot_duration,
250- ) ;
251-
252- Ok ( ( slot, timestamp) )
253- } ,
282+ slot_duration,
254283 spawner : & task_manager. spawn_essential_handle ( ) ,
255284 registry : config. prometheus_registry ( ) ,
256285 telemetry : telemetry. as_ref ( ) . map ( |x| x. handle ( ) ) ,
257- offchain_tx_pool_factory : OffchainTransactionPoolFactory :: new ( transaction_pool. clone ( ) ) ,
258286 } ) ?;
259287
260288 let import_setup = ( block_import, grandpa_link, babe_link) ;
@@ -337,7 +365,7 @@ pub fn new_full_base(
337365 config : Configuration ,
338366 disable_hardware_benchmarks : bool ,
339367 with_startup_data : impl FnOnce (
340- & sc_consensus_babe :: BabeBlockImport < Block , FullClient , FullGrandpaBlockImport > ,
368+ & FullBabeBlockImport ,
341369 & sc_consensus_babe:: BabeLink < Block > ,
342370 ) ,
343371) -> Result < NewFullBase , ServiceError > {
@@ -448,6 +476,7 @@ pub fn new_full_base(
448476 tx_handler_controller,
449477 sync_service : sync_service. clone ( ) ,
450478 telemetry : telemetry. as_mut ( ) ,
479+ tracing_execute_block : None ,
451480 } ) ?;
452481
453482 if let Some ( hwbench) = hwbench {
0 commit comments