Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35654. ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Quoting myself from the issue: If the chainstate is corrupted to the point that the condition described here is reached, I'm not sure if the check introduced here actually improves the situation for the running node. Commit 822755a also explicitly works around the "no valid first entry" scenario. The reasons stated here (crc collisions, and fork tools) also don't seem very compelling to me. If this is really something worthwhile, maybe just frame it as a correctness improvement and getting rid of a weird albeit harmless edge case? |
`CCoinsViewDB::Cursor()` already handles an empty coin keyspace after `Seek(DB_COIN)`, but could still accept an undecodable first coin key as a valid cursor position. `CCoinsViewDBCursor::Next()` invalidates the cursor for the same decode failure later in iteration, so the warmup path had a small malformed-chainstate consistency gap. Make initial cursor setup match `Next()`: keep the cached key invalid unless the first key decodes successfully. Add a unit test that writes a valid `Coin` under a malformed `DB_COIN` key and checks the cursor is invalid. Co-authored-by: Shuvam Pandey <[email protected]> Co-authored-by: Arthur Ariel Sabintsev <[email protected]> Co-authored-by: CruzMolina <[email protected]>
e835635 to
3837d91
Compare
Adjusted the code comment, commit message, PR description and title - let me know if this is what you meant |
Yes, that is what I meant. I'm still not sure if the change is worthwhile. This was repeatedly flagged and picked up by AI agents. I get the impression that this is more busywork than anything, but at this point it will just be picked up again and again, which seems like even more of a time sink, so I'd rather this change get in. ACK 3837d91 |
|
Following up on the "is this worthwhile" question above traced through the Before this fix: a corrupted first record means one garbage entry gets After this fix: Given the project's general preference for failing loudly on corrupted state |
|
Thanks for the hint @650DataNerd - a malformed first coin can short circuit iteration, we need to make deserialization error fatal like we do in #34132. |
Problem:
CCoinsViewDB::Cursor()already handles the case whereSeek(DB_COIN)finds no coin record, but could still accept an undecodable first coin key as a valid cursor position.CCoinsViewDBCursor::Next()already invalidates the cursor for the same decode failure later in iteration, so initial cursor setup has a small correctness mismatch.Fix: Make initial cursor setup match
Next(): keep the cached key invalid unless the first key decodes successfully.Fixes #35172, with credit to the issue author and previous attempts #35191 and #35248.