Skip to content

Cap concurrent Electrum checkpoint Merkle proof builds - #258

Merged
agoodminute merged 1 commit into
Blockstream:new-indexfrom
agoodminute:fix/cap-checkpoint-merkle-proof-concurrency
Sep 8, 2026
Merged

Cap concurrent Electrum checkpoint Merkle proof builds#258
agoodminute merged 1 commit into
Blockstream:new-indexfrom
agoodminute:fix/cap-checkpoint-merkle-proof-concurrency

Conversation

@agoodminute

Copy link
Copy Markdown
Collaborator

Summary

get_header_merkle_proof builds a checkpoint Merkle proof — walking and hashing every header from genesis up to cp_height — whenever an Electrum request sets a non-zero cp_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_height and 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_proof now takes a checkpoint_proof_concurrency_limit parameter and acquires a permit before building the proof, so at most that many builds run at once, process-wide.
  • New config option --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. 0 rejects all such requests.
  • Threaded the new limit through Connection::new / RPC startup alongside the existing txs_limit / subscription_limit.

EddieHouston
EddieHouston previously approved these changes Sep 8, 2026

@EddieHouston EddieHouston left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm b9203b6

@agoodminute
agoodminute force-pushed the fix/cap-checkpoint-merkle-proof-concurrency branch from b9203b6 to b391e2f Compare September 8, 2026 11:25
@EddieHouston
EddieHouston self-requested a review September 8, 2026 11:30

@EddieHouston EddieHouston left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b391e2f lgtm

@agoodminute
agoodminute merged commit 4b1a018 into Blockstream:new-index Sep 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants