Minimal message and safe state creation, maintenance and transition based on https://github.com/cbc-casper/cbc-casper-paper
The purpose of this library is to abstractly define the CBC-Casper message stucture and define functions for the construction and proper execution of protocols of the casper family. We aimed at pushing as much functionality as possible directly to the abstract message layer, in such a way that a developer can create a protocol fairly easy using this library.
The design decision was to be as general as possible, and leave all the specific stuff for the implementer of the protocol. For the time being, we aim at mathematical correctness, and mostly purely functional protocol executions, rather than on performance.
The idea is to have a mathematical correct and possibly ineficient version of functions that can be used as ground truth for comparing with efficient versions.
To benefit from the casper-cbc safety proofs this library builds upon, developers using this library have to implement the CasperMsg trait. The CasperMsg trait in turn requires implementing other traits in this library, such as the Sender trait for validators, the Estimate trait for the estimate, and the Data trait if the estimate carries data.
One generic type implementing the CasperMsg trait, namely Message, is also provided that helps getting to a compliant CasperMsg trait concrete type implementation easily.
We present examples of naive consensus protocols: a binary consensus, and an integer consensus that use the generic type Message<Estimate, Sender> implementation to generate the protocols. We also present an example blockchain implementation.
In order to get started using the library, the best way is to study the examples
folder. It is also instructive to run the tests.
To run the unit tests, run cargo test -- --nocapture
, or cargo test $TEST --
--nocapture
, where TEST
is the function name of a particular unit test.
If the integration tests are to be run as well, issue cargo test --features
integration_test -- --nocapture
, or cargo test --features integration_test $TEST --
--nocapture
, where TEST
is the function name of a particular integration test.
This library is experimental and might change dramatically.
Install clippy with rustup
in Rust stable
rustup component add clippy
Install rustfmt in Rust stable
rustup component add rustfmt