Skip to content

Commit

Permalink
feat: failure of min difficulty should not add block to list of bad b…
Browse files Browse the repository at this point in the history
…locks (#5805)

Description
---
Blocks that fail min difficulty should not be added to the list of bad
blocks.

Motivation and Context
---
By adding the blocks to the list of bad blocks we open up the local node
to be spammed to write bad block hashes into the database. These waste
space and they require a write lock on the database. Checking the
difficulty is a very quick and inexpensive check.
  • Loading branch information
SWvheerden authored Oct 9, 2023
1 parent 05fc2e9 commit 38dc014
Showing 1 changed file with 0 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,6 @@ where B: BlockchainBackend + 'static
PowAlgorithm::Sha3x => sha3x_difficulty(&new_block.header)?,
};
if achieved < min_difficulty {
self.blockchain_db
.add_bad_block(
new_block.header.hash(),
self.blockchain_db.get_chain_metadata().await?.height_of_longest_chain(),
)
.await?;
return Err(CommsInterfaceError::InvalidBlockHeader(
BlockHeaderValidationError::ProofOfWorkError(PowError::AchievedDifficultyBelowMin),
));
Expand Down

0 comments on commit 38dc014

Please sign in to comment.