Skip to content

Peer to peer

The peer-to-peer layer (P2P) of the Internet Computer, the bottommost layer in the protocol stack, is responsible for the secure and reliable communication between the nodes of a subnet. The P2P layer realizes a virtual peer-to-peer network between the nodes of a subnet, building upon the Internet Protocol (IP) connectivity between the nodes. This makes the P2P layer the communications fabric that connects all the nodes of a subnet. Using P2P, a node can send a network message, also called artifact, to all the nodes in the subnet. Artifacts include ingress messages which contain input to canisters submitted by users or protocol messages (e.g., block proposals) generated by the IC protocol. P2P ensures that the necessary artifacts are eventually delivered to the nodes of the subnet. That is, no upper bound on when this happens can be given. This asynchronous communication network assumption is used for the ICP’s communication and consensus layers as it reflects the properties of real-world networks. The P2P layer is used by the consensus layer, the next layer in the stack above it, to broadcast artifacts to the nodes in the subnet.

Adverts

Whenever a subnet node receives or generates an artifact to be broadcast, the node makes the artifact available to all peers. Every node doing so ensures that the artifact will eventually be delivered to all subnet nodes. However, doing so in a naïve way by simply sending the artifact to all peers would result in nodes receiving as many copies of the same artifact as the node has peers, which unnecessarily consumes networking bandwidth for transmitting duplicate messages and reduces the achievable throughput of the subnet.

This duplication of delivered artifacts in the naïve approach is mitigated by nodes sending adverts for artifacts to their peers instead of sending the artifacts themselves. An advert specifies its corresponding artifact, but is a small message only containing the hash of the artifact to unambiguously refer to it and some additional metadata. A node only pushes adverts for artifacts to its peers. After receiving an advert, a node may request the corresponding artifact from one or more of its peers who sent it an advert for that artifact.

Prioritization of artifacts

As an optimization, the P2P layer allows the prioritization of artifacts such that the more crucial artifacts are requested more quickly than the others. This principle is well known from traditional networking and applies equally well to a blockchain system.

Security

To prevent Denial of Service (DoS) attacks, nodes will only request and accept connections with nodes in the same subnet. Subnet membership is managed by the Network Nervous System (NNS). Thanks to the information stored in the NNS canisters P2P can guarantee that all the communication between two nodes is encrypted and authenticated, by using TLS.

Additional information

Blogpost on P2P