test: check IBD insufficient work disconnect of outbound peers #36426

pull brunoerg wants to merge 1 commits into bitcoin:master from brunoerg:test-minchainwork-outbound-disconnect changing 1 files +37 −0
  1. brunoerg commented at 11:55 PM on October 2, 2026: contributor

    While in IBD, outbound peers (full-relay and block-relay-only) whose headers chain has less work than nMinimumChainWork are disconnected. This behavior was not covered by any test, since the functional tests only connect nodes to each other via manual connections, and the default minimum chain work is zero.

    This adds a test case that restarts node2 with a higher -minimumchainwork and check that both outbound-full-relay and block-relay-only peers serving headers below it are disconnected, while inbound and manual peers are not.

  2. DrahtBot added the label Tests on Oct 2, 2026
  3. DrahtBot commented at 11:55 PM on October 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, kevkevinpal, sedited

    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-->

  4. test: check IBD insufficient work disconnect of outbound peers
    While in IBD, outbound peers (full-relay and block-relay-only) whose
    headers chain has less work than nMinimumChainWork are disconnected.
    This behavior was not covered by any test, since the functional tests
    only connect nodes to each other via manual connections, and the
    default minimum chain work is zero.
    
    Restart node2 with a higher -minimumchainwork and check that both
    outbound-full-relay and block-relay-only peers serving headers below
    it are disconnected, while inbound and manual peers are not.
    c502b65c00
  5. brunoerg force-pushed on Oct 3, 2026
  6. DrahtBot added the label CI failed on Oct 3, 2026
  7. DrahtBot removed the label CI failed on Oct 3, 2026
  8. in test/functional/feature_minchainwork.py:70 in c502b65c00
      65 | +        self.restart_node(2, extra_args=["-minimumchainwork=0x1000"])
      66 | +        node = self.nodes[2]
      67 | +        assert_equal(node.getblockchaininfo()['initialblockdownload'], True)
      68 | +        # Headers already in node2's block index (ancestors of its tip) skip the
      69 | +        # low-work headers sync, so they reach the insufficient work check.
      70 | +        headers = [from_hex(CBlockHeader(), node.getblockheader(node.getblockhash(height), False))
    


    maflcko commented at 8:02 AM on October 3, 2026:
            headers = [from_hex(CBlockHeader(), node.getblockheader(node.getblockhash(height), verbose=False))
    

    nit: I prefer named args for integral-like literals for clarity

  9. maflcko approved
  10. maflcko commented at 8:04 AM on October 3, 2026: member

    lgtm ACK c502b65c007bce1a5d9c6399e836b5372eef3399

    Just a stupid nit, feel free to ignore or pick.

  11. kevkevinpal commented at 4:33 PM on October 3, 2026: contributor

    ACK c502b65

    Thanks for adding this coverage. It makes sense to add, and I was able to run it locally successfully.

  12. sedited approved
  13. sedited commented at 9:16 AM on October 5, 2026: contributor

    ACK c502b65c007bce1a5d9c6399e836b5372eef3399

  14. sedited merged this on Oct 5, 2026
  15. sedited closed this on Oct 5, 2026

  16. brunoerg deleted the branch on Oct 5, 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-10-08 23:51 UTC

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