You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// connectivity reports should not trigger if there is no block production
299
+
let now = UNIX_EPOCH.elapsed().expect("Time not available").as_secs();
300
+
// this should hold true.
301
+
if now >= block_time {
302
+
let elapsed_since_last_block = now - block_time;
303
+
// todo: this is max blocktime (heartbeat) x 2, better read the maximum blocktime.
304
+
// on phoenix protocol triggers, this would also skip the sending of disconnectivity reports.
305
+
if elapsed_since_last_block > 10*60{
306
+
info!(target:"engine","skipping early-epoch-end: now {now} ; block_time {block_time}: Block WAS created in the future ?!?! :-x. not sending early epoch end reports.");
307
+
return;
308
+
}
309
+
}else{
310
+
// if the newest block is from the future, something very problematic happened.
311
+
// the system clock could be wrong.
312
+
// or the blockchain really produces blocks from the future.
313
+
// we are just not sending reports in this case.
314
+
315
+
error!(target:"engine","early-epoch-end: now {now} ; block_time {block_time}: Block WAS created in the future ?!?! :-x. not sending early epoch end reports.");
// maybe improve here, to return with a result, that triggers a retry soon.
1284
-
debug!(target:"engine","Unable to do_validator_engine_actions: Could not acquire read lock for hbbft state. Unable to decide about early epoch end. retrying soon.");
1285
-
}
1286
-
};
1287
-
}// drop lock for hbbft_state
1260
+
None => {
1261
+
// maybe improve here, to return with a result, that triggers a retry soon.
1262
+
debug!(target:"engine","Unable to do_validator_engine_actions: Could not acquire read lock for hbbft state. Unable to decide about early epoch end. retrying soon.");
1263
+
}
1264
+
};
1265
+
}// drop lock for hbbft_state
1288
1266
1289
-
// if we do not have to do anything, we can return early.
1290
-
if !(should_connect_to_validator_set || should_handle_early_epoch_end){
trace!(target:"engine","do_validator_engine_actions: skipping because we are syncing.");
1320
+
returnOk(());
1316
1321
}
1317
1322
1318
-
self.do_keygen();
1323
+
let engine_client = client_arc.as_ref();
1324
+
let mining_address = matchself.refresh_engine_cache(engine_client){
1325
+
Some(h) => h,
1326
+
None => returnOk(()),
1327
+
};
1328
+
1329
+
let block_chain_client = match engine_client.as_full_client(){
1330
+
Some(block_chain_client) => block_chain_client,
1331
+
None => {
1332
+
returnErr("Unable to retrieve client.as_full_client()".into());
1333
+
}
1334
+
};
1335
+
1336
+
let hbbft_state_option = self.hbbft_state.try_read_for(Duration::from_millis(250));
1337
+
match hbbft_state_option {
1338
+
Some(hbbft_state) => {
1339
+
if !hbbft_state.is_validator(){
1340
+
// we are not known as validator, we dont have to further process early epoch end actions.
1341
+
returnOk(());
1342
+
}
1343
+
1344
+
// if we are a pending validator, we will also do the reserved peers management.
1345
+
// we already remember here stuff the early epoch manager needs,
1346
+
// so we do not have to acquire the lock for that long.
1347
+
let epoch_num = hbbft_state.get_current_posdao_epoch();
1348
+
let epoch_start_block = hbbft_state.get_current_posdao_epoch_start_block();
1349
+
let validator_set = hbbft_state.get_validator_set();
1350
+
1351
+
self.handle_early_epoch_end(
1352
+
block_chain_client,
1353
+
engine_client,
1354
+
&mining_address,
1355
+
epoch_start_block,
1356
+
epoch_num,
1357
+
&validator_set,
1358
+
);
1359
+
}
1360
+
None => {
1361
+
// maybe improve here, to return with a result, that triggers a retry soon.
1362
+
debug!(target:"engine","Unable to do_validator_engine_early_epoch_end_actions: Could not acquire read lock for hbbft state. Unable to decide about early epoch end. retrying soon.");
1363
+
}
1364
+
};
1319
1365
1320
1366
returnOk(());
1321
1367
}
1322
-
1323
1368
None => {
1324
1369
// client arc not ready yet,
1325
1370
// can happen during initialization and shutdown.
@@ -1417,16 +1462,21 @@ impl HoneyBadgerBFT {
1417
1462
}
1418
1463
}
1419
1464
1420
-
/** returns if the signer of hbbft is tracked as available in the hbbft contracts..*/
1465
+
/// returns if the signer of hbbft is tracked as available in the hbbft contracts.
1421
1466
pubfnis_available(&self) -> bool{
1422
1467
self.hbbft_engine_cache.lock().is_available()
1423
1468
}
1424
1469
1425
-
/** returns if the signer of hbbft is stacked. */
1470
+
/// returns if the signer of hbbft is stacked.
1426
1471
pubfnis_staked(&self) -> bool{
1427
1472
self.hbbft_engine_cache.lock().is_staked()
1428
1473
}
1429
1474
1475
+
/// returns if the signer of hbbft is a current validator.
0 commit comments