mempool: caller-budgeted template selection (SV2 roadmap, Plan A) - #807
Open
average-gary wants to merge 4 commits into
Open
average-gary wants to merge 4 commits into
average-gary wants to merge 4 commits into
Conversation
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>
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.
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 denypasses, no secondbitcoin, 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 IPCwaitNextis 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.getblocktemplateandgenerateuse it. GBT no longer re-readsfee/sigopsafter selection, so a tx evicted in between can't show up asfee: 0or understatecoinbasevalue. Removesselect_block_txs,select_block_txids(_delta)andget_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