trie: enforce strict per-depth fetch limit in Missing #33195
Closed
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The depth throttling in trie/sync’s Missing() used a strict-greater-than check (>) against maxFetchesPerDepth, which allowed scheduling one extra request per depth before breaking out of the loop. This behavior contradicts the comment that describes the value as a maximum and provides no tangible benefit, since the loop immediately breaks on the next iteration while the counter is already beyond the intended cap. Changing the comparison to greater-or-equal (>=) enforces the documented maximum precisely and prevents depth counters from exceeding the cap by one. This change aligns the implementation with the intended semantics without affecting completion logic, as decrements still occur on commit via commitNodeRequest and commitCodeRequest.