HomePhabricator

Abstract EraseBlockData out of RewindBlockIndex

Description

Abstract EraseBlockData out of RewindBlockIndex

Summary:
This PR makes a number of improvements to the InvalidateBlock (invalidateblock RPC) and RewindBlockIndex functions, primarily around breaking up their long-term cs_main holding. In addition:

  • They're made safely interruptible (bitcoind can be shutdown, and no progress in either will be lost, though if incomplete, invalidateblock won't continue after restart and will need to be called again)
  • The validation queue is prevented from overflowing (meaning invalidateblock on a very old block will not drive bitcoind OOM) (see #14289).
  • invalidateblock won't bother to move transactions back into the mempool after 10 blocks (optimization).

Partial Backport of Bitcoin Core PR15402 (commit 9d6dcc5):
https://github.com/bitcoin/bitcoin/pull/15402/commits/9d6dcc52c6cb0cdcda220fddccaabb0ffd40068d

Abstract EraseBlockData out of RewindBlockIndex

Note that the former 'else' branch in RewindBlockIndex is now
dealt with more naturally inside the EraseBlockData call (by
checking whether the parent needs to be re-added as candidate
after deleting a child).

Test Plan:

ninja check

Reviewers: Fabien, #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

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

Details

Provenance
Pieter Wuille <pieter.wuille@gmail.com>Authored on Feb 24 2019, 20:07
fpelliccioniCommitted on Dec 12 2019, 17:57
markblundebergPushed on Dec 12 2019, 21:47
Reviewer
Restricted Project
Differential Revision
D4653: Abstract EraseBlockData out of RewindBlockIndex
Parents
rSTAGING0af76c190ee7: [CI] Print the sanitizer logs
Branches
Unknown
Tags
Unknown
References
tag: phabricator/base/14821