Discussion:
[bitcoin-dev] BIP16 enforcement change in V0.16
John Newbery via bitcoin-dev
2018-01-23 21:56:50 UTC
Permalink
The upcoming v0.16 release contains a slight change to the way that BIP16
is enforced, by basing activation on block height instead of block time.
This brings BIP 16 enforcement in line with BIP 34, BIP 66 and BIP 65.

This has no impact on consensus since BIP 16 was activated before the last
checkpoint and is buried under >300,000 blocks.

I've written up the changes in the BIP style below, although I don't think
this necessarily requires a full BIP. BIP 16 enforcement will likely change
again with https://github.com/bitcoin/bitcoin/pull/11739 in the next
bitcoin core release, so a formal proposal for this as a BIP will quickly
be superseded.

<pre>
BIP: ??
Layer: Consensus
Title: Buried Deployments (P2SH)
Author: John Newbery <***@chaincode.com>
Comments-Summary: No comments yet
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-????
Status: Draft
Type: Informational
Created: 2018-01-22
License: CC-0
</pre>


==Abstract==

Enforce BIP 16 consensus rules based on block height rather than block time.

==Background==

BIP 16 was deployed via a hardcoded flag day consensus rule change. Prior
to the date of the consensus rule change being fixed, the miners signaled
readiness for the change by placing the string "/P2SH/" in the scriptSig of
the coinbase transaction txIn. The rule change was originally intended to
come into effect on 15 Feb 2012, but due to lack of miner signaling, the
activation date was pushed back to April 1st 2012. See [
https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki The BIP 16
specification] for full details on the deployment method. The final
activation method was via a hardcoded block time of 1333238400 (April 1st
2012).

Now that the chain has long since passed the block at which the P2SH
consensus rule was activated, we can (as a simplification) replace the
trigger mechanism by caching the block height at which those consensus
rules became enforced.

==Motivation==

Activating the BIP 16 consensus change based on block time has several
disadvantages:

* The consensus change can be activated and later deactivated in the same
chain (since block time is not necessarily monotonically increasing).
* It is less flexible for constructing test chains for testing P2SH and
other soft fork activation

The flag day activation mechanism for code deployments was deprecated in
favor of [https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki
IsSuperMajority] deployments, and later by [
https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki version
bits] deployments.

BIP 34, BIP 65, and BIP 66 deployments were later 'buried' by [
https://github.com/bitcoin/bips/blob/master/bip-0090.mediawiki BIP 90] with
simple height checks. This simplification of the consensus rules reduced
the technical debt associated with deployment of those consensus changes.

This BIP changes the BIP 16 activation method to also be a 'buried'
deployment, activating at the block height that BIP 16 actually activated.
For the mainnet chain, this is block height 173805.

==Considerations==

Just as for the buried BIP 34, BIP 65 and BIP 66 deployments, it is
technically possible for this to be a non-backwards compatible change. For
example, if an alternate chain were created in which block height 173805
was reached after April 1st 2012, and a block with height <173805 but block
time after April 1st 2012 included an invalid P2SH spend, older software
would see that chain as invalid, but newer software implementing this
change would not.

See [https://github.com/bitcoin/bips/blob/master/bip-0090.mediawiki BIP 90]
for justification of why this class of change is acceptable. As of January
2018, BIP 16 is buried by over 300,000 blocks. BIP 16 activation is also
protected by checkpoints (the most recent of which is at height 295000).

==Specification==

The BIP 16 activation height is set to 173805.

To determine whether to enforce BIP 16 on a given block, we just compare
the height of the block being validated with the stored activation height:

// Start enforcing P2SH (BIP16)
if (pindex->nHeight >= consensusparams.BIP16Height) {
flags |= SCRIPT_VERIFY_P2SH;
}

See the implementation for additional details.

==Implementation==

https://github.com/bitcoin/bitcoin/commit/18e071841e83044b47aa45c3e98c0796a407d445

==Acknowledgements==

Thanks to Russ Yanofsky, Marco Falke and Suhas Daftuar for suggestions and
feedback.

==Copyright==

This document is placed in the public domain.

Loading...