dgb: wire embedded mempool tx selection into work template (fees -> coinbasevalue, transactions[]) - #244
Merged
Merged
Conversation
…-> coinbasevalue, transactions[]) EmbeddedCoinNode gains an injected EmbeddedTxSource: the embedded work template's transactions[] and fee total now come from the in-process Mempool instead of being hardcoded empty/0. The fee total folds into coinbasevalue through the #207 resolve_coinbase_value SSOT (subsidy(h) + total_fees); transactions[] passes through build_work_template verbatim. The source defaults empty, so the #237 EmbeddedCoinNode call site stays byte-identical (truthful absence preserved). The heavy tx/UTXO serialization codec (TX_WITH_WITNESS pack + Hash + HexStr) lives out-of-line in embedded_tx_select.cpp (make_mempool_tx_source, compiled into dgb_coin), NOT in embedded_coin_node.hpp -- keeping that header codec-free holds the #143 btclibs SCC trap shut for guard-weight TUs. Per-tx entry shape {data,txid,hash,fee} mirrors btc/coin and the p2pool-dgb-scrypt GBT consumer (fee null when unknown -> base_subsidy fallback; unknown-fee txs excluded to avoid coinbasevalue desync). Tests: dgb_embedded_tx_select_test (3/3) pins the Mempool -> GBT shaping + fee total over a real pool; dgb_embedded_coin_node_test (+2 -> 7/7) pins the fee->coinbasevalue fold (#207) and the empty-source byte-identical invariant. Both registered in ctest + the two build.yml --target allowlists.
frstrtr
added a commit
that referenced
this pull request
Jun 20, 2026
… (surface-for-tap, consensus VALUE) (#248) * dgb: wire embedded mempool tx selection into the work template (fees -> coinbasevalue, transactions[]) EmbeddedCoinNode gains an injected EmbeddedTxSource: the embedded work template's transactions[] and fee total now come from the in-process Mempool instead of being hardcoded empty/0. The fee total folds into coinbasevalue through the #207 resolve_coinbase_value SSOT (subsidy(h) + total_fees); transactions[] passes through build_work_template verbatim. The source defaults empty, so the #237 EmbeddedCoinNode call site stays byte-identical (truthful absence preserved). The heavy tx/UTXO serialization codec (TX_WITH_WITNESS pack + Hash + HexStr) lives out-of-line in embedded_tx_select.cpp (make_mempool_tx_source, compiled into dgb_coin), NOT in embedded_coin_node.hpp -- keeping that header codec-free holds the #143 btclibs SCC trap shut for guard-weight TUs. Per-tx entry shape {data,txid,hash,fee} mirrors btc/coin and the p2pool-dgb-scrypt GBT consumer (fee null when unknown -> base_subsidy fallback; unknown-fee txs excluded to avoid coinbasevalue desync). Tests: dgb_embedded_tx_select_test (3/3) pins the Mempool -> GBT shaping + fee total over a real pool; dgb_embedded_coin_node_test (+2 -> 7/7) pins the fee->coinbasevalue fold (#207) and the empty-source byte-identical invariant. Both registered in ctest + the two build.yml --target allowlists. * dgb: inject make_mempool_tx_source into embedded run-loop work source Wire the #244 EmbeddedTxSource seam into the c2pool-dgb run loop. The EmbeddedCoinNode ctor now receives make_mempool_tx_source(mempool, BLOCK_MAX_WEIGHT): the served work template selects fee-sorted mempool transactions and folds their fees into coinbasevalue via the #207 SSOT, instead of emitting subsidy-only with an empty transactions[]. mempool is hoisted ahead of embedded_coin so the injected source (which captures it by reference) is outlived by the pool; reverse-order destruction tears the source down before the pool. The duplicate lower mempool declaration is removed. Consensus-VALUE: this changes the served template tx-selection path, so it is surface-for-tap, not auto-merge. It is byte-identical to the #237 subsidy-only baseline until the mempool is fed: wire_mempool_ingest (#245) needs an embedded coin-daemon ::dgb::interfaces::Node new_tx relay, and no such node is constructed in the run loop yet (the M3 embedded port; header_chain is likewise still unfed). So the source returns an empty selection today and the broadcast template is unchanged until live tx ingest lands. Build: c2pool-dgb links EXIT=0; --selftest OK. --------- Co-authored-by: frstrtr <frstrtr@users.noreply.github.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.
[surface-for-tap — consensus VALUE] Wires the embedded mempool tx selection into the DGB work template. Fenced:
src/impl/dgb/**only (+ the two build.yml--targetallowlist entries). Cut offorigin/master, follows #241 (the transactions[] pass-through seam).What changed
EmbeddedCoinNodetakes an injectedEmbeddedTxSource(default empty).transactions[]+ the fee total now come from the in-processMempoolrather than hardcoded empty/0.coinbasevaluevia the dgb: wire subsidy_func into embedded work source coinbasevalue (Phase B) #207resolve_coinbase_valueSSOT (subsidy(h) + total_fees);transactions[]passes throughbuild_work_templateverbatim.TX_WITH_WITNESSpack +Hash+HexStr) is out-of-line inembedded_tx_select.cpp(make_mempool_tx_source, compiled intodgb_coin) —embedded_coin_node.hppstays codec-free, holding the ci: build test_dgb_subsidy in both Linux test jobs (fix master-red NOT_BUILT) #143 btclibs SCC trap shut for guard-weight TUs.Integrator's three holds — all met
.cpp.EmptyTxSourceByteIdenticalToNoSource).total_feesflows throughresolve_coinbase_value(dgb: wire subsidy_func into embedded work source coinbasevalue (Phase B) #207 SSOT).Conformance (frstrtr/p2pool-dgb-scrypt)
Per-tx entry shape
{data,txid,hash,fee}mirrorsbtc/coinand the p2pool GBT consumer:data= with-witness submit bytes,txid= legacy sha256d,hash= wtxid,fee= per-tx fee (nullwhen unknown → base_subsidy fallback). Unknown-fee txs are excluded (including fee=0 would desynccoinbasevaluevs the daemon/p2pool GBT).coinbasevalue == subsidy(h)+total_feesasserted directly.Tests
dgb_embedded_tx_select_test3/3 — Mempool → GBT{data,txid,hash,fee}shaping + fee total over a real pool.dgb_embedded_coin_node_test5→7/7 — fee→coinbasevalue fold (dgb: wire subsidy_func into embedded work source coinbasevalue (Phase B) #207) + empty-source byte-identical invariant.c2pool-dgbbinary +dgb_template_builder_test(guard-weight) both rebuild clean.GPG-signed
47e6bcaf7. HOLD merge — operator tap (consensus VALUE surface). NEXT: wiremake_mempool_tx_sourceintomain_dgb.cpponce the embedded mempool is fed by P2P tx ingest.