refactor: Use NotNull for CreateNewBlock and pimpls #36451

pull maflcko wants to merge 3 commits into bitcoin:master from maflcko:2610-more-not-null-refactor changing 20 files +43 −34
  1. maflcko commented at 11:35 AM on October 7, 2026: member

    Current code uses nullable smart pointers for some stuff that is never null. This is perfectly fine, but a bit confusing:

    • When reading the code, it is not clear which pointer is nullable or never null.
    • Pointers that are never null still have confusing null checks (with possible error handling return branches), which are always dead in coverage reports or when applying mutation testing.
    • While some places have the redundant null checks on pointers that are never null, other places do not, which adds to the confusion.

    Clarify this at compile-time by using NotNull (or a plain reference)

  2. test: Add some NotNull test cases
    Suggested in https://github.com/bitcoin/bitcoin/pull/34844#pullrequestreview-5427569147
    fa5b5027fb
  3. refactor: Mark pimpls as NotNull
    Suggested in https://github.com/bitcoin/bitcoin/pull/34844#pullrequestreview-5268474301
    
    Mostly to see at compile time which m_impl is nullable. E.g.:
    src/ipc/libmultiprocess/include/mp/proxy-io.h:  m_impl.reset();
    fa7a0e7744
  4. refactor: Return NotNull from CreateNewBlock
    A nullptr is never returned, so the existing code is confusing, because
    it either has redundant and dead checks for a nullptr, or the existing
    code is "missing" them.
    
    Fix both issues by marking the type as NotNull at compile-time.
    fa0e2f600b
  5. DrahtBot renamed this:
    refactor: Use NotNull for CreateNewBlock and pimpls
    refactor: Use NotNull for CreateNewBlock and pimpls
    on Oct 7, 2026
  6. DrahtBot added the label Refactoring on Oct 7, 2026
  7. DrahtBot commented at 11:35 AM on October 7, 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.

    Type Reviewers
    Concept ACK sedited, stickies-v

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #36357 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36357.svg"></sub> (mining: move BlockAssembler statics into BlockTemplateManager by w0xlt)
    • #36356 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36356.svg"></sub> (mining: move getblocktemplate cache into BlockTemplateManager by w0xlt)
    • #35671 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35671.svg"></sub> (mining: add TxCollection to bandwidth-efficiently validate external block templates by Sjors)
    • #33922 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/33922.svg"></sub> (mining: add getMemoryLoad() and track template non-mempool memory footprint by Sjors)
    • #33117 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/33117.svg"></sub> (Interfaces: Expose UTXO Snapshot Loading and Add Progress Notifications by D33r-Gee)
    • #32468 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/32468.svg"></sub> (rpc: generateblock to allow multiple outputs by polespinasa)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  8. sedited commented at 11:54 AM on October 7, 2026: contributor

    Concept ACK

  9. maflcko marked this as a draft on Oct 7, 2026
  10. maflcko commented at 12:06 PM on October 7, 2026: member

    The Windows MSVC bugs are a bit tiring. Can someone remove it? Ref: https://github.com/bitcoin/bitcoin/issues/36153

  11. DrahtBot added the label CI failed on Oct 7, 2026
  12. stickies-v commented at 1:22 PM on October 7, 2026: contributor

    Concept ACK

  13. hebasto commented at 7:55 AM on October 14, 2026: member

    The Windows MSVC bugs are a bit tiring.

    Here is an MRE: https://godbolt.org/z/Kadaq5h46.

    However, https://en.cppreference.com/cpp/compiler_support/20 lists P1825R0 as implemented in MSVC since v19.24 VS 2019 16.4.


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-14 18:51 UTC

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