Skip to content

mempool: caller-budgeted template selection (SV2 roadmap, Plan A) - #807

Open
average-gary wants to merge 4 commits into
reardencode:masterfrom
average-gary:sv2/plan-a-budgeted-selection
Open

average-gary wants to merge 4 commits into
reardencode:masterfrom
average-gary:sv2/plan-a-budgeted-selection

Conversation

@average-gary

@average-gary average-gary commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Starts Q-64 (SV2 template provider). The first commit adds the roadmap (docs/sv2-template-provider.md): three plans, one PR each, and the result of the dependency spike (reuse the stratum-core wire crates: cargo deny passes, no second bitcoin, static musl link works).

docs/quality.md: the old backlog row Q-64 "GBT longpoll / waitNext (then Sv2)" is replaced by the ranked Q-64 template-provider row. GBT longpoll already ships; Core's IPC waitNext is dropped (TDP push covers those clients). See the roadmap's Out of scope.

Plan A: template selection takes a caller budget (SelectBudget { max_weight_wu, reserved_sigops, min_sat_kvb }) and returns each tx with its base fee and sigop cost from one lock. getblocktemplate and generate use it. GBT no longer re-reads fee/sigops after selection, so a tx evicted in between can't show up as fee: 0 or understate coinbasevalue. Removes select_block_txs, select_block_txids(_delta) and get_live_sigop_cost. The node-wide sigop reserve now applies only to admission. No new flags, and GBT output for an unchanged mempool is unchanged.

Local: fmt, clippy -D warnings, cargo deny, ast-grep and OS smoke pass on macOS. The full workspace suite passes in a Linux container, apart from two 20 s wall-time P2P tests that pass when rerun alone.

🤖 Generated with Claude Code

average-gary and others added 4 commits September 28, 2026 12:40
Split Q-64 into three plans, one PR each: A (caller-budgeted template
selection behind GBT), B (mine a block through the TP), C (fee-delta
push). B stays whole: a TP without tip push or SubmitSolution strands
miners on stale tips or drops found blocks.

Step 0 spike: reuse the crates.io stratum-core wire crates (noise_sv2
2.0.0, codec_sv2 7.0.0, framing_sv2 8.0.0, binary_sv2 7.0.0,
template_distribution_sv2 7.0.0, parsers_sv2 0.6.0, common_messages_sv2
9.0.0). cargo deny passes; no second bitcoin; secp256k1 0.28 comes in via
noise_sv2 only and links alongside 0.29 in a static musl binary. A Noise
NX roundtrip of SetupConnection, NewTemplate, and a 3 MB
RequestTransactionData.Success decodes field-equal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TxGraph::select_block_template takes a SelectBudget (weight, sigop
reserve, -blockmintxfee floor) and returns each pick with its base fee
and sigop cost, read under the same graph borrow as the selection. The
graph-global reserve now serves admission only; ActiveMempool passes it
for the existing template path until the hub moves to the new call.

select_block_txids / select_block_txids_delta go away. The sigop
skip-and-continue unit now drives the reserve through the budget and
absorbs the configured-reserve unit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MempoolHub::select_block_template(budget) returns each selected tx with
its base fee and sigop cost from one read lock; template_budget(min) is
the node's own budget (template weight, configured sigop reserve). GBT
and generate use it, so GBT no longer re-reads fee and sigops per tx
after the lock drops: a tx evicted in between used to report fee 0 and
understate coinbasevalue. Plan B passes per-client budgets to the same
call.

select_block_txs (hub and ActiveMempool) and get_live_sigop_cost have
no callers left and go away; the hub sigop tests read through the
selection instead, and the chain-ops GBT beat pins the reported fee.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cap concurrent TP sessions (Electrum max_connections pattern) so the
retained-template RAM trade has a real bound, with a B1 contract and red
case. Record Core's IPC waitNext as out of scope in place of the old Q-64
backlog row; GBT longpoll already ships. B1 adds the CRATES.md row with
the new crate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant