Skip to content

Testnet 5 (BIP95) - #35861

Open
fjahr wants to merge 29 commits into
bitcoin:32.xfrom
fjahr:2026-07-t5-draft
Open

fjahr wants to merge 29 commits into
bitcoin:32.xfrom
fjahr:2026-07-t5-draft

Conversation

@fjahr

@fjahr fjahr commented Aug 1, 2026

Copy link
Copy Markdown
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.

@DrahtBot

DrahtBot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

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

External sites

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 <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

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.

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/kernel/chainparams.cpp: CreateGenesisBlock(testnet5_genesis_msg, testnet5_genesis_script, 1794632593, 0x653d9131, 0x1a0fffff, 0x2230c000, 50 * COIN)
  • src/test/bip54_tests.cpp: AddCoins(coins, CTransaction(tx_create), 0, false)
  • src/test/bip54_tests.cpp: Coin(spent_txo, 0, 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).

2026-11-22 11:23:43

@DrahtBot

DrahtBot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task iwyu: https://github.com/bitcoin/bitcoin/actions/runs/30713233158/job/91404317894
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.”

Hints

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.

Comment thread src/chainparamsbase.cpp Outdated
Comment on lines +50 to +51
case ChainType::TESTNET5:
return std::make_unique<CBaseChainParams>("testnet5", 18334);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clashes with testnet3's Tor port?

@fjahr fjahr Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@polespinasa polespinasa left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
+        }
+    }
+}

@fjahr

fjahr commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

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!

darosior and others added 6 commits November 13, 2026 23:06
… 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.
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.
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.
BIP95 enforces the BIP54 rules on Testnet 5 from block 1. This also covers
timewarp, so BIP94 is not enforced.
@fjahr

fjahr commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

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.

@polespinasa

polespinasa commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Achow is already running a seeder that we can commit here so users can relay on.
Note that it has been running for a few hours and it takes time to start returning results.
Also we should update the generate fixed seeds script:

$ git diff
diff --git a/contrib/seeds/README.md b/contrib/seeds/README.md
index 388ddd5453..5aa47b2477 100644
--- a/contrib/seeds/README.md
+++ b/contrib/seeds/README.md
@@ -20,6 +20,7 @@ curl https://mainnet.achownodes.xyz/seeds.txt.gz | gzip -dc >> seeds_main.txt
 curl https://signet.achownodes.xyz/seeds.txt.gz | gzip -dc > seeds_signet.txt
 curl https://testnet.achownodes.xyz/seeds.txt.gz | gzip -dc > seeds_test.txt
 curl https://testnet4.achownodes.xyz/seeds.txt.gz | gzip -dc > seeds_testnet4.txt
+curl https://testnet5.achownodes.xyz/seeds.txt.gz | gzip -dc > seeds_testnet5.txt
 curl https://raw.githubusercontent.com/asmap/asmap-data/main/latest_asmap.dat > asmap-filled.dat
 python3 makeseeds.py -a asmap-filled.dat -s seeds_main.txt > nodes_main.txt
 python3 makeseeds.py -a asmap-filled.dat -s seeds_signet.txt -m 266000 > nodes_signet.txt
