Skip to content

netsync: reduce maximum blocks requested to avoid being banned - #2678

Open
allocz wants to merge 3 commits into
btcsuite:masterfrom
allocz:2026-11-03-fix-ibd-ban
Open

allocz wants to merge 3 commits into
btcsuite:masterfrom
allocz:2026-11-03-fix-ibd-ban

Conversation

@allocz

@allocz allocz commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Change Description

OnGetData() in server.go increases the ban score based in the inv
vector count of the received getdata message. When performing IBD
between two btcd nodes, the previous block request limit caused the node
performing IBD to be banned.

Limiting the amount of requested blocks to 505 causes the ban score to
not be increased, this way we avoid the ban.

Fixes #2626

Steps to Test

As described in the issue #2626

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

`OnGetData()` in `server.go` increases the ban score based in the inv
vector count of the received getdata message. When performing IBD
between two btcd nodes, the previous block request limit caused the node
performing IBD to be banned.

Limiting the amount of requested blocks to 505 causes the ban score to
not be increased, this way we avoid the ban.
The function extraction makes testing easier, as we have less state to
deal with in the tests.
@allocz

allocz commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@kcalvinalvin can you take a look?

This commit implements TestGetDataAddBanScore, which asserts the
behavior of getDataAddBanScore based on the getdata inv vector count and
message count.
@allocz
allocz force-pushed the 2026-11-03-fix-ibd-ban branch from 2b9642c to 1bb1197 Compare November 5, 2026 16:32

@Roasbeef Roasbeef left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The 505-block cap keeps the getdata ban-score increment at zero, and the global/per-peer in-flight tracking and refill paths still account for the requested blocks.

Validated with go test ./netsync and go test . at this head. I didn't run an end-to-end IBD sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: btcd archive node banning inbound connections that are performing IBD

2 participants