cardinal-cryptography/alephbft

Aleph is an asynchronous and Byzantine fault tolerant consensus protocol aimed

This repository contains a Rust implementation of AlephBFT that offers a convenient

Aleph Consensus

Overview

Aleph is an asynchronous and Byzantine fault tolerant consensus protocol aimed at ordering arbitrary messages (transactions). It has been designed to operate continuously under conditions where there is no bound on message-delivery delay and under the assumption that there is a significant probability of malicious behavior, making it an excellent fit for blockchain-related applications. For more information, check the paper

This repository contains a Rust implementation of AlephBFT that offers a convenient API enabling seamless application to various problems. The prime application of the repository is the consensus engine (sometimes called the "finality gadget") of the Aleph Zero blockchain.

Detailed documentation

If the crate's documentation seems to be not comprehensive enough, please refer to the detailed version.

Implementation status

  • current version is asynchronous, so it's driven by consensus events as opposed to some clock ticks
  • while being asynchronous, the performance is still optimal in partially synchronous environment
  • guaranteed safety even in asynchronous environment
  • BFT - secure if less than one third of the committee is malicious
  • secure against fork bombs, for details see the paper
  • network overhead optimized to not send all parents hashes but a bitmap and a control hash
  • thorough testing, including malicious scenarios, and high code coverage

Future work

  • Asynchronous liveness is an important theoretical property and there is a lot of technical sophistication that comes in the design of AlephBFT in order to achieve it, however on the practical side there is still little evidence that performing such attacks against liveness in real-world scenarios is possible. Still, no matter how unlikely such attacks might be, we take them very seriously and plan to add randomness to AlephBFT in one of the future releases. We decided to go for a version without randomness first, as it gives an incredibly simple and at the same time secure and robust BFT consensus protocol. Adding randomness introduces some complexity into the protocol, so it makes sense to add it on top of a well-tested, working product. The API of the protocol will not change and we will make the use of randomness configurable.
  • We see a big value in keeping a critical piece of code such as a consensus protocol as self-contained as possible, so we would like to get rid of the only major dependency - parity-scale-codec

Using the crate

  • Import AlephBFT in your crate

  • AlephBFT requires user to provide it with an implementation of the following traits:

    • The DataIO trait is an abstraction for a component that provides data items and allows to input ordered data items. DataIO is parametrized with a Data generic type representing the type of items we would like to order.

    • The KeyBox trait is an abstraction for digitally signing arbitrary data and verifying signatures created by other nodes.

    • The Network trait defines the functionality we expect from the network layer:

  • Having all the above traits implemented, one can create a [Committee Member][member-link] and run it as an asynchronous task with an execution engine of choice.

Dependencies

The repository is mainly self-contained. It is implemented using Rust's async features and depends only on the futures create from the standard library. Moreover, it has some usual dependencies like log and rand and one bigger for encoding, namely parity-scale-codec. In future work, we plan to get rid of this dependency.

Examples

Currently we provide two basic examples of running AlephBFT. The first one: dummy-honest implements a committee member that is not cryptographically secure and serves only as a working example of what traits need to be implemented and how to implement them. The example may be run using:

cargo run --example dummy_honest my_id n_members n_finalized

my_id -- our index, 0-based
n_members -- size of the committee
n_finalized -- number of data to be finalized

The second example: blockchain is meant for benchmarking AlephBFT in the blockchain setting. It implements a simple round-robin blockchain assuming honest participation. The simplest way to run it is to use the provided script as follows (assuming we start in the root directory)

where 4 in the above is the number of committee members and can be replaced by any reasonable number. Running this script will result in generating log files node0.log, node1.log, ... corresponding to subsequent nodes. The achieved transactions per second should be among the final log messages in these files.

Tests

There are many unit tests and several integration tests that may be run by standard command cargo test --lib or cargo test --lib --skip medium if you want to run just small tests. Alternatively, you may run the run_local_pipeline.sh script.

Fuzzing

There are fuzzing tests that try to crash the whole application by creating arbitrary data for the network layer and feeding it into the member implementation. To run those tests you need to install afl and cargo-fuzz. cargo-fuzz requires you to use a nightly Rust toolchain. afl differs from cargo-fuzz in that it requires so called corpus data to operate, i.e. some non-empty data set that do not crash the application. Both tools are using LLVM's instrumentation capabilities in order to guide the fuzzing process basing on code-coverage statistics.

cargo-fuzz/libfuzzer

afl

You will need to generate some seed data first in order to run it.

The gen_fuzz bin is able to both generate and verify data for the afl tool.

Code Coverage

You may generate the code coverage summary using the gen_cov_data.sh script and then a detailed raport for every file with cov_report.sh. Make sure to first install all the required tools with install_cov_tools.sh.

Resources

  • Papers: current version, old version
  • docs: crate documentation, reference

License

AlephBFT is licensed under the terms of the the Apache License 2.0.

Founding

The implementation in this repository is founded by Aleph Zero Foundation.

Information - Updated Sep 17, 2022

Stars: 29
Forks: 17
Issues: 6

Solana blockchain repo and docs

Please make sure you are always using the latest stable rust version as this is a crypto library and require safe code

Solana blockchain repo and docs

Blockchain Commons torgap-sig

torgap-sig is a fork of spdx:BSD-2-Clause Plus Patent License

Blockchain Commons torgap-sig

Blockchain Commons torgap-sig-cli-rust

torgap-sig-cli-rust is a fork of Minisign, with support for

Blockchain Commons torgap-sig-cli-rust

Phala Blockchain

pRuntime (Phala Network Secure Enclave Runtime) is a runtime to execute confidential smart contracts, based on confidential computing

Phala Blockchain

A Blockchain implementation in Rust

MIT (c) Doublify Technologies

A Blockchain implementation in Rust

Simple Blockchain

cargo run para ejecutar la app, cargo build para crear un ejecutable

Simple Blockchain

A Blockchain implementation in pure Rust

Below find an example usage of the library:

A Blockchain implementation in pure Rust

Blockchain for Rust Developers

Suggested implementation for learning the basics of blockchain from the book

Blockchain for Rust Developers

Blockchain Example with Rust

Triển khai lại ý tưởng của (Learn Blockchains by Building One)[

Blockchain Example with Rust
Facebook Instagram Twitter GitHub Dribbble
Privacy