Testnet 5 (BIP95) #35861

pull fjahr wants to merge 27 commits into bitcoin:32.x from fjahr:2026-07-t5-draft changing 62 files +6857 −140
  1. fjahr commented at 6:44 PM on August 1, 2026: contributor

    Implements BIP 95 (Testnet 5). Relative to Testnet 4 it removes the 20-minute minimum-difficulty exception, raises the minimum difficulty, and enforces BIP 54 from block 1. The Genesis block has not been mined yet.

    Based on #35793, only the top five commits belong to this PR.

    Per the discussion in a recent IRC meeting: since BIP 95 activates BIP 54 from block 1, this depends on #35793 and won't make the v32 feature freeze. So we can review and settle the changes now, but leave this in draft until #35793 lands. Once reviewers are happy with the state of the draft here we can add the Genesis block and the network can get started without being included in a release. We can then ship a patched v32 release with Testnet 5 included. A solo-mining ckpool endpoint is likely being set up and will be advertised here. There are no DNS or fixed seeds yet.

  2. DrahtBot commented at 6:45 PM on August 1, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    Concept ACK polespinasa, fanquake
    Stale ACK johnnyasantoss

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35852 (scripted-diff: Use inline const(expr) over static constexpr in headers by maflcko)
    • #35657 (refactor: avoid redundant input lookup in CheckTxInputs by arejula27)
    • #35570 (refactor: Change some validation.cpp methods to return BlockValidationState by optout21)
    • #35569 (Encapsulation for CTransaction by purpleKarrot)
    • #35301 (Silent Payments: Implement bip352 (take 2) by Eunovo)
    • #34864 (coins: tighten cache entry state invariants by l0rinc)
    • #32729 (test,refactor: extract script template helpers and expand sigop coverage by l0rinc)
    • #32468 (rpc: generateblock to allow multiple outputs by polespinasa)
    • #29491 ([EXPERIMENTAL] Schnorr batch verification for blocks by fjahr)
    • #28690 (build: Introduce internal kernel library by sedited)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

    LLM Linter (✨ experimental)

    Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

    • src/test/bip54_tests.cpp: AddCoins(coins, CTransaction(tx_create), 0, false)
    • src/test/bip54_tests.cpp: AddCoins(coins, CTransaction(tx_create_last), 0, false)
    • src/test/bip54_tests.cpp: AddCoins(coins, CTransaction(tx_create_single), 0, false)
    • src/test/bip54_tests.cpp: coins.AddCoin(tx.tx.vin[i].prevout, Coin(spent_txo, 0, false), false)
    • src/test/fuzz/bip54.cpp: coins.AddCoin(tx.vin.back().prevout, Coin(std::move(prev_txo), 0, false), false)

    Possible places where comparison-specific test macros should replace generic comparisons:

    • test/functional/data/invalid_txs.py: assert len(tx.serialize_without_witness()) == 63 → Prefer assert_equal(len(tx.serialize_without_witness()), 63).
    • test/functional/data/invalid_txs.py: assert MIN_STANDARD_TX_NONWITNESS_SIZE - 1 == 64 → Prefer assert_equal(MIN_STANDARD_TX_NONWITNESS_SIZE - 1, 64).
    • test/functional/feature_bip54.py: assert height % 144 == 0 → Prefer assert_equal(height % 144, 0).

    <sup>2026-11-14 11:23:37</sup>

  3. fjahr force-pushed on Aug 1, 2026
  4. DrahtBot added the label CI failed on Aug 1, 2026
  5. DrahtBot commented at 7:16 PM on August 1, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task iwyu: https://github.com/bitcoin/bitcoin/actions/runs/30713233158/job/91404317894</sub> <sub>LLM reason (✨ experimental): CI failed because IWYU (include-what-you-use) reported a failure and forced the job to exit with “Failure generated from IWYU.”</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  6. DrahtBot removed the label CI failed on Aug 1, 2026
  7. DrahtBot added the label Needs rebase on Aug 14, 2026
  8. fjahr force-pushed on Aug 15, 2026
  9. fjahr force-pushed on Aug 15, 2026
  10. DrahtBot added the label CI failed on Aug 15, 2026
  11. in src/chainparamsbase.cpp:51 in 31ed5baf68
      46 | @@ -46,6 +47,8 @@ std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const ChainType chain)
      47 |          return std::make_unique<CBaseChainParams>("testnet3", 18332);
      48 |      case ChainType::TESTNET4:
      49 |          return std::make_unique<CBaseChainParams>("testnet4", 48332);
      50 | +    case ChainType::TESTNET5:
      51 | +        return std::make_unique<CBaseChainParams>("testnet5", 18334);
    


    darosior commented at 7:34 AM on October 2, 2026:

    This clashes with testnet3's Tor port?


    fjahr commented at 9:05 AM on November 4, 2026:

    Ugh, I thought I had taken everything into account but I guess I didn't look at T3 seriously enough. I moved T5 to 18352/18353/18354 (RPC/P2P/onion), so 183N3 scheme that keeps our existing pattern for RPC = P2P-1 and onion = P2P+1 and that testnet3 already follows with N=3. This means we need changes the P2P port in BIP95, so I'll push an update for that. I think the BIP change is fine since there is no other implementation yet and I think there is some value in keeping the pattern in place.

  12. polespinasa commented at 8:47 PM on November 2, 2026: member

    Approach ACK

    Can we use this PR to also add the bash completation? See bitcoin-cli.bash.

    diff --git a/contrib/completions/bash/bitcoin-cli.bash b/contrib/completions/bash/bitcoin-cli.bash
    index ff34ad9ff6..2559c5530a 100644
    --- a/contrib/completions/bash/bitcoin-cli.bash
    +++ b/contrib/completions/bash/bitcoin-cli.bash
    @@ -9,7 +9,7 @@ _bitcoin_rpc() {
         local rpcargs=()
         for i in ${COMP_LINE}; do
             case "$i" in
    -            -conf=*|-datadir=*|-regtest|-rpc*|-testnet|-testnet4)
    +            -conf=*|-datadir=*|-regtest|-rpc*|-testnet|-testnet4|-testnet5)
                     rpcargs=( "${rpcargs[@]}" "$i" )
                     ;;
             esac
    
    

    Should we add tests for the restored difficulty behavior?

    Maybe also some activation unit tests? Maybe test that block1 has bip54 active?

    diff --git a/src/test/versionbits_tests.cpp b/src/test/versionbits_tests.cpp
    index 7dcc5c676c..361be3f3d6 100644
    --- a/src/test/versionbits_tests.cpp
    +++ b/src/test/versionbits_tests.cpp
    @@ -5,6 +5,7 @@
     #include <chain.h>
     #include <chainparams.h>
     #include <consensus/params.h>
    +#include <deploymentstatus.h>
     #include <test/util/random.h>
     #include <test/util/common.h>
     #include <test/util/setup_common.h>
    @@ -492,4 +493,20 @@ BOOST_FIXTURE_TEST_CASE(versionbits_computeblockversion, BlockVersionTest)
         }
     }
     
    +BOOST_AUTO_TEST_CASE(testnet5_consensuscleanup_activation)
    +{
    +    for (const auto chain_type : {ChainType::TESTNET4, ChainType::TESTNET5}) {
    +        BOOST_TEST_CONTEXT(ChainTypeToString(chain_type)) {
    +            const auto chain_params{CreateChainParams(ArgsManager{}, chain_type)};
    +            // Evaluate block 1 with the default deployment parameters, without mining genesis.
    +            CBlockIndex genesis{chain_params->GenesisBlock()};
    +            genesis.nHeight = 0;
    +            VersionBitsCache cache;
    +            BOOST_CHECK_EQUAL(DeploymentActiveAfter(&genesis, chain_params->GetConsensus(),
    +                                                   Consensus::DEPLOYMENT_CONSENSUSCLEANUP, cache),
    +                              chain_type == ChainType::TESTNET5);
    +        }
    +    }
    +}
    
    
  13. fjahr force-pushed on Nov 4, 2026
  14. fjahr commented at 9:05 AM on November 4, 2026: contributor

    Rebased on v32.1 with the latest state of the BIP 54 pull.

    Can we use this PR to also add the bash completation?

    Done

    Should we add tests for the restored difficulty behavior?

    Added two cases: no 20-minute exception on testnet5, and the raised powLimit.

    Maybe also some activation unit tests? Maybe test that block1 has bip54 active?

    Taken with small tweaks, thanks!

  15. fjahr changed the base branch on Nov 4, 2026
  16. DrahtBot removed the label Needs rebase on Nov 4, 2026
  17. polespinasa commented at 4:18 PM on November 4, 2026: member

    looks pretty good to me right now. If it was not a draft I would directly ACK it ;)

  18. in src/kernel/chainparams.cpp:544 in a81e5c2d8a outdated
     539 | +                testnet5_genesis_script,
     540 | +                0, // TODO: nTime
     541 | +                0, // TODO: nNonce
     542 | +                0x1a0fffff,
     543 | +                1,
     544 | +                50 * COIN);
    


    ajtowns commented at 4:54 PM on November 9, 2026:

    After https://github.com/bitcoin/bips/pull/2347 expect this to change to something like

            // TODO: these are placeholders
            const char* testnet5_genesis_msg = "2026-11-09 975190 0000000000000000000153b627e5d18a5b7f2e1b4d601c7abaf5889c1af136ca";
            const CScript testnet5_genesis_script = CScript() << OP_RETURN << "ffebf16a00000000"_hex;
            genesis = CreateGenesisBlock(testnet5_genesis_msg,
                    testnet5_genesis_script,
                    1794239567, // nTime
                    0x14eab764, // nNonce
                    0x1b01fffe, // nBits (nb: placeholder has wrong difficulty)
                    0x20066000, // nVersion
                    50 * COIN);
    

    ajtowns commented at 5:23 AM on November 14, 2026:

    Params are here:

            const char* testnet5_genesis_msg = "2026-11-14 975744 0000000000000000000123e2681e2f82acdcb9430a15eec24cc85b400691d479";
            const CScript testnet5_genesis_script = CScript() << OP_RETURN << "95ebf76a02000000"_hex;
            genesis = CreateGenesisBlock(testnet5_genesis_msg,
                    testnet5_genesis_script,
                    1794632593, // nTime
                    0x653d9131, // nNonce
                    0x1a0fffff,
                    0x2230c000, // nVersion
                    50 * COIN);
            consensus.hashGenesisBlock = genesis.GetHash();
            assert(consensus.hashGenesisBlock == uint256{"00000000000008c1637e7d3252dc1c333d4546fd6fff6a474b200d674a91d497"});
            assert(genesis.hashMerkleRoot == uint256{"8c5899b65c5b0834adb17af314e22a9bf067e7ed8144c37967b5ec56b5a6e28d"});
    

    Also here and here.


    polespinasa commented at 8:15 AM on November 14, 2026:

    For reviewers, the params can be verified here: https://lapis.erisian.com.au/chain.json

  19. fanquake commented at 7:04 PM on November 12, 2026: member

    Concept ACK

  20. fjahr force-pushed on Nov 13, 2026
  21. fjahr marked this as ready for review on Nov 13, 2026
  22. fjahr commented at 9:04 AM on November 13, 2026: contributor

    Adapted the Genesis block layout to BIP95 v0.3.0 with @ajtowns suggested height at 975,744. For anyone intersted, this is in roughly 15 hours, if you want to point some hash power at the pool and be part of (testnet) history, here is the relevant information: https://gist.github.com/ajtowns/ebb148819c6028387271e6f0dce5e1da

    Also taken out of draft status.

  23. DrahtBot removed the label CI failed on Nov 13, 2026
  24. DrahtBot added the label Backport on Nov 13, 2026
  25. johnnyasantoss commented at 3:22 PM on November 13, 2026: none

    cACK 987ddefe254165510673524d7f74ca050a65bf60

    One minor inconvenience is that the boost tests are mostly comparing against testnet4 and a observer without external/historical context may not understand why.

  26. DrahtBot requested review from fanquake on Nov 13, 2026
  27. DrahtBot requested review from polespinasa on Nov 13, 2026
  28. chainparams: add versionbits deployment for BIP 54 187f50f090
  29. scripted-diff: rename BIP54-sigops constants to MAX_TX_BIP54_SIGOPS
    Today's constant for the BIP54-sigops limit is named MAX_TX_LEGACY_SIGOPS.
    BIP54 counts sigops differently from existing sigops-based checks. Since
    we are overloading the sigops term, make clear the constant refers to
    BIP54-sigops, not other kinds of pre-existing sigops.
    
    Also update the functional test framework's constant that has
    "standardness" in its name, since we are about to make it consensus
    critical (func test scripted-diff courtesy of Anthony Towns).
    
    -BEGIN VERIFY SCRIPT-
    sed -i 's/MAX_TX_LEGACY_SIGOPS/MAX_TX_BIP54_SIGOPS/g' $(git grep -l MAX_TX_LEGACY_SIGOPS src/)
    sed -i 's/MAX_STD_LEGACY_SIGOPS/MAX_TX_BIP54_SIGOPS/g' $(git grep -l MAX_STD_LEGACY_SIGOPS)
    sed -i 's/signature operations in validating a transaction./signature operations in a single transaction, per BIP54./' test/functional/test_framework/script_util.py
    -END VERIFY SCRIPT-
    
    Co-Authored-by: Anthony Towns <aj@erisian.com.au>
    9c80714fc0
  30. moveonly: move CheckSigopsBIP54 from policy to consensus
    Move the function that checks whether a transaction respects the BIP54 sigops rule to the
    consensus folder (along with the accompanying constant), as it will be made consensus-critical
    in the next commit. Can be reviewed with git's --color-moved option.
    61efe64591
  31. consensus: clarify legacy sigops means non-segwit sigops b38223de6b
  32. qa: use valid BIP 54 blocks to test "bad-blk-sigops" in p2p_segwit.py
    Commit 6e60c362bc1e373a284911381e2a513f57f5f26b introduced a test using
    BIP54-invalid blocks to test legacy sigops accounting. This commit
    updates this test to break down the outputs spent in multiple
    transactions, in order to make the test BIP 54 valid. Failing that, the
    following commit would change the failure reason from "bad-blk-sigops"
    to "bad-txns-legacy-sigops".
    1852d8c161
  33. validation: make BIP54 sigops check consensus-critical
    When BIP54 is active, enforce that block transactions do not violate the BIP54 limit on the
    number of legacy sigops present in Scripts that get executed during block validation.
    
    Note how the BIP 54 sigops check can't be bypassed anymore in the mempool with -acceptnonstdtxn.
    Furthermore, a BIP 54 failure now always returns `TxValidationResult::TX_CONSENSUS`. It could be
    possible to preserve the `TxValidationResult::TX_INPUTS_NOT_STANDARD` error prior to activation
    instead. But it would diverge more from the code tested on Bitcoin Inquisition and introduce
    complexity for little benefits: the error is not used for disconnection decisions anymore, and is
    not exposed to users in RPC errors. Hence, we prefer not to.
    6622bfaef8
  34. qa: add to utilities a version of SignSignature for Taproot inputs
    In Taproot the signature commits to the list of spent outputs.
    9c093179bc
  35. qa: extensive unit tests for BIP54 legacy sigops limit
    Test the newly introduced limit with various combinations of inputs and outputs types,
    historical transactions, and exercise some implementation-specific edge cases. Record
    each test case and optionally write them to disk as JSON to generate the BIP test vectors.
    31f89e5a45
  36. fuzz: add a fuzz target for the BIP54 sigops check
    The fuzz target was specifically crafted to support seeding it with the BIP54 test vectors
    generated by the unit test in the previous commit.
    079297b2fc
  37. scripted-diff: rename testnet4 timewarp constant
    We are going to introduce the timewarp fix for mainnet with a greater grace period. Rename
    the MAX_TIMEWARP value for testnet to differentiate them.
    
    -BEGIN VERIFY SCRIPT-
    
    for f in $(git grep -l MAX_TIMEWARP); do sed -i "s/MAX_TIMEWARP/MAX_TIMEWARP_TESTNET4/g" "$f"; done
    
    -END VERIFY SCRIPT-
    06f84185a4
  38. miner: update a timewarp comment to refer specifically to BIP 54 8da847cfb7
  39. validation: prevent timewarp attacks with a 2h grace period 196109b15c
  40. validation: prevent negative difficulty adjustment intervals 4065d73c72
  41. qa: BIP54 test vectors for timewarp and Murch-Zawy
    Documentation about the test vectors, including about their structure and content, as well as
    reproduction instructions, is available here: https://github.com/bitcoin/bips/tree/master/bip-0054/test_vectors
    1d6b2f6ca2
  42. validation: enforce that coinbase transactions are timelocked to block height
    When BIP 54 is active, coinbase transactions must have their nLockTime field set to the block height
    minus 1 (since it encodes the last height at which the transaction is invalid), and their nSequence
    field may be anything but the maximum value (which indicates "final", bypassing timelock
    validation).
    69d6954308
  43. qa: BIP54 test vectors for restrictions on coinbase transactions
    Documentation about the test vectors' structure and content, as well as instructions for generating
    them is available at https://github.com/bitcoin/bips/tree/master/bip-0054/test_vectors .
    6479f7b078
  44. Avoid creating <= 64-byte transactions in most functional tests. ec850865a4
  45. [test] Separate 64B and 63B tx size tests 7b2be924db
  46. validation: make 64-byte transactions invalid
    64-byte transactions are also now treated as a consensus failure in
    PreChecks, like BIP54-sigops check failures. Note this only changes the
    RPC error, and not the disconnection behaviour in P2P since
    266dd0e10d08c0bfde63205db15d6c210a021b90.
    b415126cc0
  47. qa: unit tests for BIP54 rule on 64-byte transactions (with JSON test vectors)
    This adds tests exercising the bounds of the checks on the invalid transaction size, for various
    types of transactions (legacy, Segwit, bytes in input/output to get to 64 bytes) as well as
    sanity checking against some known historical violations.
    
    Thanks to Chris Stewart for digging up the historical violations to this rule.
    07dcb89cd0
  48. qa: end-to-end test all BIP54 mitigations
    The previously introduced unit tests extensively test the specific implementation of each
    mitigation. This functional test complements them by end-to-end testing all mitigations.
    For the added timestamp constraints, it mimicks how they would get exploited (by implementing pseudo
    timewarp and Murch-Zawy attacks) and demonstrates those exploits are not possible anymore after
    BIP54 activates.
    f99c168c5b
  49. doc: add a BIP 54 entry to bips.md be806861e1
  50. testnet: Introduce Testnet5 (BIP95)
    Testnet 5 is specified in BIP95. It drops the 20-minute minimum-difficulty
    exception of Testnet 3/4 and raises the minimum difficulty to nBits
    0x1a0fffff.
    ef12208cc0
  51. kernel: Add Testnet5 (BIP95) to the C API f45ad14f37
  52. testnet: Activate BIP54 on Testnet5 (BIP95)
    BIP95 enforces the BIP54 rules on Testnet 5 from block 1. This also covers
    timewarp, so BIP94 is not enforced.
    5f5fcf3e6d
  53. doc: add BIP95 entry to bips.md d1b5fd61ca
  54. doc: add release note for Testnet5 (BIP95) ee50560967
  55. fjahr force-pushed on Nov 14, 2026
  56. fjahr commented at 11:23 AM on November 14, 2026: contributor

    Rebased on the latest version of #35793 and added the genesis block from bitcoin/bips#2356. The node can now sync the current chain when you have a node to manually connect to and -testnet5 -addnode=lapis.erisian.com.au:18353 works for now.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-16 00:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me