kernel: document process_block storage and two aborting preconditions #36632

pull fametrano wants to merge 2 commits into bitcoin:master from fametrano:kernel-doc-process-block-dos changing 1 files +11 −1
  1. fametrano commented at 9:59 PM on October 23, 2026: none

    btck_chainstate_manager_process_block stores blocks that bitcoind skips when it did not request them. It processes every block as if requested. A block is therefore stored even if it has less work than the tip, is more than 288 blocks ahead of it, is below the minimum chain work, or was pruned before. I document that a caller taking blocks from untrusted sources must apply these checks itself. I leave the header path undocumented, as discussed in #33822 (review). #34022, which proposed removing the flag, was closed. Blocks differ because force_processing changes what is stored.

    The second commit documents two preconditions that abort the process. btck_precomputed_transaction_data_create aborts when spent_outputs is set and its length differs from the input count. A nested btck_chainstate_manager_import_blocks call on the same chainstate manager also aborts. I checked both aborts with a small program against the library. The kernel library builds, and the whitespace and commit-message lints pass.

    This is one of several PRs from a large audit of Bitcoin Core that I did with the help of LLM tools. The audit produced its evidence all at once, which is why the PRs arrive together. I understand each change fully and will answer review questions myself.

  2. kernel: document that process_block stores unrequested blocks
    btck_chainstate_manager_process_block processes every block as
    requested. Validation therefore does not skip a block that has less
    work than the tip, is more than 288 blocks ahead of it, is below the
    minimum chain work, or was pruned before. bitcoind skips such blocks
    when it did not ask for them.
    
    The API does not say so. Document that a caller taking blocks from
    untrusted sources has to apply these checks itself.
    ed2c4a344a
  3. DrahtBot added the label Validation on Oct 23, 2026
  4. DrahtBot commented at 9:59 PM on October 23, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. kernel: document two aborting preconditions
    btck_precomputed_transaction_data_create aborts when spent_outputs is
    set and its length differs from the number of inputs. A nested
    btck_chainstate_manager_import_blocks call on the same chainstate
    manager also aborts. The header states neither.
    
    I add both to the header. I keep the asserts, since #35312 treats
    invalid arguments as programmer errors.
    dda2c1f325
  6. sedited commented at 10:21 AM on October 26, 2026: contributor

    The first commit seems already documented to me. The second one's importblocks behaviour seems ok to add.


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-10-27 17:51 UTC

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