Skip to content

dgb: wire embedded P2P tx relay into the in-process Mempool - #245

Merged
frstrtr merged 1 commit into
masterfrom
dgb/embedded-mempool-ingest-feed
Jun 19, 2026
Merged

dgb: wire embedded P2P tx relay into the in-process Mempool#245
frstrtr merged 1 commit into
masterfrom
dgb/embedded-mempool-ingest-feed

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Adds c2pool::dgb::wire_mempool_ingest (coin/mempool_ingest.hpp) — the tx analog of wire_header_ingest. Subscribes a Mempool to dgb::interfaces::Node::new_tx so the embedded coin P2P tx relay (ADD_P2P_HANDLER(tx)) populates the pool the embedded work template selects from. Until now new_tx fired into the void and the embedded mempool stayed empty regardless of P2P traffic.

Connector adds no policy — delegates txid/dedup/weight/byte-cap to Mempool::add_tx (the insertion SSOT). Called without a UTXOViewCache, so fees stay fee_known=false until a UTXO view feeds them, matching the conservative shaper default (fee=null, excluded from the coinbasevalue fold) so a P2P-fed mempool cannot desync coinbasevalue vs daemon GBT.

NON-CONSENSUS: this only opens the feed; it is not yet called from main_dgb.cpp and the served template is unchanged. Wiring it + the make_mempool_tx_source drain into the run loop is the follow-up surface-for-tap slice.

Test: dgb_mempool_ingest_test 5/5 (links the full dgb_coin codec; in BOTH build.yml --target allowlists, #143 trap avoided).

Add c2pool::dgb::wire_mempool_ingest (coin/mempool_ingest.hpp): subscribe a
Mempool to dgb::interfaces::Node::new_tx so the embedded coin P2P tx relay
(ADD_P2P_HANDLER(tx)) populates the pool the embedded work template selects
from. Until now new_tx fired into the void and the embedded mempool stayed
empty regardless of P2P traffic, so an injected EmbeddedTxSource would have
nothing to select and transactions[] stayed empty.

Tx analog of wire_header_ingest (new_headers -> HeaderChain): the connector
adds no policy, delegating txid/dedup/weight/byte-cap to Mempool::add_tx (the
insertion SSOT). add_tx is called without a UTXOViewCache, so fees stay
fee_known=false until a UTXO view feeds them -- matching the conservative
shaper default (fee=null, excluded from the coinbasevalue fold) so a P2P-fed
mempool cannot desync coinbasevalue vs daemon GBT.

Non-consensus: this only opens the feed; it is not yet called from
main_dgb.cpp and the served template is unchanged. Wiring it plus the
make_mempool_tx_source drain into the run loop is the follow-up
surface-for-tap slice.

dgb_mempool_ingest_test 5/5 (links the full dgb_coin codec; in BOTH
build.yml --target allowlists, #143).
@frstrtr
frstrtr merged commit 4ebd5f8 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