Testnet 5 (BIP95)

bitcoin/bitcoin: PR #35861

1 minor finding · 10 suggestions

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

Findings

Link

[minor] · Future-leaf Taproot test repeats the Tapscript spend

In the BIP54 dependency tests, reusing completed signature data leaves the future-leaf case spending the original Tapscript leaf, losing the intended coverage and recording the same transaction under a different label.

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

Details and suggested fix

The first successful SignSignature sets sigdata.complete = true. Changing the keystore and reassigning tr_spenddata do not clear that flag, so the second call returns immediately from ProduceSignature and writes the unchanged witness back. VerifyTxin therefore verifies the previous spend again. Clearing complete alone is insufficient because SignTaprootScript only supports leaf version 0xc0. Build the future-leaf witness directly from builder.GetSpendData(), using leaf_script_future and its control block. Assert that (control[0] & TAPROOT_LEAF_MASK) == 0xc2, then verify it with the existing consensus-flag helper before recording the case.


Optional improvements

Link

[suggestion] · Release note omits mandatory Testnet5 mining-client changes

Once Testnet5 launches, GBT miners must advertise consensuscleanup and construct height-timelocked coinbases, but the release note does not explain either requirement.

Location: doc/release-notes-testnet5.md:7 (head).

Details and suggested fix

Document that getblocktemplate requests must include "consensuscleanup" alongside "segwit" in rules. Its always-active, non-optional deployment makes requests omitting it fail with RPC_INVALID_PARAMETER. GBT supplies coinbasevalue, so external coinbase builders must also set nLockTime = height - 1 and use a non-final input nSequence; otherwise blocks fail with bad-cb-locktime or bad-cb-sequence. Locktime zero satisfies the height requirement only at height 1. These concrete client obligations deserve an explicit mining note rather than only the statement that BIP54 is enforced.


Link

[suggestion] · Handwritten signer and network documentation omits Testnet5

Testnet5 adds a signer chain name, datadir, configuration section and RPC port, but the handwritten signer specification and user-facing network lists still omit them.

Location: src/external_signer.h:32 (head).

Details and suggested fix

Add testnet5 to the --chain values in doc/external-signer.md: the wallet passes Params().GetChainTypeString() unchanged, so external signers receive --chain testnet5, which the published list does not describe. Also document testnet5/ in doc/files.md, [testnet5] in doc/bitcoin-conf.md, and port 18352 in doc/REST-interface.md. Add the section to the literal footer in contrib/devtools/gen-bitcoin-conf.sh; regeneration alone cannot create it. The updated help text already exposes the ports. A particular signer's rejection of the new chain name has not been established.


Link

[suggestion] · Testnet5's BIP95 definition is split across introduction and activation

Although head activates BIP54 correctly, the introduction omits a required BIP95 rule and its test, forcing reviewers to combine two commits to validate the network definition.

Location: src/kernel/chainparams.cpp:512 at 87632a6ccbc9 (commit) (commit).

Details and suggested fix

87632a6ccbc9ceb8621d5b306b7de8fdbbc125d2 introduces Testnet5 with enforce_BIP94 = false and BIP54 NEVER_ACTIVE. bb8ca3ee746dea10b9fbd69bb49ff4d2b9281397 then enables BIP54 and adds testnet5_consensuscleanup_activation. Fold that activation commit into the introduction so the complete consensus definition and block-1 activation test can be reviewed together. The direct parent, 07b7e96b27676ee0da186e74dfc1737a1b48a662, already contains BIP54 validation; the intervening C API exposure commit, 1489e756615d4b6a15488a1ad3915ec3cecc1881, does not require an inactive deployment and can remain separate. Update the surviving “is intended to enforce” comment to “enforces” at the same time. With the genesis still unmined, this concerns review flow rather than a live-network failure.


Link

[suggestion] · Chain-selector tests never enable -testnet5

The updated util_ChainMerge digest reflects the new error text, but its fixtures never enable -testnet5, leaving the new selection and mutual-exclusion branches without focused coverage.

Location: src/test/argsman_tests.cpp:1101 (head).

Details and suggested fix

util_ChainMerge still registers and generates only -testnet4 and -regtest, as does the focused selector test. Removing the new Testnet5 return branch or its conflict-count term would therefore leave those generated results unchanged. Extend the selector assertions to check that -testnet5 and -chain=testnet5 select Testnet5, that -notestnet5 and -testnet5=0 leave main selected, and that combining -testnet5 with -testnet4 or -chain=main throws. These checks do not require a mined genesis.


Link

[suggestion] · Testnet5's genesis sanity test does not verify proof of work

