Skip to content

validation: fix misleading checkblockindex comments - #29299

Merged
glozow merged 2 commits into
bitcoin:masterfrom
mzumsande:202401_cbi_assert
Jan 30, 2024
Merged

glozow merged 2 commits into
bitcoin:masterfrom
mzumsande:202401_cbi_assert

Conversation

@mzumsande

Copy link
Copy Markdown
Contributor

The two assumptions there were described as test-only, which has led to confusion whether they should exist.
However, they are necessary in general, as the changed comment explains - without them, the check would fail everywhere where it is enabled.
The second commit moves this assert down to the other checks.

Closes #29261

These exceptions are not related to situations specific to tests,
but are required in general:
Without the first check CheckBlockindex could fail for blocks where we
only know the header.
Without the second, it could fail when blocks are received out of order.
There is a designated section meant for the actual consistency
checks, marked by a comment.
@DrahtBot

DrahtBot commented Jan 23, 2024 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK ryanofsky, maflcko, naumenkogs

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Comment thread src/validation.cpp Resolved

@ryanofsky ryanofsky left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 9819db4. Thanks for figuring this issue out and fixing it. Would suggest changing pr name from "improve comments" to "fix misleading comments" since previous comments were wrong about the reasons the conditions are needed.

I also think it would be good to split up the assert and make it stricter, so feel free to use the code from #29261 (comment) to use in the second commit, if that helps. (Would be good to keep the first commit unchanged because it's a direct and straightforward fix.)

@maflcko

maflcko commented Jan 25, 2024

Copy link
Copy Markdown
Member

ACK 9819db4 🌦

Show signature

Signature:

untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: ACK 9819db4ccaa03519a78d4d9ecce9f89f5be669e5 🌦
/nSt0HlzU30n9tRv3NbydVteYOku+aPTyCh6PYQEjYJEORLApik/3CZKJsb6mUFPkY5ZQj5R4YjViUjIDo8GBg==

@mzumsande mzumsande changed the title validation: improve checkblockindex comments validation: fix misleading checkblockindex comments Jan 25, 2024
@mzumsande

Copy link
Copy Markdown
Contributor Author

Changed the title as suggested.

I also think it would be good to split up the assert and make it stricter, so feel free to use the code from #29261 (comment)

The suggestion looks good to me just by reading the code, but I want to test it more before including it. Will either update the PR in a few days, or alternatively (I don't mind either way) that could be a follow-up to this trivial doc-only PR.

@naumenkogs

Copy link
Copy Markdown
Contributor

ACK 9819db4

@glozow
glozow merged commit 7005766 into bitcoin:master Jan 30, 2024
@mzumsande
mzumsande deleted the 202401_cbi_assert branch February 1, 2024 18:16
@bitcoin bitcoin locked and limited conversation to collaborators Jan 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

assumeutxo: nTx and nChainTx violations in CheckBlockIndex

6 participants