Skip to content

dgb: wire EmbeddedCoinNode into production CoinNode work source - #237

Merged
frstrtr merged 1 commit into
masterfrom
dgb/embedded-coinnode-prod-wire
Jun 19, 2026
Merged

dgb: wire EmbeddedCoinNode into production CoinNode work source#237
frstrtr merged 1 commit into
masterfrom
dgb/embedded-coinnode-prod-wire

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Phase B: light up the embedded in-process work source in the c2pool-dgb run-loop.

What

run_node() (main_dgb.cpp) constructed CoinNode coin_node(/*embedded=*/nullptr, /*rpc=*/nullptr) — the embedded source was never wired, so get_work_view() returned an empty view. This constructs EmbeddedCoinNode(header_chain, params.subsidy_func) and passes it as the embedded source. The production CoinNode now serves templates from the live embedded chain + coin subsidy schedule via the #207 -> subsidy_func SSOT.

Discipline

  • header_chain hoisted ahead of coin_node so EmbeddedCoinNode (HeaderChain&) and coin_node (EmbeddedCoinNode*) outlive the tracker callback; DGBWorkSource keeps the same non-owning ref.
  • transactions[]/bits held back truthfully (no embedded mempool / next-target source yet — MultiShield V4 next-target is V37). No fabrication.
  • dgb: v36 donation version-gate (pillar 4 of modern-layer activation) #82 submit seam UNCHANGED: rpc=nullptr keeps has_rpc()==false, so submit_block_hex returns false LOUDLY independent of the embedded source.

Scope / fences

  • 1 file, src/c2pool/main_dgb.cpp (DGB binary glue). No src/impl/ltc|doge|btc, no shared base, no build.yml.
  • p2pool-merged-v36 surface: NONE (local seam wiring; coinbasevalue path already conformed).

Evidence

  • Build c2pool-dgb EXIT=0; --selftest OK.
  • Contract pinned by existing guards: coin_node_seam_test Filesystem #2 (embedded present + rpc null -> WorkView from embedded) / Json multiline reading #3 (submit -> false), dgb_embedded_coin_node_test 5/5.

HOLD merge — integrator lands with operator push approval.

Construct EmbeddedCoinNode(header_chain, subsidy_func) in run_node() and
pass it as the embedded source of the run-loop CoinNode (was embedded=
nullptr). The production CoinNode now serves get_work_view() from the
in-process embedded chain + the coin subsidy schedule via the #207 ->
subsidy_func SSOT, instead of returning an empty view.

header_chain is hoisted ahead of coin_node so EmbeddedCoinNode (holds a
HeaderChain&) and coin_node (holds the EmbeddedCoinNode*) both outlive the
tracker callback captured below; DGBWorkSource keeps the same non-owning
ref. transactions[]/bits stay held back truthfully (no mempool/next-target
source yet); coinbasevalue is subsidy(next_height)+0 over the live chain.

The #82 submit seam is unchanged: rpc=nullptr keeps has_rpc()==false so
submit_block_hex returns false LOUDLY, independent of the embedded source
(coin_node.cpp !m_rpc guard). Contract pinned by coin_node_seam_test #2/#3
(embedded present + rpc null) and dgb_embedded_coin_node_test 5/5.

Build c2pool-dgb EXIT=0, --selftest OK.
@frstrtr
frstrtr merged commit 6f7ee0a into master Jun 19, 2026
27 checks passed
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>
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