summaryrefslogtreecommitdiff
path: root/05/4e48949f69e0be17e704543827dc496eac4672
blob: 03cfda411ad57d53e0dec663d5805fe1a57cef7b (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
Return-Path: <jim.posen@gmail.com>
Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org
	[172.17.192.35])
	by mail.linuxfoundation.org (Postfix) with ESMTPS id 826E5CC2
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Mon, 11 Dec 2017 21:56:10 +0000 (UTC)
X-Greylist: whitelisted by SQLgrey-1.7.6
Received: from mail-it0-f50.google.com (mail-it0-f50.google.com
	[209.85.214.50])
	by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9574EE7
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Mon, 11 Dec 2017 21:56:09 +0000 (UTC)
Received: by mail-it0-f50.google.com with SMTP id r6so19434056itr.3
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Mon, 11 Dec 2017 13:56:09 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=hdIGP5V3oNovMEemLh1PDM9TpfRBmdH4YC69V0/9IMQ=;
	b=IoOdpSZNx5X1Vf41A8/RA030+7uVd3BeTO3P61rEgq9u1j85+LriNDJDKrEOm79HkR
	pQ+wS+Zip/40wKGuI9NdOuV7CbomUfebbItH/Rm+IYA654eaJpQxpXKaWUA9R1muHG3z
	7HkkkNDv6Bmm77pStou3tmC+e+xd/9IS+/uR8lUe3jNVuA29B8JSDvtqQB27e0BiKsH/
	sYfsRch0N9pfl4mIhzrS0bbxAVePZstWYJV14tRQKhSQOZDXbNPFTjPqBE7Mgwl5wMuI
	PMGcKb6xGoGSxIfRvmbS4p6G4mwfXXtLzM+h+bIHgsWAdkbUQ6hwPA7q2WaKaqcns5Wg
	RV5g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=hdIGP5V3oNovMEemLh1PDM9TpfRBmdH4YC69V0/9IMQ=;
	b=fXQ33+QIM2cOVQYrQ3E0rHrvohZoY1Ytby45vVfmhGCzSkBBgpbb/QhBGxVJH9r2XR
	kq0WZQZl/eqdozL4zNQoXiw3Y+TcHkqCnzGHcKls4gO1GjixOQF9lzr0hEX7/9fJ0mq2
	SM884PRJgkhE0aqpRSQN0Etwshws1f93DCRrx58QlFPMpKa6cchEHgbO6J0sthlEjc9p
	3ThpYGHYqFfZZPnKL+d2Elfk3ZMTIBy1Sf0yLCc962KUL75ITRnXeKVuCvNb6lRGlJr8
	LnNX7ekS1IT/yQ2r9j7E4Ulf/tiPgRylY8qhEBtUxP15a+5Iu3b9p/RsIPwJA6DuqPAM
	rhYQ==
X-Gm-Message-State: AKGB3mK8S0CSWtCHmQ/ZSEczwkQff/BgrMLjd3dC+K6bKFa4j1fCHEjD
	HKQciiPP9qUA6HqiR2HhtVRjFmxGTfhupZoOcpYL8w==
X-Google-Smtp-Source: ACJfBotH1SDgggmlNJoL/ILdaXackQ/Ml8KSrG/Z0yVpNtJr8f8j1pZLUVz1fnQmDiFLo2p/Bnwn0pST+O9vIpHjhDM=
X-Received: by 10.36.129.212 with SMTP id q203mr3291311itd.152.1513029368727; 
	Mon, 11 Dec 2017 13:56:08 -0800 (PST)
MIME-Version: 1.0
Received: by 10.107.13.9 with HTTP; Mon, 11 Dec 2017 13:56:08 -0800 (PST)
In-Reply-To: <CAAS2fgROykenGH43_FXun+q4u+=94tKqnRW=kQQ2AQFeXKdW=Q@mail.gmail.com>
References: <CADZtCShywq_s9ZK3oBBTUdCgjrTxbyeb-p7QrhJJ3mwRAECCMA@mail.gmail.com>
	<CAAS2fgROykenGH43_FXun+q4u+=94tKqnRW=kQQ2AQFeXKdW=Q@mail.gmail.com>
From: Jim Posen <jim.posen@gmail.com>
Date: Mon, 11 Dec 2017 13:56:08 -0800
Message-ID: <CADZtCSi1vimZ88kqG=HQHa3sHeLtvMjdJrZuqS2=iYr-=EHaLw@mail.gmail.com>
To: Gregory Maxwell <greg@xiph.org>
Content-Type: multipart/alternative; boundary="94eb2c08b2380ecd1e0560179ae5"
X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW
	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: Mon, 11 Dec 2017 21:57:51 +0000
Cc: Bitcoin Protocol Discussion <bitcoin-dev@lists.linuxfoundation.org>
Subject: Re: [bitcoin-dev] "Compressed" headers stream
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: Mon, 11 Dec 2017 21:56:10 -0000

--94eb2c08b2380ecd1e0560179ae5
Content-Type: text/plain; charset="UTF-8"

On Mon, Dec 11, 2017 at 1:04 PM, Gregory Maxwell <greg@xiph.org> wrote:

> On Mon, Dec 11, 2017 at 8:40 PM, Jim Posen via bitcoin-dev
> <bitcoin-dev@lists.linuxfoundation.org> wrote:
> > Firstly, I don't like the idea of making the net header encoding
> dependent
> > on the specific header validation rules that Bitcoin uses (eg. the fact
> that
> > difficulty is only recalculated every 2016 blocks). This would be
> coupling
>
> In the last proposal I recall writing up, there was a one byte flag on
> each header to indicate what was included.
>
>
Is there a link somewhere to that proposal? The only thing I could find was
your forwarded email
<https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-September/014904.html>
on
this thread.


> Nbits _never_ needs to be sent even with other consensus rules because
> its more or less necessarily a strict function of the prior headers.
> This still holds in every clone of Bitcoin I'm aware of; sending it
> with the first header in a group probably makes sense so it can be
> checked independently.
>
> > with insufficient benefit.
>
> another >18% reduction in size beyond the removal of prev. is not
> insubstantial by any means.  I don't think it should lightly be
> ignored.
>
>
Omitting nBits entirely seems reasonable, I wrote up a possible
implementation here
<https://github.com/bitcoin/bitcoin/compare/master...jimpo:compact-headers-difficulty>.
The downside is that it is more complex because it leaks into the
validation code. The extra 4 byte savings is certainly nice though.


> Prev omission itself is not, sadly, magically compatible:  I am quite
> confident that if there is a bitcoin hardfork it would recover the
> nbits/4-guarenteed always-zero bits of prev to use as extra nonce for
> miners. This has been proposed many times, implemented at least once,
> and the current requirement for mining infrastructure to reach inside
> the coinbase txn to increment a nonce has been a reliable source of
> failures.  So I think we'd want to have the encoding able to encode
> leading prev bits.
>
> Many altcoins also change the header structures. If the better thing
> is altcoin incompatible, we should still do it. Doing otherwise would
> competitively hobble Bitcoin especially considering the frequent
> recklessly incompetent moves made by various altcoins and the near
> total lack of useful novel development we've seen come out of the
> clones.
>
> Probably the most important change in a new header message wouldn't be
> the encoding, but it would be changing the fetching mechanism so that
> header sets could be pulled in parallel, etc.
>
> I would rather not change the serialization of existing messages,
> nodes are going to have to support speaking both messages for a long
> time, and I think we already want a different protocol flow for
> headers fetching in any case.
>

Can you elaborate on how parallel header fetching might work? getheaders
requests could probably already be pipelined, where the node requests the
next 2,000 headers before processing the current batch (though would make
sense to check that they are all above min difficulty first).

I'm open to more ideas on how to optimize the header download or design the
serialization format to be more flexible, but I'm concerned that we forgo a
40-45% bandwidth savings on the current protocol for a long time because
something better might be possible later on or there might be a hard fork
that at some point requires another upgrade. I do recognize that supporting
multiple serialization formats simultaneously adds code complexity, but in
this case the change seems simple enough to me that the tradeoff is worth
it.

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

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On M=
on, Dec 11, 2017 at 1:04 PM, Gregory Maxwell <span dir=3D"ltr">&lt;<a href=
=3D"mailto:greg@xiph.org" target=3D"_blank">greg@xiph.org</a>&gt;</span> wr=
ote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border=
-left:1px #ccc solid;padding-left:1ex"><span class=3D"">On Mon, Dec 11, 201=
7 at 8:40 PM, Jim Posen via bitcoin-dev<br>
&lt;<a href=3D"mailto:bitcoin-dev@lists.linuxfoundation.org">bitcoin-dev@li=
sts.<wbr>linuxfoundation.org</a>&gt; wrote:<br>
&gt; Firstly, I don&#39;t like the idea of making the net header encoding d=
ependent<br>
&gt; on the specific header validation rules that Bitcoin uses (eg. the fac=
t that<br>
&gt; difficulty is only recalculated every 2016 blocks). This would be coup=
ling<br>
<br>
</span>In the last proposal I recall writing up, there was a one byte flag =
on<br>
each header to indicate what was included.<br>
<br></blockquote><div><br></div><div>Is there a link somewhere to that prop=
osal? The only thing I could find was your <a href=3D"https://lists.linuxfo=
undation.org/pipermail/bitcoin-dev/2017-September/014904.html">forwarded em=
ail</a>=C2=A0on this thread.</div><div>=C2=A0</div><blockquote class=3D"gma=
il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef=
t:1ex">
Nbits _never_ needs to be sent even with other consensus rules because<br>
its more or less necessarily a strict function of the prior headers.<br>
This still holds in every clone of Bitcoin I&#39;m aware of; sending it<br>
with the first header in a group probably makes sense so it can be<br>
checked independently.<br>
<br>
&gt; with insufficient benefit.<br>
<br>
another &gt;18% reduction in size beyond the removal of prev. is not<br>
insubstantial by any means.=C2=A0 I don&#39;t think it should lightly be<br=
>
ignored.<br>
<br></blockquote><div><br></div><div>Omitting nBits entirely seems reasonab=
le, I wrote up a possible implementation <a href=3D"https://github.com/bitc=
oin/bitcoin/compare/master...jimpo:compact-headers-difficulty">here</a>. Th=
e downside is that it is more complex because it leaks into the validation =
code. The extra 4 byte savings is certainly nice though.</div><div>=C2=A0</=
div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex">
Prev omission itself is not, sadly, magically compatible:=C2=A0 I am quite<=
br>
confident that if there is a bitcoin hardfork it would recover the<br>
nbits/4-guarenteed always-zero bits of prev to use as extra nonce for<br>
miners. This has been proposed many times, implemented at least once,<br>
and the current requirement for mining infrastructure to reach inside<br>
the coinbase txn to increment a nonce has been a reliable source of<br>
failures.=C2=A0 So I think we&#39;d want to have the encoding able to encod=
e<br>
leading prev bits.<br>
<br>
Many altcoins also change the header structures. If the better thing<br>
is altcoin incompatible, we should still do it. Doing otherwise would<br>
competitively hobble Bitcoin especially considering the frequent<br>
recklessly incompetent moves made by various altcoins and the near<br>
total lack of useful novel development we&#39;ve seen come out of the<br>
clones.<br>
<br>
Probably the most important change in a new header message wouldn&#39;t be<=
br>
the encoding, but it would be changing the fetching mechanism so that<br>
header sets could be pulled in parallel, etc.<br>
<br>
I would rather not change the serialization of existing messages,<br>
nodes are going to have to support speaking both messages for a long<br>
time, and I think we already want a different protocol flow for<br>
headers fetching in any case.<br>
</blockquote></div><br></div><div class=3D"gmail_extra">Can you elaborate o=
n how parallel header fetching might work? getheaders requests could probab=
ly already be pipelined, where the node requests the next 2,000 headers bef=
ore processing the current batch (though would make sense to check that the=
y are all above min difficulty first).</div><div class=3D"gmail_extra"><br>=
</div><div class=3D"gmail_extra">I&#39;m open to more ideas on how to optim=
ize the header download or design the serialization format to be more flexi=
ble, but I&#39;m concerned that we forgo a 40-45% bandwidth savings on the =
current protocol for a long time because something better might be possible=
 later on or there might be a hard fork that at some point requires another=
 upgrade. I do recognize that supporting multiple serialization formats sim=
ultaneously adds code complexity, but in this case the change seems simple =
enough to me that the tradeoff is worth it.=C2=A0</div></div>

--94eb2c08b2380ecd1e0560179ae5--