Notify collators about seconded collation (#2430)

* Notify collators about seconded collation

This pr adds functionality to inform a collator that its collation was
seconded by a parachain validator. Before this signed statement was only
gossiped over the validation substream. Now, we explicitly send the
seconded statement to the collator after it was validated successfully.

Besides that it changes the `CollatorFn` to return an optional result
sender that is informed when the build collation was seconded by a
parachain validator.

* Add test

* Make sure we only send `Seconded` statements

* Make sure we only receive valid statements

* Review feedback
This commit is contained in:
Bastian Köcher
2021-02-14 17:36:04 +01:00
committed by GitHub
parent 1b3d00d9d3
commit 4975521d48
21 changed files with 315 additions and 147 deletions
@@ -63,11 +63,18 @@ async fn collating_using_adder_collator(task_executor: sc_service::TaskExecutor)
collator.collator_id(),
);
charlie.register_collator(collator.collator_key(), para_id, collator.create_collation_function()).await;
charlie.register_collator(
collator.collator_key(),
para_id,
collator.create_collation_function(charlie.task_manager.spawn_handle()),
).await;
// Wait until the parachain has 4 blocks produced.
collator.wait_for_blocks(4).await;
// Wait until the collator received `12` seconded statements for its collations.
collator.wait_for_seconded_collations(12).await;
join!(
alice.task_manager.clean_shutdown(),
bob.task_manager.clean_shutdown(),