While all the nodes operate on their local time (i.e. the local time of the computer they are being run on) large differences in time between nodes are not allowed. If you are really out of sync with an NTP server, you will experience problems with syncing blocks, consensus, etc. So while not strictly enforced, it is necessary to have accurate local time.
As for the attack you are describing, Ethereum has some checks in place:
- In PoW (Ethash) your block will be accepted if you are 15 seconds ahead (or less). If you are trying to propagate a block with a stale timestamp, the block will be instantly rejected.
var (
...
allowedFutureBlockTime = 15 * time.Second
...
)
...
if header.Time > uint64(time.Now().Add(allowedFutureBlockTime).Unix()) {
return consensus.ErrFutureBlock
}
...
...
if header.Time <= parent.Time {
return errZeroBlockTime
}
- In PoA (Clique) nodes don't get any leeway to propagate "blocks from the future".
// Don't waste time checking blocks from the future
if header.Time > uint64(time.Now().Unix()) {
return consensus.ErrFutureBlock
}
So to summarise: you are absolutely right about the network not allowing blocks that have a delta in time that is too large.
Edit. Clarification from comments: it's really all about the majority of clients (the 51%). If the majority of clients disable dagger-hashimoto (PoW) block verification you can propagate bogus blocks, etc. So it's essential for clients to operate on the same protocol - this ensures consensus between all of them.