Skip to content
Merged

4.0.1 #318

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Diamond Node Software 4.0.1

First hotfix
Mitigates the transaction spam caused by flaws in the transaction management of report disconnectivity transactions.

- [Reduce Intervals for connectivity checks](https://github.com/DMDcoin/diamond-node/issues/313)
- [connectivity reports should not trigger if there is no block production](https://github.com/DMDcoin/diamond-node/issues/243)

## Diamond Node Software 4.0.0

Official Node Software start version for the DMD Diamond network version 4.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "Diamond Node"
name = "diamond-node"
# NOTE Make sure to update util/version/Cargo.toml as well
version = "4.0.0"
version = "4.0.1"
license = "GPL-3.0"
authors = [
"bit.diamonds developers",
Expand Down
48 changes: 37 additions & 11 deletions crates/ethcore/src/engines/hbbft/hbbft_early_epoch_end_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
};
use std::{
collections::BTreeMap,
time::{Duration, Instant},
time::{Duration, Instant, UNIX_EPOCH},
};

use super::{
Expand Down Expand Up @@ -261,8 +261,8 @@ impl HbbftEarlyEpochEndManager {
}
}

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

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

let treshold: u64 = 2;
// start of implementation for:
// https://github.com/DMDcoin/diamond-node/issues/243
// connectivity reports should not trigger if there is no block production
let now = UNIX_EPOCH.elapsed().expect("Time not available").as_secs();
// this should hold true.
if now >= block_time {
let elapsed_since_last_block = now - block_time;
// todo: this is max blocktime (heartbeat) x 2, better read the maximum blocktime.
// on phoenix protocol triggers, this would also skip the sending of disconnectivity reports.
if elapsed_since_last_block > 10 * 60 {
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.");
return;
}
} else {
// if the newest block is from the future, something very problematic happened.
// the system clock could be wrong.
// or the blockchain really produces blocks from the future.
// we are just not sending reports in this case.

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.");
return;
}
// end of implementation for:
// https://github.com/DMDcoin/diamond-node/issues/243

let threshold: u64 = 2;

// todo: read this out from contracts: ConnectivityTrackerHbbft -> reportDisallowPeriod
// requires us to update the Contracts ABIs:
// https://github.com/DMDcoin/diamond-node/issues/115
let treshold_time = Duration::from_secs(12 * 60); // 12 Minutes = 1 times the heartbeat + 2 minutes as grace period.
let threshold_time = Duration::from_secs(12 * 60); // 12 Minutes = 1 times the heartbeat + 2 minutes as grace period.

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

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