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

CollationGenerationConfig closure is now optional #2772

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions client/collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub mod relay_chain_driven {
let config = CollationGenerationConfig {
key,
para_id,
collator: Box::new(move |relay_parent, validation_data| {
collator: Some(Box::new(move |relay_parent, validation_data| {
// Cloning the channel on each usage effectively makes the channel
// unbounded. The channel is actually bounded by the block production
// and consensus systems of Polkadot, which limits the amount of possible
Expand All @@ -218,7 +218,7 @@ pub mod relay_chain_driven {

this_rx.await.ok().flatten()
})
}),
})),
};

overseer_handle
Expand Down Expand Up @@ -301,6 +301,7 @@ mod tests {
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
use cumulus_test_runtime::{Block, Header};
use futures::{channel::mpsc, executor::block_on, StreamExt};
use polkadot_node_primitives::CollationGenerationConfig;
use polkadot_node_subsystem::messages::CollationGenerationMessage;
use polkadot_node_subsystem_test_helpers::ForwardSubsystem;
use polkadot_overseer::{dummy::dummy_overseer_builder, HeadSupportsParachains};
Expand Down Expand Up @@ -390,13 +391,19 @@ mod tests {
.0
.expect("message should be send by `start_collator` above.");

let CollationGenerationMessage::Initialize(config) = msg;
let collator_fn = match msg {
CollationGenerationMessage::Initialize(CollationGenerationConfig {
collator: Some(c),
..
}) => c,
_ => panic!("unexpected message or no collator fn"),
};

let validation_data =
PersistedValidationData { parent_head: header.encode().into(), ..Default::default() };
let relay_parent = Default::default();

let collation = block_on((config.collator)(relay_parent, &validation_data))
let collation = block_on(collator_fn(relay_parent, &validation_data))
.expect("Collation is build")
.collation;

Expand Down