0094 - Final - Standards - May 27, 2024 (2 years, 1 month ago)
27
2024
BIP: 94
Layer: Applications
Title: Testnet 4
Author: Fabian Jahr <[email protected]>
Comments-Summary: No comments yet.
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP 94
Status: Final
Type: Standards Track
Created: 2024-05-27
License: CC0-1.0
Post-History: https://gnusha.org/pi/bitcoindev/CADL_X[email protected]/
https://gnusha.org/pi/bitcoindev/a6e3VPsXJf9p3gt_FmNF_Up-wrFuNMKTN30-xCSDHBKXzXnSpVflIZIj2NQ8Wos4PhQCzI2mWEMvIms_FAEs7rQdL15MpC_Phmu_fnR9iTg=@protonmail.com/
https://github.com/bitcoin/bitcoin/pull/29775
A new test network with the goal to replace Testnet 3. This network comes with small but important improvements of the consensus rules, that should make it impractical to attack the network using only CPU mining.
Quoting the original mailing list post from Jameson Lopp 1 :
Testnet3 has been running for 13 years. It's on block 2.5 million something and the block reward is down to ~0.014 TBTC, so mining is not doing a great job at distributing testnet coins anymore. The reason the block height is insanely high is due to a rather amusing edge case bug that causes the difficulty to regularly get reset to 1, which causes a bit of havoc. If you want a deep dive into the quirk: https://blog.lopp.net/the-block-storms-of-bitcoins-testnet/
Testnet3 is being actively used for scammy airdrops; those of us who tend to be generous with our testnet coins are getting hounded by non-developers chasing cheap gains.
As a result, TBTC is being actively bought and sold; one could argue that the fundamental principle of testnet coins having no value has been broken.
Since then the issue with block storms has been further demonstrated on Testnet 3 when three years' worth of blocks were mined in a few weeks while rendering the network practically unusable at the same time.
Testnet 4 follows the same consensus rules as mainnet with the following three exceptions. Additionally, all soft forks that are active on mainnet as of May 2024 are enforced from genesis.
This rule was implemented in Testnet 3 2 and is preserved in Testnet 4.
1. For any block except the first block in a difficulty period:
a. If the block's timestamp is >20 minutes past the timestamp of the previous block
b. Then the block MUST use the minimum difficulty value (
nBits
=
0x1d00ffff
), regardless of the network's actual difficulty
2. The first block of each difficulty period MUST use the actual network difficulty.
This rule enables CPU mining on testnet but has led to block storms 3 which rule #2 below addresses.
This is a new rule to address block storms caused by the 20-minute exception.
In Mainnet and Testnet 3, the difficulty adjustment calculation uses the difficulty value of the last block in the previous period as its base. When the 20-minute exception is applied to this last block, it is mined at difficulty 1, causing the next period's difficulty to be constrained between 1-4, leading to block storms.
1. For difficulty adjustment calculations between periods:
a. The base difficulty value MUST be taken from the first block of the previous difficulty period
b. NOT from the last block as in previous implementations
2. The adjustment factor calculation remains unchanged:
a. Multiplication factor based on the duration of the previous difficulty period
b. Limited to no less than 1/4 and no more than 4x
This change ensures that the actual network difficulty is used for adjustment calculations rather than potentially manipulated values from the last block in a period.
This rule prevents time warp attacks that could otherwise be used to amplify block storms 4 .
1. For any block whose height modulo 2016 equals 0 (i.e., the first block of each difficulty period):
a. The block's
nTime
field MUST be greater than or equal to the
nTime
field of the immediately prior block minus 600 seconds
2. These blocks MUST still comply with existing Median-Time-Past
nTime
restrictions
This rule is based on The Great Consensus Cleanup proposal 5 and prevents miners from manipulating timestamps to artificially lower difficulty.
The applied changes were the result of discussions on the mailing list and the PR. The selected changes try to strike a balance between minimal changes to the network (keeping it as close to mainnet as possible) while making it more robust against attackers that try to disrupt the network. Several alternative designs were considered:
acceptnonstdtxn
in bitcoin core by default
was dismissed as it had led to confusion among layer-2s that had used
testnet for transaction propagation tests and expected it to behave
similarly to mainnet.
One known downside of the chosen approach is that if the difficulty is gradually raised by a miner with significant hash rate, and this miner disappears, then each difficulty adjustment period requires one block at the actual difficulty.
This would cause the network to stall once per difficulty adjustment period until the real difficulty is adjusted downwards enough for the remaining hash rate to find this block in reasonable time.
All consensus rules active on mainnet at the time of this proposal are enforced from block 1, the newest of these rules being the Taproot softfork.
03/May/2024 000000000000000000001ebd58c244970b3aa9d783bb001011fbe8ea8e98e00e
000000000000000000000000000000000000000000000000000000000000000000
0x1d00ffff
The resulting genesis block hash is
00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043
,
and the block hex is
0100000000000000000000000000000000000000000000000000000000000000000000004e7b2b9128fe0291db0693af2ae418b767e657cd407e80cb1434221eaea7a07a046f3566ffff001dbb0c78170101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff5504ffff001d01044c4c30332f4d61792f323032342030303030303030303030303030303030303030303165626435386332343439373062336161396437383362623030313031316662653865613865393865303065ffffffff0100f2052a010000002321000000000000000000000000000000000000000000000000000000000000000000ac00000000
.
The message start is defined as
0x1c163f28
. These four
bytes were randomly generated and have no special meaning.
The default p2p port for Testnet 4 is `48333`.
The rules used by Testnet 4 are backwards compatible to the rules of Testnet 3. Existing software that implements support for Testnet 3 would only require addition of the network parameters (magic number, genesis block, etc.) to be able to follow Testnet 4.
However, implementations that only implement Testnet 3's rules would accept a chain that violates Testnet 4's rules and are therefore susceptible to being forked off. It is recommended that any implementations check blocks in regard to all the new rules of Testnet 4 and reject blocks that fail to comply.
Pull request at https://github.com/bitcoin/bitcoin/pull/29775
This document is licensed under the Creative Commons CC0 1.0 Universal license.