Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Support pre-runtime digest and instant seal #15

Merged
merged 56 commits into from
Dec 8, 2021

Conversation

JoshOrndorff
Copy link
Contributor

@JoshOrndorff JoshOrndorff commented Nov 4, 2021

This PR updates the runtime, authoring, and block-import components of nimbus to support authorship information coming from from a pre-runtime digest, as opposed to the author inherent as it had previously. Authoring, and block import continue to support the old author inherent to facilitate a smooth migration of live networks. These are the first steps in switching entirely to the preruntime digest which means this PR solves #2 and works toward #23.

This PR adds the NimbusBlockImport, which, at the moment, is nearly a copy paste of cumulus's ParachainBlockImport except that the parachain import rules can be optionally disabled. This also provides an obvious place to include actual nimbus-specific import logic should it ever become necessary.

Instant seal

This PR also adds an instant seal feature to the example node which has all the normal advantages of instant seal (easy to quickly experiment). The instant seal worker also uses the pre-runtime digests. In order to add the manual seal worker, some of the slot prediction and header sealing logic had to be factored out of the parachain consensus worker into re-usable helper functions. This also paves the way for #3 .

To try the instant seal feature:

./target/release/parachain-collator run-instant-seal --dev --tmp

Migration

This PR makes breaking changes to the runtime's assumptions about authorship. To ensure a smooth upgrade of live chains, it is recommended that you proceed as follows:

  • Client side upgrade to this code so that authoring nodes begin inserting the pre-runtime digest (nimbus 0.9)
  • Runtime upgrade to start using the pre-runtime digest, and ignore the author inherent (nimbus 0.9)
  • Client upgrade to stop inserting author inherent (nimbus 1.0)

Note that the block import logic will always retain support for blocks authored with the author inherent to ensure that new nodes can sync old chains from genesis.

See #14 about de-duplicating this code
@JoshOrndorff
Copy link
Contributor Author

Should probably still add tests to pallet author inherent.

@JoshOrndorff JoshOrndorff changed the title Optional pre-runtime digest support and instant seal Support pre-runtime digest and instant seal Nov 19, 2021
nimbus-consensus/src/lib.rs Outdated Show resolved Hide resolved
pallets/author-inherent/src/exec.rs Outdated Show resolved Hide resolved
pallets/author-inherent/src/exec.rs Outdated Show resolved Hide resolved
pallets/author-inherent/src/lib.rs Show resolved Hide resolved
pallets/author-inherent/src/lib.rs Outdated Show resolved Hide resolved
pallets/author-inherent/src/lib.rs Show resolved Hide resolved
@JoshOrndorff JoshOrndorff merged commit d610b68 into main Dec 8, 2021
tgmichel pushed a commit that referenced this pull request Dec 16, 2021
* checkpoint. Gonna try switching to preruntime digest first

* pallet allows preruntime digests and validates at end of block

* remove incorrect comment

* factor slot prediction into helper function, start sketching manual seal consensus data provider

* better message for future self

* preruntime digest interface

* `create_digest` compiles

* service compiles

* whoe service checks

* allow running from cli

* actually install our new manual seal consensus data provider

* Handle no-key scenario

* Preruntime digest an no memoizing author account

* remove wrong comment. Better to follow aura

* prune commented inherent-related code

* Hack in fake signature in manual seal.

* unused import

* verifier supports both digest types

* duplicate code from verifier to executor wrapper

See #14 about de-duplicating this code

* author inherent no longer required

* sign blocks in manual seal !!

* Hack import queue so it works in instant seal although it is now broken in parachain mode.

* prune some debugging logs

* NimbusBlockImport with optional parachain rules

* we can use std on the client-side

* remove unnecessary generic

* indentation and comment

* use constant instead of hard-coded nmbs

* code style: map instead of if let

* assume relay chain slot beacon in manual seal for now

* Actually checkvalidity and send notification when using preruntime digest

* Typos from code review

Co-authored-by: Amar Singh <[email protected]>
Co-authored-by: girazoki <[email protected]>

* Proper index

Co-authored-by: Amar Singh <[email protected]>

* Switch consensus worker from inherent to preruntime digest.

Was it really that easy!?

* map from author id to account id in FindAuthor

* more toward parachain consensus worker

* Update nimbus-consensus/src/import_queue.rs

* inherent is a no-op

* Revert "more toward parachain consensus worker"

This reverts commit 807e72b.

* validators don't need backward compatability

* Fix incorrect merge conflict resolution. Still detect NimbusApi

* Add copyright to manual seal file.

Hell Yeah CI!

* Typo found by @girazoki

* stray space

* Single author in dev spec so that `run-instant-seal --dev` works with one node

* warnings

* Apply suggestions from code review

Co-authored-by: girazoki <[email protected]>
Co-authored-by: Éloïs <[email protected]>

* better weight in `on_initialize`

* thoughts about the legacy author inherent

* sketch kick-off inherent in pallet

* fees

* Update the inherent extrinsics

Co-authored-by: Amar Singh <[email protected]>
Co-authored-by: girazoki <[email protected]>
Co-authored-by: Éloïs <[email protected]>
(cherry picked from commit d610b68)

# Conflicts:
#	Cargo.lock
#	nimbus-consensus/Cargo.toml
#	nimbus-consensus/src/lib.rs
#	pallets/author-inherent/src/lib.rs
#	parachain-template/node/Cargo.toml
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.

Introduce pre-runtime digest
4 participants