From d6fa479bf4efffcd1ebe7cd9ee0a423e6f6bc6fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 25 Jun 2019 17:53:37 +0200 Subject: [PATCH] Pass `relay_parent` hash to `produce_candidate` (#300) * Pass `relay_parent` hash to `produce_candidate` * Fixes compilation --- collator/src/lib.rs | 9 ++++++++- test-parachains/adder/collator/src/main.rs | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/collator/src/lib.rs b/collator/src/lib.rs index 548b90491f69c..c6323776816f9 100644 --- a/collator/src/lib.rs +++ b/collator/src/lib.rs @@ -100,9 +100,11 @@ impl fmt::Display for Error { pub trait ParachainContext: Clone { type ProduceCandidate: IntoFuture; - /// Produce a candidate, given the latest ingress queue information and the last parachain head. + /// Produce a candidate, given the relay parent hash, the latest ingress queue information + /// and the last parachain head. fn produce_candidate>( &self, + relay_parent: Hash, last_head: HeadData, ingress: I, ) -> Self::ProduceCandidate; @@ -124,6 +126,7 @@ pub trait RelayChainContext { /// Produce a candidate for the parachain, with given contexts, parent head, and signing key. pub fn collate<'a, R, P>( + relay_parent: Hash, local_id: ParaId, last_head: HeadData, relay_context: R, @@ -142,6 +145,7 @@ pub fn collate<'a, R, P>( ingress .and_then(move |ingress| { para_context.produce_candidate( + relay_parent, last_head, ingress.0.iter().flat_map(|&(id, ref msgs)| msgs.iter().cloned().map(move |msg| (id, msg))) ) @@ -327,6 +331,7 @@ impl Worker for CollationNode where }; let collation_work = collate( + relay_parent, para_id, HeadData(last_head), context, @@ -427,6 +432,7 @@ mod tests { fn produce_candidate>( &self, + _relay_parent: Hash, _last_head: HeadData, ingress: I, ) -> Result<(BlockData, HeadData, Extrinsic), InvalidHead> { @@ -476,6 +482,7 @@ mod tests { ])); let collation = collate( + Default::default(), id, HeadData(vec![5]), context.clone(), diff --git a/test-parachains/adder/collator/src/main.rs b/test-parachains/adder/collator/src/main.rs index 2c0adab8ece7a..ca0ab87064a39 100644 --- a/test-parachains/adder/collator/src/main.rs +++ b/test-parachains/adder/collator/src/main.rs @@ -23,7 +23,7 @@ use std::sync::Arc; use adder::{HeadData as AdderHead, BlockData as AdderBody}; use substrate_primitives::Pair; use parachain::codec::{Encode, Decode}; -use primitives::parachain::{HeadData, BlockData, Id as ParaId, Message, Extrinsic}; +use primitives::{Hash, parachain::{HeadData, BlockData, Id as ParaId, Message, Extrinsic}}; use collator::{InvalidHead, ParachainContext, VersionInfo}; use parking_lot::Mutex; @@ -49,6 +49,7 @@ impl ParachainContext for AdderContext { fn produce_candidate>( &self, + _relay_parent: Hash, last_head: HeadData, ingress: I, ) -> Result<(BlockData, HeadData, Extrinsic), InvalidHead>