forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge bitcoin#30666: validation: fix m_best_header tracking and BLOCK…
…_FAILED_CHILD assignment 0bd53d9 test: add test for getchaintips behavior with invalid chains (Martin Zumsande) ccd98ea test: cleanup rpc_getchaintips.py (Martin Zumsande) f5149dd validation: mark blocks building on an invalid block as BLOCK_FAILED_CHILD (Martin Zumsande) 783cb73 validation: call RecalculateBestHeader in InvalidChainFound (Martin Zumsande) 9275e96 rpc: call RecalculateBestHeader as part of reconsiderblock (Martin Zumsande) a51e917 validation: add RecalculateBestHeader() function (Martin Zumsande) Pull request description: `m_best_header` (the most-work header not known to be on an invalid chain) can be wrong in the context of invalidation / reconsideration of blocks. This can happen naturally (a valid header is received and stored in our block tree db; when the full block arrives, it is found to be invalid) or triggered by the user with the `invalidateblock` / `reconsiderblock` rpc. We don't currently use `m_best_header` for any critical things (see OP of bitcoin#16974 for a list that still seems up-to-date), so it being wrong affects mostly rpcs. This PR proposes to recalculate it if necessary by looping over the block index and finding the best header. It also suggest to mark headers between an invalidatetd block and the previous `m_best_header` as invalid, so they won't be considered in the recalculation. It adds tests to `rpc_invalidateblock.py` and `rpc_getchaintips.py` that fail on master. One alternative to this suggested in the past would be to introduce a continuous tracking of header tips (bitcoin#12138). While this might be more performant, it is also more complicated, and situations where we need this data are only be remotely triggerable by paying the cost of creating a valid PoW header for an invalid block. Therefore I think it isn't necessary to optimise for performance here, plus the solution in this PR doesn't perform any extra steps in the normal node operation where no invalidated blocks are encountered. Fixes bitcoin#26245 ACKs for top commit: fjahr: reACK 0bd53d9 achow101: ACK 0bd53d9 TheCharlatan: Re-ACK 0bd53d9 Tree-SHA512: 23c2fc42d7c7bb4f9b4ba4949646b3d0031dd29ed15484e436afd66cd821ed48e0f16a1d02f45477b5d0d73a006f6e81a56b82d9721e0dee2e924219f528b445
- Loading branch information
Showing
5 changed files
with
113 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters