Make collation an optional return (#1787)

This pr changes the collator interface function to return an optional
collation instead of a collation. This is required as the parachain
itself can fail to generate a valid collation for various reason. Now if
the collation fails it will return `None`.

Besides that the pr adds some `RuntimeDebug` derive for `ValidationData`
and removes some whitespaces.
This commit is contained in:
Bastian Köcher
2020-10-06 11:57:10 +02:00
committed by GitHub
parent 22e7d54f4d
commit a4662104db
7 changed files with 51 additions and 34 deletions
@@ -22,14 +22,21 @@ The process of generating a collation for a parachain is very parachain-specific
```rust
pub struct Collation {
/// Hash of `CandidateCommitments` as understood by the collator.
pub commitments_hash: Hash,
/// Fees paid from the chain to the relay chain validators.
pub fees: Balance,
/// Messages destined to be interpreted by the Relay chain itself.
pub upward_messages: Vec<UpwardMessage>,
/// New validation code.
pub new_validation_code: Option<ValidationCode>,
/// The head-data produced as a result of execution.
pub head_data: HeadData,
/// Proof to verify the state transition of the parachain.
pub proof_of_validity: PoV,
}
struct CollationGenerationConfig {
key: CollatorPair,
collator: Box<dyn Fn(&ValidationData) -> Box<dyn Future<Output = Collation>>>
collator: Box<dyn Fn(&ValidationData) -> Box<dyn Future<Output = Option<Collation>>>>
para_id: ParaId,
}
```