Skip to content

Conversation

@jgarzik
Copy link
Contributor

@jgarzik jgarzik commented Apr 11, 2012

Add a pong message that is sent in reply to a ping. It echoes back a nonce
field that is now added to the ping message. Send a nonce of zero in ping
messages.

Original author: Mike Hearn @ Google

Modified Mike's change to introduce a mild form of protocol documentation in
version.h.

@jgarzik
Copy link
Contributor Author

jgarzik commented Apr 11, 2012

This is intended to supercede pull request #932, for the following minor reasons:

  1. removes the actual protocol version increment. IMO this should be external to the 'pong message' commit.

and under the principle of making code self-documenting...

  1. use a named constant rather than a magic number for version behavior switching. bitcoin code is too full of magic numbers, and we should resist adding more.
  2. place that constant in sipa's newly minted version.h, as a central location for future version-related constants like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the nonce optional, if you don't want a pong?

@jgarzik
Copy link
Contributor Author

jgarzik commented Apr 11, 2012

Independent, yes, but where is a better place for version information than version.{h,cpp}?

It is an odd policy that the "version" module excludes certain classes of version information and not others. That seems to violate the Principle of Least Surprise.

@sipa
Copy link
Member

sipa commented Apr 11, 2012

Agree, but calling them both "_VERSION" will be very confusing.

@jgarzik
Copy link
Contributor Author

jgarzik commented Apr 11, 2012

No more confusing than the existing PROTOCOL_VERSION vs. CLIENT_VERSION, each with the _VERSION suffix (which I argue is not confusing at all, but rather a logical naming scheme for each).

If it appeals to one's sense of symmetry, we can move PROTOCOL_VERSION to version.* as well.

@laanwj
Copy link
Member

laanwj commented Apr 12, 2012

IMO, version.h should contain version information for the current client, that will change over time.

I agree that feature-specific thresholds that will be "written in stone forever" should go somewhere else. Maybe there will eventually be enough for a bip_versions.h :-) (if we tracked down other magic version numbers we could already do so)

Another suggestion would be to rename it to BIP0031_MIN_VERSION to it clear that it is a version threshold (though the comment explains this as well of course...).

@jgarzik
Copy link
Contributor Author

jgarzik commented Apr 12, 2012

No, we don't need multiple version.* modules in the tree.

@sipa
Copy link
Member

sipa commented Apr 12, 2012

To me, mixing the client version (metadata about the project you're compiling) and the network version (a property of the protocol being implemented) in the same module is wrong. It's like having a source file in firefox that encdes both information about the firefox browser version and the differences between HTML4 and HTML5.

The fact that both are called version and have a similar number scheme is an historic artifact, and I would prefer to get them separated rather sooner than later. Maybe remove the moniker '_VERSION' from all protocol-related code, and simply call it "protocol 60000". I agree that we need nice constants for magic protocol switches, but they do not belong in version.h. Really.

@jgarzik
Copy link
Contributor Author

jgarzik commented Apr 12, 2012

This is being WAY overthought.

  1. It is silly to have multiple version modules, for that will create confusion among outside reviewers.
  2. It is silly to put version constants outside the existing version module, for humans outside the dev team will naturally look for anything version-related in a module called "version."
  3. It is even more silly to rename a protocol version constant to something other than "VERSION". It -is- a version number.

It is not a historical accident that the protocol version is called "PROTOCOL_VERSION". The naming precisely describes its purpose, and changing that name would be detrimental to understanding by outside reviewers.

It is just bonkers to remove the "_VERSION" word from all version-related constants in bitcoin unrelated to client version. That is creating more problems than it is solving.

@laanwj
Copy link
Member

laanwj commented Apr 12, 2012

You can use the exact same argument that this causes confusion for "outside
reviewers". Do we need to increase the BIP0031_VERSION with a new release?
How is it different from the CLIENT and PROTOCOL version?... etc.

@jgarzik
Copy link
Contributor Author

jgarzik commented Apr 12, 2012

Helpfully, there is a comment for outside reviewers in the code I added, solving this imagined problem.

@sipa
Copy link
Member

sipa commented Apr 12, 2012

Certainly, a comment saying "This relates to the protocol version being used in P2P connections, and is independent from the client version" is enough to make it acceptable (I see no such comment right now, though...). Still, such constants belong in the networking code, imho.

Jeff Garzik and others added 2 commits April 12, 2012 12:11
Add a pong message that is sent in reply to a ping. It echoes back a nonce
field that is now added to the ping message. Send a nonce of zero in ping
messages.

Original author: Mike Hearn @ Google

Modified Mike's change to introduce a mild form of protocol documentation in
version.h.
… file.

* move PROTOCOL_VERSION to version.h

* move CLIENT_VERSION* to version.h, make available past cpp stage

* clearly separate client, network version portions of version.h
@jgarzik
Copy link
Contributor Author

jgarzik commented Apr 12, 2012

Updated to add such comments, and further illustrate the usage.

@sipa
Copy link
Member

sipa commented Apr 12, 2012

Other magic protocol version constants:

  • protocol.h: 31402 (nTime in CAddress)
  • main.cpp: 31402 (avoid requesting addresses from older nodes)
  • main.cpp: 32000...32400 (don't ask for blocks from these versions)

stored in version.h.

Also, a minor CAddress code reformat while we're in there, fixing
some incorrect indentation.
@jgarzik
Copy link
Contributor Author

jgarzik commented Apr 13, 2012

added, along with 209

@sipa
Copy link
Member

sipa commented Apr 16, 2012

Meh, ACK.

@luke-jr
Copy link
Member

luke-jr commented Apr 16, 2012

Reminder to bump our own PROTOCOL_VERSION to 60001 too...

@jgarzik
Copy link
Contributor Author

jgarzik commented Apr 16, 2012

@luke-jr yes, that will come in a separate cover

jgarzik pushed a commit that referenced this pull request Apr 17, 2012
BIP 0031: pong message
@jgarzik jgarzik merged commit 865a0c1 into bitcoin:master Apr 17, 2012
coblee pushed a commit to litecoin-project/litecoin that referenced this pull request Jul 17, 2012
lateminer pushed a commit to lateminer/bitcoin that referenced this pull request Jan 22, 2019
Remove OP_RETURN based replay protection (REQ-6-1, Aug 1st '17 HF)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants