// notable accomplishment · formal verification at the infra layer · devcon 8
leanp2p
Bringing libp2p to Lean 4: towards verified networking for Ethereum.
A Lean 4 implementation of libp2p, beginning with Ethereum consensus-layer networking — shared on stage at the Resilient Networking Hub during the Devcon 8 workshop “Building Resilient Ethereum”.
// what it is
Executable, machine-checked networking specifications
Leanp2p is a community-developed initiative combining formal methods, executable protocol specifications, interoperability testing and security-oriented engineering. Its first target is the Ethereum consensus layer.
The longer-term ambition is verified networking: machine-checked protocol invariants, stronger guarantees around state transitions, greater confidence in protocol evolution, and more secure, interoperable distributed systems.
It does not replace existing consensus clients — it provides a common foundation against which their protocol behaviour can be checked and improved.
// why leanp2p
Client diversity needs shared, precise definitions
Ethereum's security depends on independently developed consensus clients interoperating through shared networking protocols. Specifications without executable, machine-checked definitions leave room for differences in:
- Peer authentication and identity verification
- Secure transport negotiation and cryptographic handshakes
- Stream multiplexing and connection lifecycle management
- Message encoding, decoding and validation
- Request/response protocol handling
- Gossipsub mesh management and state transitions
- Peer scoring, penalties and message propagation
// vision
Three complementary principles
Formal specification
Represent networking protocol behaviour precisely in Lean 4, making protocol structures, invariants and state transitions amenable to machine checking.
Interoperability and conformance
Reusable test vectors, executable specifications and conformance suites so independent implementations can validate behaviour against shared expectations.
Security adoption
Work with consensus-client maintainers to integrate specifications and tests, identify security-relevant discrepancies, and upstream fixes and regression tests.
// initial scope
Ethereum consensus networking first
| Component | Protocol | Purpose |
|---|---|---|
| Transport | TCP | Establish network connections |
| Security | Noise | Authenticate peers and establish secure channels |
| Multiplexing | Yamux | Multiplex streams over connections |
| Identification | libp2p Identify | Exchange peer and protocol information |
| Request/response | SSZ-Snappy | Support Ethereum consensus networking protocols |
| Pubsub | Gossipsub v1.1 | Support consensus message dissemination |