Repository navigation
blockchain: refuse a v2 header committing to a height below the BLAKE2b activation - #2
Merged
Merged
Conversation
…KE2b activation, as Knots does in CheckBlockHeader CheckHeaderV2Sanity is the context-free part of Knots' CheckBlockHeader for BLAKE2b headers: a v2 header must commit to a height where BLAKE2b proof of work is required (bad-version-sha256d), and a network without BLAKE2b configured takes no v2 header. It needs only the header, so it runs where the real height is not known yet (an orphan block), next to checkBlockSanity in ProcessBlock and CheckConnectBlockTemplate, and in verifychain; checkHeaderV2Context still checks the committed height against the real one. Exported for light clients (neutrino's context-free header check). Tests: a header committing to the activation height and one to the block below it, and a network without BLAKE2b.
Owner
|
Thanks, merged. It matches Knots' Two nits if you send the neutrino follow-up: no test covers the call sites (removing the call in |
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.
Follow-up to #1, as you suggested: refuse a v2 header that commits to a height below the BLAKE2b activation, as Knots does in
CheckBlockHeader(bad-version-sha256d).CheckHeaderV2Sanity(header, params)is the context-free part of Knots'CheckBlockHeaderfor v2 headers: the committed height must be a BLAKE2b height, and a network without BLAKE2b configured takes no v2 header (ErrUnsupportedProofOfWork, as incheckHeaderV2Context). It needs only the header, so it covers the case where the real height isn't known yet (an orphan block);checkHeaderV2Contextstill checks the committed height against the real one once it is.checkBlockSanityinProcessBlockandCheckConnectBlockTemplate, and inverifychain.CheckBlockHeaderSanitykeeps its signature (neutrino calls it withpowLimitonly); the new function is exported so neutrino's context-free check can call it too, which I can send once this is tagged.TestCheckHeaderV2Sanity: the real activation header (961640) is accepted, the same header committing to 961639 is refused withErrBadHeaderV2, a classic header passes, and a network without BLAKE2b refuses the v2 one.go test ./...passes exceptTestHelp(getblock/getblockheaderverbose results have no help formm_rhs), which fails the same onblake2bwithout this change.