Coder Social home page Coder Social logo

mirbft's Introduction

MirBFT Library

MirBFT is a library implementing the Mir byzantine fault tolerant consensus protocol in a network transport, storage, and cryptographic algorithm agnostic way. MirBFT hopes to be a building block of a next generation of distributed systems, providing an implementation of atomic broadcast which can be utilized by any distributed system.

Mir improves on traditional atomic broadcast protocols like PBFT and Raft which always have a single active leader by allowing concurrent leaders and reconciling total order in a deterministic and provably safe way. The multi-leader nature of Mir should lead to exceptional performance especially on wide area networks but should be suitable for LAN deployments as well.

Build Status GoDoc

Architecture

The high level structure of the MirBFT library steals heavily from the architecture of etcdraft. A single threaded state machine is mutated by short lived, non-blocking operations. Operations which might block or which have any degree of computational complexity (like signing, hashing, etc.) are delegated to the caller.

For more information, see the detailed design document. Note, the documentation has fallen a bit behind based on the implementation work that has happened over the last few months. The documentation should be taken with a grain of salt.

Using Mir

This repository is a new project and under active development and as such, is not suitable for use (yet!). Watch for releases occurring later in 2020.

Preview

Currently, there are severe limitations ot the Mir implementation, notably no view/epoch change, and no state transfer, as well as no ability to resume a node after stopping it. However, sample processors are included, and the basic client implementation will look something like this:

replicas := []mirbft.Replica{{ID: 0}, {ID: 1}, {ID: 2}, {ID: 3}}

config := &mirbft.Config{
	ID:     uint64(i),
	Logger: zap.NewProduction(),
	BatchParameters: mirbft.BatchParameters{
		CutSizeBytes: 1,
	},
}

doneC := make(chan struct{})

node, err := mirbft.StartNewNode(config, doneC, replicas)
// handle err

processor := &sample.SerialProcessor{
	Node:      node,
	Validator: validator, // sample.Validator interface impl
	Hasher:    hasher,    // sample.Hasher interface impl
	Committer: &sample.SerialCommitter{
		Log:                  log, // sample.Log interface impl
		OutstandingSeqBucket: map[uint64]map[uint64]*mirbft.Entry{},
	},
	Link: network, // sample.Link interface impl
}

go func() {
	for {
		ticker := time.NewTicker(time.Millisecond)
		defer ticker.Stop()


		select {
		case actions := <-node.Ready():
			processor.Process(&actions)
		case <-ticker.C:
			node.Tick()
		case <-doneC:
			// exit
		}
	}
}

// Perform application logic
err := node.Propose(context.TODO(), []byte("some-data"))
...

Note that sample.SerialProcessor and sample.SerialCommitter are rudimentary implementations which for simplicity do not exploit parallelism across the hashing/validation/committing, but could parallelized for a production system. Future samples may include a parallelized Procecessor and or Committer.

mirbft's People

Contributors

guoger 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.