Skip to content

dgb: emit GBT scaffold fields (version/curtime/mintime/transactions) in work template (Stage 4c) - #212

Merged
frstrtr merged 2 commits into
masterfrom
dgb/stage-4c-gbt-scaffold-fields
Jun 19, 2026
Merged

dgb: emit GBT scaffold fields (version/curtime/mintime/transactions) in work template (Stage 4c)#212
frstrtr merged 2 commits into
masterfrom
dgb/stage-4c-gbt-scaffold-fields

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Stage 4c — GBT scaffold fields in get_current_work_template()

Builds on #211 (e2714b9, height+coinbasevalue wire). Surfaces the GBT-shaped fields the embedded path can derive truthfully from current chain state, ahead of a full dgb::coin::TemplateBuilder port (M3 TODO):

field source notes
version BIP9 base 0x20000000 | DGB_BLOCK_VERSION_SCRYPT (0x0000) pins the Scrypt algo lane; coin/dgb_block_algo.hpp SSOT
curtime wall-clock GBT suggested header nTime
mintime median_time_past()+1 (#209) DGB Core nTime > MTP lower bound; empty chain → 0
transactions [] embedded mempool tx selection unwired; no fabricated entries, fees stay 0

Deliberately NOT emitted yet (need accessors the Scrypt-only HeaderSample doesn't carry; following slices): previousblockhash (tip block hash not stored), bits (next-target compact off the DigiShield window). The per-connection coinbase (gentx + ShareTracker ref_hash + PPLNS payout map) lands in build_connection_coinbase() — that output is consensus-bearing and surfaces for an operator tap, not this field wire.

Scope

Test

dgb_work_source_test 15/15+WorkTemplateEmitsGbtScaffoldFields pins version==0x20000000, mintime==0 (empty chain), curtime>=0, transactions[] present-but-empty, and asserts previousblockhash/bits remain absent.

HOLD merge — integrator verifies the full CI rollup on the head SHA before landing.

frstrtr added 2 commits June 19, 2026 14:17
…Stage 4c)

get_current_work_template() now emits the next-block height and its
coinbasevalue instead of an empty object. The coinbasevalue is derived
through the #207 embedded SSOT (coinbase_value -> resolve_coinbase_value
-> subsidy_func) keyed on next_block_height() (#209, == tip.height + 1;
== base_height for an empty chain). Embedded path: no external-daemon GBT
value is plumbed in yet and mempool-fee aggregation is unwired, so
total_fees = 0; a present GBT coinbasevalue stays authoritative and fees
add on top of subsidy in later slices without changing this SSOT call.

The remaining GBT template fields (previousblockhash, bits, version,
curtime, mintime, transactions[]) and the build_connection_coinbase gentx
assembly land in following Stage 4c/4d slices.

Test: +WorkTemplateEmitsHeightAndCoinbaseValueViaSsot pins height +
coinbasevalue to the p2pool-dgb-scrypt oracle subsidy at the phase3 era
boundary; existing stub-default assertion relaxed. dgb_work_source_test
14/14.
…in work template (Stage 4c)

get_current_work_template() now surfaces the GBT-shaped fields the embedded
path can derive TRUTHFULLY from current chain state, ahead of a full
dgb::coin::TemplateBuilder port (M3 TODO), alongside the existing height +
coinbasevalue:

  version      BIP9 base | DGB Scrypt algo nibble. A DGB template MUST pin the
               Scrypt lane: the mining algo lives in 4 nVersion bits
               (coin/dgb_block_algo.hpp SSOT) and Scrypt is the all-zero
               codepoint (DGB_BLOCK_VERSION_SCRYPT == 0x0000). Any other nibble
               is a non-Scrypt algo that is accept-by-continuity / V37, never a
               template this V36 binary emits.
  curtime      current wall-clock; GBT's suggested header nTime.
  mintime      median_time_past()+1 (#209 accessor) = DGB Core
               ContextualCheckBlockHeader lower bound (nTime > MTP). Empty chain
               returns INT64_MIN (unconstrained) -> emitted as 0.
  transactions empty array: embedded mempool tx SELECTION is unwired, so no
               transactions are fabricated and fees stay 0 (consistent with the
               total_fees=0 coinbasevalue).

Deliberately NOT emitted yet (need accessors the Scrypt-only HeaderSample does
not carry; following Stage 4c/4d slices):
  previousblockhash  tip block hash (HeaderSample stores no hash yet)
  bits               next-block compact target off the DigiShield retarget window
and the per-connection coinbase (gentx + ShareTracker ref_hash + PPLNS payout
map) assembles in build_connection_coinbase() -- consensus-bearing output that
surfaces for an operator tap, not in this field wire.

Test: +WorkTemplateEmitsGbtScaffoldFields pins version == 0x20000000, mintime
== 0 on an empty chain, curtime >= 0, transactions[] present-but-empty, and
asserts previousblockhash/bits remain absent. dgb_work_source_test 15/15.

Fenced to src/impl/dgb (2 files); no new gtest target, build.yml untouched.
@frstrtr
frstrtr merged commit 1e257a5 into master Jun 19, 2026
18 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