PChord: Towards A Error-Free Distributed Hash Table using P
Project Overview
Problem
Building distributed systems is hard, and ensuring their correctness is even harder. To address this challenge, most system builders rely on a two-phase approach. At the protocol level, they use formal methods to validate the system’s correctness, while at the implementation level, they rely on extensive software testing to ensure the implementation is free of bugs. Unfortunately, this two-phase approach can be difficult, or even impossible, in many software development environments. Creating invariants and proofs can be time-consuming, and ensuring that the implementation accurately reflects the specifications is no simple task. Importantly, it requires developers to learn a new skill that diverges significantly from what they are used to (e.g., declarative programming).
Approach
In this project, we use the P programming language Ankush Desai, Vivek Gupta, Ethan Jackson, Shaz Qadeer, Sriram Rajamani, and Damien Zufferey. 2013. P: safe asynchronous event-driven programming. SIGPLAN Not. 48, 6 (June 2013), 321–332. https://doi.org/10.1145/2499370.2462184 , an asynchronous event-driven programming language that combines model-checking and programming into one activity for the developer. P programs are written as state machines that interact with each other through events. The P compiler then generates C/C# code that can be deployed, or an intermediate model that can be verified using the P model checker. For this project, we use P to implement the Chord protocol Ion Stoica, Robert Morris, David Karger, M. Frans Kaashoek, and Hari Balakrishnan. 2001. Chord: A scalable peer-to-peer lookup service for internet applications. SIGCOMM Comput. Commun. Rev. 31, 4 (October 2001), 149–160. https://doi.org/10.1145/964723.383071 , which is a protocol that allows for performing efficient look-ups on a distributed hash table, in a peer-to-peer enviornment. Afterwards, we examine the overall system-building process that is facilitated by P and analyze the feasbility of building provably correct distributed systems using it.
Results
Image of Chord Protocol’s Ring Structure. Source:
University of Edinburgh
PChord is an implementation of the Chord protocol using the
P language, designed to guarantee correctness in both its
design and implementation. Specifically, PChord has been
verified and tested for three safety properties, ensuring
that Chord’s ring structure always remains in a valid state.
Our experience building PChord demonstrated that P’s
capacity for developing provably safe systems is promising,
despite the inherent challenges of modeling systems with
state machine-based formal methods.