Coder Social home page Coder Social logo

distributedcomponents / verdi-lockserv Goto Github PK

View Code? Open in Web Editor NEW
13.0 6.0 5.0 60 KB

An implementation of a simple asynchronous message-passing lock server, verified in Coq using the Verdi framework

License: BSD 2-Clause "Simplified" License

Makefile 5.84% Coq 58.80% Shell 4.91% OCaml 27.90% Python 1.64% Perl 0.91%
verdi coq distributed-systems mutual-exclusion proof

verdi-lockserv's Introduction

Verdi LockServ

Build Status

An implementation of a simple asynchronous message-passing lock server, verified to achieve mutual exclusion in the Coq proof assistant using the Verdi framework. By extracting Coq code to OCaml and linking the results to a trusted shim that handles network communication, the certified system can run on real hardware.

Requirements

Definitions and proofs:

Executable programs:

Client to interface with program:

Testing of unverified code:

Building

The recommended way to install the OCaml and Coq dependencies of Verdi LockServ is via OPAM:

opam repo add coq-released https://coq.inria.fr/opam/released
opam repo add distributedcomponents-dev http://opam-dev.distributedcomponents.net
opam install verdi StructTact cheerios verdi-runtime cheerios-runtime ocamlbuild ocamlfind

Then, run ./configure in the root directory. This will check for the appropriate version of Coq and ensure all necessary dependencies can be located.

By default, the script assumes that Verdi, StructTact, and Cheerios are installed in Coq's user-contrib directory, but this can be overridden by setting the Verdi_PATH, StructTact_PATH, and Cheerios_PATH environment variables.

Finally, run make in the root directory. This will compile the lock server definitions, check the proofs of mutual exclusion, and extract OCaml event handler code.

To build an OCaml program from the extracted code called LockServMain.native in the extraction/lockserv directory, run make lockserv in the root directory.

Running LockServ on a Cluster

LockServMain accepts the following command-line options:

-me NAME             name for this node
-port PORT           port for inputs
-node NAME,IP:PORT   node in the cluster
-debug               run in debug mode

Possible node names are Server, Client-0, Client-1, etc.

For example, to run LockServMain on a cluster with IP addresses 192.168.0.1, 192.168.0.2, 192.168.0.3, input port 8000, and port 9000 for inter-node communication, use the following:

# on 192.168.0.1
$ ./LockServMain.native -port 8000 -me Server -node Server,192.168.0.1:9000 \
                -node Client-0,192.168.0.2:9000 -node Client-1,192.168.0.3:9000

# on 192.168.0.2
$ ./LockServMain.native -port 8000 -me Client-0 -node Server,192.168.0.1:9000 \
                -node Client-0,192.168.0.2:9000 -node Client-1,192.168.0.3:9000

# on 192.168.0.3
$ ./LockServMain.native -port 8000 -me Client-1 -node Server,192.168.0.1:9000 \
                -node Client-0,192.168.0.2:9000 -node Client-1,192.168.0.3:9000

Client Program for LockServ

There is a simple client written in Python in the directory extraction/lockserv/script that can be used as follows:

$ python -i client.py
>>> c=Client('192.168.0.2', 8000)
>>> c.send_lock()
'Locked'
>>> c.send_unlock()

Tests for Unverified Code

Some example unit tests for unverified OCaml code are included in extraction/lockserv/test. To execute these tests, first install the OUnit library via OPAM:

opam install ounit

Then, go to extraction/lockserv and run make test.

LockServ with Sequence Numbering

As originally defined, the lock server does not tolerate duplicate messages, which means that LockServMain can potentially give unexpected results when the underlying UDP-based runtime system generates duplicates. However, the Verdi framework defines a sequence numbering verified system transformer that when applied allows the lock server to ignore duplicate messages, while still guaranteeing mutual exclusion.

The directory extraction/lockserv-seqnum contains the files needed to produce an OCaml program called LockServSeqNumMain which uses sequence numbering. After running ./configure in the root directory, simply run make in extraction/lockserv-seqnum to compile the program. LockServSeqNumMain has the same command-line options as LockServMain, and the Python client can be used to interface with nodes in both kinds of clusters.

LockServ with Verified Serialization

The standard lock server serializes messages over the network via OCaml's Marshal module, which must be trusted to trust the whole system. However, using the Cheerios serialization library and a Verdi verified system transformer for Cheerios, the use of Marshal can be eliminated while upholding the same mutual exclusion guarantees.

The directory extraction/lockserv-serialized contains the files needed to produce an OCaml program called LockServSerializedMain which uses Cheerios and its runtime library. After running ./configure in the root directory, simply run make in extraction/lockserv-serialized to compile the program. LockServSerializedMain has the same command-line options as LockServMain, and the Python client can be used to interface with nodes in both kinds of clusters.

verdi-lockserv's People

Contributors

justinads avatar kethku avatar palmskog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.