Skip to content

Commit 0838d7e

Browse files
authored
Merge pull request #318 from DMDcoin/4.0
4.0.1
2 parents 8ce0248 + 847c3a8 commit 0838d7e

File tree

8 files changed

+208
-109
lines changed

8 files changed

+208
-109
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Diamond Node Software 4.0.1
2+
3+
First hotfix
4+
Mitigates the transaction spam caused by flaws in the transaction management of report disconnectivity transactions.
5+
6+
- [Reduce Intervals for connectivity checks](https://github.com/DMDcoin/diamond-node/issues/313)
7+
- [connectivity reports should not trigger if there is no block production](https://github.com/DMDcoin/diamond-node/issues/243)
8+
19
## Diamond Node Software 4.0.0
210

311
Official Node Software start version for the DMD Diamond network version 4.

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description = "Diamond Node"
33
name = "diamond-node"
44
# NOTE Make sure to update util/version/Cargo.toml as well
5-
version = "4.0.0"
5+
version = "4.0.1"
66
license = "GPL-3.0"
77
authors = [
88
"bit.diamonds developers",

crates/ethcore/src/engines/hbbft/hbbft_early_epoch_end_manager.rs

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
};
1010
use std::{
1111
collections::BTreeMap,
12-
time::{Duration, Instant},
12+
time::{Duration, Instant, UNIX_EPOCH},
1313
};
1414

1515
use super::{
@@ -261,8 +261,8 @@ impl HbbftEarlyEpochEndManager {
261261
}
262262
}
263263

264-
/// decides on the memorium data if we should update to contract data.
265-
/// end executes them.
264+
/// decides on the memorium data if we should update to contract data,
265+
/// and sends out transactions to do so.
266266
pub fn decide(
267267
&mut self,
268268
memorium: &HbbftMessageMemorium,
@@ -286,25 +286,51 @@ impl HbbftEarlyEpochEndManager {
286286
debug!(target: "engine", "early-epoch-end: detected attempt to break because of is_major_syncing() instead of is_synincg()no decision: syncing");
287287
}
288288

289-
let block_num = if let Some(block) = full_client.block(BlockId::Latest) {
290-
block.number()
289+
let (block_num, block_time) = if let Some(block) = full_client.block(BlockId::Latest) {
290+
(block.number(), block.timestamp())
291291
} else {
292292
error!(target:"engine", "early-epoch-end: could not retrieve latest block.");
293293
return;
294294
};
295295

296-
let treshold: u64 = 2;
296+
// start of implementation for:
297+
// https://github.com/DMDcoin/diamond-node/issues/243
298+
// 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.");
316+
return;
317+
}
318+
// end of implementation for:
319+
// https://github.com/DMDcoin/diamond-node/issues/243
320+
321+
let threshold: u64 = 2;
322+
297323
// todo: read this out from contracts: ConnectivityTrackerHbbft -> reportDisallowPeriod
298324
// requires us to update the Contracts ABIs:
299325
// https://github.com/DMDcoin/diamond-node/issues/115
300-
let treshold_time = Duration::from_secs(12 * 60); // 12 Minutes = 1 times the heartbeat + 2 minutes as grace period.
326+
let threshold_time = Duration::from_secs(12 * 60); // 12 Minutes = 1 times the heartbeat + 2 minutes as grace period.
301327

302-
if self.start_time.elapsed() < treshold_time {
303-
debug!(target: "engine", "early-epoch-end: no decision: Treshold time not reached.");
328+
if self.start_time.elapsed() < threshold_time {
329+
debug!(target: "engine", "early-epoch-end: no decision: Threshold time not reached.");
304330
return;
305331
}
306332

307-
if block_num < self.start_block + treshold {
333+
if block_num < self.start_block + threshold {
308334
// not enought blocks have passed this epoch,
309335
// to judge other nodes.
310336
debug!(target: "engine", "early-epoch-end: no decision: not enough blocks.");
@@ -328,7 +354,7 @@ impl HbbftEarlyEpochEndManager {
328354
if let Some(node_history) = epoch_history.get_history_for_node(validator) {
329355
let last_message_time = node_history.get_last_good_message_time();
330356
let last_message_time_lateness = last_message_time.elapsed();
331-
if last_message_time_lateness > treshold_time {
357+
if last_message_time_lateness > threshold_time {
332358
// we do not have to send notification, if we already did so.
333359
if !self.is_reported(client, validator_address) {
334360
// this function will also add the validator to the list of flagged validators.

0 commit comments

Comments
 (0)