mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Merge #15402: Granular invalidateblock and RewindBlockIndex
519b0bc5dcMake last disconnected block BLOCK_FAILED_VALID, even when aborted (Pieter Wuille)8d220417cdOptimization: don't add txn back to mempool after 10 invalidates (Pieter Wuille)9ce9c37004Prevent callback overruns in InvalidateBlock and RewindBlockIndex (Pieter Wuille)9bb32eb571Release cs_main during InvalidateBlock iterations (Pieter Wuille)9b1ff5c742Call InvalidateBlock without cs_main held (Pieter Wuille)241b2c74acMake RewindBlockIndex interruptible (Pieter Wuille)880ce7d46bCall RewindBlockIndex without cs_main held (Pieter Wuille)436f7d735fRelease cs_main during RewindBlockIndex operation (Pieter Wuille)1d342875c2Merge the disconnection and erasing loops in RewindBlockIndex (Pieter Wuille)32b2696ab4Move erasure of non-active blocks to a separate loop in RewindBlockIndex (Pieter Wuille)9d6dcc52c6Abstract 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
This commit is contained in:
@@ -443,7 +443,7 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc
|
||||
bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main);
|
||||
|
||||
/** Mark a block as invalid. */
|
||||
bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindex);
|
||||
|
||||
/** Remove invalidity status from a block and its descendants. */
|
||||
void ResetBlockFailureFlags(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
Reference in New Issue
Block a user