HomePhabricator

Merge #12431: Only call NotifyBlockTip when chainActive changes

Description

Merge #12431: Only call NotifyBlockTip when chainActive changes

Summary:
f98b54352 Only call NotifyBlockTip when the active chain changes (James O'Beirne)
152b7fb25 [tests] Add a (failing) test for waitforblockheight (James O'Beirne)

Pull request description:

This is a subset of the more controversial https://github.com/bitcoin/bitcoin/pull/12407, but this also adds a test demonstrating the bug.

In InvalidateBlock, we're calling NotifyBlockTip with the now-invalid block's prev regardless of what chain the ancestor block is on. This could create numerous issues, but it at least screws up `waitforblockheight` (or anything else relying on `rpc/blockchain.cpp:latestblock`) when InvalidateBlock is called on a block not in chainActive, which can happen via RPC.

Only call NotifyBlockTip when the block being marked invalid is on the active chain.

Tree-SHA512: 9a54fe5e8c7eb489daf5df4483c0986129e871e2ca931a456ba869ecb5d5a8d4f7bd27ccc9e711e9292c9ed79ddef896c85d0e81fc76883503e327995b0e914f

Backport of Core PR12431
https://github.com/bitcoin/bitcoin/pull/12431/files
Completes T680

Test Plan:

make check
test_runner.py

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D3748

Details

Provenance
Wladimir J. van der Laan <laanwj@gmail.com>Authored on Mar 15 2018, 15:55
jasonbcoxCommitted on Jul 26 2019, 18:16
jasonbcoxPushed on Jul 26 2019, 21:10
Reviewer
Restricted Project
Differential Revision
D3748: Merge #12431: Only call NotifyBlockTip when chainActive changes
Parents
rSTAGING785e6b906f9c: Bump version to 0.19.12
Branches
Unknown
Tags
Unknown