Review report

core: PR #35906

Design and approach

Document or enforce ContextualCheckBlock’s structural precondition (src/validation.h:420, head)

The public declaration lets callers pass a deserialized but structurally invalid block directly. When HEIGHTINCB is active, the BIP34 check indexes block.vtx[0]->vin[0] without first checking that either vector is nonempty, so an empty block can cause out-of-bounds access instead of a validation failure. Existing AcceptBlock callers avoid this by running CheckBlock first, but the new API does not state that prerequisite. Document that callers must first pass CheckBlock, or add guards if standalone validation of arbitrary blocks is intended.

Represent the required predecessor as non-null in the public API (src/validation.h:411, head)

ContextualCheckBlockHeader asserts that pindexPrev is non-null before using it, and its checks require a predecessor; current in-tree callers provide one. The new public declaration takes a pointer, allowing callers to pass nullptr and discover the precondition only through an assertion or undefined behavior. Taking const CBlockIndex& instead, and dereferencing the existing caller pointers, would encode the required predecessor in the API without changing behavior for valid callers.

💡 Suggestion

Test buried-deployment activation at the height boundary (src/test/validation_check_header_tests.cpp:197, head)

The rejection cases set prev.nHeight to DeploymentHeight(dep), testing the block after activation; the acceptance cases use height 100 rather than the immediately preceding height. A regression that activates only when prev.nHeight >= DeploymentHeight(dep) would still pass the rejection tests. Set the predecessor to deployment height minus one to test rejection on the first enforced block, and to deployment height minus two to test acceptance immediately before activation. This directly covers the boundary without changing the intended version checks.

Review coverage was incomplete. The adversarial review had incomplete evidence. The adversarial_glm review did not complete.