Glossary

Network-Adjusted Time

Network-adjusted time is a Bitcoin node's local clock offset by the median time reported by connected peers, used historically for block timestamp validation.

Key Takeaways

  • Network-adjusted time is a node's system clock corrected by the median offset collected from connected peers during the version handshake, helping nodes agree on roughly what time it is even when individual clocks drift.
  • A safety cap of 70 minutes prevents malicious peers from skewing a node's perception of time too far, limiting the impact of time-warp attacks and other timestamp manipulation.
  • Bitcoin Core v27.0 removed network-adjusted time from consensus validation, replacing it with unadjusted system time and a warning when a node's clock drifts significantly from peers.

What Is Network-Adjusted Time?

Network-adjusted time is the mechanism Bitcoin nodes have historically used to establish a shared sense of "now" across a decentralized network where no central clock exists. Rather than trusting its own system clock alone, a node collects time offsets from its peers and applies the median offset to its local clock. The result is an adjusted timestamp that reflects the network's approximate consensus on the current time.

This matters because block timestamps in Bitcoin are not arbitrary: they must satisfy consensus rules that bound how far in the past or future a timestamp can be. A node with an inaccurate local clock could reject valid blocks or accept invalid ones. By anchoring its time perception to the network's median, a node reduces the chance that local clock drift causes consensus failures.

The concept originated in Satoshi Nakamoto's original Bitcoin Core implementation and remained part of the consensus logic for over a decade. As of Bitcoin Core v27.0 (released in 2024), adjusted time has been removed from validation and replaced with direct system time, though the peer-offset warning system remains.

How It Works

When a Bitcoin node connects to a peer, the two exchange version messages that include their current UTC timestamps. The receiving node compares the peer's reported time against its own system clock and stores the difference as an offset.

  1. Node A connects to Node B and sends a version message containing its current Unix timestamp
  2. Node B receives the message, computes the offset (peer_time minus local_time), and stores it
  3. This process repeats with each new peer connection, building a collection of offsets
  4. Once at least five peer offsets are collected, the node takes the median of all stored offsets
  5. The median offset is added to the local system clock to produce the network-adjusted time

The 70-Minute Safety Cap

To prevent malicious peers from manipulating a node's time perception, Bitcoin Core enforces a maximum adjustment limit. If the median offset exceeds 70 minutes in either direction, the node ignores it and falls back to its unadjusted system time. This constant is defined in the source code as DEFAULT_MAX_TIME_ADJUSTMENT:

// Maximum amount of time that the node clock
// can be adjusted by peer offsets
static const int64_t DEFAULT_MAX_TIME_ADJUSTMENT = 70 * 60; // 70 minutes in seconds

This cap creates a tradeoff: it allows enough flexibility to correct moderate clock drift (a few minutes is common on consumer hardware), but it limits the damage an attacker controlling several peer connections could inflict. The value was configurable via the now-deprecated -maxtimeadjustment flag.

Sampling Limits

The original implementation only sampled offsets from the first 200 unique peers a node connected to. After 200 samples, the offset collection stopped growing, and the median remained fixed until the node restarted. Additionally, the median was only recalculated when the sample count was odd, which introduced a subtle quirk: after reaching 200 samples (an even number), the offset would never update again.

While this behavior was acknowledged as a bug in Bitcoin Core issue #4521, developers noted it may have provided incidental protection against long-running manipulation attempts. An attacker connecting many peers late in a node's uptime could not influence the already- locked median.

The GetAdjustedTime Function

In the original codebase, the adjusted time was calculated by two key functions:

// Returns the median offset from peer timestamps
int64_t GetTimeOffset() {
    LOCK(cs_nTimeOffset);
    return nTimeOffset;
}

// Returns system time plus the median peer offset
int64_t GetAdjustedTime() {
    return GetTime() + GetTimeOffset();
}

Every time a consensus rule needed to compare a block timestamp against "the current time," it called GetAdjustedTime() rather than reading the raw system clock. This was the single point where peer-reported time influenced consensus validation.

Role in Block Timestamp Validation

Bitcoin enforces two consensus rules on block header timestamps, and network-adjusted time was historically involved in one of them:

  • Past limit: a block's timestamp must be strictly greater than the median-time-past (MTP), which is the median timestamp of the previous 11 blocks. This prevents miners from backdating blocks.
  • Future limit: a block's timestamp must not exceed the node's current time plus two hours. This is where network-adjusted time was used: the "current time" was the adjusted value, not raw system time.

