1

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 BIP 113.

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

1
  • 1
    What do you mean three different ones? They're all the same: the median timestamp of the past 11 blocks. Apr 18, 2021 at 20:04

2 Answers 2

6

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.

0
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.