AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 19 Bitcoin

Merge bitcoin/bitcoin#36451: refactor: Use NotNull for CreateNewBlock and pimpls

Public commit record

What the developer wrote

Authored by Ryan Ofsky

91/100 · Strong
Merge bitcoin/bitcoin#36451: refactor: Use NotNull for CreateNewBlock and pimpls

fa9158641839e6dbc3cab63b07929998247b1f97 refactor: Return NotNull from CreateNewBlock (MarcoFalke)
fa071a2c451d2cab12e181711b2dd64d61f3ea18 refactor: Mark pimpls as NotNull (MarcoFalke)
fa4785828e804f44726102070fb1adeacbdce6e5 util: refactor: Add and use MakeNotNullShared and MakeNotNullUnique (MarcoFalke)
faf85b0321797a811260a90f6b9a839a9ad9e3c2 test: Add some NotNull test cases (MarcoFalke)

Pull request description:

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)

ACKs for top commit:
l0rinc:
reACK fa9158641839e6dbc3cab63b07929998247b1f97
ViniciusCestarii:
reACK fa9158641839e6dbc3cab63b07929998247b1f97
enochaz:
ACK fa9158641839
ryanofsky:
Code review ACK fa9158641839e6dbc3cab63b07929998247b1f97. Nice cleanup: makes it obvious that `CreateNewBlock` can't fail and that these pimpls are always set, and removes the dead error paths that went with them.

Tree-SHA512: 7bcf67bf9f41d146e6f5db0782fb42e5ce93970ea914004f9f30d47d64f2e182a93a064c16bf1d56cc6962fdb95409bbe03eea015f6738710fdbbee8212c212f
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This is a code cleanup change that makes the type system express 'this pointer can never be null' for several internal objects and for block templates. It removes redundant null checks and adds helper functions to create such non-null pointers. There is no security vulnerability being fixed here, and no behavior change to the running program.

Recommended action

No security action required. Treat as normal code-quality refactor during review/merge.

Security signals we found

01

No security-relevant bug is patched

02

Change is purely a type-system refactor

03

Removes dead null-check error paths rather than adding safety checks

04

No input validation, cryptography, consensus, or networking logic is modified

Risk score

Why this scored 19/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 5/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.