validation: do not add the snapshot to candidates set of the background chainstate #34786

pull mzumsande wants to merge 1 commits into bitcoin:master from mzumsande:202603_assumeutxo_sbi changing 2 files +6 −13
  1. mzumsande commented at 11:53 am on March 10, 2026: contributor

    The snapshot block needs to be added to the candidates set of the assumed-valid chain because it will be the tip of that chainstate right after snapshot activation.

    However, adding it also to the background chainstate is not necessary for anything. Before, the index would be in the set without being connectable. It will be eventually added to the set as part of the normal block download - no extra logic is necessary here.

    This simplifies a unit test which had a comment that having the block in the set is “not intended”. This was suggested here and here in #34521

    Note that adding the snapshot block was harmless, since FindMostWorkChain() lazily removes blocks without data from the set, so this does not fix a bug but just simplifies some code.

  2. validation: do not add the snapshot block to candidates of bg chainstate
    The snapshot block needs to be added to the candidates set of the
    assumed-valid chain because it will be the tip of that chainstate
    right after snapshot activation.
    However, adding it also to the background chainstate is not necessary
    for anything. Before, the index would linger in the set without being
    connectable. It will be eventually added to the set as part of the
    normal block download - no extra logic is necessary here.
    69baddc910
  3. DrahtBot added the label Validation on Mar 10, 2026
  4. DrahtBot commented at 11:54 am on March 10, 2026: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK sedited, fjahr, stratospher, achow101
    Concept ACK Bortlesboat

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

  5. sedited commented at 4:55 pm on March 10, 2026: contributor
    Concept ACK, thanks for the follow up.
  6. Bortlesboat commented at 4:09 am on March 15, 2026: none
    Concept ACK 69baddc91033d2e42947260cde0f6780959f16b2. Removing TargetBlock() correctly limits the snapshot-block special-case to cs2 where it’s actually needed — the test’s own “not intended” comment was the tell.
  7. sedited added this to the milestone 32.0 on Mar 20, 2026
  8. sedited approved
  9. sedited commented at 8:33 am on March 24, 2026: contributor
    ACK 69baddc91033d2e42947260cde0f6780959f16b2
  10. DrahtBot requested review from Bortlesboat on Mar 24, 2026
  11. sedited removed review request from Bortlesboat on Mar 24, 2026
  12. sedited requested review from fjahr on Mar 24, 2026
  13. in src/validation.cpp:4924 in 69baddc910
    4920@@ -4921,7 +4921,7 @@ void Chainstate::PopulateBlockIndexCandidates()
    4921         // With assumeutxo, the snapshot block is a candidate for the tip, but it
    4922         // may not have BLOCK_VALID_TRANSACTIONS (e.g. if we haven't yet downloaded
    4923         // the block), so we special-case it here.
    4924-        if (pindex == SnapshotBase() || pindex == TargetBlock() ||
    4925+        if (pindex == SnapshotBase() ||
    


    fjahr commented at 9:28 am on March 24, 2026:
    nit: Maybe biased because I just reviewed something else where this confused people but there could be a comment like this here added too: “Note that this only adds the tip to the snapshot chainstate and not the historical chainstate because SnapshotBase() is nullptr for the historical chainstate.” But it’s not a blocker because the docs of SnapshotBase() make it clear already.
  14. fjahr commented at 9:31 am on March 24, 2026: contributor
    ACK 69baddc91033d2e42947260cde0f6780959f16b2
  15. DrahtBot requested review from Bortlesboat on Mar 24, 2026
  16. stratospher commented at 1:56 pm on March 24, 2026: contributor
    ACK 69baddc.
  17. achow101 commented at 9:51 pm on March 24, 2026: member
    ACK 69baddc91033d2e42947260cde0f6780959f16b2
  18. achow101 merged this on Mar 24, 2026
  19. achow101 closed this on Mar 24, 2026


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: 2026-04-10 21:13 UTC

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