test: fix block file integrity check in feature_blocksxor.py #37051

pull theStack wants to merge 1 commits into bitcoin:master from theStack:test-fix-blocksxor-verifychain-assert changing 1 files +1 −1
  1. theStack commented at 4:16 PM on December 2, 2026: contributor

    This PR is a late follow-up fix for #30657 (commit faa1b9b0e6de7d213699fbdbc2e25a2a81c35cdc): The verifychain RPC returns false on failure instead of raising, so the block/undo file integrity check after manually un-XORing the files could never fail. Corruption in recent blocks is still caught by the startup check (-checkblocks, default 6), but older blocks are only read by verifychain(nblocks=0), whose result was ignored.

    The fix can be verified with the following diff, which makes the node write blocks at heights 1-99 without obfuscation (the genesis block is excluded, as it is read back right after writing):

    --- a/src/node/blockstorage.cpp
    +++ b/src/node/blockstorage.cpp
    @@ -1155,6 +1155,7 @@ FlatFilePos BlockManager::WriteBlock(const CBlock& block, int nHeight)
             return FlatFilePos();
         }
         AutoFile file{OpenBlockFile(pos, /*fReadOnly=*/false)};
    +    if (nHeight > 0 && nHeight < 100) file.SetObfuscation({});
         if (file.IsNull()) {
             LogError("OpenBlockFile failed for %s while writing block", pos.ToString());
             m_opts.notifications.fatalError(_("Failed to write block."));
    

    Running the test with this patch applied passes on master, but fails on this PR (use test_runner.py to use a fresh blocks cache for each run).

  2. test: fix block file integrity check in feature_blocksxor.py
    verifychain returns false on failure instead of raising, so the
    block/undo file integrity check after manually un-XORing the files
    could never fail. Corruption in recent blocks is still caught by the
    startup check (-checkblocks, default 6), but older blocks are only
    read by verifychain(nblocks=0), whose result was ignored.
    219c5c8ef7
  3. DrahtBot added the label Tests on Dec 2, 2026
  4. DrahtBot commented at 4:24 PM on December 2, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK maflcko, l0rinc

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. maflcko commented at 5:09 PM on December 2, 2026: member

    lgtm ACK 219c5c8ef79a7a521562b5112d7a77b3a27d13dd

  6. l0rinc commented at 5:16 PM on December 2, 2026: contributor

    ACK 219c5c8ef79a7a521562b5112d7a77b3a27d13dd

  7. fanquake merged this on Dec 3, 2026
  8. fanquake closed this on Dec 3, 2026

  9. fanquake referenced this in commit 9340bb49f1 on Dec 3, 2026
  10. fanquake commented at 10:38 AM on December 3, 2026: member

    Backported to 32.x in #37052.


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-12-04 12:51 UTC

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