Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 0A05ED32 for ; Mon, 11 Dec 2017 20:40:03 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-it0-f65.google.com (mail-it0-f65.google.com [209.85.214.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 334F8463 for ; Mon, 11 Dec 2017 20:40:02 +0000 (UTC) Received: by mail-it0-f65.google.com with SMTP id r6so18953230itr.3 for ; Mon, 11 Dec 2017 12:40:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=7cRhwl0rqgzXhoC5A7BQo0qeV40twdMllTjPRoV+S+8=; b=MZzFAOBmRmpjaRkuDA9PlfTMsZZIZA+UjYyeSj3PzOUTuf9UvDraOaf2NVrFDjcpwq 5Al5f0v8xEGMuA8cRwZNdluDuPZvIoUferfKb7r1P2SEbfsFgT79CbgfbmZX5m8Y6+8L Wpoww0BLoXojPcJcjhU6sO3nh/gtsw1VfXE3M3KpAqbr8Bang5bHI8us6P9E26XSkg/B AOu9z9puxo/wBjL7zVxieQrmRnDND/BVuEN6mMM3lpDbURkliK292h9G9gZNfszxChws ajQFxCCVQjbX9tRskjMC46WMDE0KU5Td3StBem7B7ZWcMz6JHB8it7CpFm5sHxS9SNUi vKMQ== 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=7cRhwl0rqgzXhoC5A7BQo0qeV40twdMllTjPRoV+S+8=; b=YswntPNgelGENbUT68zkNVXm4qu/EijHXldd01V3OaddO7zQGUd5/SuAuYHAOTZsRd cMJzNrSSos9ZZtQBmsxBgNj+9k/GKLz+F5XQugxPBrkKrQIkaNlhRXokyjD1cIytOiPr 26WtTF6zdUzbMn/vILDFoyknxIaxa+GFSw14MR918DH1Rl0yU7AxVQgr0MBiHiaPxKdv aOr+COQTt5xti2hEHgxPkTrzoUysb4RyglzgfV/1mg3G1c5aiyw37B8hOYo8+iiTEPyT RNVS3g42qqDxom0VLTon1rI64LXlox4xcRvZ4+SkA//FwT88igO77XqUbiJVhEq+clSc FlJQ== X-Gm-Message-State: AKGB3mIBSgaTNhQ4LLRWUqF/NXetLwhurF0QGHfZ4sKsinkk5t3lYKRC vHqHhmRP++MAPu873B7BAWf0GF8WFClqTgU6RZzogZfH X-Google-Smtp-Source: ACJfBouQnH0U4dQyWmJh50b3NbgfZPh3UdxPOTTQXNz2+mqzKsAU2d91SJkA0g23ikA8RqFgqfssTDf2HMdVc62ekHY= X-Received: by 10.107.201.134 with SMTP id z128mr2160887iof.177.1513024801159; Mon, 11 Dec 2017 12:40:01 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.13.9 with HTTP; Mon, 11 Dec 2017 12:40:00 -0800 (PST) From: Jim Posen Date: Mon, 11 Dec 2017 12:40:00 -0800 Message-ID: To: bitcoin-dev@lists.linuxfoundation.org Content-Type: multipart/alternative; boundary="94eb2c0b84f0cf3f4b05601689ed" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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: Mon, 11 Dec 2017 20:43:53 +0000 Subject: [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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2017 20:40:03 -0000 --94eb2c0b84f0cf3f4b05601689ed Content-Type: text/plain; charset="UTF-8" I want to resurrect this thread from August/September because it seems like a significant improvement for light clients at very little cost. From the mailing list, it seems like this got stalled in determining how many more bytes could be save in addition to the prev_block. The ideas I've gathered from Greg Maxwell's forwarded email are: 1. Omit nBits altogether and have the receiving node determine it from chain context. 2. Include nBits only on headers with a height that is a multiple of 2016 since it does not change in between. 3. Compress nTime to two bytes by using the bounds on allowed values from the consensus rules. I propose just moving ahead with only the exclusion of the prev_block, as IMO the other savings are not worth the added complexity. 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 together the two layers, breaking net compatibility for some alts, and possibly making consensus rule changes even more difficult for a savings with insufficient benefit. So if you buy that argument, I'm not in favor of #2 or #3. Option 1 is still viable, though it has some downsides. The implementation leaks into the validation code, whereas calculating prev_block can occur just at the net layer (see implementation below). Also, nodes would now be *required* to sync the header chain from the genesis block, whereas they had the option of starting from some checkpoint before. So switching gears, I'd like to ask what the best way to actually implement this change is. Solutions I can think of are: 1. New headers command name like "cmpctheaders" or "headersv2". 2. Change serialization of existing headers message in a new protocol version. 3. Change serialization of existing headers message with new service bit. I wrote up some proof-of-concept implementations in Core a) just omitting prev_block and b) omitting nBits as well . If people think a) is reasonable, I'll write up a BIP. > Hi everyone, the Bitcoin headers are probably the most condensed and > important piece of data in the world, their demand is expected to grow. > When sending a stream of continuous block headers, a common case in IBD and > in disconnected clients, I think there is a possible optimization of the > transmitted data: The headers after the first could avoid transmitting the > previous hash cause the receiver could compute it by double hashing the > previous header (an operation he needs to do anyway to verify PoW). In a > long stream, for example 2016 headers, the savings in bandwidth are about > 32/80 ~= 40% without compressed headers 2016*80=161280 bytes with > compressed headers 80+2015*48=96800 bytes What do you think? In > OpenTimestamps calendars we are going to use this compression to give > lite-client a reasonable secure proofs (a full node give higher security > but isn't feasible in all situations, for example for in-browser > verification) To speed up sync of a new client Electrum starts with the > download of a file > ~36MB containing the first 477637 headers. For this kind of clients could > be useful a common http API with fixed position chunks to leverage http > caching. For example /headers/2016/0 returns the headers from the genesis > to the 2015 header included while /headers/2016/1 gives the headers from > the 2016th to the 4031. Other endpoints could have chunks of 20160 blocks > or 201600 such that with about 10 http requests a client could fast sync > the headers --94eb2c0b84f0cf3f4b05601689ed Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I want to resurrect this thread from August/September= because it seems like a significant improvement for light clients at very = little cost. From the mailing list, it seems like this got stalled in deter= mining how many more bytes could be save in addition to the prev_block.

The ideas I've gathered from Greg Maxwell's f= orwarded email are:

1. Omit nBits altogether and h= ave the receiving node determine it from chain context.
2. Includ= e nBits only on headers with a height that is a multiple of 2016 since it d= oes not change in between.
3. Compress nTime to two bytes by usin= g the bounds on allowed values from the consensus rules.

I propose just moving ahead with only the exclusion of the prev_bloc= k, as IMO the other savings are not worth the added complexity.
<= br>
Firstly, I don't like the idea of making the net header e= ncoding dependent on the specific header validation rules that Bitcoin uses= (eg. the fact that difficulty is only recalculated every 2016 blocks). Thi= s would be coupling together the two layers, breaking net compatibility for= some alts, and possibly making consensus rule changes even more difficult = for a savings with insufficient benefit. So if you buy that argument, I'= ;m not in favor of #2 or #3.

Option 1 is still via= ble, though it has some downsides. The implementation leaks into the valida= tion code, whereas calculating prev_block can occur just at the net layer (= see implementation below). Also, nodes would now be required to sync= the header chain from the genesis block, whereas they had the option of st= arting from some checkpoint before.

So switching g= ears, I'd like to ask what the best way to actually implement this chan= ge is. Solutions I can think of are:

1. New header= s command name like "cmpctheaders" or "headersv2".
2. Change serialization of existing headers message in a new protocol= version.
3. Change serialization of existing headers message wit= h new service bit.

I wrote up some proof-of-concep= t implementations in Core a) just omitting prev_block and b)= omitting nBits as well. If people think a) is re= asonable, I'll write up a BIP.
=C2=A0
Hi everyone, the Bitcoin headers are proba= bly the most condensed and important piece of data in the world, their dema= nd is expected to grow. When sending a stream of continuous block headers, = a common case in IBD and in disconnected clients, I think there is a possib= le optimization of the transmitted data: The headers after the first could = avoid transmitting the previous hash cause the receiver could compute it by= double hashing the previous header (an operation he needs to do anyway to = verify PoW). In a long stream, for example 2016 headers, the savings in ban= dwidth are about 32/80 ~=3D 40% without compressed headers 2016*80=3D161280= bytes with compressed headers 80+2015*48=3D96800 bytes What do you think? = In OpenTimestamps calendars we are going to use this compression to give li= te-client a reasonable secure proofs (a full node give higher security but = isn't feasible in all situations, for example for in-browser verificati= on) To speed up sync of a new client Electrum starts with the download of a= file <https= ://headers.electrum.org/blockchain_headers> ~36MB containing the fir= st 477637 headers. For this kind of clients could be useful a common http A= PI with fixed position chunks to leverage http caching. For example /header= s/2016/0 returns the headers from the genesis to the 2015 header included w= hile /headers/2016/1 gives the headers from the 2016th to the 4031. Other e= ndpoints could have chunks of 20160 blocks or 201600 such that with about 1= 0 http requests a client could fast sync the headers
--94eb2c0b84f0cf3f4b05601689ed--