Rustie Lin UC Berkeley CS, Distributed Systems, Blockchain

libp2p consensus

Ideating on how to use libp2p to write consensus simulations for education purposes. Also trying out speccing/note-taking in markdown for the time being


libp2p is transport agnostic and supports many foundational protocols, which are abstractly called trasport protocols (e.g. TCP/IP, UDP, QUIC, etc.)

Two core operations:

  • Listen: for inbound connection
  • Dial: for outbound connection

Each transport needs its own address scheme, and libp2p uses multiaddr to encode many different addressing schemes.


// Multiaddr vs tarditional construction

Multiaddr construction is explicit about protocols being described.

When dialing, need to also include PeerId of the peer so as to prevent impersonation. (e.g. authentication)


The switch manages transports and coordinates other processes such as protocol negotiation, stream multiplexing, and establishing secure communication, etc. It exposes the connection stack API.


Previous implementations of consensus simulation were light weight and relaxed. This will be a bigger project built from the ground up and part of a lecture series. Better to use the tech iteself

  • Theory
  • Implementation
    • How libp2p works at a high level, what we can take away
      • Tutorials
      • Conceptual docs
    • Create a framework for distributed systems in examples(?)
      • Limit the API even further
      • Usage of go-libp2p-swarm? Probably want even lower level


  1. libp2p conceptual docs