Re: [Bitcoin-development] Missing fRelayTxes in version message

2013-06-20 Thread Turkey Breast
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'm 
saying is that optional lengths shouldn't be used (a field exists or not) and 
for every field change, the protocol version should be upgraded.

Now that fRelayTxes is part of the protocol, the version number should be 
upgraded to reflect this fact.




 From: Mike Hearn m...@plan99.net
To: Paul Lyon pml...@hotmail.ca 
Cc: Turkey Breast turkeybre...@yahoo.com; 
bitcoin-development@lists.sourceforge.net 
bitcoin-development@lists.sourceforge.net 
Sent: Wednesday, June 19, 2013 3:20 PM
Subject: Re: [Bitcoin-development] Missing fRelayTxes in version message
 


If you want to criticise the Bitcoin protocol for sloppyness, the variable 
length of some messages isn't where I'd start.

Note that ping has the same issue, its length has changed over time to include 
the nonce.

If your parser can't handle that kind of thing, you need to fix it. The 
protocol has always worked that way.




On Wed, Jun 19, 2013 at 3:03 PM, Paul Lyon pml...@hotmail.ca wrote:

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.
 
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.
 
Paul
 
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. 
 
From: Mike Hearn
Sent: ‎Wednesday‎, ‎June‎ ‎19‎, ‎2013 ‎7‎:‎43‎ ‎AM
To: Turkey Breast
Cc: bitcoin-development@lists.sourceforge.net
 
Bitcoin-Qt on master does send it now although it doesn't affect anything, but 
as old pre-filtering versions will continue to exist, you'll always have to be 
able to deserialize version messages without it.


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


The standard does not say it should appear. Read it again - BIP 37 says about 
the new version message field:
If false then broadcast transactions will not be announced until a 
filter{load,add,clear} command is received. If missing or true, no change in 
protocol behaviour occurs.
 



On Wed, Jun 19, 2013 at 12:33 PM, Turkey Breast turkeybre...@yahoo.com wrote:

It's a problem if you work with iterators to deserialize the byte stream. Even 
failing that, it's just sloppy programming. What happens in the future when 
new fields are added to the version message? It'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.


And yes, it was a problem for me that caused a lot of confusion why this byte 
didn'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't help other implementations to have an unclear behaviour that depends 
on some magic from one implementation.





 From: Mike Hearn m...@plan99.net
To: Turkey Breast turkeybre...@yahoo.com 
Cc: bitcoin-development@lists.sourceforge.net 
bitcoin-development@lists.sourceforge.net 
Sent: Wednesday, June 19, 2013 11:39 AM

Subject: Re: [Bitcoin-development] Missing fRelayTxes in version message
 


It has to be optional because old clients don't send it, obviously.


Why is this even an issue? There's no problem with variable length messages 
in any codebase that I'm aware of. Is this solving some actual problem?



On Wed, Jun 19, 2013 at 12:30 AM, Turkey Breast turkeybre...@yahoo.com 
wrote:

That'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't see why a 1 byte flag needs to be 
optional anyway.





 From: Mike Hearn m...@plan99.net
To: Turkey Breast turkeybre...@yahoo.com 
Cc: Bitcoin Dev bitcoin-development@lists.sourceforge.net 
Sent: Tuesday, June 18, 2013 9:48 PM
Subject: Re: [Bitcoin-development] Missing fRelayTxes in version message
 


It's not a bug (although there was recently a change to make bitcoind/qt 
always send this field anyway). 


I don't know where Amir is going with BIP 60. Version messages have always 
been variable length. There's nothing inherent in the Bitcoin protocol that 
says all messages are fixed length, indeed, tx messages

Re: [Bitcoin-development] Missing fRelayTxes in version

2013-06-20 Thread Turkey Breast
I don't get why this is such a contentious change?

Before I was able to use asserts to check the expected length of length of 
messages per protocol version, I could pass in dumb iterators that just parse 
the byte stream and I could serialize and deserialize a message to check the 
parser is correct (in debug mode).

This 'simple' change causes all that behaviour to be lost. You can no longer 
just use iterators but must know the remaining length (or if you use 
std::distance, you can only use specific std containers - not just anything 
with an iterator and an operator++). You cannot check the deserialization 
process by serializing the deserialized message and comparing it to the 
original data (because the bool is always present in the serializer).

It's a bit stupid you call it buggy code when this behaviour has never been 
present in Bitcoin. The BIP doesn't introduce any unwanted side-effects and is 
a trivial reasonable change.

If you want optional fields then the proper way to do it, is to either set a 
flag in the Services field of the version message to indicate different 
formats for messages (i.e use this template structure for a message, not that 
one), introduce a new message (if the changes are big), to approve/improve 
Stefan's BIP 32 for custom services or to have a value in the byte stream 
indicating which fields are present (maybe a bitfield or so).

Using a quirk of an implementation is just bad form and sloppy coding. Optional 
fields should have their own mechanism that allows them to remain as optional 
fields between protocol version upgrades.


The bitcoind software can probably be improved too, by checking that the length 
of the version message is consistent for the protocol version given by the 
connected node. Right now it makes no assumptions based on that which is a 
mistake (new clients can broadcast older version messages that don't have all 
the fields required). Probably the software should penalise hosts which do that.

What's the big deal to update the protocol version number from 70001 to 70002? 
It's not like we'll run out of integers. The field has now gone from optional 
to required now anyway - that's a behaviour change. It'd be good to enforce 
that. I see this as a bug.




 From: Mike Hearn m...@plan99.net
To: Pieter Wuille pieter.wui...@gmail.com 
Cc: Bitcoin Dev bitcoin-development@lists.sourceforge.net; Tamas Blummer 
ta...@bitsofproof.com 
Sent: Thursday, June 20, 2013 11:17 AM
Subject: Re: [Bitcoin-development] Missing fRelayTxes in version
 


There's no problem, but there's no benefit either. It also locks us in to a 
potentially problematic guarantee - what if in future we want to have, say, two 
optional new pieces of data in two different messages. We don't want to require 
that if version  X then you have to implement all features up to and including 
that point.

Essentially the number of fields in a message is like a little version number, 
just for that message. It adds flexibility to keep it that way, and there's no 
downside, seeing as that bridge was already crossed and people with parsers 
that can't handle it need to fix their code anyway.

So I have a slight preference for keeping things the way they are, it keeps 
things flexible for future and costs nothing.




On Thu, Jun 20, 2013 at 11:06 AM, Pieter Wuille pieter.wui...@gmail.com wrote:

On Thu, Jun 20, 2013 at 09:36:40AM +0200, Mike Hearn wrote:
 Sure but why not do that when there's an actual new field to add? Does
 anyone have a proposal for a feature that needs a new version field at the
 moment? There's no point changing the protocol now unless there's actually
 a new field to add.

 Anyway I still don't see why anyone cares about this issue. The Bitcoin
 protocol does not and never has required that all messages have a fixed
 number of fields per version. Any parser written on the assumption it did
 was just buggy. Look at how tx messages are relayed for the most obvious
 example of that pattern in action - it's actually the raw byte stream
 that's stored and relayed to ensure that fields added in new versions
 aren't dropped during round-tripping. Old versions are supposed to preserve
 fields from the future.

Actually, that is not the same issue. What is being argued for here is that
the version in the version message itself should indicate which fields are
present, so a parser doesn't need to look at the length of the message. That
seems like a minor but very reasonable request to me, and it's trivial to do.
That doesn't mean that you may receive versions higher than what you know of,
and thus messages with fields you don't know about. That doesn't matter, you
can just ignore them.

I see no problem with raising the protocol version number to indicate
all fields up to fRelayTxes are required, if the announced nVersion is above 
N.
In fact, I believe (though haven't checked) all previous additions to the 
version
message were accompanied with 

Re: [Bitcoin-development] Missing fRelayTxes in version message

2013-06-19 Thread Turkey Breast
It's a problem if you work with iterators to deserialize the byte stream. Even 
failing that, it's just sloppy programming. What happens in the future when new 
fields are added to the version message? It'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.

And yes, it was a problem for me that caused a lot of confusion why this byte 
didn'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't 
help other implementations to have an unclear behaviour that depends on some 
magic from one implementation.




 From: Mike Hearn m...@plan99.net
To: Turkey Breast turkeybre...@yahoo.com 
Cc: bitcoin-development@lists.sourceforge.net 
bitcoin-development@lists.sourceforge.net 
Sent: Wednesday, June 19, 2013 11:39 AM
Subject: Re: [Bitcoin-development] Missing fRelayTxes in version message
 


It has to be optional because old clients don't send it, obviously.

Why is this even an issue? There's no problem with variable length messages in 
any codebase that I'm aware of. Is this solving some actual problem?



On Wed, Jun 19, 2013 at 12:30 AM, Turkey Breast turkeybre...@yahoo.com wrote:

That'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't see why a 1 byte flag needs to be 
optional anyway.





 From: Mike Hearn m...@plan99.net
To: Turkey Breast turkeybre...@yahoo.com 
Cc: Bitcoin Dev bitcoin-development@lists.sourceforge.net 
Sent: Tuesday, June 18, 2013 9:48 PM
Subject: Re: [Bitcoin-development] Missing fRelayTxes in version message
 


It's not a bug (although there was recently a change to make bitcoind/qt 
always send this field anyway). 


I don't know where Amir is going with BIP 60. Version messages have always 
been variable length. There'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.



On Tue, Jun 18, 2013 at 7:45 PM, Turkey Breast turkeybre...@yahoo.com wrote:

See this BIP. I'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.


https://en.bitcoin.it/wiki/BIP_0060#Code_Updates


This BIP details everything that needs to be done and proposes a protocol 
upgrade.

--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
___
Bitcoin-development mailing list
Bitcoin-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bitcoin-development





--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
___
Bitcoin-development mailing list
Bitcoin-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bitcoin-development

--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Bitcoin-development mailing list
Bitcoin-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bitcoin-development


[Bitcoin-development] Missing fRelayTxes in version message

2013-06-18 Thread Turkey Breast
See this BIP. I'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.

https://en.bitcoin.it/wiki/BIP_0060#Code_Updates

This BIP details everything that needs to be done and proposes a protocol 
upgrade.
--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Bitcoin-development mailing list
Bitcoin-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bitcoin-development


Re: [Bitcoin-development] Missing fRelayTxes in version message

2013-06-18 Thread Turkey Breast
That'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't see why a 1 byte flag needs to be 
optional anyway.




 From: Mike Hearn m...@plan99.net
To: Turkey Breast turkeybre...@yahoo.com 
Cc: Bitcoin Dev bitcoin-development@lists.sourceforge.net 
Sent: Tuesday, June 18, 2013 9:48 PM
Subject: Re: [Bitcoin-development] Missing fRelayTxes in version message
 


It's not a bug (although there was recently a change to make bitcoind/qt always 
send this field anyway). 

I don't know where Amir is going with BIP 60. Version messages have always been 
variable length. There'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.



On Tue, Jun 18, 2013 at 7:45 PM, Turkey Breast turkeybre...@yahoo.com wrote:

See this BIP. I'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.


https://en.bitcoin.it/wiki/BIP_0060#Code_Updates


This BIP details everything that needs to be done and proposes a protocol 
upgrade.

--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
___
Bitcoin-development mailing list
Bitcoin-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bitcoin-development

--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Bitcoin-development mailing list
Bitcoin-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bitcoin-development