From 38dc014405eb6887210861bd533f2b1dd17f48c2 Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Mon, 9 Oct 2023 19:36:10 +0200 Subject: [PATCH] feat: failure of min difficulty should not add block to list of bad blocks (#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. --- .../core/src/base_node/comms_interface/inbound_handlers.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/base_layer/core/src/base_node/comms_interface/inbound_handlers.rs b/base_layer/core/src/base_node/comms_interface/inbound_handlers.rs index 710990bdb1..d2c2935928 100644 --- a/base_layer/core/src/base_node/comms_interface/inbound_handlers.rs +++ b/base_layer/core/src/base_node/comms_interface/inbound_handlers.rs @@ -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), ));