Summary
Invalidate any block whose timestamp is more than 20 minutes than its previous block's timestamp, after block height 151,200 (epoch 75 boundary).
Motivation
Testnet4's min-difficulty rule (allowing difficulty-1 blocks after 20 minutes) is being exploited, causing ~85-90% of blocks to be CPU-mined min-difficulty blocks. This results in a race of CPU miners broadcasting blocks at exactly the second that it's acceptable. This race is so intense that CPU miners have figured out sending empty blocks, as they propagate faster than those that contain transactions, resulting in a network where transactions are confirmed at only the remaining ASIC blocks, that have ~1 hour average block times.
After the fork, min difficulty blocks will no longer be allowed, as blocks that have a timestamp longer than 20 minutes than their previous blocks become invalid.
Previously, PR #34420 addressed the same issue, but the change was a hard fork. The current soft fork proposal fixes the problem for non-upgraded nodes as long as majority of the hashrate is mining on upgraded clients, and therefore fixes the problem with the least network disruption.
Changes
- Add
min_difficulty_blocks_fix_heightconsensus parameter (default0= disabled). - Set fork height to 151,200 for testnet4 (epoch 75 boundary).
- In
ContextualCheckBlockHeader(), reject any block whose timestamp exceeds the previous block's timestamp by more than2 * nPowTargetSpacing(1200 seconds on testnet4) once the activation height is reached. Because the min-difficulty rule only kicks in when the inter-block gap is strictly greater than2 * nPowTargetSpacing, capping the gap at exactly that boundary makes min-difficulty blocks impossible -- without touching the min-difficulty rule itself. - Add
GetMaximumTime()innode/minermirroringGetMinimumTime(), and clamp candidate block timestamps (both inBlockAssembler::CreateNewBlock()andUpdateTime()) so thatgetblocktemplatenever returns acurtimethat would produce a block rejected by the new rule. - Add unit tests covering boundary behavior of
GetMaximumTimeand clamping behavior ofUpdateTime.
Soft fork properties
This is a strict tightening of consensus rules:
- Any block valid under the new rule is also valid under the old rules.
- Blocks at heights below 151,200 are completely unaffected.
- Non-upgraded nodes continue to accept blocks mined by upgraded miners (they satisfy the old ruleset). Propagation to non-upgraded nodes happens naturally through normal chain gossip, so no coordinated upgrade is required beyond sufficient hashrate majority adopting the rule by the activation height.
Test Plan
./build/bin/test_bitcoin --run_test=testnet4_miner_tests-- all boundary and clamping tests pass.- Regression:
./build/bin/test_bitcoin --run_test=miner_tests,pow_tests,validation_tests,validation_block_tests-- no regressions. - Manual: pre-activation behavior on live testnet4 matches expectations (
getblocktemplatereturns acurtimebelow the prospective cap).
Discussion
bitcoin-dev mailing list thread [#1](/bitcoin-bitcoin/1/) bitcoin-dev mailing list thread [#2](/bitcoin-bitcoin/2/) Bitcointalk thread Supersedes hard fork proposal #34420