summaryrefslogtreecommitdiff
path: root/4b/e3ccc7fb64df95f01c494ad80872d7a15345ae
blob: 43772dcac5d35db268716fe0fed4fde9550f1a8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
Return-Path: <john@chaincode.com>
Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org
	[172.17.192.35])
	by mail.linuxfoundation.org (Postfix) with ESMTPS id 75A2D1076
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Tue, 23 Jan 2018 21:57:14 +0000 (UTC)
X-Greylist: whitelisted by SQLgrey-1.7.6
Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com
	[209.85.215.50])
	by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 30921EC
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Tue, 23 Jan 2018 21:57:13 +0000 (UTC)
Received: by mail-lf0-f50.google.com with SMTP id o89so2532765lfg.10
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Tue, 23 Jan 2018 13:57:13 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=chaincode-com.20150623.gappssmtp.com; s=20150623;
	h=mime-version:from:date:message-id:subject:to;
	bh=zy9qONpMKQR0b4jpKDsHfmxa5HTBMhU4zDIvqXVDGfs=;
	b=zId7CoouPaMES9Ykwe2wBcfrIA2axo0keWddPYpMDhLwxvyPicknYXmCOLs10MfqzQ
	t+s9h7DA4KDV/g5amS86F0aXpjakvIqTu8r2u6wZLHDNfdQM+pBwdkEWMiiLdmW7l1OK
	p6+OAyPZGeW+EGaxMR5VchtgC0W2d8E3rYzi+NJY2f9x5gw5ZCRHvSSiL68igiZzNmIL
	diBHpvig2ZeXVbvqh6jhyZ6NXmUvJWwXTGPH/OzBqrZsGKYJcyUbcPXT1+ToKmdI3dQ7
	aEThNwNQNCqZaJzZxIry+ravqMxJ81T3yJjXgi3Hwnm/LopYWDdOwyMmlfr97d2fpeRJ
	BgfA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
	bh=zy9qONpMKQR0b4jpKDsHfmxa5HTBMhU4zDIvqXVDGfs=;
	b=n3sFMma4qpkYkTtgSfdz7RZzclNbtZFSysamJyx8YFHlUj5G7qSLDI8d28GnQmVipA
	EF3rX0e5ovqTs/rITKGDmb8tLl+w7IPJYJg2yjs9DkY0QqRbOoA7v9pnP2qQDRrdl1NT
	PIEZgR4b+mV4WYo8iYHdDqMOYMDQmheBjwcyO2DRosV09UDfzORav5oev+QRY9QIFl5u
	BBIRie6g3P68Wjj262rHXVyX/BAwyiIDda9z7PH6Y96+hbcCjE3p55spujR8URuAvJxz
	ziM/tC4d0OgvlkMv6+xY3/htxVUpmzzIBVn2znEEGyz7PlSO/VqJj7HvQNMQ6N5h4Ft2
	Ak6A==
X-Gm-Message-State: AKwxytcLk5FbJRKmn8ndSc7jDLzsHVEvxmbBULHnW3TetW3M+djasXA7
	9/P2Ulh033yXDFoaVH45jf9L6653nTYbJpreBXNwmTQ1/Wg=
X-Google-Smtp-Source: AH8x224G1Hr75Moxiy6dxmseTx3qQkLJMRzR04BILdGfmQAPbL5QKssYKTZLdmaH9Mo/eOAapXNGEccs5L36+gfP4Vw=
X-Received: by 10.46.5.15 with SMTP id 15mr2049436ljf.98.1516744631209; Tue,
	23 Jan 2018 13:57:11 -0800 (PST)
MIME-Version: 1.0
Received: by 10.46.80.72 with HTTP; Tue, 23 Jan 2018 13:56:50 -0800 (PST)
From: John Newbery <john@chaincode.com>
Date: Tue, 23 Jan 2018 16:56:50 -0500
Message-ID: <CAMPtzUdcQxOktwhHe602Y7xDTsAYT0LoSY1iLBYSTnb=k8Y08A@mail.gmail.com>
To: bitcoin-dev@lists.linuxfoundation.org
Content-Type: multipart/alternative; boundary="001a114a7e12f5671f056378a083"
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID, HTML_MESSAGE, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
	smtp1.linux-foundation.org
X-Mailman-Approved-At: Tue, 23 Jan 2018 21:57:53 +0000
Subject: [bitcoin-dev] BIP16 enforcement change in V0.16
X-BeenThere: bitcoin-dev@lists.linuxfoundation.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Bitcoin Protocol Discussion <bitcoin-dev.lists.linuxfoundation.org>
List-Unsubscribe: <https://lists.linuxfoundation.org/mailman/options/bitcoin-dev>,
	<mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=unsubscribe>
List-Archive: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/>
List-Post: <mailto:bitcoin-dev@lists.linuxfoundation.org>
List-Help: <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=help>
List-Subscribe: <https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev>,
	<mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=subscribe>
X-List-Received-Date: Tue, 23 Jan 2018 21:57:14 -0000

--001a114a7e12f5671f056378a083
Content-Type: text/plain; charset="UTF-8"

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 <john@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.

--001a114a7e12f5671f056378a083
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>The upcoming v0.16 release contains a slight change t=
o the way that BIP16 is enforced, by basing activation on block height inst=
ead of block time. This brings BIP 16 enforcement in line with BIP 34, BIP =
66 and BIP 65.</div><div><br></div><div>This has no impact on consensus sin=
ce BIP 16 was activated before the last checkpoint and is buried under &gt;=
300,000 blocks.</div><div><br></div><div>I&#39;ve written up the changes in=
 the BIP style below, although I don&#39;t think this necessarily requires =
a full BIP. BIP 16 enforcement will likely change again with <a href=3D"htt=
ps://github.com/bitcoin/bitcoin/pull/11739">https://github.com/bitcoin/bitc=
oin/pull/11739</a> in the next bitcoin core release, so a formal proposal f=
or this as a BIP will quickly be superseded.=C2=A0</div><div><br></div><div=
>&lt;pre&gt;</div><div>=C2=A0 BIP: ??</div><div>=C2=A0 Layer: Consensus</di=
v><div>=C2=A0 Title: Buried Deployments (P2SH)</div><div>=C2=A0 Author: Joh=
n Newbery &lt;<a href=3D"mailto:john@chaincode.com">john@chaincode.com</a>&=
gt;</div><div>=C2=A0 Comments-Summary: No comments yet</div><div>=C2=A0 Com=
ments-URI: <a href=3D"https://github.com/bitcoin/bips/wiki/Comments:BIP-??"=
>https://github.com/bitcoin/bips/wiki/Comments:BIP-??</a>??</div><div>=C2=
=A0 Status: Draft</div><div>=C2=A0 Type: Informational</div><div>=C2=A0 Cre=
ated: 2018-01-22</div><div>=C2=A0 License: CC-0</div><div>&lt;/pre&gt;</div=
><div><br></div><div><br></div><div>=3D=3DAbstract=3D=3D</div><div><br></di=
v><div>Enforce BIP 16 consensus rules based on block height rather than blo=
ck time.</div><div><br></div><div>=3D=3DBackground=3D=3D</div><div><br></di=
v><div>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 sign=
aled readiness for the change by placing the string &quot;/P2SH/&quot; in t=
he scriptSig of the coinbase transaction txIn. The rule change was original=
ly intended to come into effect on 15 Feb 2012, but due to lack of miner si=
gnaling, the activation date was pushed back to April 1st 2012. See [<a hre=
f=3D"https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki">https:=
//github.com/bitcoin/bips/blob/master/bip-0034.mediawiki</a> The BIP 16 spe=
cification] for full details on the deployment method. The final activation=
 method was via a hardcoded block time of 1333238400 (April 1st 2012).</div=
