1

According to the Yellow Paper, the restrictions on block timestamps, Hs, are,

  • Hs ∈ ℙ256 (Mathematical term #35) ― ①,
  • and Hs > P(H)Hs (Mathematical term #48 and #56) ― ②,

where P(H)Hs is the parent (previous) block's timestamp, and ℙ256 is a set of natural numbers less than 2256.

It seems the Yellow Paper allows future blocks (blocks that have a future timestamp) ― ③, as there's no restriction apart from ① and ②.

But how do Ethereum clients actually cope with them? Do they really accept any future blocks as the Yellow Paper allows?

I took a quick glance at the source code of geth and cpp-ethereum, and it seems ErrFutureBlock and "allowFutureBlocks" are relevant, but I couldn't fully understand what they are doing with them.

If there's something I missed or was wrong above, please let me know.

1
  • 1
    This is an excellent question. Pretty math! Commented Oct 31, 2017 at 12:06

1 Answer 1

3

I read the source code of Eth, Geth, Parity, pyethapp.

  • Eth keeps future blocks (in m_future map object) and later processes them at the time specified in the timestamp.
  • Geth and Parity accept future blocks, but only maximum 30 seconds future ones. Otherwise, discard. So clever.

If they were naïve clients, so implemented the block timestamp validation with only the restrictions on the Yellow Paper, they would have integer overflow vulnerabilities may lead to Denial of Service.

In short

Do they really accept any future blocks as the Yellow Paper allows?

No.

3
  • Out of interest, if Geth and Parity get a block with a timestamp 29 seconds in the future, do they update the timestamp of the block they're mining to be later than the one they just accepted, or do they just keep trying to mine a block that, if successful, they would consider invalid because the timestamp goes backwards? Commented Oct 2, 2017 at 1:50
  • 1
    @EdmundEdgar Good catch. Now I'm reading the source code of Parity and Geth about what you said. I'll comment as my investigation gets done. Commented Oct 2, 2017 at 4:44
  • @EdmundEdgar Done. They update the timestamp of the block they're mining to be 1 second later than the future block they just accepted. Geth waits (sleeps) for some seconds not to mine future blocks, whereas Parity doesn't. :) Commented Oct 2, 2017 at 13:40

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.