<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 11, 2017 at 9:56 PM, Jim Posen via bitcoin-dev <span dir="ltr">&lt;<a href="mailto:bitcoin-dev@lists.linuxfoundation.org" target="_blank">bitcoin-dev@lists.linuxfoundation.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"></span><div>Omitting nBits entirely seems reasonable, I wrote up a possible implementation <a href="https://github.com/bitcoin/bitcoin/compare/master...jimpo:compact-headers-difficulty" target="_blank">here</a>. The 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></div></div></blockquote><div><br></div><div>A compromise would be to have 1 byte indicating the difference since the last header.</div><div><br></div><div>Since the exponent doesn&#39;t use the full range you could steal bits from there to indicate mode.</div><div><br></div><div>- no change</div><div>- mantissa offset (for small changes)</div><div>- full difficulty</div><div><br></div><div>This would support any nBits rule and you say 3 of the 4 bytes.<br></div><div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra">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).</div></div></blockquote><div><br></div><div>I suggest adding a message where you can ask for the lowest N hashes between 2 heights on the main chain.<br></div><div><br></div><div>The reply is an array of {height, header} pairs for the N headers with the lowest hash in the specified range.<br></div><div><br></div><div>All peers should agree on which headers are in the array.  If there is disagreement, then you can at least narrow down on which segment there is disagreement.</div><div><br></div><div>It works kind of like a cut and choose.  You pick one segment of the ones he gave you recursively.<br></div><div><br></div><div>You can ask a peer for proof for a segment between 2 headers of the form.<br></div><div><br></div><div>- first header + coinbase with merkle branch</div><div>- all headers in the segment<br></div><div><br></div><div>This proves the segment has the correct height and that all the headers link up.</div><div><br></div><div>There is a method called &quot;high hash highway&quot; that allows compact proofs of total POW.<br></div></div></div></div>