---
# System prepended metadata

title: EPF Cohort 5

---

# EPF Cohort 5 - Prysm - Writing a custom golang implementation of libp2p

## Context
As an Ethereum consensus client, [Prysm](https://github.com/prysmaticlabs/prysm) currently relies on the Go implementation of [libp2p](https://libp2p.io/) ([golibp2p](https://github.com/libp2p/go-libp2p)) provided by [Protocol Labs](https://protocol.ai/) for peer-to-peer communication between the beacon nodes of the Ethereum network. Using this off-the-shelf tool allows the Prysm team to focus on other areas. However, this also means that the Prysm team is entirely dependent on an external team or company for such a critical component of the networking layer.

## Project proposal
The project proposal involves developing an in-house implementation of the necessary parts of the libp2p protocol. The project can be broken down into the following steps:
1. Thoroughly understand the various components involved in libp2p networking within the Ethereum beacon chain.
2. Create a package that implements only the required components ([golibp2p](https://github.com/libp2p/go-libp2p) includes many components that Prysm does not use). 
3. Develop and implement an extensive test plan.
4. Replace the [golibp2p](https://github.com/libp2p/go-libp2p) implementation in the Prysm beacon node with the new in-house version, initially hidden behind a feature flag.
5. Compare the networking performance of the beacon node using the external and in-house implementations on the Holesky testnet.

## The building blocks of Ethereum Beacon Chain P2P
- **Peers discovery**: To discover peers in the network, the [devp2p/discv5](https://github.com/ethereum/devp2p/blob/master/discv5/discv5.md) discovery protocol is used. Prysm currently uses the [go-ethereum](https://pkg.go.dev/github.com/ethereum/go-ethereum/p2p/discover) implementation of this protocol. **This block is outside of the libp2p scope. Thus, this is outside the scope of this project.**
- **Protocol negotiation**: The [NOISE (XX) protocol framework](https://github.com/libp2p/specs/tree/master/noise) negotiation allows secure communication between peers.
- **Multiplexing**: [multistream-select](https://github.com/multiformats/multistream-select/), [mplex](https://github.com/libp2p/specs/tree/master/mplex) and [yamux](https://github.com/libp2p/specs/blob/master/yamux/README.md) protocols are the multiplexing methods used to conduct parallel conversations.
- **pub/sub**: [gossipsub v1](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.0.md) libp2p Protocol including the [gossipsub v1.1 extension](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md) is used for messages gossiping between peers.
- **Encoding**: [SSZ encoding](https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md) is used to encode messages

General P2P specifications can be found in all `p2p-interface.md` documents in the various forks of the [consensus specification](https://github.com/ethereum/consensus-specs/tree/dev/specs).

## To vendor or to re-implement?
The goal of this project is to have a libp2p implementation directly integrated into Prysm, tailored specifically to Prysm's requirements. If a particular package from Protocol Labs' golibp2p implementation already meets Prysm's needs, it can be vendored as-is. However, in the more likely scenario that Protocol Labs' golibp2p implementation includes more features than Prysm strictly requires, the package must be slimmed down and rewritten to fit Prysm's needs.

The goal of this project is not to reimplement core libraries (e.g., NOISE) that are already dependencies of Protocol Labs' golibp2p implementation. These dependencies can be reused as-is.
