Skip to content
ZIPs.tools

ZIP 113

Median Time Past as endpoint for lock-time calculations

  • Draft
Proposal metadata
ID
113
Status
Draft
Category
Consensus
Owners
  • Daira-Emma Hopwood
Created
2019-06-07
License
MIT
Contents
  1. Terminology
  2. Abstract
  3. Motivation
  4. Specification
  5. Reference Implementation
  6. Acknowledgements
  7. Deployment
  8. Compatibility
  9. References
Preamble
ZIP
113
Title
Median Time Past as endpoint for lock-time calculations
Credits
  • Thomas Kerin
  • Mark Friedenbach
  • Gregory Maxwell
Category
Consensus
Status
Draft
Created
2019-06-07
License
MIT

Terminology

The key words "MUST" and "MAY" in this document are to be interpreted as described in RFC 2119.1

Abstract

This ZIP is a proposal to redefine the semantics used in determining a time-locked transaction's eligibility for inclusion in a block. The median of the last PoWMedianBlockSpan (11) blocks is used instead of the block's timestamp, ensuring that it increases monotonically with each block.

Motivation

At present, transactions are excluded from inclusion in a block if the present time or block height is less than or equal to that specified in the locktime. Since the consensus rules do not mandate strict ordering of block timestamps, this has the unfortunate outcome of creating a perverse incentive for miners to lie about the time of their blocks in order to collect more fees by including transactions that by wall clock determination have not yet matured.

This ZIP proposes comparing the locktime against the median of the past PoWMedianBlockSpan blocks' timestamps, rather than the timestamp of the block including the transaction. Existing consensus rules guarantee this value to monotonically advance, thereby removing the capability for miners to claim more transaction fees by lying about the timestamps of their block.

This proposal seeks to ensure reliable behaviour in locktime calculations as required by 2 (CHECKLOCKTIMEVERIFY) and matching the behavior of3 (CHECKSEQUENCEVERIFY). This also matches the use of Median Time Past in difficulty adjustment as specified in section 7.6.3 of4.

Specification

Let PoWMedianBlockSpan be as defined in5 section 5.3, and let the median function be as defined in6 section 7.6.3.

The Median Time Past of a block is specified as the median of the timestamps of the prior PoWMedianBlockSpan blocks, as calculated by MedianTime(height) in7 section 7.6.3.

The values for transaction locktime remain unchanged. The difference is only in the calculation determining whether a transaction can be included. After activation of this ZIP, lock-time constraints of a transaction MUST be checked according to the Median Time Past of the transaction's block.

[FIXME make this a proper specification, independent of the zcashd implementation.]

Lock-time constraints are checked by the consensus method IsFinalTx(). This method takes the block time as one parameter. This ZIP proposes that after activation calls to IsFinalTx() within consensus code use the return value of GetMedianTimePast(pindexPrev) instead.

The new rule applies to all transactions, including the coinbase transaction.

Reference Implementation

This will be based on Bitcoin PR 6566.

Acknowledgements

This ZIP is based on BIP 113, authored by Thomas Kerin and Mark Friedenbach.

Mark Friedenbach designed and authored the reference implementation for Bitcoin.

Gregory Maxwell came up with the original idea, in #bitcoin-wizards on 2013-07-16 and 2013-07-17.

Deployment

At the time of writing it has not been decided which network upgrade (if any) will implement this proposal.

This ZIP is designed to be deployed simultaneously with8 and9.

Compatibility

At the post-Blossom block target spacing of 75 seconds, transactions generated using time-based lock-time will take approximately 7.5 minutes longer to confirm than would be expected under the old rules. This is not known to introduce any compatibility concerns with existing protocols. This delay is less than in Bitcoin due to the faster block target spacing in Zcash.

References


  1. Key words for use in RFCs to Indicate Requirement Levels↩︎

  2. BIP 65: OP_CHECKLOCKTIMEVERIFY↩︎

  3. ZIP 112: CHECKSEQUENCEVERIFY↩︎

  4. Zcash Protocol Specification, Version 2019.0.1 or later [Overwinter+Sapling+Blossom]↩︎

  5. Zcash Protocol Specification, Version 2019.0.1 or later [Overwinter+Sapling+Blossom]↩︎

  6. Zcash Protocol Specification, Version 2019.0.1 or later [Overwinter+Sapling+Blossom]↩︎

  7. Zcash Protocol Specification, Version 2019.0.1 or later [Overwinter+Sapling+Blossom]↩︎

  8. ZIP 68: Consensus-enforced transaction replacement signaled via sequence numbers↩︎

  9. ZIP 112: CHECKSEQUENCEVERIFY↩︎

Citation graph

Hover or tap a node to see its title and citations.
Loading citation graph…