<div dir="ltr">If you want to criticise the Bitcoin protocol for sloppyness, the variable length of some messages isn&#39;t where I&#39;d start.<div><br></div><div>Note that ping has the same issue, its length has changed over time to include the nonce.</div>
<div><br></div><div style>If your parser can&#39;t handle that kind of thing, you need to fix it. The protocol has always worked that way.</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Jun 19, 2013 at 3:03 PM, Paul Lyon <span dir="ltr">&lt;<a href="mailto:pmlyon@hotmail.ca" target="_blank">pmlyon@hotmail.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div dir="ltr" style="font-family:Calibri,&#39;Segoe UI&#39;,Meiryo,&#39;Microsoft YaHei UI&#39;,&#39;Microsoft JhengHei UI&#39;,&#39;Malgun Gothic&#39;,&#39;Khmer UI&#39;,&#39;Nirmala UI&#39;,Tunga,&#39;Lao UI&#39;,Ebrima,sans-serif;font-size:12pt">
<div>I’m also running into this exact same issue with my parser, now I understand why the relay field behavior I was seeing doesn’t match the wiki.</div><div> </div><div>So to parse a version message, you can’t rely on the protocol version? You have to know how long the payload is, and then parse the message accordingly? I agree with Turkey Breast, this seems a bit sloppy to me.</div>
<div> </div><div>Paul</div><div> </div><div>P.S. I’ve never used a dev mailing list before and I want to get involved with the Bitcoin dev community, so let me know if I’m horribly violating any mailing list etiquette. <span style="font-family:&quot;Segoe UI Symbol&quot;,&quot;Apple Color Emoji&quot;">😊</span></div>
<div> </div><div style="padding-top:5px;border-top-color:rgb(229,229,229);border-top-width:1px;border-top-style:solid"><div><font face="Calibri, &#39;Segoe UI&#39;, Meiryo, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft JhengHei UI&#39;, &#39;Malgun Gothic&#39;, &#39;Khmer UI&#39;, &#39;Nirmala UI&#39;, Tunga, &#39;Lao UI&#39;, Ebrima, sans-serif" style="line-height:15pt;letter-spacing:0.02em;font-family:Calibri,&quot;Segoe UI&quot;,Meiryo,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft JhengHei UI&quot;,&quot;Malgun Gothic&quot;,&quot;Khmer UI&quot;,&quot;Nirmala UI&quot;,Tunga,&quot;Lao UI&quot;,Ebrima,sans-serif;font-size:11pt"><b>From:</b> Mike Hearn<br>
<b>Sent:</b> ‎Wednesday‎, ‎June‎ ‎19‎, ‎2013 ‎7‎:‎43‎ ‎AM<br><b>To:</b> Turkey Breast<br><b>Cc:</b> <a href="mailto:bitcoin-development@lists.sourceforge.net" target="_blank">bitcoin-development@lists.sourceforge.net</a></font></div>
</div><div><div class="h5"><div> </div><div dir="ltr">Bitcoin-Qt on master does send it now although it doesn&#39;t affect anything, but as old pre-filtering versions will continue to exist, you&#39;ll always have to be able to deserialize version messages without it.<div>

<br></div><div>Bitcoin version messages have always had variable length, look at how the code is written in main.cpp. If you didn&#39;t experience issues until now all it means is that no sufficiently old nodes were talking to yours.</div>

<div><br></div><div>The standard does not say it should appear. Read it again - BIP 37 says about the new version message field:</div><div><table style="line-height:19.2px;border-collapse:collapse;font-size:12.8px;background-color:rgb(249,249,249);font-family:sans-serif;margin:1em 0px;border:1px solid rgb(170,170,170)">

<tbody><tr><td style="padding:0.2em;border:1px solid rgb(170,170,170)">If false then broadcast transactions will not be announced until a filter{load,add,clear} command is received. <b>If missing or true</b>, no change in protocol behaviour occurs.<br>

</td></tr></tbody></table></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 19, 2013 at 12:33 PM, Turkey Breast <span dir="ltr">&lt;<a title="mailto:turkeybreast@yahoo.com" href="mailto:turkeybreast@yahoo.com" target="_blank">turkeybreast@yahoo.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt">
<div><span>It&#39;s a problem if you work with iterators to deserialize the byte stream. Even failing that, it&#39;s just sloppy programming. What happens in the future when new fields are added to the version message? It&#39;s not a big deal to say that this protocol version has X number of fields, that (higher) protocol version message has X + N number of fields. Deterministic number of fields per protocol version is sensical and how Bitcoin has been for a long time.</span></div>

