30 releases (16 breaking)

0.24.0 Feb 26, 2023
0.22.0 Feb 12, 2023
0.16.0 Dec 21, 2022
0.9.0 Feb 10, 2021
0.8.0-alpha.5 Mar 24, 2020

#6 in #grandpa

Download history 764/week @ 2024-03-13 1100/week @ 2024-03-20 1056/week @ 2024-03-27 1027/week @ 2024-04-03 860/week @ 2024-04-10 1031/week @ 2024-04-17 1066/week @ 2024-04-24 875/week @ 2024-05-01 871/week @ 2024-05-08 977/week @ 2024-05-15 998/week @ 2024-05-22 1088/week @ 2024-05-29 831/week @ 2024-06-05 731/week @ 2024-06-12 854/week @ 2024-06-19 737/week @ 2024-06-26

3,318 downloads per month
Used in 12 crates (3 directly)

GPL-3.0-or-later…

530KB
12K SLoC

Integration of the GRANDPA finality gadget into substrate.

This crate is unstable and the API and usage may change.

This crate provides a long-running future that produces finality notifications.

Usage

First, create a block-import wrapper with the block_import function. The GRANDPA worker needs to be linked together with this block import object, so a LinkHalf is returned as well. All blocks imported (from network or consensus or otherwise) must pass through this wrapper, otherwise consensus is likely to break in unexpected ways.

Next, use the LinkHalf and a local configuration to run_grandpa_voter. This requires a Network implementation. The returned future should be driven to completion and will finalize blocks in the background.

Changing authority sets

The rough idea behind changing authority sets in GRANDPA is that at some point, we obtain agreement for some maximum block height that the current set can finalize, and once a block with that height is finalized the next set will pick up finalization from there.

Technically speaking, this would be implemented as a voting rule which says, "if there is a signal for a change in N blocks in block B, only vote on chains with length NUM(B) + N if they contain B". This conditional-inclusion logic is complex to compute because it requires looking arbitrarily far back in the chain.

Instead, we keep track of a list of all signals we've seen so far (across all forks), sorted ascending by the block number they would be applied at. We never vote on chains with number higher than the earliest handoff block number (this is num(signal) + N). When finalizing a block, we either apply or prune any signaled changes based on whether the signaling block is included in the newly-finalized chain.

License: GPL-3.0-or-later WITH Classpath-exception-2.0

Dependencies

~54–94MB
~1.5M SLoC