Fix #4162: limit concurrent outgoing TransactionListQuery conversations#4164
Draft
Fix #4162: limit concurrent outgoing TransactionListQuery conversations#4164
Conversation
|
Coverage Impact This PR will not change total coverage. Modified Files with Diff Coverage (2)
🤖 Increase coverage with AI coding...🚦 See full report on Qlty Cloud » 🛟 Help
|
…ngeQuery messages When many peers connect at startup, sendTransactionListQuery/sendTransactionRangeQuery can be called for many peers simultaneously. Each peer responds with TransactionList messages that cause BBolt writes, starving read operations (e.g. notifier startup). Add a token bucket (buffered channel, pre-filled to capacity) that rate-limits both sendTransactionListQuery and sendTransactionRangeQuery. The bucket is refilled at the configured rate (default 2/s, configurable via network.v2.transactionlistqueryrate). Queries that find no token available are dropped; the gossip/state-comparison mechanism will retry them naturally. Unlike a semaphore, a rate limiter is unaffected by slow or non-responsive peers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
48c077d to
332ea98
Compare
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.

Summary
Second mitigation for #4162.
sendTransactionListQuery/sendTransactionRangeQueryis called for each peer that has missing transactionsTransactionListmessages, causing a flood of BBolt writesnotifier.Run()during startup)Fix: a token bucket rate-limiter shared by both
sendTransactionListQueryandsendTransactionRangeQuery. Queries that find no token available are dropped — the gossip/state-comparison mechanism retries them naturally.1s / rate) up to the bucket capacitynetwork.v2.transactionlistqueryrate)Test plan
TestProtocol_sendTransactionListQuery/rate_limit_reached_-_query_is_dropped: drains the bucket, verifies the next query is dropped without error and no conversation is left openTestProtocolV2_Pagination: integration test still passesnetwork/...tests pass🤖 Generated with Claude Code