Bitcoin Relay Network and Network Discovery

In this article, we learn more about relay networks in Bitcoin and how network discovery is done on the Bitcoin protocol.

Table of contents.

  1. Introduction.
  2. Relay Networks.
  3. Network Discovery.
  4. Summary.
  5. References.

Introduction

When a node boots up it connects to at least one other node that was online using the TCP protocol on port 8333. This is referred to as bootstrapping. Here the bootstrapping node knows a single IP address that belongs to an active bitcoin node. The node can also query a DNS server that responds with a list of IP addresses that belong to bitcoin nodes. Some of these nodes may be inactive or active.

After a connection is established, the version message is the first message to be sent. This message holds information that is useful to identify the node. Once connected, if the node is a full node, the first order of business is to update its local copy of the blockchain.

A relay network provides additional connectivity between mining nodes in the Bitcoin protocol. It minimizes network latency during the transmission of blocks between miners. It is important for blocks to be distributed throughout the network as fast as possible since immediately after a block is discovered, the competition for mining the next node between miners starts again. This mechanism cannot only be tasked to the P2P network hence the relay network.

In this article, we learn more about relay networks in Bitcoin and how network discovery is done on the Bitcoin protocol.

Relay Networks.

Apart from the Bitcoin peer-to-peer network serving the needs of blockchain node types, it also exhibits too high network latency that is used to serve the specialized needs of the mining nodes. Miners usually are competitively solving a cryptographic puzzle specified by the network protocol. During this race, miners are required to minimize the time between the propagation of a winning block and the start of the next round of competition. Bitcoin mining is directly related to profit margins.

We define a Bitcoin relay network as a network that attempts to minimize the latency during block transmissions between miners. The original relay network created back in 2015 by Matt Collaro allows fast synchronization of blocks between miners with very low latency.
It comprises of several specialized nodes hosted on the distributed AWS cloud infrastructure that connects the majority of miners and mining pools.

This network was later replaced in 2016 with FIBRE(Fast Internet Bitcoin Relay Network) also created by Matt Collaro. This was a UDP relay network that relayed blocks within a network of nodes. It implements compact block optimization that further reduces the data being transmitted and latency.
FIBRE - Fast Internet Bitcoin Relay Engine is an implementation designed to relay blocks within the Bitcoin network without delay beyond the speed of light through fibre. It provides a faster way to propagate blocks in the network, therefore, decentralizing the availability of a high-speed relay network, this means that anyone can set up one.
It improves the Bitcoin Relay networks in two ways;

  • First it eliminates latency spikes by sending extra data to compensate for the loss of network packets.
  • Secondly, it is based on the compression provided by compact block work in Bitcoin Core software.

Falcon is another proposed relay network. It uses cut-through-routing instead of store-and-forward. This reduces network latency by propagating parts of a block as they are received rather than waiting for a block to be completed.

Relay networks are overlay networks that add to Bitcoin additional connectivity between network nodes with specialized needs. We can compare relay networks to specialized paths/roads(shortcuts) used to avoid the heavy traffic on the main highway.

Network Discovery.

During the booting up of a network node, a network discovery service runs that is able to find other nodes connected to the network. This process is very important for a node to participate in the blockchain. A node refers to other sources of truth in order to make sure that the data is consistent among the nodes.
The Discovery of existing nodes is random and not dependent on the geographical location of network nodes, meaning any node in the world can be discovered first.

TCP protocol on port 8333 is used to connect two nodes together. A handshake between the two nodes involves the original node sending the version message containing basic identifying information.

This information includes;

nVersion - the P2P protocol version of the client.
nLocalServices - local services the node supports.
nTime - the current timestamp
addrYou - the IP address of a remote node.
addrMe - Ip address of the local node.
subver - the subversion of the software running on the node.
bestHeight - the nodes block height in the blockchain.

The following process is demonstrated in the image below;

bit88

In order to discover other peers on the network, two ways are used;

  1. The first involves querying the DNS using a number of DNS seeds - DNS servers providing a list of IP addresses of Bitcoin nodes.
    DNS seeds comprise of a list of static IP addresses of stable bitcoin nodes that are currently listening.

  2. Another method of node discovery involves providing an IP address of a single bitcoin node to a bootstrapping node for introductions, this node can later disconnect from the initial node and establish links to other peer nodes. Once one or more connections are established, the new nodes send an addr message containing their own Ip address to their neighbors. Neighbors then forward the message to their neighbors, this ensures the newly connected node is properly introduced to other nodes. In addition to this, the newly connected node asks the neighbors to return a list of IP addresses of other peers, this allows the node to find peers to connect to and broadcast its existence on the network for discovery by other nodes.

This is demonstrated using the image below

bit89

For a node to establish diverse paths in the network, multiple connections to different peers are required. Since some paths are unreliable, nodes will continue discovery as unreliable discoveries are done away with.

Summary

A Bitcoin full node maintains the full copy of the Bitcoin blockchain database.
The TCP connection on port 8333 is the default protocol and port used by Bitcoin.
The Bitcoin relay network provides additional connectivity between mining nodes in the Bitcoin protocol by minimizing the network latency during the transmission of blocks between miners.
A single connection is needed for bootstrapping purposes after which the node introduces the original node to its neighbors that offer further introductions to their nodes.
Connecting to neighboring nodes consumes network resources, this is solved by nodes remembering the successful connections and using them in the next reboot.

References

Effects of a Simple Relay Network on the Bitcoin Network