diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -3,3 +3,7 @@ This release includes the following features and fixes: + - Add the finalized block concept. Finalized blocks cannot be reorged, which protects the network against deep reorgs. + - Add the `-maxreorgdepth` configuration to configure at what depth block are considered final. Default is 10. Use -1 to disable. + - Introduce `finalizeblock` RPC to finalize a block at the will of the node operator. + - Introduce a penalty to alternative chains based on the depth of the fork. This makes it harder for an attacker to do mid size reorg. diff --git a/test/functional/abc-finalize-block.py b/test/functional/abc-finalize-block.py --- a/test/functional/abc-finalize-block.py +++ b/test/functional/abc-finalize-block.py @@ -42,7 +42,7 @@ alt_node.generate(10) # Wait for node 0 to invalidate the chain. - def wait_for_invalid_block(block): + def wait_for_invalid_block(node, block): def check_block(): for tip in node.getchaintips(): if tip["hash"] == block: @@ -51,7 +51,13 @@ return False wait_until(check_block) - wait_for_invalid_block(alt_node.getbestblockhash()) + # node do not accept alt_node's chain due to tip being finalized, + # even though it is longer. + wait_for_invalid_block(node, alt_node.getbestblockhash()) + assert_equal(node.getbestblockhash(), tip) + + # alt_node has mined 10 block, so tip must be invalid due to finalization. + wait_for_invalid_block(alt_node, tip) self.log.info("Test that an invalid block cannot be finalized...") assert_raises_rpc_error(-20, RPC_FINALIZE_INVALID_BLOCK_ERROR,