Commit b50554b
committed
Merge bitcoin/bitcoin#29370: assumeutxo: Get rid of faked nTx and nChainTx values
9d9a745 assumeutxo: Remove BLOCK_ASSUMED_VALID flag (Ryan Ofsky)
ef174e9 test: assumeutxo snapshot block CheckBlockIndex crash test (Ryan Ofsky)
0391458 test: assumeutxo stale block CheckBlockIndex crash test (Ryan Ofsky)
ef29c8b assumeutxo: Get rid of faked nTx and nChainTx values (Ryan Ofsky)
9b97d5b doc: Improve comments describing setBlockIndexCandidates checks (Ryan Ofsky)
0fd915e validation: Check GuessVerificationProgress is not called with disconnected block (Ryan Ofsky)
63e8fc9 ci: add getchaintxstats ubsan suppressions (Ryan Ofsky)
f252e68 assumeutxo test: Add RPC test for fake nTx and nChainTx values (Ryan Ofsky)
Pull request description:
The `PopulateAndValidateSnapshot` function introduced in f6e2da5 from #19806 has been setting fake `nTx` and `nChainTx` values that can show up in RPC results (bitcoin/bitcoin#29328) and make `CBlockIndex` state hard to reason about, because it is difficult to know whether the values are real or fake.
Revert to previous behavior of setting `nTx` and `nChainTx` to 0 when the values are unknown, instead of faking them. Also drop no-longer needed `BLOCK_ASSUMED_VALID` flag.
Dropping the faked values also fixes assert failures in the `CheckBlockIndex` `(pindex->nChainTx == pindex->nTx + prev_chain_tx)` check that could happen previously if forked or out-of-order blocks before the snapshot got submitted while the snapshot was being validated. The PR includes two commits adding tests for these failures and describing them in detail.
Compatibility note: This change could cause new `-checkblockindex` failures if a snapshot was loaded by a previous version of Bitcoin Core and not fully validated, because fake `nTx` values will have been saved to the block index. It would be pretty easy to avoid these failures by adding some compatibility code to `LoadBlockIndex` and changing `nTx` values from 1 to 0 when they are fake (when `(pindex->nStatus & BLOCK_VALID_MASK) < BLOCK_VALID_TRANSACTIONS`), but a little simpler not to worry about being compatible in this case.
ACKs for top commit:
Sjors:
re-ACK 9d9a745
achow101:
ACK 9d9a745
mzumsande:
Tested ACK 9d9a745
maflcko:
ACK 9d9a745 🎯
Tree-SHA512: b1e1e2731ec36be30d5f5914042517219378fc31486674030c29d9c7488ed83fb60ba7095600f469dc32f0d8ba79c49ff7706303006507654e1762f26ee416e0File tree
8 files changed
+231
-156
lines changed- doc/design
- src
- test
- util
- test
- functional
- sanitizer_suppressions
8 files changed
+231
-156
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | 54 | | |
61 | 55 | | |
62 | 56 | | |
63 | | - | |
64 | | - | |
65 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
66 | 60 | | |
67 | 61 | | |
68 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
106 | 109 | | |
107 | | - | |
| 110 | + | |
108 | 111 | | |
109 | 112 | | |
110 | | - | |
| 113 | + | |
| 114 | + | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
| |||
124 | 128 | | |
125 | 129 | | |
126 | 130 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
| 131 | + | |
| 132 | + | |
142 | 133 | | |
143 | 134 | | |
144 | 135 | | |
| |||
173 | 164 | | |
174 | 165 | | |
175 | 166 | | |
176 | | - | |
| 167 | + | |
| 168 | + | |
177 | 169 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | 170 | | |
182 | 171 | | |
183 | 172 | | |
184 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
185 | 176 | | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | 177 | | |
192 | 178 | | |
193 | 179 | | |
| |||
262 | 248 | | |
263 | 249 | | |
264 | 250 | | |
265 | | - | |
266 | | - | |
| 251 | + | |
| 252 | + | |
267 | 253 | | |
268 | 254 | | |
269 | 255 | | |
270 | 256 | | |
271 | | - | |
272 | | - | |
273 | | - | |
| 257 | + | |
| 258 | + | |
274 | 259 | | |
275 | 260 | | |
276 | 261 | | |
| |||
318 | 303 | | |
319 | 304 | | |
320 | 305 | | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | 306 | | |
330 | 307 | | |
331 | 308 | | |
| |||
335 | 312 | | |
336 | 313 | | |
337 | 314 | | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | 315 | | |
345 | 316 | | |
346 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
101 | 104 | | |
102 | 105 | | |
103 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | 279 | | |
283 | 280 | | |
284 | 281 | | |
| |||
410 | 407 | | |
411 | 408 | | |
412 | 409 | | |
413 | | - | |
| 410 | + | |
414 | 411 | | |
415 | 412 | | |
416 | 413 | | |
| |||
421 | 418 | | |
422 | 419 | | |
423 | 420 | | |
424 | | - | |
425 | 421 | | |
426 | 422 | | |
427 | 423 | | |
| |||
456 | 452 | | |
457 | 453 | | |
458 | 454 | | |
459 | | - | |
| 455 | + | |
460 | 456 | | |
461 | 457 | | |
462 | 458 | | |
463 | 459 | | |
464 | | - | |
| 460 | + | |
465 | 461 | | |
466 | | - | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
467 | 465 | | |
468 | 466 | | |
469 | 467 | | |
470 | | - | |
471 | 468 | | |
472 | 469 | | |
473 | 470 | | |
474 | 471 | | |
475 | | - | |
476 | 472 | | |
477 | 473 | | |
478 | 474 | | |
479 | 475 | | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | 476 | | |
484 | 477 | | |
485 | 478 | | |
486 | | - | |
487 | | - | |
488 | 479 | | |
489 | 480 | | |
490 | 481 | | |
| |||
0 commit comments