Cap concurrent Electrum checkpoint Merkle proof builds - #258
Merged
agoodminute merged 1 commit intoSep 8, 2026
Merged
Conversation
agoodminute
force-pushed
the
fix/cap-checkpoint-merkle-proof-concurrency
branch
from
September 8, 2026 11:25
b9203b6 to
b391e2f
Compare
EddieHouston
self-requested a review
September 8, 2026 11:30
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
get_header_merkle_proofbuilds a checkpoint Merkle proof — walking and hashing every header from genesis up tocp_height— whenever an Electrum request sets a non-zerocp_height. Until now there was no limit on how many of these builds could run at once; each is comparatively expensive, and every concurrent call added its own CPU cost with no coordination between connections.Why
Since each build's cost scales with
cp_heightand there was no shared limit, a burst of concurrent requests could add up to significant CPU work across cores. Capping how many run at once keeps that work bounded regardless of how many connections request it simultaneously.Changes
get_header_merkle_proofnow takes acheckpoint_proof_concurrency_limitparameter and acquires a permit before building the proof, so at most that many builds run at once, process-wide.--electrum-checkpoint-proof-concurrency-limit(electrum_checkpoint_proof_concurrency_limit), default 2. A request past the limit fails immediately rather than queuing behind in-flight builds.0rejects all such requests.Connection::new/RPCstartup alongside the existingtxs_limit/subscription_limit.