20
20
21
21
use astar_primitives:: * ;
22
22
use cumulus_client_cli:: CollatorOptions ;
23
- use cumulus_client_consensus_aura:: collators:: basic as basic_aura ;
23
+ use cumulus_client_consensus_aura:: collators:: lookahead :: { self as aura , Params as AuraParams } ;
24
24
use cumulus_client_consensus_common:: ParachainBlockImport ;
25
25
use cumulus_client_consensus_relay_chain:: Verifier as RelayChainVerifier ;
26
26
use cumulus_client_service:: {
27
27
prepare_node_config, start_relay_chain_tasks, BuildNetworkParams , DARecoveryProfile ,
28
28
StartRelayChainTasksParams ,
29
29
} ;
30
- use cumulus_primitives_core:: ParaId ;
30
+ use cumulus_primitives_aura:: AuraUnincludedSegmentApi ;
31
+ use cumulus_primitives_core:: {
32
+ relay_chain:: { CollatorPair , ValidationCode } ,
33
+ ParaId ,
34
+ } ;
31
35
use cumulus_relay_chain_inprocess_interface:: build_inprocess_relay_chain;
32
36
use cumulus_relay_chain_interface:: { RelayChainInterface , RelayChainResult } ;
33
37
use cumulus_relay_chain_minimal_node:: build_minimal_relay_chain_node_with_rpc;
34
38
use fc_consensus:: FrontierBlockImport ;
35
39
use fc_rpc_core:: types:: { FeeHistoryCache , FilterPool } ;
36
40
use futures:: StreamExt ;
37
- use polkadot_service:: CollatorPair ;
38
41
use sc_client_api:: BlockchainEvents ;
39
42
use sc_consensus:: { import_queue:: BasicQueue , ImportQueue } ;
40
43
use sc_executor:: NativeElseWasmExecutor ;
@@ -351,6 +354,7 @@ where
351
354
) -> Result < sc_consensus:: DefaultImportQueue < Block > , sc_service:: Error > ,
352
355
SC : FnOnce (
353
356
Arc < TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > > ,
357
+ Arc < TFullBackend < Block > > ,
354
358
ParachainBlockImport <
355
359
Block ,
356
360
FrontierBlockImport <
@@ -562,6 +566,7 @@ where
562
566
if is_authority {
563
567
start_consensus (
564
568
client. clone ( ) ,
569
+ backend. clone ( ) ,
565
570
parachain_block_import,
566
571
prometheus_registry. as_ref ( ) ,
567
572
telemetry. map ( |t| t. handle ( ) ) ,
@@ -1066,6 +1071,7 @@ where
1066
1071
/// Start collating with the `shell` runtime while waiting for an upgrade to an Aura compatible runtime.
1067
1072
fn start_aura_consensus_fallback < RuntimeApi , Executor > (
1068
1073
client : Arc < TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > > ,
1074
+ backend : Arc < TFullBackend < Block > > ,
1069
1075
parachain_block_import : ParachainBlockImport <
1070
1076
Block ,
1071
1077
FrontierBlockImport <
@@ -1104,6 +1110,7 @@ where
1104
1110
+ sp_block_builder:: BlockBuilder < Block >
1105
1111
+ fp_rpc:: EthereumRuntimeRPCApi < Block >
1106
1112
+ AuraApi < Block , AuraId >
1113
+ + AuraUnincludedSegmentApi < Block >
1107
1114
+ cumulus_primitives_core:: CollectCollationInfo < Block > ,
1108
1115
sc_client_api:: StateBackendFor < TFullBackend < Block > , Block > :
1109
1116
sc_client_api:: StateBackend < BlakeTwo256 > ,
@@ -1171,9 +1178,6 @@ where
1171
1178
}
1172
1179
1173
1180
// Move to Aura consensus.
1174
- let slot_duration =
1175
- cumulus_client_consensus_aura:: slot_duration ( & * client) . expect ( "aura is present; qed" ) ;
1176
-
1177
1181
let announce_block = {
1178
1182
let sync_service = sync_oracle. clone ( ) ;
1179
1183
Arc :: new ( move |hash, data| sync_service. announce_block ( hash, data) )
@@ -1186,23 +1190,28 @@ where
1186
1190
client. clone ( ) ,
1187
1191
) ;
1188
1192
1189
- basic_aura :: run :: < Block , AuraPair , _ , _ , _ , _ , _ , _ , _ > ( basic_aura :: Params {
1193
+ aura :: run :: < Block , AuraPair , _ , _ , _ , _ , _ , _ , _ , _ , _ > ( AuraParams {
1190
1194
create_inherent_data_providers : move |_, ( ) | async move { Ok ( ( ) ) } ,
1191
1195
block_import : parachain_block_import. clone ( ) ,
1192
1196
para_client : client. clone ( ) ,
1197
+ para_backend : backend,
1193
1198
relay_client : relay_chain_interface. clone ( ) ,
1199
+ code_hash_provider : move |block_hash| {
1200
+ client
1201
+ . code_at ( block_hash)
1202
+ . ok ( )
1203
+ . map ( |c| ValidationCode :: from ( c) . hash ( ) )
1204
+ } ,
1194
1205
sync_oracle : sync_oracle. clone ( ) ,
1195
1206
keystore,
1196
1207
collator_key,
1197
1208
para_id,
1198
1209
overseer_handle,
1199
- slot_duration,
1200
1210
relay_chain_slot_duration : Duration :: from_secs ( 6 ) ,
1201
1211
proposer : cumulus_client_consensus_proposer:: Proposer :: new ( proposer_factory) ,
1202
1212
collator_service,
1203
- // We got around 500ms for proposing
1204
- authoring_duration : Duration :: from_millis ( 500 ) ,
1205
- collation_request_receiver : Some ( request_stream) ,
1213
+ authoring_duration : Duration :: from_millis ( 2000 ) ,
1214
+ reinitialize : true ,
1206
1215
} )
1207
1216
. await
1208
1217
} ) ;
@@ -1215,6 +1224,7 @@ where
1215
1224
1216
1225
fn start_aura_consensus < RuntimeApi , Executor > (
1217
1226
client : Arc < TFullClient < Block , RuntimeApi , NativeElseWasmExecutor < Executor > > > ,
1227
+ backend : Arc < TFullBackend < Block > > ,
1218
1228
parachain_block_import : ParachainBlockImport <
1219
1229
Block ,
1220
1230
FrontierBlockImport <
@@ -1253,6 +1263,7 @@ where
1253
1263
+ sp_block_builder:: BlockBuilder < Block >
1254
1264
+ fp_rpc:: EthereumRuntimeRPCApi < Block >
1255
1265
+ AuraApi < Block , AuraId >
1266
+ + AuraUnincludedSegmentApi < Block >
1256
1267
+ cumulus_primitives_core:: CollectCollationInfo < Block > ,
1257
1268
sc_client_api:: StateBackendFor < TFullBackend < Block > , Block > :
1258
1269
sc_client_api:: StateBackend < BlakeTwo256 > ,
@@ -1287,23 +1298,28 @@ where
1287
1298
client. clone ( ) ,
1288
1299
) ;
1289
1300
1290
- let fut = basic_aura :: run :: < Block , AuraPair , _ , _ , _ , _ , _ , _ , _ > ( basic_aura :: Params {
1301
+ let fut = aura :: run :: < Block , AuraPair , _ , _ , _ , _ , _ , _ , _ , _ , _ > ( AuraParams {
1291
1302
create_inherent_data_providers : move |_, ( ) | async move { Ok ( ( ) ) } ,
1292
1303
block_import : parachain_block_import. clone ( ) ,
1293
1304
para_client : client. clone ( ) ,
1305
+ para_backend : backend,
1294
1306
relay_client : relay_chain_interface. clone ( ) ,
1307
+ code_hash_provider : move |block_hash| {
1308
+ client
1309
+ . code_at ( block_hash)
1310
+ . ok ( )
1311
+ . map ( |c| ValidationCode :: from ( c) . hash ( ) )
1312
+ } ,
1295
1313
sync_oracle : sync_oracle. clone ( ) ,
1296
1314
keystore,
1297
1315
collator_key,
1298
1316
para_id,
1299
1317
overseer_handle,
1300
- slot_duration : cumulus_client_consensus_aura:: slot_duration ( & * client) ?,
1301
1318
relay_chain_slot_duration : Duration :: from_secs ( 6 ) ,
1302
1319
proposer : cumulus_client_consensus_proposer:: Proposer :: new ( proposer_factory) ,
1303
1320
collator_service,
1304
- // We got around 500ms for proposing
1305
- authoring_duration : Duration :: from_millis ( 500 ) ,
1306
- collation_request_receiver : None ,
1321
+ authoring_duration : Duration :: from_millis ( 2000 ) ,
1322
+ reinitialize : false ,
1307
1323
} ) ;
1308
1324
1309
1325
task_manager
0 commit comments