From From EIP 2, the Homestead difficulty adjustment algorithm is:

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

where // is the integer division operator, eg. 6 // 2 = 3, 7 // 2 = 3, 8 // 2 = 4.

Due to differences in the clock settings on different miner's computers, can block_timestamp be before parent_timestamp?

And if block_timestamp CANNOT be before parent_timestamp, how are differences in the clock settings on different miner's computers taken into account?

EDIT June 12 2016 I've moved the second question above into How do Ethereum mining nodes maintain a time consistent with the network?

This question was prompted by the question How does the Ethereum Homestead difficulty adjustment algorithm work?, which was prompted by the question What was the first block mined with Homestead?

Other related Q&As:

2 Answers 2


block_timestamp CANNOT be before parent_timestamp

This is enforced by the protocol, see yellow paper:

Hs is the timestamp of block H and must fulfil the relation: (48) Hs > P(H)Hs

Also in my empirical research on Homesteads blocktimes there was not a single negative value.

  • Out of interest, was there any 0 values? Jun 12, 2016 at 0:36
  • 1
    No zeros, but a substantial amount of 1s times Jun 12, 2016 at 4:35
  • 1
    Note that the protocol has no other restrictions on timestamps; some game theory is what prevents timestamps from being far out in the future: ethereum.stackexchange.com/questions/5927/…
    – eth
    Jun 12, 2016 at 8:11

As mentioned, the protocol prevents this from happening.

As for miners' clocks, the protocol can't tell what their actual clock says. A miner could simply lie, put a different timestamp in, and the protocol would be none-the-wiser. The protocol attempts to prevent this by the difficulty adjustment formula.

To quote the Yellow Paper:

This mechanism enforces a homeostasis in terms of the time between blocks; a smaller period between the last two blocks results in an increase in the difficulty level and thus additional computation required, lengthening the likely next period. Conversely, if the period is too large, the difficulty, and expected time to the next block, is reduced.

The Homestead difficulty formula change was to address the very issue of miners reporting wrong timestamps.

Your Answer

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

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