mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-13 06:04:42 +02:00
ba01b00d45refactor: use for loops in FindMostWorkChain (stratospher)aa0eef735btest: add InvalidateBlock/ReconsiderBlock asymmetry test (stratospher)1b0b3e2c2cvalidation: remove redundant marking in FindMostWorkChain (stratospher) Pull request description: recent PRs like #31405, #30666 mark all `m_block_index` descendants as invalid immediately whenever an invalid block is encountered in `SetBlockFailureFlags`. so by the time we reach `FindMostWorkChain`, the block in `setBlockIndexCandidates` already has `BLOCK_FAILED_VALID` set on it - not just on its ancestor. this means `pindexTest = pindexFailed` whenever `fFailedChain` fires, and the inner `while (pindexTest != pindexFailed)` loop body is never reached! I think we can remove it but I've just replaced it with `Assume` in this PR for safety + good to document this invariant in case the code changes in future. (noticed by @ stickies-v in https://github.com/bitcoin/bitcoin/pull/32950#discussion_r2815053885) the second commit is unrelated and adds a unit test for the situation in https://github.com/bitcoin/bitcoin/issues/32173 ACKs for top commit: fjahr: re-ACKba01b00d45optout21: crACKba01b00d45w0xlt: ACKba01b00d45ryanofsky: Code review ACKba01b00d45, just tweaking comment and for loop condition since last review. Tree-SHA512: a8be3c30b1c41b76690d16d850e87e9e71fa6a1ecaa8b90ec997ffee1aace48b336a7009a480cd016103759d79c964b3d761a13ae936523808b2930beb68dae5
43 KiB
43 KiB