The future-time rule is notable because it was the only consensus rule in Bitcoin that depended on data external to the blockchain itself. Every other rule can be validated deterministically from the chain data alone. This made network-adjusted time a subtle but critical piece of the consensus infrastructure.

Interaction with Timelocks

Timelocks that use absolute timestamps (via OP_CHECKLOCKTIMEVERIFY) are validated against the median-time-past of the current block rather than against network-adjusted time directly. However, because miners set block timestamps within the bounds enforced by adjusted time, the system still indirectly influenced when timelocked transactions could be spent. A node with significantly skewed adjusted time might have a different view of which timelocked outputs were spendable, potentially causing it to reject blocks that most of the network considered valid.

Why It Was Removed

Despite its long history, network-adjusted time carried several well-known weaknesses that led to its removal from Bitcoin Core's consensus logic in v27.0 (via PR #28956):

  • Security assumption: the mechanism implicitly assumed an honest majority among a node's outbound peers. If an attacker controlled enough of a victim's early connections, they could shift the node's adjusted time by up to 70 minutes, enough to cause the node to reject valid blocks or accept blocks with manipulated timestamps.
  • Timestamp overflow bug: a vulnerability disclosed in 2024 (fixed in v0.21.0) showed that signed-integer overflow in version message processing could bypass the 70-minute cap entirely, allowing an attacker to set arbitrary time offsets.
  • Modern NTP availability: when Bitcoin was created in 2009, many consumer systems had unreliable clocks. Today, NTP synchronization is ubiquitous, making the two-hour future window more than sufficient to absorb any realistic clock drift without peer adjustment.
  • Complexity and attack surface: maintaining adjusted time added code complexity and created an additional vector for eclipse attacks, where an attacker isolates a node from the honest network.

The replacement is straightforward: block timestamp validation now uses the unadjusted system clock. If a node's clock is more than 10 minutes off from the median of its peers, it logs a warning so the operator can correct the drift.

Use Cases and Practical Context

Block Validation

The primary use case for network-adjusted time was determining whether an incoming block's timestamp fell within the acceptable future window. Without some form of time agreement, a node with a clock running 90 minutes slow would reject blocks that the rest of the network considers valid, causing it to stall on a stale chain tip.

Mining Timestamp Selection

Miners use the current time when constructing block templates. A miner whose adjusted time is significantly off might produce blocks that other nodes reject for having a timestamp too far in the future. Network-adjusted time historically helped miners stay within the consensus window even if their local clock was slightly wrong.

Network Synchronization

During initial block download, a node validates thousands of historical blocks. The two-hour future-time rule applied to the adjusted time of the validating node, which meant a node syncing in 2026 needed to understand that historical blocks were valid relative to the peers' times when they were originally broadcast, not relative to 2026 system time. The removal of adjusted time simplified this process by anchoring validation to the system clock directly.

Risks and Considerations

Time Manipulation Attacks

Before the 70-minute cap and the eventual removal, an attacker who controlled a majority of a node's peer connections could shift its time perception. This could cause the victim to mine on a fork, reject valid blocks, or accept blocks that the honest network rejects. The time-warp attack is a related but distinct threat that exploits flexibility in block timestamps to manipulate difficulty adjustments, and the Great Consensus Cleanup proposal includes a fix for it.

Eclipse Attack Synergy

Network-adjusted time was especially dangerous in combination with eclipse attacks. If an attacker surrounded a victim with malicious peers (all reporting skewed timestamps), the median offset would shift toward the attacker's desired value. This was bounded by the 70-minute cap but could still cause meaningful disruption, particularly for miners or time-sensitive timelock transactions.

Consensus Divergence Risk

Because adjusted time depended on which peers a node happened to connect to, two nodes could compute different adjusted times and therefore disagree on whether a borderline block timestamp was valid. This non-determinism was a persistent source of concern: it was the only consensus rule where the outcome depended on the node's network conditions rather than purely on blockchain data. The removal in v27.0 eliminated this class of risk entirely.

Layer 2 Implications

For layer 2 protocols like the Lightning Network and Spark, timestamp accuracy matters because timelocked transactions enforce deadlines for channel closures, penalty enforcement, and HTLC resolution. If a node's time perception is skewed, it might misjudge when a timelock has expired, potentially missing a deadline to broadcast a justice transaction or claim an expired HTLC. The move to unadjusted system time makes this behavior more predictable for layer 2 participants who rely on accurate block timestamps.

This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.