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

Commit

Permalink
CollationGenerationConfig closure is now optional (#2772)
Browse files Browse the repository at this point in the history
* CollationGenerationConfig closure is now optional

* fix test
  • Loading branch information
rphmeier authored Jul 11, 2023
1 parent 3772536 commit bd68bf9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
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

0 comments on commit bd68bf9

Please sign in to comment.