The timewarp bug
A flaw in Bitcoin's difficulty adjustment that lets a hashrate majority lower difficulty by faking block timestamps; BIP-54 proposes the fix.
The wiki's angle: the timewarp fix is the headline item in the Consensus Cleanup that Robin Linus discussed on S17 E48.[3][2]
The bug
Optech describes time warp as “an exploit of Bitcoin's difficulty adjustment algorithm that allows miners controlling a large amount of hashrate to prevent difficulty from increasing even as the rate of block production increases”[1]. Header times only need to exceed the median of the previous 11 blocks, so a majority can keep most timestamps low and set the last block of each 2016-block period to the current time[1]. Repeated, this halves difficulty and lets miners speed up block production[1].
Consequences
BIP-54 says that “In the worst case, an attacker can bring down the difficulty to its minimum within 38 days of starting the attack”[2]. Optech notes the original fear that miners could claim all remaining subsidy, and that faster blocks and slower median time could also harm timelocked contracts and overload nodes[1].
The fix
BIP-54 fixes it “by preventing the timestamp of the first block of a difficulty period from being lower than the previous block's, with a two-hour grace period”[2]. An earlier proposal used a ten-minute grace period, which was adopted for testnet4[2]. See Great Consensus Cleanup and Antoine Poinsot[2].
References
- secondaryBitcoin Optech topic, “Time warp” [archived]
- primaryBIP-54, “Consensus Cleanup” (Antoine Poinsot, Matt Corallo) [archived]
- episodeS17 E48: Robin Linus on Peter Todd's guess of a 2029 Great Consensus Cleanup▶ listen at 39:14timestamp transcript-derived, pending a listen [archived]