Skip to content

dgb: stand up worker->mint share-accept seam on DGBWorkSource (Phase B) [HOLD/surface-for-tap] - #295

Merged
frstrtr merged 1 commit into
masterfrom
dgb/worksource-mint-share-seam
Jun 21, 2026
Merged

dgb: stand up worker->mint share-accept seam on DGBWorkSource (Phase B) [HOLD/surface-for-tap]#295
frstrtr merged 1 commit into
masterfrom
dgb/worksource-mint-share-seam

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Phase B pool/share, worker->mint run-loop standup — producer half.

What

mining_submit (work_source.cpp:292) classifies a Scrypt submission three ways. The won-block outcome already dispatches via SubmitBlockFn; the share-difficulty outcome — "pow_hash <= share target -> record share in tracker" — had no seam. This stands that seam up, parallel to SubmitBlockFn:

  • MintShareInputs — raw-bytes found-share fields (header, coinbase, subsidy, prev_share/tip, merkle_branches, payout_script, segwit), decoupled from share/BlockType serialization exactly like SubmitBlockFn.
  • MintShareFn + set_mint_share_fn() — the callback main_dgb.cpp binds to mint_local_share_with_ratchet (run_loop_mint.hpp, the dgb: bind AutoRatchet {mint,vote} selector to the share-mint path (Phase B) #294 helper) -> create_local_share, where the AutoRatchet chooses the {mint,vote} version pair. Mirrors the existing set_best_share_hash_fn idiom (empty until wired).
  • try_mint_share() — thread-safe dispatch (copies fn under lock); unbound -> logs loudly + returns NULL hash, no silent drop.

Why this is the next pillar

Only the won-block path existed. This is the producer half of the worker->mint standup; the consumer half (binding it to the ratchet helper + create_local_share) lands in main_dgb once the #294 helper is on master, and the live invocation point lands with stage 4d (real Scrypt classify in mining_submit).

Safety / scope

Tests

dgb_work_source_test 20/20 (17 prior + 3 new: forward+pass-through, empty-until-wired no-silent-drop, stub-does-not-reach). Test file already in the build.yml allowlist (no NOT_BUILT risk).

mining_submit (work_source.cpp:292) classifies a Scrypt submission three
ways; the won-block outcome already dispatches via SubmitBlockFn, but the
share-difficulty outcome -- "pow_hash <= share target -> record share in
tracker" -- had no seam. This adds the producer half of the worker->mint
run-loop standup, parallel to SubmitBlockFn:

  - MintShareInputs: raw-bytes found-share fields (header, coinbase,
    subsidy, prev_share/tip, merkle_branches, payout_script, segwit),
    decoupled from share/BlockType serialization like SubmitBlockFn.
  - MintShareFn + set_mint_share_fn(): the callback main_dgb.cpp binds to
    mint_local_share_with_ratchet (run_loop_mint.hpp) -> create_local_share,
    where the AutoRatchet chooses the {mint,vote} version pair. Mirrors the
    set_best_share_hash_fn idiom (empty until wired).
  - try_mint_share(): thread-safe dispatch (copies fn under lock); when
    unbound, logs loudly and returns a NULL hash -- no silent drop.

No behavior change: the 4a mining_submit stub still rejects every
submission and never reaches the seam (the classify branch lands in 4d).
+3 KATs (forward+pass-through, empty-until-wired no-silent-drop, stub
does-not-reach), dgb_work_source_test 20/20.
@frstrtr
frstrtr merged commit e967f9a into master Jun 21, 2026
29 checks passed
frstrtr added a commit that referenced this pull request Jun 21, 2026
…ssify->dispatch) [#82 leg-2 / Stage 4d]

Replace the Stage-4a mining_submit stub with the live hot path. Reconstruct
the 80-byte DGB block header from the JobSnapshot + miner inputs (coinbase =
coinb1||en1||en2||coinb2; merkle ascent from the coinbase txid; header =
version|prev|merkle|ntime|nbits|nonce, all little-endian / prevhash reversed
to internal order), run the DGB-Scrypt PoW digest through the #286 scrypt_pow
SSOT, expand both compact targets via compact_to_target, and classify via the
Stage-4d submit_classify SSOT (tighten-first):

  WonBlock    -> serialize the full block (BIP144 coinbase witness when segwit
                 active) and hand it to the dual-path broadcaster submit_block_fn
                 (P2P relay + submitblock RPC fallback, #82); scream-never-drop
                 on a won block that reaches no sink.
  ShareAccept -> forward the found-share fields to try_mint_share (the #295
                 producer seam -> #294 mint bind); degrades to accepted-without-
                 credit when no mint fn is wired (no silent drop).
  Reject      -> stratum low-difficulty error.

work_source.cpp / work_source_test.cpp only; per-coin isolation held. The
header layout is byte-for-byte Bitcoin (only the PoW digest differs, Scrypt);
no share format, coinbase commitment, or PPLNS math touched -> p2pool-merged-v36
surface NONE. +3 KATs pin the three-way ladder dispatch by job targets (23/23).
frstrtr added a commit that referenced this pull request Jun 21, 2026
…ssify->dispatch) [#82 leg-2 / Stage 4d] (#297)

Replace the Stage-4a mining_submit stub with the live hot path. Reconstruct
the 80-byte DGB block header from the JobSnapshot + miner inputs (coinbase =
coinb1||en1||en2||coinb2; merkle ascent from the coinbase txid; header =
version|prev|merkle|ntime|nbits|nonce, all little-endian / prevhash reversed
to internal order), run the DGB-Scrypt PoW digest through the #286 scrypt_pow
SSOT, expand both compact targets via compact_to_target, and classify via the
Stage-4d submit_classify SSOT (tighten-first):

  WonBlock    -> serialize the full block (BIP144 coinbase witness when segwit
                 active) and hand it to the dual-path broadcaster submit_block_fn
                 (P2P relay + submitblock RPC fallback, #82); scream-never-drop
                 on a won block that reaches no sink.
  ShareAccept -> forward the found-share fields to try_mint_share (the #295
                 producer seam -> #294 mint bind); degrades to accepted-without-
                 credit when no mint fn is wired (no silent drop).
  Reject      -> stratum low-difficulty error.

work_source.cpp / work_source_test.cpp only; per-coin isolation held. The
header layout is byte-for-byte Bitcoin (only the PoW digest differs, Scrypt);
no share format, coinbase commitment, or PPLNS math touched -> p2pool-merged-v36
surface NONE. +3 KATs pin the three-way ladder dispatch by job targets (23/23).

Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
frstrtr added a commit that referenced this pull request Jun 23, 2026
…B) (#295)

mining_submit (work_source.cpp:292) classifies a Scrypt submission three
ways; the won-block outcome already dispatches via SubmitBlockFn, but the
share-difficulty outcome -- "pow_hash <= share target -> record share in
tracker" -- had no seam. This adds the producer half of the worker->mint
run-loop standup, parallel to SubmitBlockFn:

  - MintShareInputs: raw-bytes found-share fields (header, coinbase,
    subsidy, prev_share/tip, merkle_branches, payout_script, segwit),
    decoupled from share/BlockType serialization like SubmitBlockFn.
  - MintShareFn + set_mint_share_fn(): the callback main_dgb.cpp binds to
    mint_local_share_with_ratchet (run_loop_mint.hpp) -> create_local_share,
    where the AutoRatchet chooses the {mint,vote} version pair. Mirrors the
    set_best_share_hash_fn idiom (empty until wired).
  - try_mint_share(): thread-safe dispatch (copies fn under lock); when
    unbound, logs loudly and returns a NULL hash -- no silent drop.

No behavior change: the 4a mining_submit stub still rejects every
submission and never reaches the seam (the classify branch lands in 4d).
+3 KATs (forward+pass-through, empty-until-wired no-silent-drop, stub
does-not-reach), dgb_work_source_test 20/20.

Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
frstrtr added a commit that referenced this pull request Jun 23, 2026
…ssify->dispatch) [#82 leg-2 / Stage 4d] (#297)

Replace the Stage-4a mining_submit stub with the live hot path. Reconstruct
the 80-byte DGB block header from the JobSnapshot + miner inputs (coinbase =
coinb1||en1||en2||coinb2; merkle ascent from the coinbase txid; header =
version|prev|merkle|ntime|nbits|nonce, all little-endian / prevhash reversed
to internal order), run the DGB-Scrypt PoW digest through the #286 scrypt_pow
SSOT, expand both compact targets via compact_to_target, and classify via the
Stage-4d submit_classify SSOT (tighten-first):

  WonBlock    -> serialize the full block (BIP144 coinbase witness when segwit
                 active) and hand it to the dual-path broadcaster submit_block_fn
                 (P2P relay + submitblock RPC fallback, #82); scream-never-drop
                 on a won block that reaches no sink.
  ShareAccept -> forward the found-share fields to try_mint_share (the #295
                 producer seam -> #294 mint bind); degrades to accepted-without-
                 credit when no mint fn is wired (no silent drop).
  Reject      -> stratum low-difficulty error.

work_source.cpp / work_source_test.cpp only; per-coin isolation held. The
header layout is byte-for-byte Bitcoin (only the PoW digest differs, Scrypt);
no share format, coinbase commitment, or PPLNS math touched -> p2pool-merged-v36
surface NONE. +3 KATs pin the three-way ladder dispatch by job targets (23/23).

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