Skip to content

dgb: wire get_current_gbt_prevhash() through tip_hash() SSOT (Stage 4b) - #217

Merged
frstrtr merged 2 commits into
masterfrom
dgb/stage-4b-prevhash-getter
Jun 19, 2026
Merged

dgb: wire get_current_gbt_prevhash() through tip_hash() SSOT (Stage 4b)#217
frstrtr merged 2 commits into
masterfrom
dgb/stage-4b-prevhash-getter

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Stacked on #216. The Stage-4b prevhash getter still returned an empty string while get_current_work_template() emits previousblockhash from chain_.tip_hash() (#216). This routes the getter through the SAME tip_hash() accessor + u256_be_display_hex formatter so the dedicated getter and the assembled template can never silently diverge — one truthful source.

  • Empty string when tip_hash() == nullopt (empty chain / block_hash==0 sentinel from the not-yet-wired embedded P2P header ingest) — truthful absence, never a fabricated id.
  • Non-consensus read-only getter, fenced to src/impl/dgb (no shared-base touch).
  • +1 test (GbtPrevhashGetterMatchesTemplateField) asserting getter == template field on a seeded tip and joint-absence with no tip. dgb_work_source_test 17/17 PASS, build EXIT=0.

Test target already in both ctest + build.yml allowlists (no #143 trap). HOLD merge — stack base #216 is itself held behind #211 operator tap.

frstrtr added 2 commits June 19, 2026 16:46
…rk template (Stage 4c)

HeaderSample gains a sha256d block-id slot (block_hash, u256; 0 == not
populated here, the same sentinel pow_hash uses) and HeaderChain gains a
tip_hash() accessor returning the newest header's id or nullopt when the
chain is empty / the tip carries no hash. get_current_work_template emits
previousblockhash as GBT-conventional big-endian display hex ONLY when
tip_hash() is present -- a truthful conditional, never a fabricated hash.
The embedded P2P header-download -> validate_and_append ingest that
populates block_hash lands in a following slice; until then tip_hash() is
nullopt and previousblockhash is held back exactly as before.

bits stays HELD BACK: the only embedded next-target source is the
DigiShield damped multiply, which DGB Core runs as MultiShield V4 (a
global window across all 5 algos == V37); a Scrypt-only walk cannot
reconstruct it, so the ingest path demotes that gate to a no-op. Emitting
a digishield-derived bits would be a known-wrong value. The authoritative
bits is the external-daemon GBT value, not plumbed into this embedded
path yet -- surfaced as [decision-needed].

Fenced to src/impl/dgb (4 files); test cases added to existing targets
header_chain_test (31 -> 35) and dgb_work_source_test (15 -> 16), no new
gtest target so the build.yml allowlist is unchanged. Both green.
The Stage-4b prevhash getter still returned {} while get_current_work_template
emits previousblockhash from chain_.tip_hash() (#216). Route the getter through
the SAME tip_hash() accessor and u256_be_display_hex formatter so the dedicated
getter and the assembled template cannot silently diverge: one truthful source.
Empty string when tip_hash() == nullopt (empty chain / unpopulated block_hash
sentinel) -- a truthful absence, never a fabricated id. Non-consensus read-only
getter, fenced to src/impl/dgb. +1 test asserting getter == template field on a
seeded tip and joint-absence with no tip; dgb_work_source_test 17/17.
@frstrtr
frstrtr force-pushed the dgb/stage-4b-prevhash-getter branch from a36257d to aad2050 Compare June 19, 2026 16:47
@frstrtr
frstrtr merged commit aad2050 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