In progress
Modelling and Verifying the Cardano Peer-to-Peer Network
CSP models of Cardano's node-to-node mini-protocols and network multiplexer, mechanised in Agda, with proofs of deadlock freedom, divergence freedom and refinement against specifications.
Problem
Cardano nodes communicate through the Ouroboros node-to-node mini-protocols, multiplexed over shared TCP connections. Each protocol is simple in isolation, but correctness questions arise from their composition: can the network deadlock or diverge, and does the multiplexer behave like an ideal medium?
Approach
The models are written in CSP as process trees using csp-ptree-agda, and reasoned about in the traces, failures and failures-divergences models, divergence-respecting weak bisimulation and LTL.
- Mini-protocols. KeepAlive, ChainSync, BlockFetch, TxSubmission2, LeiosNotify and LeiosFetch are modelled as pairs of API-driven client and server peer processes, renamed into one shared network alphabet.
- Network medium. A faithful rendering of the multiplexer is related to a simple copy specification, and the two are proved equivalent in the failures-divergences model, both for the whole medium and per TCP link.
- Whole-network systems. Peers are composed in parallel with the medium, and wire traffic is hidden. Scenarios include a four-node diamond topology with configurable and breakable links, and a topology-generic N-node layer.
Results so far
- Deadlock freedom, divergence freedom and refinement or equivalence of the medium against its specification.
- Block-liveness analyses for the four-node diamond, through CSP refinement and LTL.
- Announcement safety and block provenance for arbitrary topologies, and a prototype model of Leios.
- Prioritisation of BlockFetch (Praos) over LeiosFetch (Leios) at each link’s send arbiter.
Results hold for the stated models and parameters. Some developments are still being ported to the current link-indexed model, as recorded in the repository.
How to use it
The models need Agda 2.8.0, csp-ptree-agda and the standard libraries. Type-check a module from src/Network_CSP_Model, for example agda Cardano_network/ChainSync.agda. The repository READMEs give a reading order and the memory limits for the larger proofs.