add: BLAKE2b (v2) block header support - #167
Closed
kwsantiago wants to merge 1 commit into
Closed
Conversation
Owner
|
Thanks for the contribution, however, I'm not going to maintain BLAKE2b support in fork-observer and won't merge it here. My recommendation would be for you (or anyone else who wants to use it) to maintain this in a blake2b fork-observer fork. |
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.
Bitcoin Knots v29.4.1 hardforks the PoW at mainnet 961,640 and testnet4 150,308. fork-observer can't read those headers, so nodes on that chain sit frozen at the last shared block.
Breakages:
chunks(80)desyncs and the REST batch fails. Esplora and mempool.space hit the same viaconsensus::deserialize.Header::block_hash()is wrong for them.Adds a
blake2bmodule that parses both versions, hashes each correctly, and serializes back to exact wire bytes. Headers travel asParsedHeader(Headerplus v2 fields). It derefs toHeader, and its inherentblock_hash()shadows the SHA256d one, so existing call sites stay correct unchanged. Can swap that for an explicit accessor if you prefer: same behavior, bigger diff.Electrum, btcd and block-dn convert with
.into(). The Core RPC path fetches the raw header now, since the typed model is fixed at 80 bytes and would silently return the wrong hash.Scope: ingestion only.
headertree.rsstill ranks tips by cumulative work, so a BLAKE2b branch is tracked and drawn but never active. Ranking across two PoW functions is your call.Tested against a Knots v29.4.1 testnet4 node across height 150,308: 133 headers ingested, every hash confirmed against the node, restart reloads from SQLite still correct. Unit tests use real headers from both networks. Build, test and fmt pass with
--all-features.Every block so far has
flags & 3 == 0, so the other three hashing variants match the reference implementation but are unverified.