<div style="font-family:times new roman,new york,times,serif;font-size:16px;font-style:normal;background-color:transparent"><br><span></span></div><div style="font-family:times new roman,new york,times,serif;font-size:16px;font-style:normal;background-color:transparent">

<span>And yes, it was a problem for me
 that caused a lot of confusion why this byte didn&#39;t exist in many version messages despite the standard saying it should and the code in bitcoind indicating it should. Nowhere was this written. It doesn&#39;t help other implementations to have an unclear behaviour that depends on some magic from one implementation.<br>

</span></div><div><br></div>  <div style="font-family:times new roman,new york,times,serif;font-size:12pt"> <div style="font-family:times new roman,new york,times,serif;font-size:12pt"> <div dir="ltr"> <hr size="1">  <font face="Arial"><div>

 <b><span style="font-weight:bold">From:</span></b> Mike Hearn &lt;<a title="mailto:mike@plan99.net" href="mailto:mike@plan99.net" target="_blank">mike@plan99.net</a>&gt;<br> <b><span style="font-weight:bold">To:</span></b> Turkey Breast &lt;<a title="mailto:turkeybreast@yahoo.com" href="mailto:turkeybreast@yahoo.com" target="_blank">turkeybreast@yahoo.com</a>&gt; <br>

</div><b><span style="font-weight:bold">Cc:</span></b> &quot;<a title="mailto:bitcoin-development@lists.sourceforge.net" href="mailto:bitcoin-development@lists.sourceforge.net" target="_blank">bitcoin-development@lists.sourceforge.net</a>&quot; &lt;<a title="mailto:bitcoin-development@lists.sourceforge.net" href="mailto:bitcoin-development@lists.sourceforge.net" target="_blank">bitcoin-development@lists.sourceforge.net</a>&gt; <br>

 <b><span style="font-weight:bold">Sent:</span></b> Wednesday, June 19, 2013 11:39 AM<div><div><br> <b><span style="font-weight:bold">Subject:</span></b> Re: [Bitcoin-development] Missing fRelayTxes in version message<br>

 </div></div></font> </div><div><div> <div><br>
<div><div dir="ltr">It has to be optional because old clients don&#39;t send it, obviously.<div><br></div><div>Why is this even an issue? There&#39;s no problem with variable length messages in any codebase that I&#39;m aware of. Is this solving some actual problem?</div>


</div><div><br><br><div>On Wed, Jun 19, 2013 at 12:30 AM, Turkey Breast <span dir="ltr">&lt;<a title="mailto:turkeybreast@yahoo.com" href="mailto:turkeybreast@yahoo.com" rel="nofollow" target="_blank">turkeybreast@yahoo.com</a>&gt;</span> wrote:<br>

<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt">
<div><span>That&#39;s me. I never said to make all messages fixed length. I said to make a fixed number of fields per protocol. So given a protocol version number, you know the number of fields in a message. This is not only easier for parsing messages, but just good practice. I don&#39;t see why a 1 byte flag needs to be optional anyway.<br>


</span></div><div><div><br></div>  </div><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div> </div><div style="font-family:times new roman,new york,times,serif;font-size:12pt">
<div> <div dir="ltr"> <hr size="1">  <font face="Arial"> <b><span style="font-weight:bold">From:</span></b> Mike Hearn &lt;<a title="mailto:mike@plan99.net" href="mailto:mike@plan99.net" rel="nofollow" target="_blank">mike@plan99.net</a>&gt;<br>
 <b><span style="font-weight:bold">To:</span></b> Turkey Breast &lt;<a title="mailto:turkeybreast@yahoo.com" href="mailto:turkeybreast@yahoo.com" rel="nofollow" target="_blank">turkeybreast@yahoo.com</a>&gt; <br>

<b><span style="font-weight:bold">Cc:</span></b>
 Bitcoin Dev &lt;<a title="mailto:bitcoin-development@lists.sourceforge.net" href="mailto:bitcoin-development@lists.sourceforge.net" rel="nofollow" target="_blank">bitcoin-development@lists.sourceforge.net</a>&gt; <br> <b><span style="font-weight:bold">Sent:</span></b> Tuesday, June 18, 2013 9:48 PM<br>


 <b><span style="font-weight:bold">Subject:</span></b> Re: [Bitcoin-development] Missing fRelayTxes in version message<br> </font> </div></div><div><div> <div><br>
<div><div dir="ltr">It&#39;s not a bug (although there was recently a change to make bitcoind/qt always send this field anyway). <div><br></div><div>I don&#39;t know where Amir is going with BIP 60. Version messages have always been variable length. There&#39;s nothing inherent in the Bitcoin protocol that says all messages are fixed length, indeed, tx messages are allowed to have arbitrary data appended after them that gets relayed.</div>



