Skip to content

dgb(#82): stand StratumServer up in main_dgb.cpp --run — submitblock-RPC arm wired - #187

Merged
frstrtr merged 5 commits into
masterfrom
dgb/stratum-standup-closer
Jun 19, 2026
Merged

dgb(#82): stand StratumServer up in main_dgb.cpp --run — submitblock-RPC arm wired#187
frstrtr merged 5 commits into
masterfrom
dgb/stratum-standup-closer

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 19, 2026

Copy link
Copy Markdown
Owner

#82 dual-path won-block closer — miner-facing Stratum standup (submitblock-RPC arm)

Stacks on the run-loop (#182 spine + node-construct) and the #186 DGBWorkSource 4a skeleton. Closes the SEAM both branches left: stand the Stratum work source up + bridge to the won-block broadcaster.

What --run now does

  • Constructs the miner-facing path on the run-loop io_context:
    • c2pool::dgb::HeaderChain + dgb::coin::MempoolMVP-unwired this slice. The 4a work source returns default work; mining_submit low-diff-rejects via the 0.0 compute_share_difficulty sentinel before the broadcaster, so no garbage block is ever emitted. Same posture btc::stratum landed its skeleton wiring with.
    • dgb::coin::CoinNode(nullptr,nullptr) + a SubmitBlockFn bridging block_bytes -> hex -> submit_block_hex (rpc.cpp:387, REAL, not a stub) — the submitblock-RPC arm of the dual-path broadcaster. has_rpc()==false => returns false loudly (the dgb(test): lock CoinNode submit/seam contract (#82 RPC-fallback half) #163 seam guard: no silent drop).
    • dgb::stratum::DGBWorkSource + core::StratumServer, gated on a new --stratum [HOST:]PORT flag (mirrors main_btc.cpp). Acceptor lifecycle wired into the signal_set handler: stratum stop() runs before ioc.stop() so live miner sessions close cleanly.
  • CMake: link c2pool-dgb against dgb_stratum.

Isolation / scope

  • Single-coin: no bitcoin_family / src/core touch. core::StratumServer consumed, not modified. No -DAUX_DOGE.

Remaining for the closer (NEXT slice)

The embedded P2P-relay arm (m_on_block_found -> reconstruct_won_block -> broadcast_won_block) needs the reconstructor stack (#163/#166/#167/#177), HELD off master. Once it lands on this base I bind it and capture the two-arm independent broadcast evidence the acceptance gate calls for (kill P2P sink -> submitblock alone broadcasts; kill RPC -> embedded P2P alone broadcasts).

Evidence

  • Build EXIT=0 (-DCOIN_DGB=ON): dgb_stratum + c2pool-dgb link clean.
  • --run --stratum 127.0.0.1:5022 smoke:
    • `DGBWorkSource constructed (min_diff=0.0005 ... vardiff=on)`
    • `StratumServer started on 127.0.0.1:5022`
    • `sharechain peer listening on port 5024`
    • SIGINT -> `StratumServer stopped (closed 0 active sessions)` -> `io_context stopped — clean exit`, EXIT=0.

HOLD merge — integrator lands per merge-card; sequencing: #183 net_name first, #182 run-loop, #186 work source, then this.

@frstrtr
frstrtr force-pushed the dgb/stratum-standup-closer branch from 5205645 to 1a561f9 Compare June 19, 2026 08:04
frstrtr added 5 commits June 19, 2026 11:04
…(--run)

Stand up the run-loop spine in main_dgb.cpp behind a new --run flag: a
boost::asio::io_context plus an explicit graceful shutdown driven from
signal_set(SIGINT, SIGTERM), mirroring main_btc.cpp s teardown contract.

This is the lifecycle every node subsystem (sharechain peer dgb::Node,
embedded digibyted P2P, Stratum acceptor) and the #82 won-block dispatch
handler hangs off. Standing the spine up first keeps the next increments
(node/Config construction over LevelDB, P2P listen, Stratum, and the
m_on_block_found -> reconstruct_won_block -> broadcast_won_block binding
landed across #163/#166/#167/#173/#174/#176/#177/#179) build-verifiable
rather than landing a large unverified port in one step.

--selftest / bare invocation unchanged (live ShareTracker::score() path).
External digibyted RPC fallback posture preserved.

Build: c2pool-dgb links EXIT=0 (-DCOIN_DGB=ON). Smoke: --selftest OK
(block_period=75s SSOT); --run spine up, SIGINT -> clean shutdown exit 0.
…run)

Second stacked run-loop slice. main_dgb.cpp --run now constructs the real
dgb::Config + dgb::Node (pool::NodeBridge<NodeImpl, Legacy, Actual>) on the
spine io_context, opens the sharechain LevelDB, and binds the P2P listener on
PoolConfig::P2P_PORT (5024) — the sharechain peer is live, not just the
io_context spine.

Config is set directly from the p2pool-dgb-scrypt oracle constants (PREFIX
1c0553f2..., IDENTIFIER 4b62545b...), skipping Config::init() yaml load, the
same contract main_btc.cpp uses. DEFAULT_BOOTSTRAP_HOSTS is empty until DGB
p2pool nodes come online, so there are no outbound seeds to dial this slice;
the node listens and waits for inbound peers. The per-coin net dir is digibyte/
(bucket-1 isolation).

Constructing the node pulls BaseNode::connected (boost::log) and the NodeImpl
TU, so the c2pool-dgb exe must link the real dgb pool runtime, not just the
header-only score path. Wire the exe to link the dgb OBJECT lib + dgb_coin +
core/pool/sharechain/storage base, mirroring the c2pool-btc link set;
c2pool_merged_mining is pulled for symbol resolution of the core web_server
tangle only (same as c2pool-btc) and does NOT enable -DAUX_DOGE — DGB default
build stays standalone. Only the c2pool-dgb target stanza changes; per-coin
isolation holds.

Build EXIT=0. Smoke: --run binds 0.0.0.0:5024 (ss-confirmed), SIGINT ->
graceful shutdown -> clean exit 0, LevelDB closed cleanly; --selftest still
drives the live score() path; --version OK.

SEAM (next slice): stand up the Stratum work source + bind
make_on_block_found(reconstruct_won_block, p2p_sink) into m_on_block_found
to close the #82 embedded P2P relay path (submitblock RPC fallback at
rpc.cpp:387 is already real, not a stub).
…ks c2pool-dgb

The run-loop slice switched c2pool-dgb to link the dgb and dgb_coin OBJECT
libs, but both were defined only inside if(COIN_DGB). The coin-matrix CI job
configures without -DCOIN_DGB, so the targets were undefined and CMake emitted
raw -ldgb/-ldgb_coin, failing the link (cannot find -ldgb). Mirror btc/ltc,
which define their per-coin libs unconditionally; keep only the test subtree
behind COIN_DGB (build.yml sets the flag and builds those targets).

Verified: fresh configure with COIN_DGB=OFF builds + links c2pool-dgb and
--help smokes clean (EXIT=0).
…RPC arm wired

Stacks on the run-loop (#182 spine + node-construct) and the DGBWorkSource
4a skeleton (#186): closes the SEAM both left for "stand the Stratum work
source up + bind the won-block broadcaster."

--run now constructs the miner-facing path on the run-loop io_context:
  - c2pool::dgb::HeaderChain + dgb::coin::Mempool (MVP-unwired this slice —
    the 4a work source returns default work; mining_submit low-diff-rejects
    via the 0.0 compute_share_difficulty sentinel BEFORE the broadcaster, so
    no garbage block is ever emitted)
  - dgb::coin::CoinNode(nullptr,nullptr) + a SubmitBlockFn bridging
    block_bytes -> hex -> submit_block_hex (rpc.cpp:387, REAL not a stub):
    the submitblock-RPC arm of the #82 dual-path broadcaster. has_rpc()==false
    => returns false LOUDLY (the #163 seam guard: no silent drop).
  - dgb::stratum::DGBWorkSource + core::StratumServer, gated on a new
    --stratum [HOST:]PORT flag (mirrors main_btc.cpp). Acceptor lifecycle is
    wired into the signal_set handler: stratum stop() runs BEFORE ioc.stop()
    so live miner sessions close cleanly.

CMake: link c2pool-dgb against dgb_stratum. Single-coin (no bitcoin_family /
src/core touch); core::StratumServer consumed, not modified. No -DAUX_DOGE.

Remaining for the #82 closer (NEXT slice): the embedded P2P-relay arm
(m_on_block_found -> reconstruct_won_block -> broadcast_won_block) needs the
reconstructor stack (#163/#166/#167/#177), HELD off master. Two-arm
independent broadcast evidence captured once both arms are live.

Build EXIT=0; --run --stratum 127.0.0.1:5022 smoke: StratumServer started,
sharechain peer on 5024, SIGINT -> ordered graceful shutdown (stratum stop
then clean exit), EXIT=0.
…in-matrix

The --run stratum standup links dgb, dgb_coin and dgb_stratum, but all three
were defined only inside if(COIN_DGB). The coin-matrix CI configures without
-DCOIN_DGB, so the targets were undefined and CMake emitted raw -ldgb/-ldgb_coin/
-ldgb_stratum, failing the link. Mirror btc/ltc: define the per-coin libs
unconditionally, keep only the test subtree behind COIN_DGB (build.yml sets it).

Verified: fresh configure with COIN_DGB=OFF builds + links c2pool-dgb and --help
smokes clean (EXIT=0).
@frstrtr
frstrtr force-pushed the dgb/stratum-standup-closer branch from 9e68970 to f8f4554 Compare June 19, 2026 11:07
@frstrtr
frstrtr merged commit d7c6df2 into master Jun 19, 2026
19 checks passed
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