[Ethereum] How do Ethereum mining nodes maintain a time consistent with the network

miningNetworknodestimestamp

We have established that the timestamp on a parent block has to be before the timestamp of a child block in Can a child block have an earlier timestamp than the parent block?.

How are differences in the clock settings on different miners' computers taken into account?

Best Answer

Ethereum nodes (regardless of mining) need to have an accurate time, otherwise they will not be able to connect to peers and to the network (https://github.com/ethereum/go-ethereum/wiki/Connecting-to-the-network).

Small differences in time are tolerated by nodes, but as one node's time gets further away from Coordinated UTC Time (per NTP), its number of peers will reduce and eventually it will have zero peers and be disconnected from the network.

A miner M wants to have a time consistent with the network, so that other miners will build upon the blocks that M mines.

Blocks must be within reasonable Unix time, otherwise miners are unlikely to build upon blocks with unreasonable timestamps. (Example)

EDIT: For clarity, in Ethereum, the only rule about timestamps is that the timestamp must be greater than the previous timestamp. There is no other rule: old docs such as the white paper and wiki may mention 15 minutes (900 seconds), and here are the corrections:

White paper:

Check that the timestamp of the block is greater than that of the referenced previous block and less than 15 minutes into the future

wiki:

Is block.timestamp <= now + 900 and is block.timestamp > parent.timestamp? (strictly greater)

Unfortunately, the outdated, wrong information has been picked up by others such as here and here.

The Yellow paper is the formal specification and see Block Header Validity (section 4.4.4, equation 48).

Related Topic