Skip to content

dgb: inject make_mempool_tx_source into embedded run-loop work source (surface-for-tap, consensus VALUE) - #248

Merged
frstrtr merged 2 commits into
masterfrom
dgb/main-embedded-tx-source-wire
Jun 20, 2026
Merged

dgb: inject make_mempool_tx_source into embedded run-loop work source (surface-for-tap, consensus VALUE)#248
frstrtr merged 2 commits into
masterfrom
dgb/main-embedded-tx-source-wire

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 19, 2026

Copy link
Copy Markdown
Owner

DRAFT — pre-staged per integrator so the DGB lane does not idle on #244's rollup. Stacked on #244 (dgb/embedded-mempool-tx-source); rebase onto its merge commit before review.

What

Wire the #244 EmbeddedTxSource seam into the c2pool-dgb run loop (src/c2pool/main_dgb.cpp). EmbeddedCoinNode now receives make_mempool_tx_source(mempool, BLOCK_MAX_WEIGHT): the served work template selects fee-sorted mempool txs and folds their fees into coinbasevalue via the #207 SSOT, instead of subsidy-only + empty transactions[].

mempool is hoisted ahead of embedded_coin (the injected source captures it by ref and must be outlived by it; reverse-order destruction tears the source down first). The duplicate lower mempool decl is removed.

Classification — surface-for-tap (consensus VALUE)

Changes the served template tx-selection path → NOT auto-merge. Byte-identical to the #237 subsidy-only baseline today: 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 until live tx ingest lands — safe ordering.

Scope correction vs the pre-stage ask

The integrator named "wire_mempool_ingest + inject make_mempool_tx_source". Only the injection is wireable now; the wire_mempool_ingest call is gated on the embedded daemon P2P node (no interfaces::Node in main yet). That call is the explicit follow-on once the embedded P2P node stands up.

Verify

  • c2pool-dgb configure + build: EXIT=0, links clean (make_mempool_tx_source resolves via dgb_coin).
  • --selftest: OK; --help/network summary unchanged.

Fenced: 1 file, src/c2pool/main_dgb.cpp, DGB tree only. No shared-base / other-coin / CMake / build.yml touch.

HOLD merge — surface-for-tap.

frstrtr added 2 commits June 19, 2026 22:39
…-> 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.
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.
@frstrtr
frstrtr marked this pull request as ready for review June 20, 2026 05:58
@frstrtr
frstrtr merged commit ddf789d into master Jun 20, 2026
27 checks passed
frstrtr added a commit that referenced this pull request Jun 23, 2026
…mpool

Wire DGBWorkSource::get_current_work_template to select fee-sorted mempool
transactions via the make_mempool_tx_source SSOT (BLOCK_MAX_WEIGHT cap),
mirroring the embedded node path (#248). The selection shapes GBT
transactions[] and its fee total folds into coinbasevalue through the #207
resolve_coinbase_value SSOT; the builder passes the array through verbatim.

On the current empty embedded mempool the call yields an empty transactions[]
and total_fees=0 -- byte-identical to the prior coinbase-only template. It
lights up unchanged once the embedded P2P mempool feed populates the pool.
DGB-tree only; shared modules untouched. dgb_share_test 26/26, block_assembly
8/8, mempool_ingest 5/5; c2pool-dgb links.
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