On bitcoin’s two “times”
This is just a follow up on comments in the thread about current wallet nLocktime practices. This is an exposition of height-based computing on bitcoin, and a potential reason it may have a renaissance in the future.
The bitcoin network was bootstrapped on it’s own timestamps (blocks). The height a transaction is committed to a block is the ultimate record, and most granular record, of the time it was spent. The standard Unix timestamps in a block header would never be used internally to resolve when a transaction was spent, because miners can fudge the time they write in a block header. All time logic started with heights as a base unit.
There is a Median Time Past (MTP) timestamp service on bitcoin, which is a derived aggregate byproduct of attested block unix timestamps. It’s created as a side effect of bitcoin’s primary height based timestamping service.
Since 2015, there have been two fairly powerful ways to program bitcoin on an absolute-basis (OP_CLV), or rolling basis (OP_CSV). Both of these OP_CODES came with functionality to enable using the primary timestamps (height) or the more ergonomic unix epoch timestamps (defined in BIP-113’s median time-past as endpoint).
The time op_code upgrades accommodated two ways of coding time on bitcoin. The pluralistic viewpoints about timestamps are as follows:
| Height (primary) |
Unix Epoch (derived) |
| Blocks are timestamps |
Unix epochs are timestamps |
| Blocks timestamp transactions |
Block headers include timestamps |
| Blockchain is a timestamp service |
Bitcoin has a timestamp service |
| Time is measured in blocks |
Time is measured in seconds and minutes |
| We can know what height it is |
We can know an aggregate time that has passed |
| Timelocks overflow after 500,000,000 |
Timelocks overflow in 2108 |
Both of the above columns are valid statements about time and timestamps.
For the last ten years, it hasn’t really mattered which definition a time-locking system used. But there MAY be a strong case in the future for many types of financial instruments to use heights over MTP.
When blocks are slow, and the price is low, and things are going great, it can be really tempting to use the conventional definition of “timestamp” (MTP epoch) exclusively in defi contracts. And for contracts among known parties with signed spending paths, the derived epoch usage of the word time is totally fine.
However, if blocks are fast, and there are lots of contracts with MEV on the network with real money on the line, and if miners or institutional traders can find a way to game the MTP timestamps, they inevitability will begin to explore gaming MTP.
As a minority chain with low hashrate, it is somewhat trivial for a well capitalized actor to mine a block (or whole series of blocks), in the same way some people can DDoS all the major exchanges and somehow assure their trades clear. We can assume, as markets develop, if there is a pot of money to be had by gaming MTP that is greater than the cost of gaming MTP, then a well capitalized actor will take that money.
The detractors of decentralized finance seem to love financing market failures then decrying the failures they exploited. If, down the road, a well capitalized actor begins flash-mining chains of blocks to exploit mean time past, they can be expected to also turn around to decry that the system is unfair and rigged against normal users/investors.
The CashScript developer guide [archive] calls the signed and MEV paradigms the “Happy Case” and the “Adversarial Case” and categorically discourages contact developers from creating self-funded MEV-powered anyone-can-spend contracts. Much of the argument against using MEV on Bitcoin Cash is limited to the fact MEV is seen as bad on ETH. The potential, resilience and reliability of a system with eight billion potential executors is largely neglected. However, a number of contract systems have employed MEV and anyone-can-spend contracts with pretty great results.
If open markets using MEV systems with MTP timestamps begin to get gamed on a regular basis, there will be two obvious pathways to toward a fairer system. The slow path would be an upgrade the BIP-113 MTP definition through the CHIP process as a counter measure. Or alternatively, app devs can immediately begin deploying new contracts version using the OG non-MTP timestamps.
Depending on how far into the future an MTP contract system has been programed (decades/centuries), it may not be practical to revert to heights. If OP_CLV and OP_CSV continue to function as before with the old block heights, it may be somewhat maddening for new developers to convert by hand between new and old heights displayed in wallets and block explorers, especially if none of the tooling in the ecosystem supports it.
If block heights simply keep incrementing at CHIP activation, then future defi contract system developers will have to convert between new and old block heights by finding the intercept at the activation height and scaling from there. It’s a simple calculation about as difficult as converting from Fahrenheit to Celsius.
Two alternatives have been proposed to eliminate the need for that calculation. Blocks could increment by 0.1 after activation instead of a whole number; this keeps the old timescale. Or the block height could be increased 10X at activation and old blocks numbers (pre-activation) could be displayed with an extra zero in wallets or explorers that wanted that.
Regardless, apps that take the long view on the “Happy MEV” trail can keep showing a height-based block time equivalent calculated from the tick API. It would just be swell if all wallets and block explorers shared in the benefits of the long game by default.
As previously stated, I think the nomenclature the ecosystem ultimately uses for heights is NOT a blocking concern for this CHIP. All this is just to articulate the hidden value of continuing to accomidate the height-based times as a primary feature.