EIPs Explained

EIP-1482 · Stagnant · Core · 2018-10-09

EIP-1482: Define a maximum block timestamp drift

Proposed writing down an explicit rule for block timestamps: later than the parent block and at most 15 seconds ahead of the validator's clock, matching what Geth and Parity already enforced.

What problem does it solve?

The Yellow Paper defined a block's timestamp as "the reasonable output of Unix's time() at this block's inception". What counts as "reasonable" was never specified. That left smart contract developers unsure how much they could trust block.timestamp, and in principle allowed different clients to disagree about which blocks are valid.

In practice the two major clients of the time, Geth and Parity, already applied the same check. EIP-1482 proposes making that de facto rule part of the specification.

How it works

No new behaviour, just an explicit definition. For block validation a timestamp must:

  1. be strictly greater than the parent block's timestamp, and
  2. be no more than 15 seconds ahead of the validating node's own system time.

A block that is too far in the future is rejected (clients may hold it until it becomes valid). A block producer therefore has some freedom to choose the timestamp, but only within a narrow window.

Sample code

The validation rule as pseudocode:

MAX_FUTURE_DRIFT = 15  # seconds

def validate_timestamp(block, parent, now):
    if block.timestamp <= parent.timestamp:
        raise InvalidBlock("timestamp not after parent")
    if block.timestamp > now + MAX_FUTURE_DRIFT:
        raise FutureBlock("timestamp too far in the future")

What this means for contract authors: treat block.timestamp as approximate.

// Fine: deadlines measured in minutes, hours or days
require(block.timestamp <= auctionEnd, "auction over");

// Risky: logic that depends on the exact second (e.g. randomness, sub-minute windows)

Things to know

  • Status is Stagnant; it was never adopted as a formal specification change.
  • The spec notes that some very early mainnet blocks might break the rule, so it might need to be relaxed for historical blocks.
  • Since the move to proof-of-stake (EIP-3675), execution-layer block timestamps are tied to the beacon chain's fixed slot times, so producers no longer have the free choice this EIP was trying to bound. The general advice still holds: never use timestamps as a source of randomness.
  • EIP-1985 separately proposed an upper range for timestamp values in the EVM.

#consensus #timestamp #core #specification

Details

Authors
Maurelian (@Maurelian)
Status
Stagnant
Type
Standards Track / Core
Created
2018-10-09

Machine-readable: Markdown · JSON