testnet

testnet

Bitcoin Testnet is a network that's like Bitcoin, except unlike the actual Bitcoin network, there's no value to the coins (at least, that's the intention). This is great because anyone can test and try out new Bitcoin software without the risk of losing anything of value.

Testnet3 is currently supported by many bitcoin wallets and explorers

Testnet Versions

What everyone calls "bitcoin testnet" today is the third such network, testnet3. The previous testnet versions were depreciated and testnet3 has been running for 13 years now. But testnet3 has some problems.

Problems with Testnet3

Block Storm Problem

Testnet3 has a bug which meant that under certain conditions, blocks can be mined very quickly, destabilizing the network and making it difficult for nodes to keep up with the chain.

This is possible because testnet3 has a special difficulty adjustment rule which was added to ensure that the chain could be extended even if a large amount of hashrate pushed up the difficulty then left the network. The testnet3 special difficulty rule allows the mining of a min-difficulty block if the new block's timestamp is more than 20 minutes.

ℹ️
This is a particular problem for a network which shares the same mining algorithm as bitcoin, because if a BTC miner pointed a modern ASIC at testnet3 they would cause the difficulty to rise significantly. If the miner then stopped mining on testnet3 the difficulty would be so high that no new blocks would be found by the rest of the network, and users of testnet3 would have to wait for the difficulty to back adjust down.

Over the past 1 year testnet3 has had a network hashrate of approximately 500 - 1000 TH/s which is equivalent to approximately 2-3 Antminer S21 Hyd. or 40-80 S9's.

However, if the last block before a difficulty retarget is a min-difficulty, it will reset the difficulty back to 1 persistently. Lopp has written about this in detail on his blog.

Bitcoin Testnet Block Storms
A deep dive into how 10 lines of code resulted in far-reaching unintended consequences for the Bitcoin test network.

This bug has been exploited repetedly on testnet3. Most recently in April 2024 when Jameson Lopp was able to generate 165,000 blocks (3 years worth) in a week, stifling the efforts of those using testnet for both non-testing and 'legitimate' testing purposes.

Short Text Note by Jameson Lopp
My griefing attack on Bitcoin testnet has resulted in over 165,000 blocks (3 years worth) generated in the past week. 😏
👎
Critics Corner. It's worth noting that there are some developers who see the blockstorms as a feature, rather than a bug.

"I mainly use testnet for checking if the utreexod implementation I'm building runs into consensus bugs due to the havoc of how testnet creates bursts of blocks and how it reorganizes itself. I find the unpredictability a feature." - Calvin Kim

Availability Problem

In order to be useful for testing, users and developers need to be able to easily get hold of testnet3 coins.

In the past this was easy, just mine with a spare computer core, which would generate enough coins for testing. People would readily share hundreds or thousands of tBTC coins on bitcoin-dev IRC channel, or you could visit a faucet, a website which gives testnet coins away for free.

Unfortunately it has become difficult to get hold of testnet3 coins as the hashrate has grown to the point that it is 500-1000 TH/s. Many faucets are completely drained, and those that are still online distribute only tens of thousands of sats and regularly hit their rate limits, which makes it difficult to get hold of the quantity of testnet3 coins required to test software at scale.

https://coinfaucet.eu/en/btc-testnet/

One reason that coins are hard to acquire is that new testnet3 coin issuance has almost completely dried up, with only 0.0122 new tBTC generated per block. This is because testnet3 is in Epoch 13, with a chain containing over 2.8 million blocks. This is linked to the first issue, the reason testnet3 has so many blocks is because it has been subject to block storm attacks.  For context, the actual bitcoin network has just entered Epoch 5, and has 3.125 new BTC generated per block.

This makes it very difficult to get access to new coins by mining it, which is the only way that new coins can be generated.

Epoch Start Block End Block Reward (BTC)
1 0 209,999 50.00
2 210,000 419,999 25.00
3 420,000 629,999 12.50
4 630,000 839,999 6.25
5 (BTC) 840,000 1,049,999 3.125
6 1,050,000 1,259,999 1.5625
7 1,260,000 1,469,999 0.78125
8 1,470,000 1,679,999 0.390625
9 1,680,000 1,889,999 0.1953125
10 1,890,000 2,099,999 0.09765625
11 2,100,000 2,309,999 0.048828125
12 2,310,000 2,519,999 0.0244140625
13 (tBTC3) 2,520,000 2,729,999 0.01220703125

Additionally, there is growing use of testnet 3 for non-testing purposes. For example, doing airdrops for different tokens, further developing markets for testnet3 coins.

👎
Critics Corner. It's worth noting that there are some developers who think the presense of a market is no bad thing.

"When I imagine what I would have to go through to mine testnet BTC, how much time and money to invest (buying/renting ASIC - CPU mining is a thing of the past), and someone offered me a simpler alternative, to just buy it, I probably wouldn't hesitate and would just buy it." - Emsit

Fixing the issues

On the 2024/03/3 Jameson Lopp posted to the bitcoin dev mailing soliciting feedback on his suggestion of resetting testnet. Not long after this he begain a griefing attack on testnet3, raising mainstream awareness of the pressing issues.

The most basic approach to fix both the block storm problem and the availability problem is to make a new testnet (testnet4) which has a new genesis block and has a small fix to address the blockstorm bug. This would ensure that testnet4 logic, like testnet3 logic, minimally diverges from the real bitcoin network logic. This is beneficial because as Voiskuil puts it, the more testnet deviates from bitcoin the less useful it becomes for testing bitcoin (as opposed for testing applications which use bitcoin). This new testnet would run alongside testet3 (there is no way to stop testnet3 from continuing) and developers would begin to switch to testnet4, before eventually dropping support for testnet3 from bitcoin core.

Other ideas which are being discussed are more complex and include

  • Changing the supply schedule to make the coins easily available by removing halvings (todd).
  • Fixing the timewarp bug whereby manipulation of the timestamps of blocks allows miners to lower the difficulty (stemming from the difficulty adjustment off-by-one bug which means that the retarget periods do not overlap).
  • Changing the minimum block difficulty.

These discussions are ongoing in a pull request in the bitcoin core github repository, and it has been suggested that the first Bitcoin Core release with testnet4 will probably be v28 in October (Sjors).