<p>MTP is defined as the median timestamp of the last 11 blocks.</p>
<p>BIP 9 determines a block height based on MTP. Every 2016 blocks BIP 9 says &quot;Does this next block have a MTP past start/timeout time?&quot;</p>
<p>You would expect to be able to predict the block height corresponding to a certain future BIP 9 MTP (start time or timeout). For this prediction to turn out to be wrong a malicious miner (or multiple miners) would have to manipulate the timestamp on at least 6 (median of 11) of the 11 blocks. Or alternatively miners could stop mining to deliberately attempt to falsify your predicted block height. This would obviously be very expensive as they would be foregoing potential block rewards.</p>

CC BY-SA 4.0
2021-04-18T18:39:26.103Z
2021-04-18T18:39:26.103Z
Michael Folkson
<p>There is only a single concept of Median Time Past (MTP) in Bitcoin, the median time of a block and the 10 blocks preceding it on the same block chain.  MTP has always been used in Bitcoin as part of the rules nodes use to determine whether a block has a valid nTime field in its header.  Those rules are:</p>
<ol>
<li><p>The nTime of a block must be greater than the MTP of its parent block.  E.g., if the MTP of a block is <code>1618782748</code> (the actual MTP of the most recent block as I write this), then the nTime of the next block must be <code>1618782748 + 1</code>.</p>
</li>
<li><p>The nTime of a block in UTC must not be more than two hours in the future according to the UTC clock on the computer of the local node.</p>
</li>
</ol>
<p>These two rules allow the Bitcoin Protocol, which has no direct way to determine the time, to bound the range of allowed times.  That's important, because the times provided in block headers are used to calculate difficulty adjustments that try to keep average block production at roughly one block every ten minutes.  This use of MTP has existed since Bitcoin 0.1.  (Those rules alone haven proven to be good enough so far, but at least one additional rule is needed to prevent miners from significantly manipulating difficulty; see the <em>time warp</em> attack for details about the problem and the proposed Consensus Cleanup soft fork for a solution.)</p>
<p>MTP has the useful property that it is monotonically increasing---it only goes up, never down (assuming no block chain reorgs).  BIP9 takes advantage of this property to avoid having to deal with cases where time moves backwards.</p>
<p>MTP also has the useful property that it's out of the control of a miner creating a single block (they can, at most, choose between two possible options whose precise values were set by previous miners).  BIP113 takes advantage of this property to eliminate an incentive problem related to timelocked transactions where miners would always be encouraged to mine blocks almost two hours in the future.  That wouldn't be a major problem, but it was nice to allow miners to continue reporting accurate times for their blocks according to their own clocks.</p>
<p>In summary, Bitcoin doesn't have three different MTPs---it has one monotonic clock that is used in three different contexts.</p>

CC BY-SA 4.0
2021-04-18T23:24:35.980Z
2021-04-19T00:39:31.117Z
2021-04-19T00:39:31.117Z
David A. Harding
<p>I think there are 3 different MTPs (median time past) in Bitcoin (though this may be incorrect). David Harding said on IRC that there was a MTP in Bitcoin v0.1 (Satoshi's first release). There is also MTP as used in BIP 9 and then there is MTP as defined in <a href="https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki" rel="nofollow noreferrer">BIP 113</a>.</p>
<p>If indeed there are 3 different MTPs in Bitcoin, why? What was the motivation?</p>

CC BY-SA 4.0
2021-04-18T20:04:49.077Z
What do you mean three different ones? They're all the same: the median timestamp of the past 11 blocks.
Pieter Wuille
<activation-mechanism><bip9-version-bits><bip8-version-bits>
What are the differences between the various MTPs in Bitcoin?
Michael Folkson
# What are the differences between the various MTPs in Bitcoin?

(Asked by: username_0 on 2021-04-18)

I think there are 3 different MTPs (median time past) in Bitcoin (though this may be incorrect). username_2 username_2 said on IRC that there was a MTP in Bitcoin v0.1 (Satoshi's first release). There is also MTP as used in BIP 9 and then there is MTP as defined in [BIP 113](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki).

If indeed there are 3 different MTPs in Bitcoin, why? What was the motivation?

**Tags:** activation-mechanism, bip9-version-bits, bip8-version-bits

> **Comments:**
> **username_1**: What do you mean three different ones? They're all the same: the median timestamp of the past 11 blocks.  

---

## 2 answers

### Answer by username_2 on 2021-04-18. Score: 6 | Accepted answer

There is only a single concept of Median Time Past (MTP) in Bitcoin, the median time of a block and the 10 blocks preceding it on the same block chain. MTP has always been used in Bitcoin as part of the rules nodes use to determine whether a block has a valid nTime field in its header. Those rules are:

1. The nTime of a block must be greater than the MTP of its parent block. E.g., if the MTP of a block is `1618782748` (the actual MTP of the most recent block as I write this), then the nTime of the next block must be `1618782748 + 1`.
2. The nTime of a block in UTC must not be more than two hours in the future according to the UTC clock on the computer of the local node.

These two rules allow the Bitcoin Protocol, which has no direct way to determine the time, to bound the range of allowed times. That's important, because the times provided in block headers are used to calculate difficulty adjustments that try to keep average block production at roughly one block every ten minutes. This use of MTP has existed since Bitcoin 0.1. (Those rules alone haven proven to be good enough so far, but at least one additional rule is needed to prevent miners from significantly manipulating difficulty; see the *time warp* attack for details about the problem and the proposed Consensus Cleanup soft fork for a solution.)

MTP has the useful property that it is monotonically increasing---it only goes up, never down (assuming no block chain reorgs). BIP9 takes advantage of this property to avoid having to deal with cases where time moves backwards.

MTP also has the useful property that it's out of the control of a miner creating a single block (they can, at most, choose between two possible options whose precise values were set by previous miners). BIP113 takes advantage of this property to eliminate an incentive problem related to timelocked transactions where miners would always be encouraged to mine blocks almost two hours in the future. That wouldn't be a major problem, but it was nice to allow miners to continue reporting accurate times for their blocks according to their own clocks.

In summary, Bitcoin doesn't have three different MTPs---it has one monotonic clock that is used in three different contexts.


---

### Answer by username_0 on 2021-04-18. Score: 0

MTP is defined as the median timestamp of the last 11 blocks.

BIP 9 determines a block height based on MTP. Every 2016 blocks BIP 9 says "Does this next block have a MTP past start/timeout time?"

You would expect to be able to predict the block height corresponding to a certain future BIP 9 MTP (start time or timeout). For this prediction to turn out to be wrong a malicious miner (or multiple miners) would have to manipulate the timestamp on at least 6 (median of 11) of the 11 blocks. Or alternatively miners could stop mining to deliberately attempt to falsify your predicted block height. This would obviously be very expensive as they would be foregoing potential block rewards.


---