diff --git a/contrib/seeds/generate-seeds.py b/contrib/seeds/generate-seeds.py
index ff2b4028f0..e3f3b1d786 100755
--- a/contrib/seeds/generate-seeds.py
+++ b/contrib/seeds/generate-seeds.py
@@ -5,13 +5,14 @@
 '''
 Script to generate list of seed nodes for kernel/chainparams.cpp.
 
-This script expects three text files in the directory that is passed as an
+This script expects five text files in the directory that is passed as an
 argument:
 
     nodes_main.txt
     nodes_signet.txt
     nodes_test.txt
     nodes_testnet4.txt
+    nodes_testnet5.txt
 
 These files must consist of lines in the format
 
@@ -22,7 +23,7 @@ These files must consist of lines in the format
 
 The output will be several data structures with the peers in binary format:
 
-   inline constexpr uint8_t chainparams_seed_{main,signet,test,testnet4}[]{
+   inline constexpr uint8_t chainparams_seed_{main,signet,test,testnet4,testnet5}[]{
        ...
    };
 
@@ -182,6 +183,9 @@ def main():
     g.write('\n')
     with open(os.path.join(indir,'nodes_testnet4.txt'), 'r') as f:
         process_nodes(g, f, 'chainparams_seed_testnet4')
+    g.write('\n')
+    with open(os.path.join(indir,'nodes_testnet5.txt'), 'r') as f:
+        process_nodes(g, f, 'chainparams_seed_testnet5')
     g.write('#endif // BITCOIN_CHAINPARAMSSEEDS_H\n')
 
 if __name__ == '__main__':
diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp
index f997be9372..189505662f 100644
--- a/src/kernel/chainparams.cpp
+++ b/src/kernel/chainparams.cpp
@@ -542,9 +542,10 @@ public:
         assert(consensus.hashGenesisBlock == uint256{"00000000000008c1637e7d3252dc1c333d4546fd6fff6a474b200d674a91d497"});
         assert(genesis.hashMerkleRoot == uint256{"8c5899b65c5b0834adb17af314e22a9bf067e7ed8144c37967b5ec56b5a6e28d"});
 
-        // No DNS or fixed seeds defined for Testnet 5 yet.
         vFixedSeeds.clear();
         vSeeds.clear();
+        // nodes with support for servicebits filtering should be at the top
+        vSeeds.emplace_back("seed.testnet5.achownodes.xyz."); // Ava Chow
 
         base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
         base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);

orangesurf added a commit to orangesurf/mempool that referenced this pull request Nov 21, 2026
Bitcoin Core has no DNS or fixed seeds for testnet5 yet
(bitcoin/bitcoin#35861), and every addnode line in the [testnet5]
section is commented out, so a node started from this file finds no
peers. Name two reachable testnet5 nodes. Remove them once the pinned
Core build has seeds.
orangesurf added a commit to orangesurf/mempool that referenced this pull request Nov 21, 2026
Backend config, nginx locations and upstreams, build and start lists, log rotation and cache warming for a testnet5 instance, following testnet4, with a [testnet5] section in bitcoin.conf, its cron lines and systemd unit, the install script, and TESTNET5_ENABLED in the site configs. Testnet5 is off in the install dialog unless ticked.

The backend config uses "NETWORK": "testnet5". Ports: bitcoind RPC 18352 and P2P 18353 (Bitcoin Core's testnet5 defaults), ZMQ 18354 and 18355, mempool backend 8988, esplora fallback 3006.

Testnet5 is in no Bitcoin Core release yet. Build bitcoin/bitcoin#35861 at ee505609676a10c389da5962b25a2c0080b9df57 into /usr/local/bitcoin-testnet5 and run the testnet5 node from there, so the other networks stay on the release.

That build has no DNS or fixed seeds for testnet5, and the other addnode lines in the section are commented out, so name two reachable testnet5 nodes. Remove them once the pinned build has seeds.

Two fixes to the install script come with it. `grep Testnet` also matched Testnet4 and Testnet5, so choosing either without Testnet still installed testnet3; it now matches the whole word, and LN-Testnet still enables testnet3 as before. The CKPool start script takes testnet3, not testnet, and reads the RPC credentials from /bitcoin/<network>.conf, which nothing created; the installer now passes testnet3 and links the file.
@fjahr

fjahr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Also we should update the generate fixed seeds script

Thanks! I added Ava's seeder in one commit and kept the changes to the fixed seeds script as a separate commit. The reason is the script change didn't work just like that. generate-seeds.py would fail because nodes_testnet5.txt doesn't exist yet and the user agent filter in makeseeds.py stops at 31.x currently so it excludes all Testnet5 nodes run 32.x and an empty list doesn't compile once chainparams.cpp uses it.

I opted for a complete fix to these issues in the second commit which adds 32.x to the filter, adds nodes_testnet5.txt (currently 6 addresses) and regenerates chainparamsseeds.h with that included. The other networks seeds are untouched.

I was a bit unsure about this initially and kept it as a separate commit because the filter is usually updated in the seed update before each release and also the list is still extremely small. But the list can be refreshed once this moves closer to merge and I don't see any harm that could be caused by updating the filter now. But if I missed something the commit can also just be dropped for now.

@arejula27

Copy link
Copy Markdown
Contributor

I think the PR description is a bit out of date now. The genesis block was already added ( bitcoin/bips#2356), there is a DNS seed and fixed seeds (49a4403) and the PR is no longer in draft. It could be nice to update .

Thanks for working on this! I'm looking forward to finding some time to try mining on it with p2poolv2.

willcl-ark added a commit to willcl-ark/dnsseedrs that referenced this pull request Nov 27, 2026
Testnet5 (BIP95) is live with over 8,000 blocks, and its constants are
available on rust-bitcoin master: magic 0x46495645 ("FIVE") and P2P port
18353, matching the chainparams in bitcoin/bitcoin#35861.

Accept --chain testnet5 and require nodes to report a starting height of
at least 8000, just below the current tip of 8442, so lagging nodes are
not served. Raise this as the chain grows, as for the other networks.
Allow testnet5 in the NixOS module and document it.
@DrahtBot

DrahtBot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants