BIP 60: Fixed Length "version" Message (Relay-Transactions Field)
2013-06-16
View on GitHub
  BIP: 60
  Layer: Peer Services
  Title: Fixed Length "version" Message (Relay-Transactions Field)
  Author: Amir Taaki <genjix@riseup.net>
  Comments-Summary: Discouraged for implementation (one person)
  Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0060
  Status: Draft
  Type: Standards Track
  Created: 2013-06-16
  License: PD

Abstract

BIP 0037 introduced a new flag to version messages which says whether to relay new transaction messages to that node.

The protocol version was upgraded to 70001, and the (now accepted) BIP 0037 became implemented.

The implementation is problematic because the RelayTransactions flag is an optional part of the version message stream.

Motivation

One property of Bitcoin messages is their fixed number of fields. This keeps the format simple and easily understood. Adding optional fields to messages will cause deserialisation issues when other fields come after the optional one.

As an example, the length of version messages might be checked to ensure the byte stream is consistent. With optional fields, this checking is no longer possible. This is desirable to check for consistency inside internal deserialization code, and proper formatting of version messages originating from other nodes. In the future with diversification of the Bitcoin network, it will become desirable to enforce this kind of strict adherence to standard messages with field length compliance with every protocol version.

Another property of fixed-length field messages is the ability to pass stream operators around for deserialization. This property is also lost, as now the deserialisation code must know the remaining length of bytes to parse. The parser now requires an additional piece of information (remaining size of the stream) for parsing instead of being a dumb reader.

Specification

version

When a node creates an outgoing connection, it will immediately advertise its version. The remote node will respond with its version. No further communication is possible until both peers have exchanged their version.

Payload:

Field SizeDescriptionData typeComments
4versionint32_tIdentifies protocol version being used by the node
8servicesuint64_tbitfield of features to be enabled for this connection
8timestampint64_tstandard UNIX timestamp in seconds
26addr_recvnet_addrThe network address of the node receiving this message
26addr_fromnet_addrThe network address of the node emitting this message
8nonceuint64_tNode random nonce, randomly generated every time a version packet is sent. This nonce is used to detect connections to self.
?user_agentvar_strUser Agent (0x00 if string is 0 bytes long)
4start_heightint32_tThe last block received by the emitting node
1relayboolWhether the remote peer should announce relayed transactions or not, see BIP 0037, since version >= 70001

A "verack" packet shall be sent if the version packet was accepted.

The following services are currently assigned:

ValueNameDescription
1NODE_NETWORKThis node can be asked for full blocks instead of just headers.

Code Updates

fRelayTx is added to the PushMessage() call inside PushVersion() (net.cpp)

void CNode::PushVersion()
{
    /// when NTP implemented, change to just nTime = GetAdjustedTime()
    int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
    CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0)));
    CAddress addrMe = GetLocalAddress(&addr);
    RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
    printf("send version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString().c_str(), addrYou.ToString().c_str(), addr.ToString().c_str());
    PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
                nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()),
                nBestHeight, true);
}

Additionally the protocol version is increased from 70001 to 70002.

Copyright

This document is placed in the public domain.


Updated

2024-11-21

See an issue with rendering or formatting? Submit an issue on GitHub

Do you find this site useful? Please consider donating some sats to support ongoing development.

bips.dev is presented by nickmonad

All content is owned and licensed by the respective author(s). This website makes no claim of ownership.