ChainSafe / ChainSafe/gossamer

Integrate Grandpa Standalone Package

Open
#3,387 1 comment 0 reactions 1 assignee Claimed by @timwu20 View on GitHub
Epic S-grandpa
Dominant language
Go
Stars
454
Forks
144
PR merge metrics
No merged PRs in 30d

Description

## Issue summary

This epic is created to describe and track the effort to intergrate our [standalone grandpa package](https://github.com/ChainSafe/gossamer/pull/3235) into the gossamer codebase.

Tasks needed for the integration:
- [x] Create the logic for handling authority set changes in grandpa. This logic can be found within substrate [here](https://github.com/paritytech/substrate/blob/master/client/consensus/grandpa/src/authorities.rs). Being addressed by #3283
- [x] Make the authority set type thread safe. Being addressed by #3351
- [x] Use the db to store grandpa state, found [here](https://github.com/paritytech/substrate/blob/master/client/consensus/grandpa/src/aux_schema.rs), although we should be able to simplify this logic for our use cases. Starting to be addressed here #3383
- [ ] Write all the grandpa networking/communication logic, found in the [substrate communication folder](https://github.com/paritytech/substrate/tree/master/client/consensus/grandpa/src/communication)
- [ ] The logic from [lib.rs](https://github.com/paritytech/substrate/blob/master/client/consensus/grandpa/src/lib.rs), which is the entrypoint to grandpa. This creates a wrapper around block_import object, which every imported block has to go through. Then a HalfLink object is created to link together the import object to the grandpa worker. Then using a HalfLink and a local config are used to run a granpda voter. Other logic this file contains is some communication logic, SharedVoterState, GrandpaParams, and VoterWork(future that powers the worker). Note: This file does not contain tests.
- [ ] Logic for [environment.rs](https://github.com/paritytech/substrate/blob/master/client/consensus/grandpa/src/environment.rs). The environment in which grandpa executes. Contains VoterSetState, grandpa environment, completed round data, and equivocation logic. NOte: this file does not contain tests.
- [x] Logic for [finality proof](https://github.com/paritytech/substrate/blob/master/client/consensus/grandpa/src/finality_proof.rs). This file contains the logic to prove grandpa finality. Tests included! Addressed in #3582
- [ ] [Custom voting rules](https://github.com/paritytech/substrate/blob/master/client/consensus/grandpa/src/voting_rule.rs) for grandpa. Also has tests!
- [ ] [block import logic](https://github.com/paritytech/substrate/blob/master/client/consensus/grandpa/src/import.rs). Block import handler for granpda. Justification import. Detect and make authority set changes. Import state logic. Note: No tests
- [x] justification for block finality found [here](https://github.com/paritytech/substrate/blob/master/client/consensus/grandpa/src/justification.rs). Verifies commits and has AncestryChain logic. Note: no tests
- [ ] [notification streams](https://github.com/paritytech/substrate/blob/master/client/consensus/grandpa/src/notification.rs) for grandpa.
- [ ] Grandpa tests, almost all of which can be found [here](https://github.com/paritytech/substrate/blob/master/client/consensus/grandpa/src/tests.rs).
- [ ] [until_imported](https://github.com/paritytech/substrate/blob/master/client/consensus/grandpa/src/until_imported.rs) is a helper stream for waiting until one or more blocks are imported before bassing through inner items. Buffers incoming messages until given hashes are imported. Note: need to come up with a way to keep track of the number of outstanding blocks that we are waiting on for the same message. Substrate uses the reference counting feature of the Arc pointer for this. Tests included!
- [ ] [rpc api](https://github.com/paritytech/substrate/tree/master/client/consensus/grandpa/rpc) for grandpa.

Tasks will be marked as complete when they are merged into the feature branch for this issue. This issue will be updated as more tasks are discovered and as progress is made. This issue will be closed when the feature branch is merged into development.

### Subtasks

- [x] #3606
- [x] #3612

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.