Testnet 5 (BIP95)

bitcoin/bitcoin: PR #35861

1 minor finding · 4 suggestions

Earlier concerns neither republished nor resolved: 5 minor findings · 16 suggestions. See the Run archive for their assessments.

Findings

Link

[minor] · The future-leaf Taproot vector duplicates the preceding Tapscript spend

The future-leaf case in bip54_legacy_sigops repeats the 0xc0 witness, leaving 0xc2 untested and producing a mislabeled duplicate if JSON vectors are exported.

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

Details and suggested fix

The preceding successful SignSignature call leaves sigdata.complete set. Changing the keystore and assigning tr_spenddata does not reset it, so ProduceSignature returns immediately and UpdateInput writes back the preceding witness. VerifyTxin consequently verifies the same Tapscript spend, and CheckWithinBIP54Limits records it again. Clearing complete alone is insufficient because SignTaprootScript only supports TAPROOT_LEAF_TAPSCRIPT. Instead, construct scriptWitness.stack = {script, control} directly from the leaf_script_future and future_leaf_version entry in builder.GetSpendData().scripts. Assert (control[0] & TAPROOT_LEAF_MASK) == future_leaf_version before verification. The mandatory flags used here accept a correctly committed unknown leaf without executing its script. BIP54 ignores witness data, so the expected sigops result stays unchanged, but this supplies the advertised coverage and distinct exported vector. Whether the same correction is needed upstream remains unconfirmed because the original-source mapping is unavailable.


Optional improvements

Link

[suggestion] · Release notes omit BIP54 compatibility changes outside Testnet5

The release notes omit BIP54's regtest, getblocktemplate, and mempool compatibility changes; default mainnet mempool acceptance is unchanged.

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

Details and suggested fix

doc/release-notes-testnet5.md announces only the new network. Regtest now enables consensuscleanup by default, requiring coinbase nLockTime = height - 1 and non-final nSequence above height zero. On regtest and Testnet5, getblocktemplate also requires consensuscleanup in rules, so existing {"rules": ["segwit"]} requests, including the documented example, are insufficient. Mempool admission now enforces the sigops limit even with -acceptnonstdtxn=1. Its rejection changes from bad-txns-nonstandard-inputs to bad-txns-legacy-sigops, and exactly-64-byte witness-stripped transactions change from tx-size-small to txn-size-64.

Add a 32.x compatibility entry covering these changes, and update the GBT example and applicable error guidance. If documenting -vbparams=consensuscleanup:0:0 for legacy fixtures, do not describe it as a permanent off switch: the deployment enters STARTED and can still lock in when the signalling threshold is reached before the timeout check.


Link

[suggestion] · BIP54 sigops rejections lose witness-independent txid caching

Changing the BIP54 sigops failure from TX_INPUTS_NOT_STANDARD to TX_CONSENSUS can cause redundant parent downloads and retained orphans for witness transactions instead of immediately rejecting their children.

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

Details and suggested fix

With standardness enabled, the base reported this failure as TX_INPUTS_NOT_STANDARD, causing MempoolRejectedTx to cache both the wtxid and txid. The new result caches only the wtxid, although the BIP54 count still depends exclusively on non-witness data and the referenced outputs. A later child therefore misses the rejected-parent check, can enter the orphanage, and triggers a parent request by txid. The existing wtxid filter drops an identical redownload without revalidation; a different witness can still reach validation, and orphan/request limits bound the extra work. Preserve txid insertion specifically for bad-txns-legacy-sigops in MempoolRejectedTx, rather than extending it to all TX_CONSENSUS failures, whose validity may depend on the witness.


Link

[suggestion] · doc/bips.md omits the 32.x backport versions for BIP54 and BIP95

Both new doc/bips.md entries list only v33.0, omitting availability in the intended 32.x backport release, whose exact patch version still needs confirmation.

Location: doc/bips.md:35 (head).

Details and suggested fix

The BIP54 entry says the rules are implemented as of v33.0, and BIP95 says Testnet5 is supported as of v33.0. However, CMakeLists.txt identifies this target as 32.1.0 and doc/release-notes.md contains the v32.1 notes. Confirm the patch release that will ship these changes and record it in both entries, following the existing BIP65 backport wording. The current metadata does not establish that shipping version; v33.0 can remain as the upstream introduction.


Link

[suggestion] · BIP54 reorg reinsertion and descendant cleanup lack coverage

Although reinsertion currently looks correct, tests do not verify that disconnecting a valid pre-activation block rejects its over-limit transaction from the mempool and removes descendants under the now-unconditional BIP54 sigops policy.

Location: src/validation.cpp:894 (head).

Details and suggested fix

ConnectBlock gates the limit on activation, whereas PreChecks enforces it even for bypass_limits=true. feature_bip54.py already accepts an over-limit transaction in the last locked-in block, but never disconnects it. Extend the fixture with -checkmempool=1: confirm an over-limit parent, admit a child and an unrelated transaction, invalidate the parent's block, and assert that the parent and child are absent while the unrelated entry remains. Keep the parent's inputs confirmed and arrange that the BIP54 limit is the only reason reinsertion fails, so another policy rejection cannot mask a skipped check. This exercises both the rejection and MaybeUpdateMempoolForReorg's removeRecursive cleanup.


Backport verdict: Needs clarification

I could not establish that this backport matches the upstream originals. It also has target-branch problems that need fixing or justifying. The packet bundles 29 commits that look like two upstream PRs: the BIP 54 implementation (#35793, 22 commits) and Testnet 5 (#35861, 7 commits). None of the commits has a resolved upstream original, so I could not check fidelity, adaptations or omitted dependencies commit by commit. The head is the 32.x release branch (CMakeLists.txt: version 32.1.0, CLIENT_VERSION_IS_RELEASE true). The PR's stated goal is a patched v32 release, but some user-visible changes are not adapted or documented for a point release. Regtest now always enforces BIP 54. As a result, getblocktemplate rejects any client that does not list the 'consensuscleanup' rule, and blocks whose coinbase lacks the nLockTime/nSequence pattern are rejected. Mempool reject reasons change, the BIP 54 sigops limit can no longer be bypassed with -acceptnonstdtxn, and doc/bips.md says 'v33.0' on a 32.x branch. Nothing I read in the code shows a consensus defect for mainnet, testnet3/4 or signet, where the deployment is NEVER_ACTIVE.

Evidence:

Required fixes:

Limitations:

Coverage details

Earlier concerns

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