feat(core): expose Block::check_context_free#177
Draft
pzafonte wants to merge 1 commit into
Draft
Conversation
Wraps btck_block_check from bitcoin/bitcoin#33908 to validate a block's structure without chainstate or block index access. Proof-of-work and merkle-root checks are optional via the BLOCK_CHECK_BASE / _POW / _MERKLE / _ALL flags, exposed through a block_check_flags submodule mirroring verify_flags. Adds AsPtr<btck_ChainParameters> for ChainParams and re-exports the owned BlockValidationState so callers can construct one. Test mirrors upstream's btck_check_block_context_free case-by-case.
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.
Wraps btck_block_check from bitcoin/bitcoin#33908. The function performs context-free validation of a block (size, weight, coinbase, transactions, sigops), with optional proof-of-work and merkle-root checks toggled via the BLOCK_CHECK_BASE / _POW / _MERKLE / _ALL flags. Useful for early rejection of invalid blocks before any chainstate-dependent validation runs.
The Rust signature mirrors the C contract: validation_state is filled in-place and the function returns a bool. Adds an AsPtr<btck_ChainParameters> impl on ChainParams and re-exports the owned BlockValidationState type since callers now need to construct one. The flag constants follow the existing VERIFY_* pattern and are also exposed via a block_check_flags submodule mirroring verify_flags.
Test mirrors upstream's btck_check_block_context_free case-by-case (valid block, mutated merkle, bad PoW, tampered coinbase, truncated bytes), reusing a single state to verify the documented reset-on-entry behavior.
Draft until subtree is synced, but tested locally on updated subree.
Closes #155.