dgb: re-land worker->mint adapter (run_loop_mint.hpp) — Phase B consumer seam#305
Merged
Conversation
…mer seam Re-lands the #294 mint_local_share_with_ratchet helper, which was lost from master in the #292/#293/#294 stacked squash-merge (no #294 merge commit reaches origin/master; the primitives dgb_select_mint_versions + create_local_share survive). This is the consumer adapter DGBWorkSource::MintShareFn binds to (work_source.hpp:197): on a ShareAccept submission it parses the 80-byte reconstructed header, asks the live AutoRatchet for the {mint, vote} version pair, and inserts the share via create_local_share, returning the minted hash (NULL on a malformed header / fail-closed). Authored against master createlocal_share signature (authoritative). Duck-typed on the inputs so the header does not pull the stratum work_source TU in. Pure adapter: tracker-insertion thread-safety is the caller bind point concern. KAT (dgb_share_test, no new exe): 80-byte header parse round-trip, short-buffer fail-closed, and adapter fail-closed + template instantiation drift-guard against create_local_share. 25/25 green.
frstrtr
added a commit
that referenced
this pull request
Jun 22, 2026
#306) Complete the worker->mint sharechain-accept path. #305 re-landed the mint_local_share_with_ratchet adapter but left set_mint_share_fn UNBOUND in main_dgb -- so a Scrypt submission classified ShareAccept reached try_mint_share, found no callback, and earned no sharechain credit (loud no-op, never a silent drop). This binds the callback. Two parts: 1. run_loop_mint.hpp: new mint_local_share_locked(node, ...) helper. The mint fires on the Stratum-submission thread, NOT the compute (think()) thread -- so, unlike the m_on_block_found won-block path, it does NOT already hold the tracker lock, and create_local_share is a tracker WRITE. Per the NodeImpl locking discipline (node.hpp:83-92, mirrored by node.cpp processing_shares_phase2) the helper takes unique_lock(try_to_lock) on the tracker mutex and NEVER blocks the io_context on think()'s exclusive hold: if the tracker is busy the mint is DECLINED this round (NULL, the worker earns no credit until its next submission), never blocked, never a racy write. A durable defer-queue is a tracked follow-up. Duck-typed on the node (tracker()/tracker_mutex()). 2. main_dgb.cpp: declare a long-lived AutoRatchet (make_dgb_ratchet, base 35 / target 36, oracle 22761e7) ahead of work_source so it outlives the callback, and bind set_mint_share_fn to mint_local_share_locked. The ratchet is touched ONLY inside the closure under the tracker lock, so its state is serialized -- no extra mutex. In-memory for now (persistence follow-up; a restart re-bootstraps to VOTING, which never regresses a crossed share). Tests (share_test.cpp, +2): pin the lock discipline -- declines without blocking and leaves the tracker untouched when the lock is held; acquires and releases (RAII) when free. dgb_share_test 27/27; c2pool-dgb links. Fenced to src/impl/dgb/ + src/c2pool/main_dgb.cpp; no shared/bitcoin_family/ src/core/other-coin touch. No new test target -> no build.yml allowlist change. 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.
Phase B — pool/share run-loop standup (slice 1: consumer adapter)
Re-lands the #294
mint_local_share_with_ratchethelper, which was lost from master in the #292/#293/#294 stacked squash-merge: there is no #294 merge commit on origin/master (only #295/#297), andsrc/impl/dgb/run_loop_mint.hppis absent — though the primitives it composes (dgb_select_mint_versions,create_local_share) both survive.DGBWorkSource::set_mint_share_fnis consequently never bound (no caller in main_dgb), so the worker->mint ShareAccept branch is a no-op today.What this does
The consumer adapter
DGBWorkSource::MintShareFnbinds to (per work_source.hpp:197 contract). On a ShareAccept submission (Scrypt PoW meets SHARE target, not block target) it:SmallBlockHeaderType,AutoRatchetfor the {mint, vote} version pair viadgb_select_mint_versions(anchored at the sharechain tip = new shareʼs parent),create_local_share, returning the minted hash (NULL on malformed header — fail-closed).Authored against masterʼs
create_local_sharesignature (authoritative). Duck-typed on the inputs so the header doesnʼt pull the stratum work_source TU in. Pure adapter — tracker-insertion thread-safety is the caller (main_dgb bind) point concern, handled in the next slice.Scope / safety
src/impl/dgb/(new header + KAT only). No shared base / other coin tree touched.dgb_share_test(no new exe, no build.yml allowlist churn): header parse round-trip, short-buffer fail-closed, adapter fail-closed + create_local_share template drift-guard. 25/25 green locally.Surface-for-tap — HOLD merge for integrator (no self-merge).