Skip to content

dgb: parity KAT for GBT prevhash formatter u256_be_display_hex - #478

Merged
frstrtr merged 1 commit into
masterfrom
dgb/hash-format-parity-kat
Jun 25, 2026
Merged

dgb: parity KAT for GBT prevhash formatter u256_be_display_hex#478
frstrtr merged 1 commit into
masterfrom
dgb/hash-format-parity-kat

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

Fenced, additive parity KAT for the GBT block-hash display formatter
dgb::coin::u256_be_display_hex (src/impl/dgb/coin/hash_format.hpp) — the
most-significant-limb-first 64-hex render of the little-endian u256 that both
the stratum work source and the embedded work path emit for the GBT
previousblockhash. The formatter had no test; a 1-nibble limb/byte-ordering
divergence there would emit a prevhash the parent daemon never accepts.

Non-circular anchor

The DGB mainnet genesis hash
7497ea1b465eb39f1c8f507bc877078fe016d6fcb6dfad3a64c98dcc6e1e8496 is the
external constant pinned by the DGB oracle at frstrtr/p2pool-dgb-scrypt
bitcoin/networks/digibyte.py:55. The test parses that literal display hex with
an independent reader, reverses to little-endian storage bytes, feeds
u256::from_le_bytes (the path a parsed tip hash takes), and asserts the
formatter reproduces the canonical string byte for byte. Additional cases pin
zero/one left-padding, most-significant-limb-first ordering, all-ones, and the
from_le_bytes byte reversal. 6/6 green locally.

Scope / safety

Off master; does not touch the #475#477 base chain.

Pin coin/hash_format.hpp u256_be_display_hex (the most-significant-limb-first
64-hex render of the LE u256 that both the stratum work source and the embedded
work path emit for the GBT "previousblockhash") against a non-circular oracle
anchor: the DGB mainnet genesis hash pinned at p2pool-dgb-scrypt
bitcoin/networks/digibyte.py:55. The test reverses that external display
constant into little-endian storage bytes, feeds u256::from_le_bytes (the path
a parsed tip hash takes), and asserts the formatter reproduces the canonical
display string byte for byte. Additional cases pin zero/one left-padding,
most-significant-limb-first limb ordering, all-ones, and the from_le_bytes
byte reversal.

Diagnostics / wire-display only: no consensus surface, no payout/subsidy/
version-gate value change. Header-only test (links only GTest); no production
call site rewired. Fenced to src/impl/dgb/. Added to both build.yml --target
allowlists (#143 NOT_BUILT trap).
@frstrtr
frstrtr merged commit 5ef41ff into master Jun 25, 2026
32 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