Skip to content

dgb: track absolute block height in HeaderChain (M3 §4c prerequisite) - #209

Merged
frstrtr merged 1 commit into
masterfrom
dgb/headerchain-block-height
Jun 19, 2026
Merged

dgb: track absolute block height in HeaderChain (M3 §4c prerequisite)#209
frstrtr merged 1 commit into
masterfrom
dgb/headerchain-block-height

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Stage 4c prerequisite — absolute block-height tracking in dgb::HeaderChain

Stage 4c (get_current_work_template / build_connection_coinbase consuming the #207 coinbasevalue SSOT) needs a next_h. The btc reference does next_h = tip.height + 1 off a height-tracking HeaderChain; DGB's HeaderChain was a retarget-sample ring with no height and no tip(). This lands that prerequisite, fenced to src/impl/dgb/.

What

  • tip_height()optional<uint32_t> (nullopt for empty chain)
  • next_block_height() → the template builder's next_h (base + size())
  • base_height() / set_base_height() → fast-start checkpoint seed (default 0 = genesis)

Height is a pure function of seed + appended-header count (index i = absolute height base+i) — no separate counter that can drift from m_chain.

DGB conformance wrinkle

DGB block height counts every block of every algo as one height. The Scrypt-only HeaderChain still appends non-Scrypt headers via accept-by-continuity, so height advances on both VALIDATED_SCRYPT and ACCEPTED_CONTINUITY ingests, and only those — a REJECTED header is checked before push_back and never advances height.

Tests

+4 tests into existing header_chain_test (no new gtest target — #143 trap avoided): empty-chain nullopt, every-algo-advances, rejected-never-advances, checkpoint-seed. 31/31 pass, build EXIT=0.

Scope / guardrails

HOLD merge — integrator merges on operator push approved.

Add tip_height()/next_block_height()/base_height()/set_base_height() to
dgb::HeaderChain. Block height is a pure function of base height + appended
header count: index i holds absolute height base+i, no separate counter that
could drift from m_chain.

DGB counts every block of every algo as one height, so height advances on
BOTH VALIDATED_SCRYPT and ACCEPTED_CONTINUITY ingests and only those -- a
REJECTED header is checked before push_back and never advances. set_base_height
seeds a fast-start checkpoint while the chain is empty (default 0 = genesis).

This is the next_h source the embedded TemplateBuilder port needs for the
BIP34 height push and the subsidy_func(height) lookup that feeds the embedded
coinbasevalue SSOT (#207); external-daemon GBT keeps its own authoritative
height field. Fenced to src/impl/dgb/. +4 tests into header_chain_test
(no new gtest target), 31/31 pass.
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