From 761e9f11366e306e6f17e19427f604d9fe4ceea5 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 13 Jul 2023 19:40:56 +0200 Subject: [PATCH 1/4] hint for time drift penalization --- crates/ethcore/src/engines/hbbft/hbbft_engine.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/ethcore/src/engines/hbbft/hbbft_engine.rs b/crates/ethcore/src/engines/hbbft/hbbft_engine.rs index 940298897..fc3b4a46b 100644 --- a/crates/ethcore/src/engines/hbbft/hbbft_engine.rs +++ b/crates/ethcore/src/engines/hbbft/hbbft_engine.rs @@ -456,6 +456,9 @@ impl HoneyBadgerBFT { .map(|(_, c)| c.timestamp) .sorted(); + // todo: use timstamps for calculating negative score. + // https://github.com/DMDcoin/diamond-node/issues/37 + let timestamp = match timestamps.iter().nth(timestamps.len() / 2) { Some(t) => t.clone(), None => { From 481b74b4e36f062d9a410387aef9bdae604ee398 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 14 Jul 2023 16:35:29 +0200 Subject: [PATCH 2/4] setting author for creating block --- crates/ethcore/src/engines/hbbft/hbbft_engine.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/ethcore/src/engines/hbbft/hbbft_engine.rs b/crates/ethcore/src/engines/hbbft/hbbft_engine.rs index fc3b4a46b..433ad3c6d 100644 --- a/crates/ethcore/src/engines/hbbft/hbbft_engine.rs +++ b/crates/ethcore/src/engines/hbbft/hbbft_engine.rs @@ -484,9 +484,15 @@ impl HoneyBadgerBFT { .write() .insert(batch.epoch, random_number); - if let Some(header) = client.create_pending_block_at(batch_txns, timestamp, batch.epoch) { + if let Some(mut header) = client.create_pending_block_at(batch_txns, timestamp, batch.epoch) { let block_num = header.number(); let hash = header.bare_hash(); + if let Some(reward_contract_address) = self.params.block_reward_contract_address { + header.set_author(reward_contract_address); + } else { + warn!("Creating block with no blockRewardContractAddress {}", block_num); + } + trace!(target: "consensus", "Sending signature share of {} for block {}", hash, block_num); let step = match self .sealing @@ -1518,6 +1524,8 @@ impl Engine for HoneyBadgerBFT { // only if no block reward skips are defined for this block. let header_number = block.header.number(); + block.header.set_author(address); + if self .params .should_do_block_reward_contract_call(header_number) From cfae11dd88f11cdbf0a47217d165a94e5bec2805 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 16 Jul 2023 12:34:56 +0200 Subject: [PATCH 3/4] cargo fmt --all -- --config imports_granularity=Crate --- crates/ethcore/src/engines/hbbft/hbbft_engine.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/ethcore/src/engines/hbbft/hbbft_engine.rs b/crates/ethcore/src/engines/hbbft/hbbft_engine.rs index 433ad3c6d..e022cbf13 100644 --- a/crates/ethcore/src/engines/hbbft/hbbft_engine.rs +++ b/crates/ethcore/src/engines/hbbft/hbbft_engine.rs @@ -484,15 +484,19 @@ impl HoneyBadgerBFT { .write() .insert(batch.epoch, random_number); - if let Some(mut header) = client.create_pending_block_at(batch_txns, timestamp, batch.epoch) { + if let Some(mut header) = client.create_pending_block_at(batch_txns, timestamp, batch.epoch) + { let block_num = header.number(); let hash = header.bare_hash(); - if let Some(reward_contract_address) = self.params.block_reward_contract_address { - header.set_author(reward_contract_address); + if let Some(reward_contract_address) = self.params.block_reward_contract_address { + header.set_author(reward_contract_address); } else { - warn!("Creating block with no blockRewardContractAddress {}", block_num); + warn!( + "Creating block with no blockRewardContractAddress {}", + block_num + ); } - + trace!(target: "consensus", "Sending signature share of {} for block {}", hash, block_num); let step = match self .sealing From ecdfd0a65aa1bf25418cba02386656727a12ba6e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 28 Jul 2023 23:24:14 +0200 Subject: [PATCH 4/4] improved debug output for early hbbft block contributions --- crates/ethcore/src/engines/hbbft/hbbft_state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ethcore/src/engines/hbbft/hbbft_state.rs b/crates/ethcore/src/engines/hbbft/hbbft_state.rs index 45d635807..23d35d781 100644 --- a/crates/ethcore/src/engines/hbbft/hbbft_state.rs +++ b/crates/ethcore/src/engines/hbbft/hbbft_state.rs @@ -316,7 +316,7 @@ impl HbbftState { if let Some(latest_block) = client.block_number(BlockId::Latest) { if honey_badger.epoch() != latest_block + 1 { - info!(target: "consensus", "Detected an attempt to send a hbbft contribution for block {} before the previous block was imported to the chain.", honey_badger.epoch()); + info!(target: "consensus", "Detected an attempt to send a hbbft contribution for block {} before the previous block was imported to the chain. (latest block: {})", honey_badger.epoch(), latest_block); return None; } }