relab / hotstuff

MIT License
166 stars 52 forks source link

hotstuff

Go Reference Test golangci-lint codecov

relab/hotstuff is a framework for experimenting with HotStuff and similar consensus protocols. It provides a set of modules and interfaces that make it easy to test different algorithms. It also provides a tool for deploying and running experiments on multiple servers via SSH.

Contents

Build Dependencies

If you modify any of the protobuf files, you will need the following to compile them:

Getting Started

Linux and macOS

Windows

NOTE: you should use ./hotstuff.exe instead of ./hotstuff when running commands.

Running Experiments

See the experimentation documentation for details.

The hotstuff command line utility can be used to run experiments locally, or on remote servers using SSH. For a list of options, run ./hotstuff help run.

The plot command line utility can be used to create graphs from measurements. Run ./plot --help for a list of options.

Safety Testing with Twins

We have implemented the Twins strategy [6] for testing the safety of the consensus implementations. See the twins documentation for details.

Modules

The following components are modular:

These modules are designed to be interchangeable and simple to implement. It is also possible to add custom modules that can interact with the modules we listed above.

Consensus Interfaces

There are two ways to implement a new consensus protocol, depending on the requirements of the new protocol. The Consensus module interface is the most general, but also the most difficult to implement. That is because it is oriented towards the other modules, and the other modules rely on it to perform certain operations, such as verifying proposals, interacting with the BlockChain, Acceptor, Executor, and Synchronizer modules, and so on. That is why we provide a simplified Rules interface and the optional ProposeRuler interface. These interfaces are only required to implement the core rules of the consensus protocol, namely deciding whether or not to vote for a proposal, whether or not it is safe to commit a block, and optionally how to create new blocks. These interfaces do not require any interaction with other modules, as that is taken care of by a default implementation of the Consensus interface.

The Consensus and Rules interfaces can also be used to override the behavior of other consensus implementations. The consensus/byzantine package contains some examples of byzantine behaviors that can be implemented by wrapping implementations of these interfaces.

Crypto Interfaces

In a similar way to the Consensus interface, the Crypto interface also introduces a simplified, lower-level interface that should be used to implement new crypto algorithms. The Crypto interface itself provides methods for working with the high-level structures such as quorum certificates. However, to make it easy to implement new crypto algorithms, the CryptoImpl interface can be used instead. This interface deals with signatures and threshold signatures directly, which are used by the Crypto interface to implement quorum certificates.

References

[1] M. Yin, D. Malkhi, M. K. Reiter, G. Golan Gueta, and I. Abraham, “HotStuff: BFT Consensus in the Lens of Blockchain,” Mar 2018.

[2] Tormod Erevik Lea, Leander Jehl, and Hein Meling. Towards New Abstractions for Implementing Quorum-based Systems. In 37th International Conference on Distributed Computing Systems (ICDCS), Jun 2017.

[3] Mohammad M. Jalalzai, Jianyu Niu, Chen Feng, Fangyu Gai. Fast-HotStuff: A Fast and Resilient HotStuff Protocol, Oct 2020.

[4] Leander Jehl. Formal Verification of HotStuff, Jun 2021.

[5] Baudet, Mathieu, et al. "State machine replication in the libra blockchain." The Libra Assn., Tech. Rep (2019).

[6]: S. Bano, A. Sonnino, A. Chursin, D. Perelman, en D. Malkhi, “Twins: White-Glove Approach for BFT Testing”, 2020.