Skip to content

Commit

Permalink
Merge pull request #45 from SurfingNerd/i40_transaction_fee_distribution
Browse files Browse the repository at this point in the history
Merging #40 as experimental.
1 Unit test is known to fail:
#53
  • Loading branch information
SurfingNerd authored Aug 10, 2023
2 parents ab61a97 + ecdfd0a commit 7d1b954
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion crates/ethcore/src/engines/hbbft/hbbft_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,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 => {
Expand All @@ -483,9 +486,19 @@ 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
Expand Down Expand Up @@ -1515,6 +1528,8 @@ impl Engine<EthereumMachine> 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)
Expand Down
2 changes: 1 addition & 1 deletion crates/ethcore/src/engines/hbbft/hbbft_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,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;
}
}
Expand Down

0 comments on commit 7d1b954

Please sign in to comment.