Git Product home page Git Product logo

honeybadgerbft_golang's Introduction

hbbft Releases Build Status Report Card

Practical implementation of the Honey Badger Byzantine Fault Tolerance consensus algorithm written in Go.

Summary

This package includes the building blocks for implementing a practical version of the hbbft protocol. The exposed engine can be plugged easily into existing applications. Users can choose to use the transport layer or roll their own. For implementation details take a look at the simulations which implements hbbft into a realistic scenario. The building blocks of hbbft exist out of the following sub-protocols:

Reliable broadcast (RBC)

Uses reedsolomon erasure encoding to disseminate an ecrypted set of transactions.

Binary Byzantine Agreement (BBA)

Uses a common coin to agree that a majority of the participants have a consensus that RBC has completed.

Asynchronous Common Subset (ACS)

Combines RBC and BBA to agree on a set of encrypted transactions.

HoneyBadger

Top level HoneyBadger protocol that implements all the above sub(protocols) into a complete --production grade-- practical consensus engine.

Usage

Install dependencies

make deps

Run tests

make test

How to plug hbbft in to your existing setup

Create a new instance of HoneyBadger.

// Create a Config struct with your prefered settings.
cfg := hbbft.Config{
    // The number of nodes in the network.
    N: 4,
    // Identifier of this node.
    ID: 101,
    // Identifiers of the participating nodes.
    Nodes: uint64{67, 1, 99, 101},
    // The prefered batch size. If BatchSize is empty, an ideal batch size will
    // be choosen for you.
    BatchSize: 100,
}

// Create a new instance of the HoneyBadger engine and pass in the config.
hb := hbbft.NewHoneyBadger(cfg)

Filling the engine with transactions. Hbbft uses an interface to make it compatible with all types of transactions, the only contract a transaction have to fullfill is the Hash() []byte method.

// Transaction is an interface that abstract the underlying data of the actual
// transaction. This allows package hbbft to be easily adopted by other
// applications.
type Transaction interface {
  Hash() []byte
}

Adding new transactions can be done be calling the following method on the hb instance.
hb.AddTransaction(tx) // can be called in routines without any problem.

Starting the engine.

hb.Start() // will start proposing batches of transactions in the network.

Applications build on top of hbbft can decide when they access commited transactions. Once consumed the output will be reset.

hb.Outputs() // returns a map of commited transactions per epoch.

for epoch, tx := range hb.Outputs() {
  fmt.Printf("batch for epoch %d: %v\n", epoch, tx)
}

A working implementation can be found in the bench folder, where hbbft is implemented over local transport.

Current project state

  • Reliable Broadcast Algorithm
  • Binary Byzantine Agreement
  • Asynchronous Common Subset
  • HoneyBadger top level protocol

TODO

  • Threshold encryption
  • Configurable serialization for transactions

References

Other language implementations

honeybadgerbft_golang's People

Contributors

hadv avatar fyrchik avatar persephony 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.