// 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”.

// gossipsub formalization

Machine-checked Gossipsub v1.1 properties

Encode these behaviours in Lean 4 and use theorem proving to show the modeled operations preserve the properties expected of the protocol.

  • Mesh management invariants and degree bounds
  • GRAFT and PRUNE transitions
  • Peer scoring and penalties
  • Heartbeat-driven state transitions
  • Message validation
  • Signing policies
  • Correctness of state transitions and preservation of protocol invariants

// an important distinction

Specification correctness vs implementation conformance

Proving a Lean specification satisfies its own invariants does not by itself establish that it represents the real-world protocol. Leanp2p treats verification as two complementary activities:

Specification assurance

Establish that the formal model accurately captures the intended protocol semantics and that its important invariants are machine-checked.

Implementation conformance

Validate that real implementations behave consistently with the specification through shared test vectors, interoperability testing, negative tests and regression suites.

// engineering head start

Already in place

An initial spike covers TCP, Noise, Yamux, Identify, SSZ-Snappy request/response and Gossipsub v1.1. The spike branch keeps the reference implementation and live Go interop cell; captured vectors moved onto main with W0.3.

  • Reference implementations
  • Theorems covering wire-format properties
  • Captured interoperability test vectors
  • Fuzz-testing infrastructure
  • A reported 3,148-check test suite
  • Reported interoperability with a Go implementation through a live interoperability test cell

// what remains

Next phase

  1. 01Strengthening and documenting the protocol specifications
  2. 02Establishing which protocol properties are formally modeled and machine-checked
  3. 03Expanding reproducible positive and negative conformance tests
  4. 04Improving cross-implementation interoperability testing
  5. 05Working with Ethereum consensus-client maintainers to validate implementation behaviour
  6. 06Identifying and addressing security-relevant discrepancies
  7. 07Integrating reusable tests and regression checks into development and CI workflows