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

Manually merged
brunoerg merged 1 commit from test-minchainwork-outbound-disconnect into master 2026-10-05 09:25:04 +00:00 AGit
brunoerg commented 2026-10-02 23:55:11 +00:00 (Migrated from github.com)

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.

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.
DrahtBot commented 2026-10-02 23:55:20 +00:00 (Migrated from github.com)

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

External sites

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 <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36426 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36426.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36426#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [maflcko](https://github.com/bitcoin/bitcoin/pull/36426#pullrequestreview-5399637650), [kevkevinpal](https://github.com/bitcoin/bitcoin/pull/36426#issuecomment-5971122345), [sedited](https://github.com/bitcoin/bitcoin/pull/36426#pullrequestreview-5412348276) | 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-->
First-time contributor

Base: c8e852d3a02a73d473228232148163cdbc8f7bb0
Head: c502b65c007bce1a5d9c6399e836b5372eef3399

No verified findings are available from this partial review.

Review coverage was incomplete. The archaeology review had incomplete evidence. The adversarial_glm review did not complete.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `c8e852d3a02a73d473228232148163cdbc8f7bb0` Head: `c502b65c007bce1a5d9c6399e836b5372eef3399` No verified findings are available from this partial review. Review coverage was incomplete. The archaeology review had incomplete evidence. The adversarial_glm review did not complete. [Full review report](<https://review.fish.foo/traces/36426-c502b65c007bce1a5d9c6399e836b5372eef3399-320-2.html>)
maflcko (Migrated from github.com) approved these changes 2026-10-03 08:04:44 +00:00
maflcko (Migrated from github.com) left a comment

lgtm ACK c502b65c00

Just a stupid nit, feel free to ignore.

lgtm ACK c502b65c007bce1a5d9c6399e836b5372eef3399 Just a stupid nit, feel free to ignore.
maflcko (Migrated from github.com) commented 2026-10-03 08:02:19 +00:00
        headers = [from_hex(CBlockHeader(), node.getblockheader(node.getblockhash(height), verbose=False))

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

```suggestion headers = [from_hex(CBlockHeader(), node.getblockheader(node.getblockhash(height), verbose=False)) ``` nit: I prefer named args for integral-like literals for clarity
kevkevinpal commented 2026-10-03 16:33:18 +00:00 (Migrated from github.com)

ACK c502b65

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

ACK [c502b65](https://github.com/bitcoin/bitcoin/pull/36426/commits/c502b65c007bce1a5d9c6399e836b5372eef3399) Thanks for adding this coverage. It makes sense to add, and I was able to run it locally successfully.
sedited (Migrated from github.com) approved these changes 2026-10-05 09:16:14 +00:00
sedited (Migrated from github.com) left a comment
ACK c502b65c007bce1a5d9c6399e836b5372eef3399
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36426
No description provided.