<div dir="ltr">I personally don&#39;t treat the relay field as optional, i.e. it is there as 0x01 if it is set. Otherwise, it is simply a trailing zero byte. Hence, the right way of reading the packet as with any network packet is to first retrieve the header information, get the actual payload length, then parse the payload accordingly. I can also choose to include 0x00 for my relay field in my outgoing packet and reflect that accordingly in my length field in the header.<div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Jun 20, 2013 at 4:20 PM, Turkey Breast <span dir="ltr">&lt;<a href="mailto:turkeybreast@yahoo.com" target="_blank">turkeybreast@yahoo.com</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 style="font-size:12pt;font-family:times new roman,new york,times,serif">I never said that Bitcoin message field lengths should always be the same. But before this change they certainly were constant per protocol version. All I&#39;m saying is that optional lengths shouldn&#39;t be used (a field exists or not) and for every field change, the protocol version should be upgraded.<br>
<br>Now that fRelayTxes is part of the protocol, the version number should be upgraded to reflect this fact.<br><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"> <b><span style="font-weight:bold">From:</span></b> Mike Hearn &lt;<a href="mailto:mike@plan99.net" target="_blank">mike@plan99.net</a>&gt;<br> <b><span style="font-weight:bold">To:</span></b> Paul Lyon &lt;<a href="mailto:pmlyon@hotmail.ca" target="_blank">pmlyon@hotmail.ca</a>&gt;
 <br><b><span style="font-weight:bold">Cc:</span></b> Turkey Breast &lt;<a href="mailto:turkeybreast@yahoo.com" target="_blank">turkeybreast@yahoo.com</a>&gt;; &quot;<a href="mailto:bitcoin-development@lists.sourceforge.net" target="_blank">bitcoin-development@lists.sourceforge.net</a>&quot; &lt;<a 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 3:20 PM<br> <b><span style="font-weight:bold">Subject:</span></b> Re: [Bitcoin-development] Missing fRelayTxes in version message<br> </font> </div>
 <div><br><div><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>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><br></div></div><div><br><br><div>
On Wed, Jun 19, 2013 at 3:03 PM, Paul Lyon <span dir="ltr">&lt;<a rel="nofollow" href="mailto:pmlyon@hotmail.ca" target="_blank">pmlyon@hotmail.ca</a>&gt;</span> wrote:<br><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div dir="ltr">
<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>😊</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"><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 rel="nofollow" href="mailto:bitcoin-development@lists.sourceforge.net" target="_blank">bitcoin-development@lists.sourceforge.net</a></font></div>

</div><div><div><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><br><br><div>On Wed, Jun 19, 2013 at 12:33 PM, Turkey Breast <span dir="ltr">&lt;<a rel="nofollow" title="mailto:turkeybreast@yahoo.com" href="mailto:turkeybreast@yahoo.com" 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>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 rel="nofollow" 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 rel="nofollow" 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 rel="nofollow" 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 rel="nofollow" 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 rel="nofollow" title="mailto:turkeybreast@yahoo.com" href="mailto:turkeybreast@yahoo.com" 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 rel="nofollow" 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 rel="nofollow" title="mailto:turkeybreast@yahoo.com" href="mailto:turkeybreast@yahoo.com" target="_blank">turkeybreast@yahoo.com</a>&gt; <br>

<b><span style="font-weight:bold">Cc:</span></b>
 Bitcoin Dev &lt;<a rel="nofollow" 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> 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 rel="nofollow" title="mailto:turkeybreast@yahoo.com" href="mailto:turkeybreast@yahoo.com" 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 rel="nofollow" title="https://en.bitcoin.it/wiki/BIP_0060#Code_Updates" href="https://en.bitcoin.it/wiki/BIP_0060#Code_Updates" 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 rel="nofollow" title="http://sf.net/" href="http://sf.net/" target="_blank">SF.net</a> email is sponsored by Windows:<br>
<br>
Build for Windows Store.<br>
<br>
<a rel="nofollow" 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 rel="nofollow" title="mailto:Bitcoin-development@lists.sourceforge.net" href="mailto:Bitcoin-development@lists.sourceforge.net" target="_blank">Bitcoin-development@lists.sourceforge.net</a><br>
<a rel="nofollow" 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><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 rel="nofollow" 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 rel="nofollow" title="mailto:Bitcoin-development@lists.sourceforge.net" href="mailto:Bitcoin-development@lists.sourceforge.net" target="_blank">Bitcoin-development@lists.sourceforge.net</a><br>
<a rel="nofollow" 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><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 rel="nofollow" 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 rel="nofollow" title="mailto:Bitcoin-development@lists.sourceforge.net" href="mailto:Bitcoin-development@lists.sourceforge.net" target="_blank">Bitcoin-development@lists.sourceforge.net</a><br>
<a rel="nofollow" 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></div><br><br></div> </div> </div>  </div></div><br>------------------------------------------------------------------------------<br>
This SF.net email is sponsored by Windows:<br>
<br>
Build for Windows Store.<br>
<br>
<a 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 href="mailto:Bitcoin-development@lists.sourceforge.net">Bitcoin-development@lists.sourceforge.net</a><br>
<a 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>