Giter Site home page Giter Site logo

finality-grandpa's Introduction

finality-grandpa

crates.io link Build Status Code coverage

GRANDPA, GHOST-based Recursive ANcestor Deriving Prefix Agreement, is a finality gadget for blockchains, implemented in Rust. It allows a set of nodes to come to BFT agreement on what is the canonical chain, which is produced by some external block production mechanism. It works under the assumption of a partially synchronous network model and with the presence of up to 1/3 Byzantine nodes.

Build & Test

The only dependency required to build and run the tests is to have a stable version of Rust installed.

git clone https://github.com/paritytech/finality-grandpa
cd finality-grandpa
cargo build
cargo test

Usage

Add this to your Cargo.toml:

[dependencies]
finality-grandpa = "0.10"

Features:

  • derive-codec - Derive Decode/Encode instances of parity-scale-codec for all the protocol messages.
  • test-helpers - Expose some opaque types for testing purposes.

Integration

This crate only implements the state machine for the GRANDPA protocol. In order to use this crate it is necessary to implement some traits to do the integration which are responsible for providing access to the underyling blockchain and setting up all the network communication.

The Chain trait allows the GRANDPA voter to check ancestry of a given block and also to query the best block in a given chain (which will be used for voting on).

The Environment trait defines the types that will be used for the input and output stream to receive and broadcast messages. It is also responsible for setting these up for a given round (through round_data), as well as timers which are used for timeouts in the protocol.

The trait exposes callbacks for the full lifecycle of a round:

  • proposed
  • prevoted
  • precommitted
  • completed

As well as callbacks for notifying about block finality and voter misbehavior (equivocations).

Substrate

The main user of this crate is Substrate and should be the main resource used to look into how the integration is done. The substrate-finality-grandpa crate should have most of the relevant integration code.

Most importantly this crate does not deal with authority set changes. It assumes that the set of authorities is always the same. Authority set handoffs are handled in Substrate by listening to signals emitted on the underlying blockchain.

Resources

License

Usage is provided under the Apache License (Version 2.0). See LICENSE for the full details.

finality-grandpa's People

Contributors

andresilva avatar bkchr avatar cmichi avatar eddyb avatar expenses avatar gnunicorn avatar jamesray1 avatar jimpo avatar koushiro avatar marcio-diaz avatar romanb avatar rphmeier avatar satoshi-kusumoto avatar stanislav-tkach avatar thiolliere avatar tomaka avatar

Watchers

 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.