Review report

core: PR #35793

3 minor findings · 5 suggestions

Earlier concerns neither republished nor resolved: 1 minor finding · 3 suggestions. See the Run archive for their assessments.

Findings

Link

[minor] · Always-active BIP54 removes valid-block coverage from two fuzz targets

The unchanged utxo_total_supply and cmpctblock fuzz targets construct coinbases that violate the new regtest rules, silently preventing further chain growth and valid-block high-bandwidth peer selection.

Location: src/kernel/chainparams.cpp:639 (head).

Details and suggested fix

utxo_total_supply deliberately resets every prepared coinbase's nLockTime to zero so that it can duplicate a coinbase later. With BIP54 always active, its chain cannot advance past height 1: otherwise-valid subsequent candidates fail bad-cb-locktime, and the harness tolerates was_valid == false. This removes the intended duplicate-coinbase and deeper supply/CVE-2018-17144 coverage. Add -vbparams=consensuscleanup:0:0 to this target's setup so its short-chain BIP30 scenarios remain possible. Separately, cmpctblock mines 200 setup blocks, then constructs every new coinbase with zero locktime and the default final sequence. These blocks cannot reach the valid-block branch that selects high-bandwidth peers. Set their coinbase nLockTime to height - 1 and sequence to CTxIn::MAX_SEQUENCE_NONFINAL. Neither commitment helper repairs these fields. This coverage loss follows from the source, not a recorded fuzzer run.


Link

[minor] · The future-tapleaf test vector reuses the Tapscript witness

The test and generated vector labelled as a 0xc2 leaf spend repeat the previous Tapscript witness, leaving the intended future-leaf case untested.

Location: src/test/bip54_tests.cpp:1060 (head).

Details and suggested fix

The first successful SignSignature call sets sigdata.complete. Clearing the keystore and reassigning tr_spenddata does not reset it, so the second call returns immediately from ProduceSignature and UpdateInput copies the unchanged witness into tx_copy2. The subsequent assertions validate that reused spend without checking which leaf it selects. Resetting sigdata alone is insufficient because SignTaprootScript rejects non-Tapscript leaf versions. Construct this witness explicitly using leaf_script_future and its control block from builder.GetSpendData().scripts, then assert that the masked control-block leaf version is 0xc2 before recording the vector.


Link

[minor] · BIP54 sigops rejections lose txid caching

Changing witness-bearing parents' BIP54 sigops failures to TX_CONSENSUS removes txid rejection caching, allowing redundant parent requests and orphan retention within existing limits.

Location: src/consensus/tx_verify.cpp:205 (head).

Details and suggested fix

For a witness-bearing transaction spending real UTXOs and exceeding 2,500 BIP54 sigops, CheckTxInputs now returns TX_CONSENSUS instead of the old standardness path's TX_INPUTS_NOT_STANDARD. PreChecks enables this on every network. MempoolRejectedTx consequently caches only the wtxid and no longer cancels txid requests. Eligible later children can enter orphan resolution and request the rejected parent by txid, and txid announcements from non-wtxidrelay peers are no longer suppressed. Identical cached wtxids remain filtered. Preserve txid caching and request cancellation specifically for bad-txns-legacy-sigops, whose count cannot depend on the witness, and add a txdownload_tests case. Do not apply that treatment to every TX_CONSENSUS failure because script failures can depend on the witness. No in-tree producer of the triggering transaction was identified, so its frequency in practice remains unconfirmed.


Optional improvements

Link

[suggestion] · BIP54 compatibility changes lack a release note

Default regtest activation changes getblocktemplate requirements and old-chain compatibility, while mempool rejection behavior changes on every network; the release notes cover neither migration nor the legacy-regtest override.

Location: src/kernel/chainparams.cpp:639 (head).

Details and suggested fix