</div><div><br><br><div>On Tue, Jun 18, 2013 at 7:45 PM, Turkey Breast <span dir="ltr">&lt;<a title="mailto:turkeybreast@yahoo.com" href="mailto:turkeybreast@yahoo.com" rel="nofollow" target="_blank">turkeybreast@yahoo.com</a>&gt;</span> wrote:<br>

<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt">
<div>See this BIP. I&#39;m not sure if this is a bug or what, but it would be good if messages always had a fixed number of fields per protocol version.</div>


<div><br></div><div style="font-family:times new roman,new york,times,serif;font-size:16px;font-style:normal;background-color:transparent"><a title="https://en.bitcoin.it/wiki/BIP_0060#Code_Updates" href="https://en.bitcoin.it/wiki/BIP_0060#Code_Updates" rel="nofollow" target="_blank">https://en.bitcoin.it/wiki/BIP_0060#Code_Updates</a></div>



<div style="font-family:times new roman,new york,times,serif;font-size:16px;font-style:normal;background-color:transparent"><br></div><div style="font-family:times new roman,new york,times,serif;font-size:16px;font-style:normal;background-color:transparent">



This BIP details everything that needs to be done and proposes a protocol upgrade.<br></div></div></div><br>------------------------------------------------------------------------------<br>
This <a title="http://sf.net/" href="http://sf.net/" rel="nofollow" target="_blank">SF.net</a> email is sponsored by Windows:<br>
<br>
Build for Windows Store.<br>
<br>
<a title="http://p.sf.net/sfu/windows-dev2dev" href="http://p.sf.net/sfu/windows-dev2dev" target="_blank">http://p.sf.net/sfu/windows-dev2dev</a><br>_______________________________________________<br>
Bitcoin-development mailing list<br>
<a title="mailto:Bitcoin-development@lists.sourceforge.net" href="mailto:Bitcoin-development@lists.sourceforge.net" rel="nofollow" target="_blank">Bitcoin-development@lists.sourceforge.net</a><br>
<a title="https://lists.sourceforge.net/lists/listinfo/bitcoin-development" href="https://lists.sourceforge.net/lists/listinfo/bitcoin-development" rel="nofollow" target="_blank">https://lists.sourceforge.net/lists/listinfo/bitcoin-development</a><br>

<br></blockquote></div><br></div>
</div><br><br></div> </div></div></div> </div>  </div></div><br>------------------------------------------------------------------------------<br>
This SF.net email is sponsored by Windows:<br>
<br>
Build for Windows Store.<br>
<br>
<a title="http://p.sf.net/sfu/windows-dev2dev" href="http://p.sf.net/sfu/windows-dev2dev" rel="nofollow" target="_blank">http://p.sf.net/sfu/windows-dev2dev</a><br>_______________________________________________<br>
Bitcoin-development mailing list<br>
<a title="mailto:Bitcoin-development@lists.sourceforge.net" href="mailto:Bitcoin-development@lists.sourceforge.net" rel="nofollow" target="_blank">Bitcoin-development@lists.sourceforge.net</a><br>
<a title="https://lists.sourceforge.net/lists/listinfo/bitcoin-development" href="https://lists.sourceforge.net/lists/listinfo/bitcoin-development" rel="nofollow" target="_blank">https://lists.sourceforge.net/lists/listinfo/bitcoin-development</a><br>

<br></blockquote></div><br></div>
</div><br><br></div> </div></div></div> </div>  </div></div><br>------------------------------------------------------------------------------<br>
This SF.net email is sponsored by Windows:<br>
<br>
Build for Windows Store.<br>
<br>
<a title="http://p.sf.net/sfu/windows-dev2dev" href="http://p.sf.net/sfu/windows-dev2dev" target="_blank">http://p.sf.net/sfu/windows-dev2dev</a><br>_______________________________________________<br>
Bitcoin-development mailing list<br>
<a title="mailto:Bitcoin-development@lists.sourceforge.net" href="mailto:Bitcoin-development@lists.sourceforge.net" target="_blank">Bitcoin-development@lists.sourceforge.net</a><br>
<a title="https://lists.sourceforge.net/lists/listinfo/bitcoin-development" href="https://lists.sourceforge.net/lists/listinfo/bitcoin-development" target="_blank">https://lists.sourceforge.net/lists/listinfo/bitcoin-development</a><br>

<br></blockquote></div><br></div>
</div></div></div></div></blockquote></div><br></div>