Commit 75ec900
committed
Merge bitcoin/bitcoin#34207: coins/refactor: enforce
2ee7f9b coins: assume `GetCoin` only returns unspent coins (Andrew Toth)
eec551a fuzz: keep `coinscache_sim` backend free of spent coins (Andrew Toth)
3e4155f test: do not return spent coins from `CCoinsViewTest::GetCoin` (Andrew Toth)
ee1e40f txdb: assert `CCoinsViewDB::GetCoin` only returns unspent coins (Lőrinc)
Pull request description:
This PR is split out from #33018 to keep that PR focused on removing the `FRESH-but-not-DIRTY` cache state.
### Problem
`::GetCoin()` is an interface for querying the UTXO set, so production implementations should only ever return unspent coins. Tests should mimic this to provide useful feedback.
### Fix:
* Add a fail-fast assertion that `CCoinsViewDB::GetCoin()` never returns a spent coin.
* Align unit tests and fuzz simulations with the production `GetCoin()` contract by never returning spent coins.
* Replace the unreachable “spent coin returned by parent” handling in `CCoinsViewCache::FetchCoin()` with `Assert(!coin.IsSpent())`, drop outdated `spent+FRESH` docs, and tighten `SanityCheck()` invariants.
Behavior is unchanged, it just aligns our tests to exercise valid states.
ACKs for top commit:
andrewtoth:
re-ACK 2ee7f9b
optout21:
crACK 2ee7f9b
achow101:
ACK 2ee7f9b
w0xlt:
reACK 2ee7f9b
Tree-SHA512: be21cc09690410fc04ca25e1ba47aae6186bc037e413b3bb1e6e9a04e6364cbfac5a2fcdc49b638fec848cd29243fab0cc0581b9923f34fafe8366828f690ed4GetCoin() returns only unspent coinsFile tree
5 files changed
+29
-44
lines changed- src
- test
- fuzz
5 files changed
+29
-44
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 58 | + | |
62 | 59 | | |
63 | 60 | | |
64 | 61 | | |
| |||
277 | 274 | | |
278 | 275 | | |
279 | 276 | | |
280 | | - | |
| 277 | + | |
281 | 278 | | |
282 | 279 | | |
283 | 280 | | |
| |||
318 | 315 | | |
319 | 316 | | |
320 | 317 | | |
321 | | - | |
| 318 | + | |
322 | 319 | | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
329 | 325 | | |
330 | 326 | | |
331 | 327 | | |
332 | 328 | | |
333 | 329 | | |
334 | | - | |
| 330 | + | |
335 | 331 | | |
336 | 332 | | |
337 | 333 | | |
| |||
340 | 336 | | |
341 | 337 | | |
342 | 338 | | |
343 | | - | |
| 339 | + | |
344 | 340 | | |
345 | 341 | | |
346 | 342 | | |
347 | | - | |
| 343 | + | |
348 | 344 | | |
349 | 345 | | |
350 | 346 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | 105 | | |
107 | 106 | | |
108 | 107 | | |
| |||
117 | 116 | | |
118 | 117 | | |
119 | 118 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | 119 | | |
127 | 120 | | |
128 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 51 | + | |
56 | 52 | | |
57 | 53 | | |
58 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
142 | | - | |
143 | 141 | | |
144 | 142 | | |
145 | 143 | | |
| |||
148 | 146 | | |
149 | 147 | | |
150 | 148 | | |
151 | | - | |
152 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | 156 | | |
162 | 157 | | |
163 | 158 | | |
| |||
167 | 162 | | |
168 | 163 | | |
169 | 164 | | |
170 | | - | |
| 165 | + | |
171 | 166 | | |
172 | | - | |
173 | | - | |
174 | 167 | | |
175 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
176 | 173 | | |
177 | 174 | | |
178 | 175 | | |
179 | 176 | | |
180 | 177 | | |
181 | | - | |
| 178 | + | |
182 | 179 | | |
183 | 180 | | |
184 | 181 | | |
| |||
263 | 260 | | |
264 | 261 | | |
265 | 262 | | |
266 | | - | |
| 263 | + | |
267 | 264 | | |
268 | 265 | | |
269 | 266 | | |
| |||
449 | 446 | | |
450 | 447 | | |
451 | 448 | | |
452 | | - | |
| 449 | + | |
453 | 450 | | |
454 | 451 | | |
455 | 452 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| |||
0 commit comments