fix(network): preserve fractional message rate credit - #904
Draft
czarcas7ic wants to merge 3 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
The transport token bucket discards fractional credit whenever it adds whole tokens. For example, an empty bucket configured for two messages per second admits one message after 750 ms, then incorrectly rejects another after the remaining 250 ms. Arrival timing can therefore reduce the configured allowance.
Solution
Preserve fractional credit between refills and discard excess credit when the bucket reaches its burst capacity. This keeps the configured rates, burst allowances, shared bucket scope, and disconnect policy unchanged.
Testing
The fractional-refill regression fails against the old accounting and passes with the fix. All 68 Linux handler tests passed, along with network Clippy for all targets, formatting, and the release node build. Tests also cover sustained traffic below the configured rate and clipping idle credit at capacity. A four-client native trial reached every target without rate-limit events. One client still entered a no-progress cooldown, so broader sync liveness remains under investigation. This arithmetic fix alone does not establish GetBlocks production readiness.
Changelog
Added an operator-facing changelog fragment; fragment validation and Markdown lint passed.
Used Codex to implement the fix and tests and prepare this description.