Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Conversation

@andresilva
Copy link
Contributor

@andresilva andresilva commented Feb 15, 2019

This PR changes grandpa block import to allow importing multiple pending authority set changes. The changes are tracked in a tree that tracks changes across all unfinalized forks, the changes must be non-overlapping (this is enforced by the runtime API) and must be finalized in-order. As blocks are finalized stale forks of the tree are pruned and their signalled changes discarded.

Additionally, the sync protocol for requesting justifications also tracks the requests in a tree using similar semantics.

TODO:

  • Tests
  • Docs
  • Conflicts

Fixes #1497.

@andresilva andresilva added A3-in_progress Pull request is in progress. No review needed at this stage. M4-core labels Feb 15, 2019
@andresilva andresilva closed this Feb 15, 2019
@andresilva andresilva reopened this Feb 15, 2019
@andresilva
Copy link
Contributor Author

@svyatonik Should I update consensus_changes to use similar logic?

@andresilva andresilva changed the title Import multiple change blocks Import multiple authority set change blocks Feb 15, 2019
@svyatonik
Copy link
Contributor

I don't think so - the logic of consensus_changes is quite simple: IF there's path from one of consensus_changes blocks to block we currently finalizing THEN create justification. There could be multiple overlapping/non-overlapping changes - it doesn't matter actually.

@rphmeier rphmeier mentioned this pull request Feb 15, 2019
5 tasks
@andresilva andresilva added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Feb 18, 2019
@andresilva
Copy link
Contributor Author

I think this is ready for a review. The plan is to merge this before #1619. After this is merged I'll take over #1619 from @rphmeier, there will be some merge conflicts and the logic needs to be adapted to support multiple pending changes.

/// assumes that changes on the same branch will be added in-order. The
/// given function `is_descendent_of` should return `true` if the second
/// hash (target) is a descendent of the first hash (base).
pub(crate) fn add_pending_change<F, E>(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if as a safety fallback we should cap the number of pending changes in a given fork. I need to think how this will interact with the offline fallback as well.

@rphmeier rphmeier added A8-looksgood and removed A0-please_review Pull request needs code review. labels Feb 19, 2019
@gavofyork gavofyork merged commit 18bbe13 into master Feb 19, 2019
@gavofyork gavofyork deleted the andre/import-multiple-change-blocks branch February 19, 2019 23:08
andresilva added a commit that referenced this pull request Feb 22, 2019
Fixing the conflicts requires (re)writing some code to properly
integrate with the changes from #1808. This commit just comments all
code that is conflicting/non-working replacing it with `unreachable!()`
statements. I prefer for the integration to be explicit over follow-up
commits rather than being buried in a merge commit.
MTDK1 pushed a commit to bdevux/substrate that referenced this pull request Apr 12, 2019
* core: implement logic for tracking dag of possible pending changes

* core: move pending justifications dag to its own crate

* core: remove unnecessary clone bounds on dag

* core: request justifications in-order from the dag

* core: dag: rename changes variables to node

* core: dag: allow finalizing blocks not part of dag

* core: dag: track best finalized number

* core: dag: add more tests

* core: sync: clean up pending justifications dag

* core: dag: derive codec decode encode

* core: dag: better error support

* core: dag: add finalization guarded by predicate

* core: grandpa: track multiple authority set changes in dag

* core: dag: add pre-order iterator

* core: grandpa: request justifications on startup

* core: dag: rearrange order of definitions

* core: rename util/dag to util/fork_tree

* core: fork_tree: add docs

* core: fork_tree: add more tests

* core: fork_tree: fix issues found in tests

* core: grandpa: fix authorities tests

* core: grandpa: add docs for is_descendent_of

* core: sync: add docs for PendingJustifications

* core: sync: add test for justification requests across forks

* core: sync: don't resend import or finality notifications in tests

* core: grandpa: add test for importing multiple change blocks

* core: grandpa: fix logic for checking if a block enacts a change

* core: grandpa: fix authorities tests
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants