Zcash in Simplified Technical English

This page is the Simplified Technical English version of ZIP 113. The source ZIP is the normative text. Read the writing rules to understand the marked words.

ZIP 113: Median Time Past as endpoint for lock-time calculations

ZIP: 113
Title: Median Time Past as endpoint for lock-time calculations
Owners: Daira-Emma Hopwood <daira@jacaranda.org>
Credits: Thomas Kerin
         Mark Friedenbach
         Gregory Maxwell
Category: Consensus
Status: Draft
Created: 2019-06-07
License: MIT

Terminology

On this page, STE words are in the place of the BCP 14 key words of the source. Refer to the key word table.

Abstract

This ZIP is a proposal for new semantics for one test. The test is if a time-locked transaction can be in a block. In the test, the median of the last PoWMedianBlockSpan (11) blocks is used in the place of the timestamp of the block. Thus this median value increases monotonically with each block.

Motivation

At this time, transactions are excluded from a block if the present time or block height is less than or equal to the locktime. In the consensus rules, block timestamps do not have to be in a strict order. Thus miners have an unwanted incentive to give a false time for their blocks. With a false time, a miner can include transactions that are not yet mature by the wall-clock time. Thus the miner can collect more fees.

In this ZIP, the proposal is to compare the locktime with the median of the timestamps of the past PoWMedianBlockSpan blocks. The comparison is not with the timestamp of the block that includes the transaction. Under the existing consensus rules, this median value always advances monotonically. Thus, with this change, miners cannot claim more transaction fees with false timestamps for their blocks.

The goal of this ZIP is reliable behavior in locktime calculations. [bip-0065] (CHECKLOCKTIMEVERIFY) has a requirement for this reliable behavior. The goal is also behavior that is the same as in [zip-0112] (CHECKSEQUENCEVERIFY).

The change also agrees with the use of Median Time Past in difficulty adjustment. That use is specified in section 7.6.3 of [protocol].

Specification

The definition of PoWMedianBlockSpan is in [protocol] section 5.3. The definition of the median function is in [protocol] section 7.6.3.

The Median Time Past of a block is the median of the timestamps of the previous PoWMedianBlockSpan blocks. This value is calculated by MedianTime(height) in [protocol] section 7.6.3.

The values for transaction locktime stay the same. The only difference is in the calculation that shows if a transaction can be included. After activation of this ZIP, the lock-time constraints of a transaction must be checked against the Median Time Past of the block of the transaction.

FIXME: Make this a full specification that does not depend on the zcashd implementation.

Lock-time constraints are checked by the consensus method IsFinalTx(). The block time is one parameter of this method. The proposal of this ZIP is a change to the calls to IsFinalTx() in consensus code. After activation, the return value of GetMedianTimePast(pindexPrev) is the parameter of these calls, in the place of the block time.

The new rule applies to all transactions. This includes the coinbase transaction.

Reference Implementation

The reference implementation will be based on Bitcoin pull request 6566.

Acknowledgements

This ZIP is based on BIP 113. Thomas Kerin and Mark Friedenbach wrote BIP 113.

Mark Friedenbach designed and wrote the reference implementation for Bitcoin.

Gregory Maxwell gave the original idea in #bitcoin-wizards on 2013-07-16 and 2013-07-17.

Deployment

At the time of writing, there was no decision about the network upgrade that will include this ZIP. It is possible that no network upgrade will include it.

This ZIP is designed for deployment at the same time as [zip-0068] and [zip-0112].

Compatibility

After Blossom, the target block spacing is 75 seconds. At this spacing, the confirmation of a transaction with time-based lock-time will be approximately 7.5 minutes later than expected under the old rules. There are no known compatibility problems with existing protocols because of this delay. This delay is less than in Bitcoin, because the target block spacing in Zcash is shorter.

References

[RFC2119]
Key words for use in RFCs to Indicate Requirement Levels
[protocol]
Zcash Protocol Specification, Version 2019.0.1 or later [Overwinter+Sapling+Blossom]
[bip-0065]
BIP 65: OP_CHECKLOCKTIMEVERIFY
[zip-0068]
ZIP 68: Consensus-enforced transaction replacement signaled via sequence numbers
[zip-0112]
ZIP 112: CHECKSEQUENCEVERIFY