The new Testnet5 sanity case inherits a helper that checks genesis-hash consistency but not proof of work, leaving the planned mined-genesis update without a direct validity check.

Location: src/test/pow_tests.cpp:235 (head).

Details and suggested fix

A mistyped nonce, time or version can produce a matching pinned hash without satisfying nBits; the helper only validates the target's encoding and range. BlockManager::ReadBlock would later reject such a header. Add BOOST_CHECK(CheckProofOfWork(chainParams->GenesisBlock().GetHash(), chainParams->GenesisBlock().nBits, consensus)); to sanity_check_chainparams with the mined-genesis update. The current deliberately unmined placeholder would fail that assertion, so this should accompany its replacement rather than be treated as an unexpected failure of the draft.


Link

[suggestion] · Testnet5 network constants lack the existing fixture coverage

Testnet5 has no getchainparams fixture to pin its P2P magic and default port, unlike the existing networks.

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

Details and suggested fix

Add a -testnet5 getchainparams entry to bitcoin-util-test.json and a getchainparams-testnet5.json fixture, following Testnet4's coverage. This would pin magic 46495645 and P2P port 18353 alongside the genesis, PoW settings and address prefix; refresh the genesis field when the mined genesis lands. The new PoW tests already cover the difficulty floor and removal of the exception, but not these networking constants. This fixture would not cover RPC/onion ports or the datadir, which the command does not output. I have not checked the constants against the BIP95 text.


Link

[suggestion] · Release note incorrectly says minimum-difficulty blocks are disallowed

The release note says Testnet5 disallows minimum-difficulty blocks, but it only removes the 20-minute exception; blocks at the raised difficulty floor remain valid.

Location: doc/release-notes-testnet5.md:6 (head).

Details and suggested fix

With fPowAllowMinDifficultyBlocks = false, GetNextWorkRequired retains the previous nBits between retargets, and retargeting still clamps to powLimit. The configured genesis also uses the floor target, 0x1a0fffff. Replace “does not allow minimum-difficulty blocks” with “removes the 20-minute minimum-difficulty exception of testnet3/testnet4”, retaining the separate statement about the raised minimum difficulty.


Link

[suggestion] · BIP54 rejection probes skip the first active block

In the BIP54 dependency functional test, a valid first active block is already connected before rejection probes begin, so a one-block delay in sigops, coinbase-locktime or transaction-size enforcement could escape coverage.

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

Details and suggested fix

reach_end_retarget_period stops at a period's last height. The signalling steps then add 145 blocks, and generate_bulk(node, 144) advances from the first locked-in block through the first active block. The RPC's status describes the tip itself, not the next block, so the subsequent invalid candidates arrive too late to test the activation boundary. Stop one block earlier with status_next == "active", submit the sigops, coinbase-locktime and 64-byte rejection candidates against that same parent, and only then connect a valid first active block. Keep the pre-activation acceptance checks as controls.


Link

[suggestion] · BIP54 sigops vectors misidentify inputs and boundary totals

In the BIP54 dependency, recorded sigops-vector descriptions misidentify input counts and script types, and adjacent comments misstate the boundary totals.

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

Details and suggested fix

Each contrived P2SH input contributes 40 BIP54-sigops: both multisig key counts are data pushes above OP_16, so each counts as 20. The accepted transaction therefore has 62 inputs and 2480 sigops; adding an input gives 63 inputs and 2520 sigops. Change the rejected vector's “62 inputs” label to “63 inputs” and correct the 2400/2600 comments to 2480/2520. The 16-of-17 cases put spent_script directly in the previous outputs, so change their recorded “P2SH inputs” descriptions to “Bare Script inputs”. These corrections make the vector descriptions identify the cases actually constructed; the validity assertions can remain unchanged.


Link

[suggestion] · BIP54 sigops fuzzing has no acceptance-result oracle

The bip54_sigops fuzz target discards the check's boolean result, so incorrect accept/reject decisions that do not crash remain invisible to this target.

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

Details and suggested fix

For example, resetting the accumulated sigops for each input could change the result without triggering any assertion here. Add a constrained mode that builds bare input scripts from known numbers of OP_CHECKSIG operations, independently totals the counts as it constructs them, and asserts result == (total <= MAX_TX_BIP54_SIGOPS). Exercise totals on both sides of the limit across multiple inputs. Keep the existing serialized-vector path unchanged for broader parsing and crash coverage. Existing unit boundary tests cover some such regressions, but this would let fuzzing check the aggregation decision rather than only execute it.


Coverage details

Earlier concerns

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