Return-Path: <sdaftuar@gmail.com> Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 5B52B12A4 for <bitcoin-dev@lists.linuxfoundation.org>; Thu, 24 Sep 2015 18:02:30 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-ob0-f177.google.com (mail-ob0-f177.google.com [209.85.214.177]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3A1DE126 for <bitcoin-dev@lists.linuxfoundation.org>; Thu, 24 Sep 2015 18:02:29 +0000 (UTC) Received: by obbmp4 with SMTP id mp4so64345912obb.3 for <bitcoin-dev@lists.linuxfoundation.org>; Thu, 24 Sep 2015 11:02:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=wQxVN9UX/nlc/b3ry4Nf/n3RRvUnmFu8KVFEJh7S0Eo=; b=pXGrl39B+/K1gmSbUJCCD0gZZZaEEzME1Jy5Qz69Fp2cDVufQhzABQZ2GoZWBSdmRh RY8qVRVwWRxCQUl8pe0GT2s1oKI6wQMmuYessJxABz78JKnsOhEJKyV/k/2XmEcQlHza dTCGsqEugACmuNPr0FAmJzDu3QGUyz91It/NnyJ/dq+p9+sVx0Uw1720z8GiYeKJ76aT nxj31Q0xV6Fz4FalHfWwHSiyCiqBCBbMvOaHZtmpdGVv4EMRiSvKNjGt5pU7oFwfpZN7 cGwC6ALhSd9DsyK/rnF1I4SMY/WX4OXow2yHNjfr/0RQRjYHVZ1nPyGd1TwKY2iwDGsG BwpQ== MIME-Version: 1.0 X-Received: by 10.182.70.101 with SMTP id l5mr570094obu.51.1443117748474; Thu, 24 Sep 2015 11:02:28 -0700 (PDT) Received: by 10.202.197.83 with HTTP; Thu, 24 Sep 2015 11:02:28 -0700 (PDT) Date: Thu, 24 Sep 2015 14:02:28 -0400 Message-ID: <CAFp6fsHBbyVo21DnQKGBVJ7P=8NqOGJ-jv0-MH9WaBD6vauudA@mail.gmail.com> From: Suhas Daftuar <sdaftuar@gmail.com> To: Bitcoin Dev <bitcoin-dev@lists.linuxfoundation.org> Content-Type: multipart/alternative; boundary=089e0149c320c45a44052082080b 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 Subject: [bitcoin-dev] [BIP Proposal] New "sendheaders" p2p message X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Bitcoin Development 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: Thu, 24 Sep 2015 18:02:30 -0000 --089e0149c320c45a44052082080b Content-Type: text/plain; charset=UTF-8 Hi, I'm proposing the addition of a new, optional p2p message to help improve the way blocks are announced on the network. The draft BIP is available here and pasted below: https://gist.github.com/sdaftuar/465bf008f0a4768c0def The goal of this p2p message is to facilitate nodes being able to optionally announce blocks with headers messages rather than with inv's, which is particularly beneficial since the introduction of headers-first download in Bitcoin Core 0.10. In particular, this allows for more efficient propagation of reorgs as it would eliminate a round trip in network communication. The implementation of this BIP (which includes code to directly fetch blocks based on announced headers) is in https://github.com/bitcoin/bitcoin/pull/6494. For additional background, please also see https://github.com/bitcoin/bitcoin/issues/5982. Note that this new p2p message is optional; nodes can feel free to ignore and continue to use inv messages to announce new blocks. Thanks to Pieter Wuille for suggesting this idea. Draft BIP text: <pre> BIP: <unassigned> Title: sendheaders message Author: Suhas Daftuar <sdaftuar@chaincode.com> Status: Draft Type: Standards Track Created: 2015-05-08 </pre> ==Abstract== Add a new message, "sendheaders", which indicates that a node prefers to receive new block announcements via a "headers" message rather than an "inv". ==Motivation== Since the introduction of "headers-first" downloading of blocks in 0.10, blocks will not be processed unless they are able to connect to a (valid) headers chain. Consequently, block relay generally works as follows: # A node (N) announces the new tip with an "inv" message, containing the block hash # A peer (P) responds to the "inv" with a "getheaders" message (to request headers up to the new tip) and a "getdata" message for the new tip itself # N responds with a "headers" message (with the header for the new block along with any preceding headers unknown to P) and a "block" message containing the new block However, in the case where a new block is being announced that builds on the tip, it would be generally more efficient if the node N just announced the block header for the new block, rather than just the block hash, and saved the peer from generating and transmitting the getheaders message (and the required block locator). In the case of a reorg, where 1 or more blocks are disconnected, nodes currently just send an "inv" for the new tip. Peers currently are able to request the new tip immediately, but wait until the headers for the intermediate blocks are delivered before requesting those blocks. By announcing headers from the last fork point leading up to the new tip in the block announcement, peers are able to request all the intermediate blocks immediately. ==Specification== # The sendheaders message is defined as an empty message where pchCommand == "sendheaders" # Upon receipt of a "sendheaders" message, the node will be permitted, but not required, to announce new blocks by sending the header of the new block (along with any other blocks that a node believes a peer might need in order for the block to connect). # Feature discovery is enabled by checking protocol version >= 70012 ==Backward compatibility== Older clients remain fully compatible and interoperable after this change. ==Implementation== https://github.com/bitcoin/bitcoin/pull/6494 --089e0149c320c45a44052082080b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hi,<div><br></div><div>I'm proposing the addition of a= new, optional p2p message to help improve the way blocks are announced on = the network.=C2=A0 The draft BIP is available here and pasted below:</div><= div><div><a href=3D"https://gist.github.com/sdaftuar/465bf008f0a4768c0def">= https://gist.github.com/sdaftuar/465bf008f0a4768c0def</a></div></div><div><= br></div><div>The goal of this p2p message is to facilitate nodes being abl= e to optionally announce blocks with headers messages rather than with inv&= #39;s, which is particularly beneficial since the introduction of headers-f= irst download in Bitcoin Core 0.10.=C2=A0 In particular, this allows for mo= re efficient propagation of reorgs as it would eliminate a round trip in ne= twork communication.</div><div><br></div><div>The implementation of this BI= P (which includes code to directly fetch blocks based on announced headers)= is in <a href=3D"https://github.com/bitcoin/bitcoin/pull/6494">https://git= hub.com/bitcoin/bitcoin/pull/6494</a>.=C2=A0 For additional background, ple= ase also see <a href=3D"https://github.com/bitcoin/bitcoin/issues/5982">htt= ps://github.com/bitcoin/bitcoin/issues/5982</a>.</div><div><br></div><div>N= ote that this new p2p message is optional; nodes can feel free to ignore an= d continue to use inv messages to announce new blocks.</div><div><br></div>= <div>Thanks to Pieter Wuille for suggesting this idea.</div><div><br></div>= <div>Draft BIP text:</div><div><br></div><div><div><font face=3D"monospace,= monospace"><pre></font></div><div><font face=3D"monospace, monospace= ">=C2=A0 BIP: <unassigned></font></div><div><font face=3D"monospace, = monospace">=C2=A0 Title: sendheaders message</font></div><div><font face=3D= "monospace, monospace">=C2=A0 Author: Suhas Daftuar <<a href=3D"mailto:s= daftuar@chaincode.com">sdaftuar@chaincode.com</a>></font></div><div><fon= t face=3D"monospace, monospace">=C2=A0 Status: Draft</font></div><div><font= face=3D"monospace, monospace">=C2=A0 Type: Standards Track</font></div><di= v><font face=3D"monospace, monospace">=C2=A0 Created: 2015-05-08</font></di= v><div><font face=3D"monospace, monospace"></pre></font></div><div><f= ont face=3D"monospace, monospace"><br></font></div><div><font face=3D"monos= pace, monospace">=3D=3DAbstract=3D=3D</font></div><div><font face=3D"monosp= ace, monospace"><br></font></div><div><font face=3D"monospace, monospace">A= dd a new message, "sendheaders", which indicates that a node pref= ers to receive new block announcements via a "headers" message ra= ther than an "inv".</font></div><div><font face=3D"monospace, mon= ospace"><br></font></div><div><font face=3D"monospace, monospace">=3D=3DMot= ivation=3D=3D</font></div><div><font face=3D"monospace, monospace"><br></fo= nt></div><div><font face=3D"monospace, monospace">Since the introduction of= "headers-first" downloading of blocks in 0.10, blocks will not b= e processed unless</font></div><div><font face=3D"monospace, monospace">the= y are able to connect to a (valid) headers chain.=C2=A0 Consequently, block= relay generally works</font></div><div><font face=3D"monospace, monospace"= >as follows:</font></div><div><font face=3D"monospace, monospace"># A node = (N) announces the new tip with an "inv" message, containing the b= lock hash</font></div><div><font face=3D"monospace, monospace"># A peer (P)= responds to the "inv" with a "getheaders" message (to = request headers up to the new tip) and a "getdata" message for th= e new tip itself</font></div><div><font face=3D"monospace, monospace"># N r= esponds with a "headers" message (with the header for the new blo= ck along with any preceding headers unknown to P) and a "block" m= essage containing the new block</font></div><div><font face=3D"monospace, m= onospace"><br></font></div><div><font face=3D"monospace, monospace">However= , in the case where a new block is being announced that builds on the tip, = it would be generally more efficient if the node N just announced the block= header for the new block, rather than just the block hash, and saved the p= eer from generating and transmitting the getheaders message (and the requir= ed block locator).</font></div><div><font face=3D"monospace, monospace"><br= ></font></div><div><font face=3D"monospace, monospace">In the case of a reo= rg, where 1 or more blocks are disconnected, nodes currently just send an &= quot;inv" for the new tip.=C2=A0 Peers currently are able to request t= he new tip immediately, but wait until the headers for the intermediate blo= cks are delivered before requesting those blocks.=C2=A0 By announcing heade= rs from the last fork point leading up to the new tip in the block announce= ment, peers are able to request all the intermediate blocks immediately.</f= ont></div><div><font face=3D"monospace, monospace"><br></font></div><div><f= ont face=3D"monospace, monospace">=3D=3DSpecification=3D=3D</font></div><di= v><font face=3D"monospace, monospace"><br></font></div><div><font face=3D"m= onospace, monospace"># The sendheaders message is defined as an empty messa= ge where pchCommand =3D=3D "sendheaders"</font></div><div><font f= ace=3D"monospace, monospace"># Upon receipt of a "sendheaders" me= ssage, the node will be permitted, but not required, to announce new blocks= by sending the header of the new block (along with any other blocks that a= node believes a peer might need in order for the block to connect).</font>= </div><div><font face=3D"monospace, monospace"># Feature discovery is enabl= ed by checking protocol version >=3D 70012</font></div><div><font face= =3D"monospace, monospace"><br></font></div><div><font face=3D"monospace, mo= nospace">=3D=3DBackward compatibility=3D=3D</font></div><div><font face=3D"= monospace, monospace"><br></font></div><div><font face=3D"monospace, monosp= ace">Older clients remain fully compatible and interoperable after this cha= nge.</font></div><div><font face=3D"monospace, monospace"><br></font></div>= <div><font face=3D"monospace, monospace">=3D=3DImplementation=3D=3D</font><= /div><div><font face=3D"monospace, monospace"><br></font></div><div><font f= ace=3D"monospace, monospace"><a href=3D"https://github.com/bitcoin/bitcoin/= pull/6494">https://github.com/bitcoin/bitcoin/pull/6494</a></font></div></d= iv></div> --089e0149c320c45a44052082080b--