Page MenuHomePhabricator

Abstract EraseBlockData out of RewindBlockIndex
ClosedPublic

Authored by fpelliccioni on Dec 5 2019, 19:19.

Details

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

Diff Detail

Repository
rABC Bitcoin ABC
Branch
feature-backport-3db0cc394-9d6dcc5
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 8434
Build 14883: Default Diff Build & Tests
Build 14882: arc lint + arc unit

Event Timeline

Need to adjust Summary

fpelliccioni edited the test plan for this revision. (Show Details)
fpelliccioni edited the summary of this revision. (Show Details)
deadalnix requested changes to this revision.Dec 6 2019, 11:41
deadalnix added inline comments.
src/validation.cpp
5034

Why would you erase the block data of every blocks that is not in the chain active? That doesn't seems to make any sense to me, and I strongly suspect this has something to do with the test suite being broken. However, I was unable to figure any of the teamcity shit out so idk what's actually broken.

This revision now requires changes to proceed.Dec 6 2019, 11:41
fpelliccioni retitled this revision from Granular invalidateblock and RewindBlockIndex to Granular invalidateblock and RewindBlockIndex (Partial).Dec 9 2019, 14:39
fpelliccioni edited the summary of this revision. (Show Details)

Solved Bitcoin-QT test

fpelliccioni retitled this revision from Granular invalidateblock and RewindBlockIndex (Partial) to Abstract EraseBlockData out of RewindBlockIndex.Dec 9 2019, 15:59

That looks better, let me do a pass over this tomorow.

One small change, but otherwise, LGTM

src/validation.cpp
4951 ↗(On Diff #14692)

Move comment on prior line.

This revision is now accepted and ready to land.Dec 11 2019, 01:11
This revision was landed with ongoing or failed builds.Dec 12 2019, 17:57
This revision was automatically updated to reflect the committed changes.