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

Rework inherent data client side #8526

Merged
116 commits merged into from
May 3, 2021
Merged

Rework inherent data client side #8526

116 commits merged into from
May 3, 2021

Conversation

bkchr
Copy link
Member

@bkchr bkchr commented Apr 3, 2021

This pr changes the inherent data system to be more flexible, especially the client side. Before this pr we only supported calling create_inherent_data and required that the inherent data was created without any context. We also shared the inherent data providers between block production and block import, while some inherents don't require any inherent data while being checked (at import).

So, the pr does the following high level changes:

  • Split create_inherent_data into create_inherent_data_providers and create_inherent_data. While the former is async and thus, can use await.
  • By default always pass the parent_hash to create_inherent_data_providers and add support for passing other arguments as well, while the caller can decide on which extra arguments to pass. This is especially useful for Cumulus that will for example also pass the relay_chain_hash a block will be build on.
  • Move ProvideInherent to frame-support, because this is a FRAME specific trait and nothing generic.
  • Reworked the inherent data providers to make the usage easier.
  • Block building and block import is now separated, making it easier to decide which inherent data is required where.

polkadot companion: paritytech/polkadot#2845

bkchr and others added 30 commits January 24, 2021 14:34
…ch/substrate into bkchr-inherent-something-future
This switches AURA to use `CurrentSlot` instead of `LastTimestamp`.
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
bkchr and others added 3 commits April 9, 2021 12:17
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
@bkchr
Copy link
Member Author

bkchr commented Apr 9, 2021

what was a bit weird to me is that now the InherentDataProvider is kind of a one-off thing, you just create it pre-filled with the data you want it to provide for a given block. My initial reaction when I read the PR description was: why wouldn't the parent hash be passed to InherentDataProvider instead of creating this new CreateInherentDataProviders trait?

I wanted to remove this "create InherentData and extract data later in the client again from the inherent data". I wanted to bake this into the type system to make it "more" obvious on what kind of inherent data providers are required by the "consensus" for example.

@andresilva andresilva added B3-apinoteworthy and removed B0-silent Changes should not be mentioned in any release notes labels May 3, 2021
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
@bkchr
Copy link
Member Author

bkchr commented May 3, 2021

bot merge

@ghost
Copy link

ghost commented May 3, 2021

Waiting for commit status.

@ghost ghost merged commit ec18031 into master May 3, 2021
@ghost ghost deleted the bkchr-inherent-something-future branch May 3, 2021 14:39
HCastano added a commit to paritytech/parity-bridges-common that referenced this pull request May 3, 2021
HCastano added a commit to paritytech/parity-bridges-common that referenced this pull request May 3, 2021
* Bump Substrate to commit `0856e0729c5f9cd5d398b93680ab154fe486e588`

* Update service to use new inherent data client

Relevant Substrate PR: paritytech/substrate#8526

* Appease Clippy
nazar-pc pushed a commit to autonomys/substrate that referenced this pull request Aug 8, 2021
* Lol

* Yeah

* Moare

* adaasda

* Convert AURA to new pallet macro

* AURA: Switch to `CurrentSlot` instead of `LastTimestamp`

This switches AURA to use `CurrentSlot` instead of `LastTimestamp`.

* Add missing file

* Update frame/aura/src/migrations.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Remove the runtime side provide inherent code

* Use correct weight

* Add TODO

* Remove the Inherent from AURA

* 🤦

* Remove unused stuff

* Update primitives authorship

* Fix babe inherent data provider

* Fix consensus-uncles

* Fix BABE

* Do some further changes to authorship primitives... :D

* More work

* Make it compile the happy path

* Make it async!

* Take hash

* More stuff

* Hacks

* Revert "Hacks"

This reverts commit cfffad8.

* Fix

* Make `execute_block` return the final block header

* Move Aura digest stuff

* Make it possible to disable equivocation checking

* Fix fix fix

* Some refactorings

* Comment

* Fixes fixes fixes

* More cleanups

* Some love

* Better love

* Make slot duration being exposed as `Duration` to the outside

* Some slot info love

* Add `build_aura_worker` utility function

* Copy copy copy

* Some stuff

* Start fixing pow

* Fix pow

* Remove some bounds

* More work

* Make grandpa work

* Make slots use `async_trait`

* Introduce `SharedData`

* Add test and fix bugs

* Switch to `SharedData`

* Make grandpa tests working

* More Babe work

* Make grandpa work

* Introduce `SharedData`

* Add test and fix bugs

* Switch to `SharedData`

* Make grandpa tests working

* More Babe work

* Make it async

* Fix fix

* Use `async_trait` in sc-consensus-slots

This makes the code a little bit easier to read and also expresses that
there can always only be one call at a time to `on_slot`.

* Make grandpa tests compile

* More Babe tests work

* Fix network test

* Start fixing service test

* Finish service-test

* Fix sc-consensus-aura

* Fix fix fix

* More fixes

* Make everything compile *yeah*

* Make manual-seal compile

* More fixes

* Start fixing Aura

* Fix Aura tests

* Fix Babe tests

* Make everything compile

* Move code around and switch to async_trait

* Fix Babe

* Docs docs docs

* Move to FRAME

* Fix fix fix

* Make everything compile

* Last cleanups

* Fix integration test

* Change slot usage of the timestamp

* We really need to switch to `impl-trait-for-tuples`

* Update primitives/inherents/src/lib.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Update primitives/inherents/src/lib.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Update primitives/inherents/src/lib.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Some extra logging

* Remove dbg!

* Update primitives/consensus/common/src/import_queue/basic_queue.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
jordy25519 pushed a commit to cennznet/substrate that referenced this pull request Sep 20, 2021
* Lol

* Yeah

* Moare

* adaasda

* Convert AURA to new pallet macro

* AURA: Switch to `CurrentSlot` instead of `LastTimestamp`

This switches AURA to use `CurrentSlot` instead of `LastTimestamp`.

* Add missing file

* Update frame/aura/src/migrations.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Remove the runtime side provide inherent code

* Use correct weight

* Add TODO

* Remove the Inherent from AURA

* 🤦

* Remove unused stuff

* Update primitives authorship

* Fix babe inherent data provider

* Fix consensus-uncles

* Fix BABE

* Do some further changes to authorship primitives... :D

* More work

* Make it compile the happy path

* Make it async!

* Take hash

* More stuff

* Hacks

* Revert "Hacks"

This reverts commit cfffad8.

* Fix

* Make `execute_block` return the final block header

* Move Aura digest stuff

* Make it possible to disable equivocation checking

* Fix fix fix

* Some refactorings

* Comment

* Fixes fixes fixes

* More cleanups

* Some love

* Better love

* Make slot duration being exposed as `Duration` to the outside

* Some slot info love

* Add `build_aura_worker` utility function

* Copy copy copy

* Some stuff

* Start fixing pow

* Fix pow

* Remove some bounds

* More work

* Make grandpa work

* Make slots use `async_trait`

* Introduce `SharedData`

* Add test and fix bugs

* Switch to `SharedData`

* Make grandpa tests working

* More Babe work

* Make grandpa work

* Introduce `SharedData`

* Add test and fix bugs

* Switch to `SharedData`

* Make grandpa tests working

* More Babe work

* Make it async

* Fix fix

* Use `async_trait` in sc-consensus-slots

This makes the code a little bit easier to read and also expresses that
there can always only be one call at a time to `on_slot`.

* Make grandpa tests compile

* More Babe tests work

* Fix network test

* Start fixing service test

* Finish service-test

* Fix sc-consensus-aura

* Fix fix fix

* More fixes

* Make everything compile *yeah*

* Make manual-seal compile

* More fixes

* Start fixing Aura

* Fix Aura tests

* Fix Babe tests

* Make everything compile

* Move code around and switch to async_trait

* Fix Babe

* Docs docs docs

* Move to FRAME

* Fix fix fix

* Make everything compile

* Last cleanups

* Fix integration test

* Change slot usage of the timestamp

* We really need to switch to `impl-trait-for-tuples`

* Update primitives/inherents/src/lib.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Update primitives/inherents/src/lib.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Update primitives/inherents/src/lib.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Some extra logging

* Remove dbg!

* Update primitives/consensus/common/src/import_queue/basic_queue.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants