kernel: Return validation state directly from process_block_header #34505

pull stringintech wants to merge 1 commits into bitcoin:master from stringintech:2026/02/kernel-refactor-process-header changing 4 files +20 −17
  1. stringintech commented at 3:03 PM on February 4, 2026: contributor

    Simplifies btck_chainstate_manager_process_block_header by returning BlockValidationState* directly instead of an int + output parameter.
    Previous API returned both int and validation state, creating ambiguity where non-zero meant either "invalid header" or "processing failure". Since ProcessNewBlockHeaders already provides complete validation info, the int return was redundant.

    Changes:

    • btck_chainstate_manager_process_block_header returns btck_BlockValidationState*: null = unhandled processing failure, non-null = validation result
    • Updated C++ wrapper and tests
  2. kernel: Return validation state directly from process_block_header
    Remove redundant int return from btck_chainstate_manager_process_block_header.
    
    Previously returned both an int result and an output validation state parameter, creating ambiguity where non-zero could mean either invalid header or processing failure. Since ProcessNewBlockHeaders already provides complete validation info, the int return was redundant.
    
    Now returns BlockValidationState pointer directly:
    - null indicates processing failure (exception)
    - non-null contains validation result (valid or invalid)
    
    Co-authored-by: stickies-v <stickies-v@protonmail.com>
    b6d51ffa99
  3. DrahtBot added the label Validation on Feb 4, 2026
  4. DrahtBot commented at 3:03 PM on February 4, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. in src/kernel/bitcoinkernel.cpp:1309 in b6d51ffa99
    1310 | -        auto result = chainman->ProcessNewBlockHeaders({&btck_BlockHeader::get(header), 1}, /*min_pow_checked=*/true, btck_BlockValidationState::get(state), /*ppindex=*/nullptr);
    1311 | -
    1312 | -        return result ? 0 : -1;
    1313 | +        auto state{std::make_unique<BlockValidationState>()};
    1314 | +        auto header_accepted = chainman->ProcessNewBlockHeaders({&btck_BlockHeader::get(header), 1}, /*min_pow_checked=*/true, *state, /*ppindex=*/nullptr);
    1315 | +        assert(header_accepted == state->IsValid());
    


    stringintech commented at 3:06 PM on February 4, 2026:

    Added assertion here is to verify consistency and can be removed once #33856 is merged.

  6. yuvicc commented at 7:57 PM on February 4, 2026: contributor

    I have adressed these changes in #33856. Also, added @stringintech & @stickies-v as co-authors there!

  7. stringintech closed this on Feb 5, 2026


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-30 21:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me