[![Crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link]
[![Build Status][build-image]][build-link]
[![Apache 2.0 Licensed][license-image]][license-link]
[![cargo-audit][cargo-audit-image]][cargo-audit-link]
<p align="center">
<a href="https://alephzero.org" target="_blank">
<img src="https://alephzero.org/wp-content/uploads/A0_logotype_bft_dark.jpg" />
</a>
</p>
### Overview
AlephBFT 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 white paper][paper-link].
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][aleph-node-link].
The code is split into several Rust packages, each having its own directory -
see the `Cargo.toml` file, which defines the layout of the whole workspace.
The main package, `aleph-bft`, is located in the `consensus` directory.
Additionally, every other package has a short README describing its role
in the AlephBFT toolset.
### Documentation
Every package is documented on [docs.rs][docs-link]. Comprehensive documentation
is available as a [mdBook][reference-link].
The book can be built locally (assuming you have installed `rustup`):
```
cargo install mdbook
cd docs
mdbook serve --open
```
### Implementation status
Highlights:
- The protocol is asynchronous, so it's driven by consensus events as opposed
to some clock ticks.
- The performance is still optimal in a partially synchronous environment.
- BFT - secure if less than one third of the committee is malicious.
- Secure against fork bombs.
- Lowered network overhead of sending DAG parent information.
- Thorough testing, including malicious scenarios, and high code coverage.
More details are available [in the book][reference-link-implementation-details].
### Using the crate
- Import AlephBFT in your crate
```toml
[dependencies]
aleph-bft = "^0.20"
```
- The main entry point is the `run_session` function, which returns a Future that runs the
consensus algorithm.
To call this function, you need to pass a configuration (defaults are available in the package),
and implement certain traits, which will provide all the necessary functionalities, such as networking
and message signing.
A comprehensive guide is available [in the documentation][reference-link-api].
### Examples
We provide two basic examples of running AlephBFT, both of which are not cryptographically secure, and assume honest, but possibly malfunctioning, participants.
The first one, `ordering`, implements a simple node that produces data items, and then waits for them to be finalized. It can also perform a simulated crash after creating a specified number of items.
For example, you may run the following command:
```
cd ./examples/ordering
./run.sh
```
that will launch 2 properly working nodes, and 2 nodes that will crash 3 times each.
The delay before relaunching a crashed node will be set to 1 second.
A faulty node will create 25 items before every crash, and another `25` in the end.
Every node will therefore create `100` items in total, and then wait for other nodes before finishing its run.
See:
```
./run.sh -h
```
for further details.
Note that if the number of properly working nodes is less or equal than two times the number of faulty nodes, they will be unable to advance the protocol on their own.
The script will try to start nodes at predefined IP addresses, `127.0.0.1:100XX`, where `XX` denotes the node id. If the port is unavailable, the node will log an error and keep trying to aquire it, waiting 10 seconds between consecutive attempts.
Running this script will result in generating log files `node0.log, node1.log, ...` corresponding to subsequent nodes.
A directory called `aleph-bft-examples-ordering-backup` will be created to store data required by the crash recovery mechanism, and the logs from subsequent runs will be appended to existing log files.
The cache and logs will be automatically cleared when launching the script again.
The second example, `blockchain`, is meant for benchmarking AlephBFT in the blockchain setting.
It implements a simple round-robin blockchain assuming honest participation.
The easiest way to run it is to use the provided script as follows (assuming we start in the root directory):
```
cd ./examples/blockchain
./run.sh 5
```
where, again, `5` denotes the number of nodes that will be started.
Here we only assume that the address `127.0.0.1:43000` is available, as the network implementation contains a simple node discovery mechanism.
The achieved transactions per second will be among the final log messages in these files.
For further details, see
```
cargo run -- --help
```
### Dependencies
The repository is mainly self-contained. It is implemented using Rust's async features and depends only on the
`futures` crate 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.
### Toolchain
This release was built and tested against the `nightly-2022-10-30` Rust toolchain.
If you want to use another version, edit the `rust-toolchain` file, or use an [override](https://rust-lang.github.io/rustup/overrides.html) with higher priority.
### 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
We provide 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.
```sh
cargo install cargo-fuzz
cargo install afl
```
#### cargo-fuzz/libfuzzer
```sh
cargo fuzz run --features="libfuzz" fuzz_target
```
#### afl
You will need to generate some `seed` data first in order to run it.
```sh
# create some random input containing network data from a locally executed test
mkdir afl_in
cargo build --bin gen_fuzz
./target/debug/gen_fuzz >./afl_in/seed
```
You might need to reconfigure your operating system in order to proceed -
in such a case follow the instructions printed by the afl tool in your terminal.
```sh
cargo afl build --features="afl-fuzz" --bin fuzz_target_afl
cargo afl fuzz -i afl_in -o afl_out target/debug/fuzz_target_afl
```
The `gen_fuzz` binary is also able to verify data for the afl tool.
```sh
cargo build --bin gen_fuzz
./target/debug/gen_fuzz | ./target/debug/gen_fuzz --check-fuzz
```
### 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][paper-link], [old version][old-paper-link]
- docs: [crate documentation][docs-link], [reference][reference-link]
### Future work
- Asynchronous liveness is an important theoretical property and there is a lot of technical
sophisticatio
快撑死的鱼
- 粉丝: 2w+
- 资源: 9156
最新资源
- 昆仑通态MCGS与3台欧姆龙E5*C温控器通讯程序功能:通过昆仑通态触摸屏,实现对3台欧姆龙E5CC温控器 设定温度值,读取实际温度,设定报警值,设定报警类型,报警上下限功能 反应灵敏,通讯稳定可靠
- 大电流电动工具,电动螺丝刀,电锯批量方案,12V,30A FOC控制
- 三菱FX3G两轴标准程序,XZ两轴,包含轴点动,回零,相对与绝对定位,只要弄明白这个程序,就可以非常了解整个项目的程序如何去编写,从哪里开始下手,
- 昆仑通态MCGS与2台台达VFD-M变频器通讯程序实现昆仑通态触摸屏与2台台达VFD-M变频器通讯,程序稳定可靠 器件:昆仑通态TPC7062KD触摸屏,2台台达VFD-M变频器,附送接线说明和设置说
- MATLAB代码:考虑安全约束及热备用的电力系统机组组合研究 关键词:机组组合 直流潮流 优化调度 参考文档:店主自编文档,模型数据清晰明了 仿真平台:MATLAB+CPLEX gurobi平台
- c#上位案例,动态添加控件 1、这是个上位机案例,自己写来通过电脑监控kuka机器人信号的工具; 3、软件界面上可以动态添加要监控的信号,可以强制输出信号 4、有c#源代码,可以作为上位机与机器人通
- 三菱FX3U与力士乐VFC-x610变频器通讯程序三菱FX3U与力士乐VFC-x610变频器通讯案例程序,有注释 并附送程序,有接线方式,设置 器件:三菱FX3U的PLC,力士乐VFCx610变频
- 台达DVP PLC与3台力士乐VFC-x610变频器通讯程序 程序带注释,并附送昆仑通态程序,有接线方式,设置 器件:台达DVP ES系列的PLC,3台力士乐VFC-x610系列变频器,昆仑通态 功
- FPGA开发:实现数码管+1602双通道秒表(联系后留邮)按键切秒表模式,所用开发板DE2-115,代码可移植,内含FPGA驱动1602代码,代码有详细注释
- 汇川PLC AM403-CPU1608TN,2020产品基于CODESYS平台二次订制软件,支持16轴ethercat总线,自带以太网 USB CANOPEN 2路485,16高速输入8高速输出,功能
- 电力电子、电机驱动、数字滤波器matlab simulink仿真模型实现及相关算法的C代码实现 配置C2000 DSP ADC DAC PWM定时器 中断等模块,提供simulink与DSP的联合仿
- labview.通用OCR识别技术
- FoobarCon_v0.9.91.0.apk
- 华为HarmonyOS应用开发者高级认证,官方专业证书
- 华为HarmonyOS应用开发者高级认证,官方专业证书
- 51单片机四层电梯控制器 基于51单片机的四层电梯控制系统 包括源代码和proteus仿真 系统硬件由51单片机最小系统、蜂鸣器电路、指示灯电路、内部按键电路、外部按键电路、步进电机、ULN2003
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