Block Timestamp Rules
The two consensus checks a node applies to the time a miner writes into a block header: it must be later than the median of the previous eleven blocks, and it may not be more than two hours ahead of the node's own clock. Both are in Satoshi's 2009 code and both are still in Bitcoin Core's validation.cpp.
A Bitcoin block header carries a 32-bit timestamp that the miner fills in. Nothing forces it to be true. The network has no clock of its own, so the rules do not try to check the time against reality. They check it against the chain and against the validating node, and they give miners a window to work in rather than a point to hit.
The first rule looks backwards. In ContextualCheckBlockHeader in src/validation.cpp, a block is rejected as time-too-old if its timestamp is less than or equal to the median time past of the previous eleven blocks. The median, not the previous block's own stamp, which is why consecutive timestamps are allowed to run backwards: a miner who rolled the time forward while searching for a nonce is not forced to stay ahead of the real clock, and a block from a slow clock is not thrown out. What the median guarantees is that the chain's notion of time never moves backwards, and that one miner cannot hold it back or push it forward, since that takes six of the eleven blocks. The same median is what BIP-113 made the reference for time locks. On mainnet about one block in sixty carries an earlier stamp than the block before it, a count The Time Warp takes from every header up to November 2026.
The second rule looks forwards and works differently. A block whose timestamp is more than MAX_FUTURE_BLOCK_TIME ahead of the node's clock is rejected as time-too-new; the constant is two hours, 7,200 seconds, in src/chain.h. This one is not quite a validity rule. The block is early rather than invalid, and the same node will accept it once the two hours have passed, which is why Bitcoin Core files it under BLOCK_TIME_FUTURE. What it stops is a miner claiming a block took longer to find than it did. Two hours is about 0.6 percent of a two-week window, so even a miner who stamps every block at the limit cannot move the next retarget by much.
Which clock the node compares against has changed once. For most of Bitcoin's life a node compared block times against network-adjusted time: its own clock corrected by the median offset reported by its peers, used only when that offset was under 70 minutes and otherwise ignored (before July 2010 there was no limit at all). Bitcoin Core 27.0 removed that from consensus code. The node now uses plain system time and keeps the peer comparison only to warn an operator whose clock is more than ten minutes off (70 minutes in the 27.x releases). The release notes give the reason: adjusting to peers quietly assumed an honest majority of connections, and the change puts the burden on the operator to keep the system clock right.
Both checks are in the earliest code in the Bitcoin Core repository, from 2009, with the same constants. Satoshi's block generator also set each new block's time to the later of network-adjusted time and median time past plus one. Bitcoin Core's template builder still does the same with system time, and getblocktemplate reports the floor to miners as mintime, which since version 29.0 is raised on the first block of a window to respect the proposed time warp rule, and since 32.1 also on the last block of a window, for BIP-54's second rule. The template uses a ten-minute grace, stricter than BIP-54's two hours. The rules work, as far as anyone can tell, for what they were built to do: stop a lone miner from bending time-locked transactions or the retarget. What they leave open is the seam between two difficulty windows, where nothing compares the first block of one with the last block of the other. That gap is the time warp attack, and closing it is the first rule in BIP-54.
Key takeaways
- Lower bound: a block's timestamp must be strictly greater than the median time past of the eleven blocks before it, which keeps the chain's clock moving forward even though individual timestamps may run backwards
- Upper bound: a block stamped more than 7,200 seconds ahead of the validating node's clock is rejected for now, not forever; it becomes acceptable once the clock catches up, so this one is about acceptance rather than validity
- Since Bitcoin Core 27.0 the node judges block times by its own system clock, not a median of its peers' clocks; since 28.0 it warns when its outbound peers' median clock is more than ten minutes off, so a node operator's clock is now part of staying in consensus
Related chapters
On the mailing list
The topic timeline: Time warp, timestamps and the consensus cleanup (58 threads).
Corrected
-
Was: The entry said Bitcoin Core warns when peers' clocks disagree by 70 minutes or more, that network-adjusted time was capped at 70 minutes, and that the median of eleven cannot be dragged backwards by one miner.
Now: Since Bitcoin Core 28.0 (PR #29623) the node warns when its outbound peers' median clock is more than ten minutes off; 70 minutes applied in 27.x. A peer offset beyond 70 minutes was ignored, not capped, and before July 2010 there was no limit. The median never moves backwards at all; one miner cannot hold it back or push it forward. The entry also notes that templates respect BIP-54's last-block rule since 32.1. Details
Sources (10)
- Bitcoin Core - src/validation.cpp: ContextualCheckBlockHeader rejects a block stamped at or below the previous block's median time past (time-too-old) and one more than MAX_FUTURE_BLOCK_TIME past NodeClock::now() (time-too-new, result BLOCK_TIME_FUTURE)
- Bitcoin Core - src/chain.h: MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60; GetMedianTimePast sorts the last nMedianTimeSpan = 11 block times and returns the middle one
- Bitcoin Core - main.cpp at the repository's first commit (2009): a block is rejected if its time is more than 2 * 60 * 60 past adjusted time or at or below the median time past; a new block's time is the later of adjusted time and median time past plus one
- Bitcoin Core 27.0 release notes (April 2024): network-adjusted time removed from consensus code and replaced with unadjusted system time; the warning for a median time offset of 70 minutes or more is kept (PR #28956)
- Bitcoin Core PR #29623 - Simplify network-adjusted time warning logic (merged 30 April 2024, in 28.0): the node warns when the median clock offset of its last 50 outbound peers is more than ten minutes (src/node/timeoffsets.h, WARN_THRESHOLD)
- Bitcoin Core PR #35949 - miner: Enforce Murch-Zawy rule (BIP54) (merged 7 September 2026, first released in 32.1): getblocktemplate raises mintime on the last block of a window to the window's first block time
- BIP-113 - Median time-past as endpoint for lock-time calculations: consensus rules do not mandate strict ordering of block timestamps, so lock times compare against the median of the past 11 blocks, which the existing rules guarantee advances monotonically
- BIP-54 - Consensus Cleanup: the first block of a difficulty period may not be stamped more than 7,200 seconds before the previous block, and the last block of a period not before its first
- BitMEX Research - Bitcoin's Block Timestamp Protection Rules (30 October 2019, Wayback Machine): a median of eleven means six blocks could be reorganised without time moving backwards; a block too far in the future is early rather than invalid; two hours is a small fraction of two weeks
- BitMEX Research - The Timewarp Attack (31 March 2025, Wayback Machine): two hours is around 0.6 percent of the difficulty adjustment period
Related terms (10)
Published . Revised . One correction logged for this page.
Edit this page on GitHub