dgb: track absolute block height in HeaderChain (M3 §4c prerequisite) - #209
Merged
Conversation
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.
This was referenced Jun 19, 2026
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.
Stage 4c prerequisite — absolute block-height tracking in
dgb::HeaderChainStage 4c (
get_current_work_template/build_connection_coinbaseconsuming the #207 coinbasevalue SSOT) needs anext_h. The btc reference doesnext_h = tip.height + 1off a height-trackingHeaderChain; DGB'sHeaderChainwas a retarget-sample ring with no height and notip(). This lands that prerequisite, fenced tosrc/impl/dgb/.What
tip_height()→optional<uint32_t>(nullopt for empty chain)next_block_height()→ the template builder'snext_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 heightbase+i) — no separate counter that can drift fromm_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_SCRYPTandACCEPTED_CONTINUITYingests, and only those — aREJECTEDheader is checked beforepush_backand 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
src/impl/dgb/coin/header_chain.hpp+ its test. No shared base / bitcoin_family / build.yml touch.2a54ce90).HOLD merge — integrator merges on operator
push approved.