Add a doc/release-notes-<PR>.md fragment explaining that regtest getblocktemplate clients must list consensuscleanup and that old/custom coinbases must now set nLockTime = height - 1 and a non-final sequence. Previously indexed blocks violating these contextual rules can survive a normal restart or -reindex-chainstate, whereas full -reindex or fresh synchronization rejects them. Document resetting old regtest data or using the legacy compatibility override shown in wallet_migration.py, -vbparams=consensuscleanup:0:0. Also cover the network-wide mempool changes: BIP54 sigops failures report bad-txns-legacy-sigops rather than bad-txns-nonstandard-inputs, -acceptnonstdtxn no longer bypasses that check, and the 64-byte stripped-size rejection changes from tx-size-small to txn-size-64. State explicitly that this PR activates no other network.


Link

[suggestion] · Inactive-deployment mempool sigops enforcement is untested

This mempool test only runs with BIP54 active, so it cannot detect accidentally gating the sigops check on consensus activation.

Location: test/functional/mempool_sigoplimit.py:231 (head).

Details and suggested fix

PreChecks now supplies enforce_bip54=true outside the standardness guard, and ValidateInputsStandardness no longer performs the total BIP54 sigops check. That unconditional flag preserves mempool rejection on networks such as mainnet where the deployment remains inactive. This case uses default always-active regtest settings, while feature_bip54.py submits its pre-activation violations only inside blocks. Before std_tx spends the fixture inputs, add a restart with -vbparams=consensuscleanup:0:0 -acceptnonstdtxn=1 and assert that the same 2505-sigop transaction still fails with bad-txns-legacy-sigops. Restore the active settings for the remaining block-rejection assertion.


Link

[suggestion] · The activation test skips violations at the BIP54 boundary

The test mines the first active block with compliant contents before trying a violation, so validation that starts enforcing one block late would still pass.

Location: test/functional/feature_bip54.py:395 (head).

Details and suggested fix

reach_end_retarget_period leaves the tip at height 143 modulo 144. The 145 signaling and filler blocks then reach the first block of the locked-in period. generate_bulk(node, 144) mines the rest of that period and the first active block, all compliant, so the first rejected violation targets the second active block. The earlier acceptance checks also do not exercise the last locked-in height. Submit an otherwise-valid coinbase-locktime or 64-byte violation at the last locked-in height and assert acceptance, then assert rejection of the equivalent violation at the first active height.


Link

[suggestion] · The bip54_sigops fuzz target has no accounting oracle

The target discards CheckSigopsBIP54's result, so accounting regressions can pass unnoticed even though crash coverage remains useful.

Location: src/test/fuzz/bip54.cpp:53 (head).

Details and suggested fix

Every decoded input uses tx.vin.emplace_back(dummy_txid, i) with an index below 65536, so its prevout is never null and Assert(!tx.IsCoinBase()) cannot exercise a failure. The final call discards the acceptance result, leaving even an unconditional return value invisible to this target. Keep the seed format and add a full reference sum in a wide integer type: sum scriptSig.GetSigOpCount(true) + prev_spk.GetSigOpCount(scriptSig) over all inputs without early exit, then assert that the production result equals total <= MAX_TX_BIP54_SIGOPS. This tests the aggregation and limit logic, though it does not independently validate the shared counting helpers.


Link

[suggestion] · The 2501-sigop P2SH vector retains invalidated signatures

The generated over-limit vector also fails legacy script validation, so it does not isolate the new BIP54 sigops rule.

Location: src/test/bip54_tests.cpp:339 (head).

Details and suggested fix

The 25 P2SH inputs are signed with the default SIGHASH_ALL before the P2PK input is appended. That digest commits to every input's outpoint, so appending the input invalidates all 25 signatures. Only the new input is then signed and verified before CheckExceedsBIP54Limits records the vector. The sigop expectation remains correct, but consumers performing full script validation also encounter unrelated signature failures. After appending the P2PK input, rebuild the earlier P2SH scriptSigs with fresh signatures and verify those inputs, as the neighboring bare-script case does.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.