Commit 141fbe4
committed
Merge bitcoin/bitcoin#34884: validation: remove unused code in FindMostWorkChain
ba01b00 refactor: use for loops in FindMostWorkChain (stratospher)
aa0eef7 test: add InvalidateBlock/ReconsiderBlock asymmetry test (stratospher)
1b0b3e2 validation: 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 bitcoin/bitcoin#32950 (comment))
the second commit is unrelated and adds a unit test for the situation in bitcoin/bitcoin#32173
ACKs for top commit:
fjahr:
re-ACK ba01b00
optout21:
crACK ba01b00
w0xlt:
ACK ba01b00
ryanofsky:
Code review ACK ba01b00, just tweaking comment and for loop condition since last review.
Tree-SHA512: a8be3c30b1c41b76690d16d850e87e9e71fa6a1ecaa8b90ec997ffee1aace48b336a7009a480cd016103759d79c964b3d761a13ae936523808b2930beb68dae5File tree
2 files changed
+94
-13
lines changed- src
- test
2 files changed
+94
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
618 | 618 | | |
619 | 619 | | |
620 | 620 | | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
621 | 709 | | |
622 | 710 | | |
623 | 711 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3127 | 3127 | | |
3128 | 3128 | | |
3129 | 3129 | | |
3130 | | - | |
3131 | 3130 | | |
3132 | | - | |
| 3131 | + | |
3133 | 3132 | | |
3134 | 3133 | | |
3135 | 3134 | | |
| |||
3143 | 3142 | | |
3144 | 3143 | | |
3145 | 3144 | | |
3146 | | - | |
3147 | 3145 | | |
3148 | | - | |
3149 | | - | |
3150 | | - | |
3151 | | - | |
3152 | | - | |
3153 | | - | |
3154 | | - | |
3155 | | - | |
| 3146 | + | |
| 3147 | + | |
| 3148 | + | |
| 3149 | + | |
| 3150 | + | |
3156 | 3151 | | |
3157 | 3152 | | |
3158 | 3153 | | |
3159 | 3154 | | |
3160 | | - | |
3161 | 3155 | | |
3162 | 3156 | | |
3163 | 3157 | | |
3164 | 3158 | | |
3165 | 3159 | | |
3166 | | - | |
3167 | 3160 | | |
3168 | 3161 | | |
3169 | 3162 | | |
| |||
0 commit comments