><div><br></div><div>Now that the chain has long since passed the block at =
which the P2SH consensus rule was activated, we can (as a simplification) r=
eplace the trigger mechanism by caching the block height at which those con=
sensus rules became enforced.</div><div><br></div><div>=3D=3DMotivation=3D=
=3D</div><div><br></div><div>Activating the BIP 16 consensus change based o=
n block time has several disadvantages:</div><div><br></div><div>* The cons=
ensus change can be activated and later deactivated in the same chain (sinc=
e block time is not necessarily monotonically increasing).</div><div>* It i=
s less flexible for constructing test chains for testing P2SH and other sof=
t fork activation</div><div><br></div><div>The flag day activation mechanis=
m for code deployments was deprecated in favor of [<a href=3D"https://githu=
b.com/bitcoin/bips/blob/master/bip-0034.mediawiki">https://github.com/bitco=
in/bips/blob/master/bip-0034.mediawiki</a> IsSuperMajority] deployments, an=
d later by [<a href=3D"https://github.com/bitcoin/bips/blob/master/bip-0009=
.mediawiki">https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki<=
/a> version bits] deployments.</div><div><br></div><div>BIP 34, BIP 65, and=
 BIP 66 deployments were later &#39;buried&#39; by [<a href=3D"https://gith=
ub.com/bitcoin/bips/blob/master/bip-0090.mediawiki">https://github.com/bitc=
oin/bips/blob/master/bip-0090.mediawiki</a> BIP 90] with simple height chec=
ks. This simplification of the consensus rules reduced the technical debt a=
ssociated with deployment of those consensus changes.</div><div><br></div><=
div>This BIP changes the BIP 16 activation method to also be a &#39;buried&=
#39; deployment, activating at the block height that BIP 16 actually activa=
ted. For the mainnet chain, this is block height 173805.</div><div><br></di=
v><div>=3D=3DConsiderations=3D=3D</div><div><br></div><div>Just as for the =
buried BIP 34, BIP 65 and BIP 66 deployments, it is technically possible fo=
r this to be a non-backwards compatible change. For example, if an alternat=
e chain were created in which block height 173805 was reached after April 1=
st 2012, and a block with height &lt;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.</div><div>=
<br></div><div>See [<a href=3D"https://github.com/bitcoin/bips/blob/master/=
bip-0090.mediawiki">https://github.com/bitcoin/bips/blob/master/bip-0090.me=
diawiki</a> BIP 90] for justification of why this class of change is accept=
able. As of January 2018, BIP 16 is buried by over 300,000 blocks. BIP 16 a=
ctivation is also protected by checkpoints (the most recent of which is at =
height 295000).</div><div><br></div><div>=3D=3DSpecification=3D=3D</div><di=
v><br></div><div>The BIP 16 activation height is set to 173805.</div><div><=
br></div><div>To determine whether to enforce BIP 16 on a given block, we j=
ust compare the height of the block being validated with the stored activat=
ion height:</div><div><br></div><div>=C2=A0 =C2=A0 // Start enforcing P2SH =
(BIP16)</div><div>=C2=A0 =C2=A0 if (pindex-&gt;nHeight &gt;=3D consensuspar=
ams.BIP16Height) {</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 flags |=3D SCRIPT_=
VERIFY_P2SH;</div><div>=C2=A0 =C2=A0 }</div><div><br></div><div>See the imp=
lementation for additional details.</div><div><br></div><div>=3D=3DImplemen=
tation=3D=3D</div><div><br></div><div><a href=3D"https://github.com/bitcoin=
/bitcoin/commit/18e071841e83044b47aa45c3e98c0796a407d445">https://github.co=
m/bitcoin/bitcoin/commit/18e071841e83044b47aa45c3e98c0796a407d445</a></div>=
<div><br></div><div>=3D=3DAcknowledgements=3D=3D</div><div><br></div><div>T=
hanks to Russ Yanofsky, Marco Falke and Suhas Daftuar for suggestions and f=
eedback.</div><div><br></div><div>=3D=3DCopyright=3D=3D</div><div><br></div=
><div>This document is placed in the public domain.</div></div>

--001a114a7e12f5671f056378a083--