Companion for Substrate#8526 (#2845)

* Update branch

* Make it compile

* Compile

* gate approval-checking logic (#2470)

* Fix build

* Updates

* Fix merge

* Adds missing crate

* Companion for Substrate#8386

https://github.com/paritytech/substrate/pull/8386

* Fix fix fix

* Fix

* Fix compilation

* Rewrite to `ParachainsInherentDataProvider`

* Make it compile

* Renamings

* Revert stuff

* Remove stale file

* Guide updates

* Update node/core/parachains-inherent/src/lib.rs

Co-authored-by: Andronik Ordian <write@reusable.software>

* Update node/core/parachains-inherent/src/lib.rs

Co-authored-by: Andronik Ordian <write@reusable.software>

* Apply suggestions from code review

* Reset accidental changes

* More

* Remove stale file

* update Substrate

Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
Co-authored-by: Andronik Ordian <write@reusable.software>
Co-authored-by: parity-processbot <>
This commit is contained in:
Bastian Köcher
2021-05-03 17:21:13 +02:00
committed by GitHub
parent 774d612eef
commit 7830bae524
16 changed files with 402 additions and 549 deletions
@@ -380,7 +380,7 @@ sequenceDiagram
participant CB as CandidateBacking
participant BD as BitfieldDistribution
participant RA as RuntimeApi
participant PO as Proposer
participant PI as ParachainsInherentDataProvider
alt receive provisionable data
alt
@@ -395,33 +395,24 @@ sequenceDiagram
Note over PV: store bitfields and backed candidates
else receive request for inherent data
PO ->> PV: RequestInherentData
PI ->> PV: RequestInherentData
alt we have already constructed the inherent data
PV ->> PO: send the inherent data
PV ->> PI: send the inherent data
else we have not yet constructed the inherent data
Note over PV,PO: Store the return sender without sending immediately
Note over PV,PI: Store the return sender without sending immediately
end
else timer times out
note over PV: Waited 2 seconds
PV -->> RA: RuntimeApiRequest::AvailabilityCores
Note over PV: construct and store the inherent data
loop over stored inherent data requests
PV ->> PO: (SignedAvailabilityBitfields, BackedCandidates)
PV ->> PI: (SignedAvailabilityBitfields, BackedCandidates)
end
end
```
In principle, any arbitrary subsystem could send a `RequestInherentData` to the `Provisioner`. In practice,
only the `Proposer` does so.
only the `ParachainsInherentDataProvider` does so.
The proposer is an atypical subsystem in that, unlike most of them, it is not primarily driven by
the `Overseer`, but instead by the `sp_consensus::Environment` and `sp_consensus::Proposer` traits
from Substrate. It doesn't make much sense to diagram this flow because it's very linear:
- Substrate creates a `Proposer` from the `ProposerFactory` once per upcoming block, using the `parent_header: Header`.
- At some later point, it calls `Proposer::propose(self, ...)`, consuming the proposer to generate a proposal
- `Proposer::propose` sends a `RequestInherentData` to the `Provisioner`. This has a fixed timeout of
2.5 seconds, meaning that the provisioner has approximately 0.5 seconds to generate and send the data.
The tuple `(SignedAvailabilityBitfields, BackedCandidates, ParentHeader)` is injected by the `Proposer`
The tuple `(SignedAvailabilityBitfields, BackedCandidates, ParentHeader)` is injected by the `ParachainsInherentDataProvider`
into the inherent data. From that point on, control passes from the node to the runtime.
@@ -564,9 +564,6 @@ enum ProvisionerMessage {
/// advancing the state of parachain consensus in a block building upon the given hash.
///
/// If called at different points in time, this may give different results.
///
/// This is expected to be used by a proposer, to inject that information into the InherentData
/// where it can be assembled into the ParaInherent.
RequestInherentData(Hash, oneshot::Sender<ParaInherentData>),
/// This data should become part of a relay chain block
ProvisionableData(ProvisionableData),