Commit 9251bc7
committed
Merge bitcoin/bitcoin#30267: assumeutxo: Check snapshot base block is not in invalid chain
2f9bde6 test: Remove unnecessary restart in assumeutxo test (Fabian Jahr)
19ce3d4 assumeutxo: Check snapshot base block is not marked invalid (Fabian Jahr)
80315c0 refactor: Move early loadtxoutset checks into ActiveSnapshot (Fabian Jahr)
Pull request description:
This was discovered in a discussion in #29996
If the base block of the snapshot is marked invalid or part of an invalid chain, we currently still load the snapshot and get stuck in a weird state where we have the snapshot chainstate but it will never connect to our valid chain.
While this scenario is highly unlikely to occur on mainnet, it still seems good to prevent this inconsistent state.
The behavior change described above is in the second commit.
The first commit refactors the early checks in the `loadtxoutset` RPC by moving them into `ActivateSnapshot()` in order to have the chance to cover them by unit tests in the future and have a more consistent interface. Previously checks were spread out between `rpc/blockchain.cpp` and `validation.cpp`. In order to be able to return the error message to users of the RPC, the return type of `ActivateSnapshot()` is changed from `bool` to `util::Result`.
The third commit removes an unnecessary restart introduced in #29428.
ACKs for top commit:
mzumsande:
re-ACK 2f9bde6
alfonsoromanz:
Re-ACK 2f9bde6. The RPC code looks much cleaner after the refactor. Also, it seems very useful to get the error message in the RPC response rather than having to rely on the logs in some scenarios if you are an RPC user.
achow101:
ACK 2f9bde6
Tree-SHA512: 5328dd88c3c7be3f1be97c9eef52ac3666c27188c30a798b3e949f3ffcb83be075127c107e4046f7f39f961a79911ea3d61b61f3c11e451b3e4c541c264eeed4File tree
6 files changed
+66
-54
lines changed- src
- rpc
- test
- fuzz
- util
- test/functional
6 files changed
+66
-54
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | 65 | | |
67 | | - | |
68 | 66 | | |
69 | 67 | | |
70 | 68 | | |
| |||
2821 | 2819 | | |
2822 | 2820 | | |
2823 | 2821 | | |
2824 | | - | |
2825 | | - | |
2826 | | - | |
2827 | | - | |
2828 | | - | |
2829 | | - | |
2830 | | - | |
2831 | | - | |
2832 | | - | |
2833 | | - | |
2834 | | - | |
2835 | | - | |
2836 | | - | |
2837 | | - | |
2838 | | - | |
2839 | | - | |
2840 | | - | |
2841 | | - | |
2842 | | - | |
2843 | | - | |
2844 | | - | |
2845 | | - | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
2846 | 2825 | | |
2847 | 2826 | | |
2848 | 2827 | | |
2849 | 2828 | | |
2850 | | - | |
2851 | | - | |
| 2829 | + | |
| 2830 | + | |
2852 | 2831 | | |
2853 | 2832 | | |
2854 | 2833 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5646 | 5646 | | |
5647 | 5647 | | |
5648 | 5648 | | |
5649 | | - | |
| 5649 | + | |
5650 | 5650 | | |
5651 | 5651 | | |
5652 | 5652 | | |
5653 | 5653 | | |
5654 | 5654 | | |
| 5655 | + | |
5655 | 5656 | | |
5656 | 5657 | | |
5657 | | - | |
5658 | | - | |
| 5658 | + | |
5659 | 5659 | | |
5660 | 5660 | | |
5661 | 5661 | | |
5662 | 5662 | | |
| 5663 | + | |
| 5664 | + | |
| 5665 | + | |
| 5666 | + | |
| 5667 | + | |
| 5668 | + | |
| 5669 | + | |
| 5670 | + | |
| 5671 | + | |
| 5672 | + | |
| 5673 | + | |
| 5674 | + | |
| 5675 | + | |
| 5676 | + | |
| 5677 | + | |
| 5678 | + | |
| 5679 | + | |
| 5680 | + | |
| 5681 | + | |
| 5682 | + | |
| 5683 | + | |
5663 | 5684 | | |
5664 | | - | |
5665 | | - | |
| 5685 | + | |
5666 | 5686 | | |
5667 | 5687 | | |
5668 | 5688 | | |
| |||
5712 | 5732 | | |
5713 | 5733 | | |
5714 | 5734 | | |
5715 | | - | |
5716 | 5735 | | |
5717 | 5736 | | |
5718 | 5737 | | |
| |||
5728 | 5747 | | |
5729 | 5748 | | |
5730 | 5749 | | |
5731 | | - | |
| 5750 | + | |
5732 | 5751 | | |
5733 | 5752 | | |
5734 | 5753 | | |
| |||
5771 | 5790 | | |
5772 | 5791 | | |
5773 | 5792 | | |
5774 | | - | |
| 5793 | + | |
5775 | 5794 | | |
5776 | 5795 | | |
5777 | 5796 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1054 | 1054 | | |
1055 | 1055 | | |
1056 | 1056 | | |
1057 | | - | |
| 1057 | + | |
1058 | 1058 | | |
1059 | 1059 | | |
1060 | 1060 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | | - | |
76 | | - | |
| 76 | + | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
| 84 | + | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
104 | | - | |
| 105 | + | |
105 | 106 | | |
106 | | - | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
117 | | - | |
118 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
| |||
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
154 | | - | |
155 | | - | |
156 | | - | |
| 156 | + | |
| 157 | + | |
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
| |||
185 | 186 | | |
186 | 187 | | |
187 | 188 | | |
188 | | - | |
189 | | - | |
| 189 | + | |
| 190 | + | |
190 | 191 | | |
191 | 192 | | |
192 | 193 | | |
| |||
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
205 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
206 | 219 | | |
207 | 220 | | |
208 | 221 | | |
| |||
290 | 303 | | |
291 | 304 | | |
292 | 305 | | |
| 306 | + | |
293 | 307 | | |
294 | 308 | | |
295 | 309 | | |
| |||
450 | 464 | | |
451 | 465 | | |
452 | 466 | | |
453 | | - | |
454 | | - | |
| 467 | + | |
| 468 | + | |
455 | 469 | | |
456 | 470 | | |
457 | 471 | | |
| |||
0 commit comments