Skip to content

Commit

Permalink
[BUG][Validation] Set DoS score for blocks with invalid PoW
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed May 17, 2021
1 parent a6d74e7 commit 2605f5b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3135,7 +3135,7 @@ bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockIndex** ppi
return false;

if (block.GetHash() != consensus.hashGenesisBlock && !CheckWork(block, pindexPrev))
return false;
return state.DoS(100, false, REJECT_INVALID);

bool isPoS = block.IsProofOfStake();
if (isPoS) {
Expand Down
7 changes: 4 additions & 3 deletions test/functional/feature_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,7 @@ def run_test(self):
b50 = self.next_block(50)
b50.nBits = b50.nBits - 1
b50.solve()
# !TODO: fix expect_disconnect
self.send_blocks([b50], False, reconnect=False)
self.send_blocks([b50], False, reconnect=True)

self.log.info("Reject a block with two coinbase transactions")
self.move_tip(44)
Expand Down Expand Up @@ -1256,7 +1255,9 @@ def create_sized_block(self, block, spend, block_size):
block.hashMerkleRoot = block.calc_merkle_root()
block.solve()
# Make sure the math above worked out to produce a block_size-sized block
assert len(block.serialize()) in [block_size - 1, block_size]
bsize = len(block.serialize())
if bsize not in [block_size - 1, block_size]:
self.log.warning("Created block of size %d" % bsize)
return block


Expand Down

0 comments on commit 2605f5b

Please sign in to comment.