@@ -109,7 +109,7 @@ fn slot_author<P: Pair>(slot: Slot, authorities: &[AuthorityId<P>]) -> Option<&A
109
109
}
110
110
111
111
/// Parameters of [`start_aura`].
112
- pub struct StartAuraParams < C , SC , I , PF , SO , BS , CAW , IDP > {
112
+ pub struct StartAuraParams < C , SC , I , PF , SO , L , CIDP , BS , CAW > {
113
113
/// The duration of a slot.
114
114
pub slot_duration : SlotDuration ,
115
115
/// The client to interact with the chain.
@@ -122,8 +122,10 @@ pub struct StartAuraParams<C, SC, I, PF, SO, BS, CAW, IDP> {
122
122
pub proposer_factory : PF ,
123
123
/// The sync oracle that can give us the current sync status.
124
124
pub sync_oracle : SO ,
125
+ /// Hook into the sync module to control the justification sync process.
126
+ pub justification_sync_link : L ,
125
127
/// Something that can create the inherent data providers.
126
- pub create_inherent_data_providers : IDP ,
128
+ pub create_inherent_data_providers : CIDP ,
127
129
/// Should we force the authoring of blocks?
128
130
pub force_authoring : bool ,
129
131
/// The backoff strategy when we miss slots.
@@ -143,46 +145,49 @@ pub struct StartAuraParams<C, SC, I, PF, SO, BS, CAW, IDP> {
143
145
}
144
146
145
147
/// Start the aura worker. The returned future should be run in a futures executor.
146
- pub fn start_aura < P , B , C , SC , PF , I , SO , CAW , BS , Error , IDP > (
148
+ pub fn start_aura < P , B , C , SC , I , PF , SO , L , CIDP , BS , CAW , Error > (
147
149
StartAuraParams {
148
150
slot_duration,
149
151
client,
150
152
select_chain,
151
153
block_import,
152
154
proposer_factory,
153
155
sync_oracle,
156
+ justification_sync_link,
154
157
create_inherent_data_providers,
155
158
force_authoring,
156
159
backoff_authoring_blocks,
157
160
keystore,
158
161
can_author_with,
159
162
block_proposal_slot_portion,
160
163
telemetry,
161
- } : StartAuraParams < C , SC , I , PF , SO , BS , CAW , IDP > ,
164
+ } : StartAuraParams < C , SC , I , PF , SO , L , CIDP , BS , CAW > ,
162
165
) -> Result < impl Future < Output = ( ) > , sp_consensus:: Error > where
166
+ P : Pair + Send + Sync ,
167
+ P :: Public : AppPublic + Hash + Member + Encode + Decode ,
168
+ P :: Signature : TryFrom < Vec < u8 > > + Hash + Member + Encode + Decode ,
163
169
B : BlockT ,
164
170
C : ProvideRuntimeApi < B > + BlockOf + ProvideCache < B > + AuxStore + HeaderBackend < B > + Send + Sync ,
165
171
C :: Api : AuraApi < B , AuthorityId < P > > ,
166
172
SC : SelectChain < B > ,
173
+ I : BlockImport < B , Transaction = sp_api:: TransactionFor < C , B > > + Send + Sync + ' static ,
167
174
PF : Environment < B , Error = Error > + Send + Sync + ' static ,
168
175
PF :: Proposer : Proposer < B , Error = Error , Transaction = sp_api:: TransactionFor < C , B > > ,
169
- P : Pair + Send + Sync ,
170
- P :: Public : AppPublic + Hash + Member + Encode + Decode ,
171
- P :: Signature : TryFrom < Vec < u8 > > + Hash + Member + Encode + Decode ,
172
- I : BlockImport < B , Transaction = sp_api:: TransactionFor < C , B > > + Send + Sync + ' static ,
173
- Error : std:: error:: Error + Send + From < sp_consensus:: Error > + ' static ,
174
176
SO : SyncOracle + Send + Sync + Clone ,
175
- CAW : CanAuthorWith < B > + Send ,
177
+ L : sp_consensus:: JustificationSyncLink < B > ,
178
+ CIDP : CreateInherentDataProviders < B , ( ) > + Send ,
179
+ CIDP :: InherentDataProviders : InherentDataProviderExt + Send ,
176
180
BS : BackoffAuthoringBlocksStrategy < NumberFor < B > > + Send + ' static ,
177
- IDP : CreateInherentDataProviders < B , ( ) > + Send ,
178
- IDP :: InherentDataProviders : InherentDataProviderExt + Send ,
181
+ CAW : CanAuthorWith < B > + Send ,
182
+ Error : std :: error :: Error + Send + From < sp_consensus :: Error > + ' static ,
179
183
{
180
- let worker = build_aura_worker :: < P , _ , _ , _ , _ , _ , _ , _ > ( BuildAuraWorkerParams {
184
+ let worker = build_aura_worker :: < P , _ , _ , _ , _ , _ , _ , _ , _ > ( BuildAuraWorkerParams {
181
185
client : client. clone ( ) ,
182
186
block_import,
183
187
proposer_factory,
184
188
keystore,
185
189
sync_oracle : sync_oracle. clone ( ) ,
190
+ justification_sync_link,
186
191
force_authoring,
187
192
backoff_authoring_blocks,
188
193
telemetry,
@@ -200,7 +205,7 @@ pub fn start_aura<P, B, C, SC, PF, I, SO, CAW, BS, Error, IDP>(
200
205
}
201
206
202
207
/// Parameters of [`build_aura_worker`].
203
- pub struct BuildAuraWorkerParams < C , I , PF , SO , BS > {
208
+ pub struct BuildAuraWorkerParams < C , I , PF , SO , L , BS > {
204
209
/// The client to interact with the chain.
205
210
pub client : Arc < C > ,
206
211
/// The block import.
@@ -209,6 +214,8 @@ pub struct BuildAuraWorkerParams<C, I, PF, SO, BS> {
209
214
pub proposer_factory : PF ,
210
215
/// The sync oracle that can give us the current sync status.
211
216
pub sync_oracle : SO ,
217
+ /// Hook into the sync module to control the justification sync process.
218
+ pub justification_sync_link : L ,
212
219
/// Should we force the authoring of blocks?
213
220
pub force_authoring : bool ,
214
221
/// The backoff strategy when we miss slots.
@@ -228,18 +235,19 @@ pub struct BuildAuraWorkerParams<C, I, PF, SO, BS> {
228
235
/// Build the aura worker.
229
236
///
230
237
/// The caller is responsible for running this worker, otherwise it will do nothing.
231
- pub fn build_aura_worker < P , B , C , PF , I , SO , BS , Error > (
238
+ pub fn build_aura_worker < P , B , C , PF , I , SO , L , BS , Error > (
232
239
BuildAuraWorkerParams {
233
240
client,
234
241
block_import,
235
242
proposer_factory,
236
243
sync_oracle,
244
+ justification_sync_link,
237
245
backoff_authoring_blocks,
238
246
keystore,
239
247
block_proposal_slot_portion,
240
248
telemetry,
241
249
force_authoring,
242
- } : BuildAuraWorkerParams < C , I , PF , SO , BS > ,
250
+ } : BuildAuraWorkerParams < C , I , PF , SO , L , BS > ,
243
251
) -> impl sc_consensus_slots:: SlotWorker < B , <PF :: Proposer as Proposer < B > >:: Proof > where
244
252
B : BlockT ,
245
253
C : ProvideRuntimeApi < B > + BlockOf + ProvideCache < B > + AuxStore + HeaderBackend < B > + Send + Sync ,
@@ -252,6 +260,7 @@ pub fn build_aura_worker<P, B, C, PF, I, SO, BS, Error>(
252
260
I : BlockImport < B , Transaction = sp_api:: TransactionFor < C , B > > + Send + Sync + ' static ,
253
261
Error : std:: error:: Error + Send + From < sp_consensus:: Error > + ' static ,
254
262
SO : SyncOracle + Send + Sync + Clone ,
263
+ L : sp_consensus:: JustificationSyncLink < B > ,
255
264
BS : BackoffAuthoringBlocksStrategy < NumberFor < B > > + Send + ' static ,
256
265
{
257
266
AuraWorker {
@@ -260,6 +269,7 @@ pub fn build_aura_worker<P, B, C, PF, I, SO, BS, Error>(
260
269
env : proposer_factory,
261
270
keystore,
262
271
sync_oracle,
272
+ justification_sync_link,
263
273
force_authoring,
264
274
backoff_authoring_blocks,
265
275
telemetry,
@@ -268,21 +278,22 @@ pub fn build_aura_worker<P, B, C, PF, I, SO, BS, Error>(
268
278
}
269
279
}
270
280
271
- struct AuraWorker < C , E , I , P , SO , BS > {
281
+ struct AuraWorker < C , E , I , P , SO , L , BS > {
272
282
client : Arc < C > ,
273
283
block_import : I ,
274
284
env : E ,
275
285
keystore : SyncCryptoStorePtr ,
276
286
sync_oracle : SO ,
287
+ justification_sync_link : L ,
277
288
force_authoring : bool ,
278
289
backoff_authoring_blocks : Option < BS > ,
279
290
block_proposal_slot_portion : SlotProportion ,
280
291
telemetry : Option < TelemetryHandle > ,
281
292
_key_type : PhantomData < P > ,
282
293
}
283
294
284
- impl < B , C , E , I , P , Error , SO , BS > sc_consensus_slots:: SimpleSlotWorker < B >
285
- for AuraWorker < C , E , I , P , SO , BS >
295
+ impl < B , C , E , I , P , Error , SO , L , BS > sc_consensus_slots:: SimpleSlotWorker < B >
296
+ for AuraWorker < C , E , I , P , SO , L , BS >
286
297
where
287
298
B : BlockT ,
288
299
C : ProvideRuntimeApi < B > + BlockOf + ProvideCache < B > + HeaderBackend < B > + Sync ,
@@ -294,11 +305,13 @@ where
294
305
P :: Public : AppPublic + Public + Member + Encode + Decode + Hash ,
295
306
P :: Signature : TryFrom < Vec < u8 > > + Member + Encode + Decode + Hash + Debug ,
296
307
SO : SyncOracle + Send + Clone ,
308
+ L : sp_consensus:: JustificationSyncLink < B > ,
297
309
BS : BackoffAuthoringBlocksStrategy < NumberFor < B > > + Send + ' static ,
298
310
Error : std:: error:: Error + Send + From < sp_consensus:: Error > + ' static ,
299
311
{
300
312
type BlockImport = I ;
301
313
type SyncOracle = SO ;
314
+ type JustificationSyncLink = L ;
302
315
type CreateProposer = Pin < Box <
303
316
dyn Future < Output = Result < E :: Proposer , sp_consensus:: Error > > + Send + ' static
304
317
> > ;
@@ -425,6 +438,10 @@ where
425
438
& mut self . sync_oracle
426
439
}
427
440
441
+ fn justification_sync_link ( & mut self ) -> & mut Self :: JustificationSyncLink {
442
+ & mut self . justification_sync_link
443
+ }
444
+
428
445
fn proposer ( & mut self , block : & B :: Header ) -> Self :: CreateProposer {
429
446
Box :: pin ( self . env . init ( block) . map_err ( |e| {
430
447
sp_consensus:: Error :: ClientImport ( format ! ( "{:?}" , e) ) . into ( )
@@ -725,13 +742,14 @@ mod tests {
725
742
726
743
let slot_duration = slot_duration ( & * client) . expect ( "slot duration available" ) ;
727
744
728
- aura_futures. push ( start_aura :: < AuthorityPair , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ > ( StartAuraParams {
745
+ aura_futures. push ( start_aura :: < AuthorityPair , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ > ( StartAuraParams {
729
746
slot_duration,
730
747
block_import : client. clone ( ) ,
731
748
select_chain,
732
749
client,
733
750
proposer_factory : environ,
734
751
sync_oracle : DummyOracle ,
752
+ justification_sync_link : ( ) ,
735
753
create_inherent_data_providers : |_, _| async {
736
754
let timestamp = TimestampInherentDataProvider :: from_system_time ( ) ;
737
755
let slot = InherentDataProvider :: from_timestamp_and_duration (
@@ -804,6 +822,7 @@ mod tests {
804
822
env : environ,
805
823
keystore : keystore. into ( ) ,
806
824
sync_oracle : DummyOracle . clone ( ) ,
825
+ justification_sync_link : ( ) ,
807
826
force_authoring : false ,
808
827
backoff_authoring_blocks : Some ( BackoffAuthoringOnFinalizedHeadLagging :: default ( ) ) ,
809
828
telemetry : None ,
@@ -853,6 +872,7 @@ mod tests {
853
872
env : environ,
854
873
keystore : keystore. into ( ) ,
855
874
sync_oracle : DummyOracle . clone ( ) ,
875
+ justification_sync_link : ( ) ,
856
876
force_authoring : false ,
857
877
backoff_authoring_blocks : Option :: < ( ) > :: None ,
858
878
telemetry : None ,
@@ -871,7 +891,7 @@ mod tests {
871
891
duration : Duration :: from_millis ( 1000 ) ,
872
892
chain_head : head,
873
893
block_size_limit : None ,
874
- } ,
894
+ }
875
895
) ) . unwrap ( ) ;
876
896
877
897
// The returned block should be imported and we should be able to get its header by now.
0 commit comments