9

Right now (may 2018), Verge (an altcoin with proof of work) was attacked by time-warp attack. More can be read here

https://blog.theabacus.io/the-verge-hack-explained-7942f63a3017

What exactly prevents from similar attack to happen to Bitcoin?

Verge has different hash logic (more frequent retarget, more concurrent hash algorithms), but the logic of the attack should, in my reading, apply also to bitcoin.

Since it did never happen in Bitcoin, I probably missed something. How is Verge different from Bitcoin that this happened in Verge, but not in bitcoin?

1 Answer 1

10

Nothing directly prevents it in Bitcoin, and indeed the attack has been demonstrated on testnet3 many times---it's the primary reason that testnet3 currently has almost three times as many blocks as Bitcoin, despite being launched several years after Bitcoin mainnet and with a something similar to[1] Bitcoin's 10-minute average block interval.

Indirectly, there are several reasons the time warp attack is less practical on Bitcoin mainnet than testnet3 or altcoins like Verge:

  1. Obvious: once blocks used in a time-warp attack are broadcast, anyone can see that median-time-past (the monotonic clock in Bitcoin) is lagging far behind real time.

  2. Slow: the time warp attack exploits the formula used for retargeting, but retargeting only runs once every 2,016 blocks (two weeks at normal rate) and can only reduce difficulty by a maximum of 75% per period. Now, 75% is a lot, but so is spending two weeks executing a publicly-visible attack. Further difficulty decreases can be executed faster due to the modified difficulty, but they're still pretty slow: 3.5 days for the second retarget; about 1 day for the third; about 6 hours for the fourth; etc...

  3. Easily fixable by miners: if honest miners control the majority of the hashrate, they can simply refuse to build on top of blocks whose timestamps are too far in the past. If median-time-past is restored to its normal trailing average before the end of the initial 2,016-block retarget period, difficulty won't be changed any more than normal.

If all these reasons do indeed provide indirect mitigation, then why do we see the attack on testnet3 every few months? Mainly because testnet3 uses the same SHA256d proof of work function as Bitcoin and so anyone who wants to mine blocks really quick can hook up some modern ASIC miners to create a bunch of testnet blocks quickly. This would normally rapidly increase difficulty, but the increase is prevented using the time warp attack. That said, in at least one case in the past where a time warp attacker made testnet3 unusable for an extended amount of time, some generous person pointed their own huge mining rig at testnet3 to overwhelm the attacker and bring difficulty back up.

On Bitcoin mainnet, if the attack was ever executed, I think the story would be different. Within days, a large percentage of the userbase would know the attack was ramping up and would start to pressure honest miners to reject the attacker's blocks. I personally expect miners would comply (as the next step would be for people to start throwing around phrases like "PoW function change"), which would defeat the attacker and cost him expected revenue for every rejected block.

If attackers expect the scenario would play out basically the same way I think it would, then there's no point in them starting the attack in the first place---which I think is what ultimately prevents time warp attacks on Bitcoin.

[1] Testnet3, unlike Bitcoin, has a rule that if no block has been mined within 20 minutes (according to block header time), that a miner can create a difficulty-1 block (the lowest difficulty). That means that even completely honest mining on testnet3 is faster than on mainnet, as on mainnet something like 20% of blocks take longer than 20 minutes to find.


Some extra notes:

  1. A fork could change the retarget calculation to use median-time-past instead of raw block header time. This could fix the time warp attack on Bitcoin, but it would probably have to be a hard fork.

  2. Since the BIP113 soft fork, median-time-past has been used to restrict which nLockTime transactions miners can include in their blocks. Not many transactions use nLockTime with a time at present, but if there was a time warp attack, users could start doing so to create a large fee incentive for miners to bring median-time-past closer to real time.

5
  • It's interesting that most of these defenses are social rather than technical. It depends on majority of miners not colluding. May 23, 2018 at 0:12
  • 4
    @KarelBílek: If a majority (>50%) of miners are colluding, then you've already lost.
    – Kevin
    May 23, 2018 at 0:49
  • 3
    Also, on testnet3, due to a quirk of how the difficult readjustment works, if the last block in a retarget period takes longer than 20 minutes to find, it will not only reset that block's difficulty to 1 but all blocks for the next retarget period will also have a difficulty of 1. That makes testnet3 easily gameable to have a very low difficulty.
    – Andrew Chow
    May 23, 2018 at 5:59
  • @David A. Harding. In this sentence: "Further difficulty increases can be executed faster due to the modified difficulty", do you mean “decreases” or the generic “changes” rather than "increases" ?
    – dbkeys
    Oct 3, 2018 at 9:48
  • 1
    @dbkeys fixed, I meant "decreases". Thanks. Oct 3, 2018 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.