Ethereum Mining – How is the Mining Difficulty Calculated?

difficultydifficulty-bombethermining

Having read various pieces of documentation, it's still not completely clear to me what dictates the difficulty rise, and how Ethereum difficulty levels differ to Bitcoin.

In the past week difficulty has jumped from around 11 to over 17, whilst GH/s has fluctuated between 800.00 – 1400.00 but with no clear correlation between the two.

Has the "difficulty bomb" now been introduced? And if yes, is there any way for approximating or calculating how much difficulty will likely rise by in the next 6-12 months?

Related: If Serenity / PoS is unlikely to be introduced until early next year, has there been any suggestion from the dev team that the effects of this "difficulty bomb" will be reduced in either the homestead or metropolis releases?

Best Answer

From https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2.md:

Mining difficulty is calculated from the time difference between blocks. The exact formula will change in Homestead. The symbol // in the following denotes integer division.

  • Frontier:

block_diff = parent_diff + parent_diff // 2048 * (1 if block_timestamp - parent_timestamp < 13 else -1) + int(2**((block.number // 100000) - 2))

  • Homestead:

block_diff = parent_diff + parent_diff // 2048 * max(1 - (block_timestamp - parent_timestamp) // 10, -99) + int(2**((block.number // 100000) - 2))

EDIT:

The problem with the frontier formula and the reason for the change was that the frontier version doesn't take into account how far off from 13 seconds the block time was. A block mined 1 second after the previous one has the same effect on the difficulty as one mined after 12 seconds. This causes block difficulty to adjust to a median block time rather than a mean.

Again, check out the EIP for more details.