p2p: ignore historical blocks when counting blocks in flight #36790

Open
sashaphmn wants to merge 2 commits from compact-blocks-bg-validation into master AGit
sashaphmn commented 2026-11-06 13:17:48 +00:00 (Migrated from github.com)

While background validation runs after loading an assumeutxo
snapshot, blocks needed only by the background (historical) chainstate
are also tracked in mapBlocksInFlight. The condition that decides
whether a new block is requested as a compact block counted those
blocks as well, so with historical blocks in flight the new block at
the tip was requested as a full block instead.

Do not count blocks that are only needed by the historical chainstate.
Compact block relay then works normally during background validation.

Behavior is unchanged when no snapshot is loaded, because in that case
there are no historical blocks to exclude.

While background validation runs after loading an assumeutxo snapshot, blocks needed only by the background (historical) chainstate are also tracked in mapBlocksInFlight. The condition that decides whether a new block is requested as a compact block counted those blocks as well, so with historical blocks in flight the new block at the tip was requested as a full block instead. Do not count blocks that are only needed by the historical chainstate. Compact block relay then works normally during background validation. Behavior is unchanged when no snapshot is loaded, because in that case there are no historical blocks to exclude.
DrahtBot commented 2026-11-06 13:18:08 +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.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36787 (cmpctblock: Cache serialized cmpctblock msg for relay [part of prefill series] by davidgumberg)
  • #35558 (p2p: Prefill compact blocks by davidgumberg)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

<!--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/36790 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36790.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36790#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. A summary of reviews will appear here. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36787](https://github.com/bitcoin/bitcoin/pull/36787) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36787.svg"></sub> (cmpctblock: Cache serialized cmpctblock msg for relay [part of prefill series] by davidgumberg) * [#35558](https://github.com/bitcoin/bitcoin/pull/35558) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35558.svg"></sub> (p2p: Prefill compact blocks by davidgumberg) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

🔵 Suggestion · Historical requests still exhaust per-peer compact-download capacity

Excluding historical requests from the global count only helps tip announcements from peers with free download slots; historically saturated peers still cannot start a compact-block download.

Location: src/net_processing.cpp:3186 (head).

🔵 Suggestion · High-bandwidth peer selection lacks snapshot-specific coverage

The new test checks only GETDATA, so reverting the snapshot-specific BlockChecked selection changes would leave its assertions intact.

Location: test/functional/feature_assumeutxo.py:432 (head).

Review coverage was incomplete.


Reviewed: a695d65fda87 · Full review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:df0443dc5cff1224f58cf2f0af2a814b52ac77c4fa18c64584a637f43b36d781:b3906d5974a831cf25d9d4076421aeb88934ca1265895f22224d53119372abb5 --> <!-- ralph-base:050982c52d9752c5feda0e5fc4a29a0dc070a83b --> <!-- ralph-head:a695d65fda872574b47f658db9fb1bfd85127124 --> <!-- ralph-case:1c5eefe146c70fd67365b1459b8aa3a3599245c4b81bfc4f77799fa480ab1382 --> **🔵 Suggestion · Historical requests still exhaust per-peer compact-download capacity** Excluding historical requests from the global count only helps tip announcements from peers with free download slots; historically saturated peers still cannot start a compact-block download. Location: [`src/net_processing.cpp:3186`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/a695d65fda872574b47f658db9fb1bfd85127124/src/net_processing.cpp#L3186>) (head). **🔵 Suggestion · High-bandwidth peer selection lacks snapshot-specific coverage** The new test checks only GETDATA, so reverting the snapshot-specific BlockChecked selection changes would leave its assertions intact. Location: [`test/functional/feature_assumeutxo.py:432`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/a695d65fda872574b47f658db9fb1bfd85127124/test/functional/feature_assumeutxo.py#L432>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`a695d65fda87`](<https://git.fish.foo/bitcoin/bitcoin/commit/a695d65fda872574b47f658db9fb1bfd85127124>) · [Full review report](<https://review.fish.foo/traces/36790-a695d65fda872574b47f658db9fb1bfd85127124-2311-1.html>) · [Previous reports](<https://review.fish.foo/traces/36790/>) [permalink](<https://review.fish.foo/traces/36790-a695d65fda872574b47f658db9fb1bfd85127124-2311-1.html>)
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!36790
No description provided.