You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge #15402: Granular invalidateblock and RewindBlockIndex
519b0bc Make last disconnected block BLOCK_FAILED_VALID, even when aborted (Pieter Wuille)
8d22041 Optimization: don't add txn back to mempool after 10 invalidates (Pieter Wuille)
9ce9c37 Prevent callback overruns in InvalidateBlock and RewindBlockIndex (Pieter Wuille)
9bb32eb Release cs_main during InvalidateBlock iterations (Pieter Wuille)
9b1ff5c Call InvalidateBlock without cs_main held (Pieter Wuille)
241b2c7 Make RewindBlockIndex interruptible (Pieter Wuille)
880ce7d Call RewindBlockIndex without cs_main held (Pieter Wuille)
436f7d7 Release cs_main during RewindBlockIndex operation (Pieter Wuille)
1d34287 Merge the disconnection and erasing loops in RewindBlockIndex (Pieter Wuille)
32b2696 Move erasure of non-active blocks to a separate loop in RewindBlockIndex (Pieter Wuille)
9d6dcc5 Abstract EraseBlockData out of RewindBlockIndex (Pieter Wuille)
Pull request description:
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).
This is not an optimal solution, as we're relying on the scheduler call sites to make sure the scheduler doesn't overflow. Ideally, the scheduler would guarantee this directly, but that needs a few further changes (moving the signal emissions out of cs_main) to prevent deadlocks.
I have manually tested the `invalidateblock` changes (including interrupting, and running with -checkblockindex and -checkmempool), but haven't tried the rewinding (which is probably becoming increasingly unnecessary, as very few pre-0.13.1 nodes remain that would care to upgrade).
Tree-SHA512: 692e42758bd3d3efc2eb701984a8cb5db25fbeee32e7575df0183a00d0c2c30fdf72ce64c7625c32ad8c8bdc56313da72a7471658faeb0d39eefe39c4b8b8474
0 commit comments