validation: invalid block handling followups #32843

pull mzumsande wants to merge 2 commits into bitcoin:master from mzumsande:202506_invalid_blocks_followup changing 2 files +21 −13
  1. mzumsande commented at 10:10 pm on June 30, 2025: contributor

    Some follow-ups from #31405:

    • avoid duplicate recalculation of failure flags and m_best_header in InvalidateBlock(), which already does the accounting for these quantities while disconnecting blocks, so recalcuation is not needed in the final InvalidChainFound call (https://github.com/bitcoin/bitcoin/pull/31405#discussion_r2138368309)
    • make it clearer that all block indexes with a CBlockIndexWorkComparator score at least as good as the tip (and no others) are expected in setBlockIndexCandidates. People think of nChainWork when the term work is used and not of the (slightly arbitrary) CBlockIndexWorkComparator tiebreaker rules, which makes the current documentation imprecise ( #31405 (review) )
    • add a comment that nChainWork, not CBlockIndexWorkComparator is used for m_best_header (https://github.com/bitcoin/bitcoin/pull/31405#discussion_r2138368441)
  2. validation: Don't repeat work in InvalidateBlock
    In InvalidateBlock, both the block failure flags
    and m_best_header are kept up to date with each block
    that is disconnected, so it's not necessary to recalculate
    them at the end of this function.
    30b190eeba
  3. DrahtBot added the label Validation on Jun 30, 2025
  4. DrahtBot commented at 10:10 pm on June 30, 2025: contributor

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

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32843.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #30214 (refactor: Improve assumeutxo state representation by ryanofsky)

    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.

  5. doc: Improve doc for candidate blocks
    It is not true in general that all blocks with the same work
    (as defined via nChainWork) as the tip are candidates expected to be in
    setBlockIndexCandidates - only ones with a better tiebreak than the tip.
    Make that clear in various spots.
    
    Also explain that we don't use CBlockIndexWorkComparator tiebreak rules
    for m_best_header.
    e32e72039f
  6. mzumsande force-pushed on Jun 30, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-07-05 18:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me