mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 15:11:03 +00:00
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:
@@ -32,8 +32,28 @@ pub struct Collation {
|
||||
pub proof_of_validity: PoV,
|
||||
}
|
||||
|
||||
type CollatorFn = Box<
|
||||
dyn Fn(Hash, &PeristedValidationData) -> Pin<Box<dyn Future<Output = Option<Collation>>>>
|
||||
/// Result of the [`CollatorFn`] invocation.
|
||||
pub struct CollationResult {
|
||||
/// The collation that was build.
|
||||
collation: Collation,
|
||||
/// An optional result sender that should be informed about a successfully seconded collation.
|
||||
///
|
||||
/// There is no guarantee that this sender is informed ever about any result, it is completly okay to just drop it.
|
||||
/// However, if it is called, it should be called with the signed statement of a parachain validator seconding the
|
||||
/// collation.
|
||||
result_sender: Option<oneshot::Sender<SignedFullStatement>>,
|
||||
}
|
||||
|
||||
/// Collation function.
|
||||
///
|
||||
/// Will be called with the hash of the relay chain block the parachain block should be build on and the
|
||||
/// [`ValidationData`] that provides information about the state of the parachain on the relay chain.
|
||||
///
|
||||
/// Returns an optional [`CollationResult`].
|
||||
pub type CollatorFn = Box<
|
||||
dyn Fn(Hash, &PersistedValidationData) -> Pin<Box<dyn Future<Output = Option<CollationResult>> + Send>>
|
||||
+ Send
|
||||
+ Sync,
|
||||
>;
|
||||
|
||||
struct CollationGenerationConfig {
|
||||
|
||||
Reference in New Issue
Block a user