lib.rs 19.1 KB
Newer Older
Shawn Tabrizi's avatar
Shawn Tabrizi committed
1
// Copyright 2017-2020 Parity Technologies (UK) Ltd.
Gav's avatar
Gav committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.

17
//! Collation node logic.
Gav's avatar
Gav committed
18
19
20
21
22
23
24
25
26
27
28
29
30
//!
//! A collator node lives on a distinct parachain and submits a proposal for
//! a state transition, along with a proof for its validity
//! (what we might call a witness or block data).
//!
//! One of collators' other roles is to route messages between chains.
//! Each parachain produces a list of "egress" posts of messages for each other
//! parachain on each block, for a total of N^2 lists all together.
//!
//! We will refer to the egress list at relay chain block X of parachain A with
//! destination B as egress(X)[A -> B]
//!
//! On every block, each parachain will be intended to route messages from some
31
//! subset of all the other parachains. (NOTE: in practice this is not done until PoC-3)
Gav's avatar
Gav committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//!
//! Since the egress information is unique to every block, when routing from a
//! parachain a collator must gather all egress posts from that parachain
//! up to the last point in history that messages were successfully routed
//! from that parachain, accounting for relay chain blocks where no candidate
//! from the collator's parachain was produced.
//!
//! In the case that all parachains route to each other and a candidate for the
//! collator's parachain was included in the last relay chain block, the collator
//! only has to gather egress posts from other parachains one block back in relay
//! chain history.
//!
//! This crate defines traits which provide context necessary for collation logic
//! to be performed, as the collation logic itself.

47
use std::collections::HashSet;
48
use std::fmt;
49
use std::sync::Arc;
50
use std::time::Duration;
51
use std::pin::Pin;
Gav's avatar
Gav committed
52

53
use futures::{future, Future, Stream, FutureExt, TryFutureExt, StreamExt, task::Spawn};
54
use log::warn;
55
56
use sc_client::BlockchainEvents;
use sp_core::{Pair, Blake2Hasher};
57
use polkadot_primitives::{
58
	BlockId, Hash, Block,
59
	parachain::{
60
61
		self, BlockData, DutyRoster, HeadData, ConsolidatedIngress, Message, Id as ParaId,
		OutgoingMessages, PoVBlock, Status as ParachainStatus, ValidatorId, CollatorPair,
62
63
64
	}
};
use polkadot_cli::{
65
66
	ProvideRuntimeApi, AbstractService, ParachainHost, IsKusama, WrappedExecutor,
	service::{self, Roles, SelectChain}
67
};
68
use polkadot_network::validation::{LeafWorkParams, ValidationNetwork};
69

70
pub use polkadot_cli::{VersionInfo, load_spec, service::Configuration};
71
pub use polkadot_network::validation::Incoming;
72
73
pub use polkadot_validation::SignedStatement;
pub use polkadot_primitives::parachain::CollatorId;
74
pub use sc_network::PeerId;
75
pub use service::RuntimeApiCollection;
76

77
const COLLATION_TIMEOUT: Duration = Duration::from_secs(30);
Gav's avatar
Gav committed
78

79
/// An abstraction over the `Network` with useful functions for a `Collator`.
80
pub trait Network: Send + Sync {
81
82
	/// Convert the given `CollatorId` to a `PeerId`.
	fn collator_id_to_peer_id(&self, collator_id: CollatorId) ->
83
		Box<dyn Future<Output=Option<PeerId>> + Send>;
84
85
86
87
88
89

	/// Create a `Stream` of checked statements for the given `relay_parent`.
	///
	/// The returned stream will not terminate, so it is required to make sure that the stream is
	/// dropped when it is not required anymore. Otherwise, it will stick around in memory
	/// infinitely.
90
	fn checked_statements(&self, relay_parent: Hash) -> Box<dyn Stream<Item=SignedStatement>>;
91
92
}

93
impl<P, E, SP> Network for ValidationNetwork<P, E, SP> where
94
95
	P: 'static + Send + Sync,
	E: 'static + Send + Sync,
96
	SP: 'static + Spawn + Clone + Send + Sync,
97
98
{
	fn collator_id_to_peer_id(&self, collator_id: CollatorId) ->
99
		Box<dyn Future<Output=Option<PeerId>> + Send>
100
	{
101
		Box::new(Self::collator_id_to_peer_id(self, collator_id))
102
103
	}

104
	fn checked_statements(&self, relay_parent: Hash) -> Box<dyn Stream<Item=SignedStatement>> {
105
		Box::new(Self::checked_statements(self, relay_parent))
106
107
108
	}
}

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/// Error to return when the head data was invalid.
#[derive(Clone, Copy, Debug)]
pub struct InvalidHead;

/// Collation errors.
#[derive(Debug)]
pub enum Error<R> {
	/// Error on the relay-chain side of things.
	Polkadot(R),
	/// Error on the collator side of things.
	Collator(InvalidHead),
}

impl<R: fmt::Display> fmt::Display for Error<R> {
	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
		match *self {
			Error::Polkadot(ref err) => write!(f, "Polkadot node error: {}", err),
			Error::Collator(_) => write!(f, "Collator node error: Invalid head data"),
		}
	}
}

131
/// The Polkadot client type.
132
pub type PolkadotClient<B, E, R> = sc_client::Client<B, E, Block, R>;
133

134
135
136
137
138
139
/// Something that can build a `ParachainContext`.
pub trait BuildParachainContext {
	/// The parachain context produced by the `build` function.
	type ParachainContext: self::ParachainContext;

	/// Build the `ParachainContext`.
140
	fn build<B, E, R, SP, Extrinsic>(
141
		self,
142
		client: Arc<PolkadotClient<B, E, R>>,
143
		spawner: SP,
144
145
146
		network: Arc<dyn Network>,
	) -> Result<Self::ParachainContext, ()>
		where
147
			PolkadotClient<B, E, R>: ProvideRuntimeApi<Block>,
148
			<PolkadotClient<B, E, R> as ProvideRuntimeApi<Block>>::Api: RuntimeApiCollection<Extrinsic>,
149
150
151
152
153
			// Rust bug: https://github.com/rust-lang/rust/issues/24159
			<<PolkadotClient<B, E, R> as ProvideRuntimeApi<Block>>::Api as sp_api::ApiExt<Block>>::StateBackend:
				sp_api::StateBackend<Blake2Hasher>,
			Extrinsic: codec::Codec + Send + Sync + 'static,
			E: sc_client::CallExecutor<Block> + Clone + Send + Sync + 'static,
154
155
156
157
158
			SP: Spawn + Clone + Send + Sync + 'static,
			R: Send + Sync + 'static,
			B: sc_client_api::Backend<Block> + 'static,
			// Rust bug: https://github.com/rust-lang/rust/issues/24159
			B::State: sp_api::StateBackend<Blake2Hasher>;
159
160
}

Gav's avatar
Gav committed
161
162
163
/// Parachain context needed for collation.
///
/// This can be implemented through an externally attached service or a stub.
164
165
/// This is expected to be a lightweight, shared type like an Arc.
pub trait ParachainContext: Clone {
166
	type ProduceCandidate: Future<Output = Result<(BlockData, HeadData, OutgoingMessages), InvalidHead>>;
167

168
169
	/// Produce a candidate, given the relay parent hash, the latest ingress queue information
	/// and the last parachain head.
Gav's avatar
Gav committed
170
	fn produce_candidate<I: IntoIterator<Item=(ParaId, Message)>>(
171
		&mut self,
172
		relay_parent: Hash,
173
		status: ParachainStatus,
Gav's avatar
Gav committed
174
		ingress: I,
175
	) -> Self::ProduceCandidate;
Gav's avatar
Gav committed
176
177
178
179
180
181
}

/// Relay chain context needed to collate.
/// This encapsulates a network and local database which may store
/// some of the input.
pub trait RelayChainContext {
182
	type Error: std::fmt::Debug;
Gav's avatar
Gav committed
183
184
185

	/// Future that resolves to the un-routed egress queues of a parachain.
	/// The first item is the oldest.
186
	type FutureEgress: Future<Output = Result<ConsolidatedIngress, Self::Error>>;
Gav's avatar
Gav committed
187
188

	/// Get un-routed egress queues from a parachain to the local parachain.
189
	fn unrouted_egress(&self, _id: ParaId) -> Self::FutureEgress;
Gav's avatar
Gav committed
190
191
}

192
/// Produce a candidate for the parachain, with given contexts, parent head, and signing key.
193
pub async fn collate<R, P>(
194
	relay_parent: Hash,
195
	local_id: ParaId,
196
	parachain_status: ParachainStatus,
197
	relay_context: R,
198
	mut para_context: P,
199
	key: Arc<CollatorPair>,
200
)
201
	-> Result<(parachain::Collation, OutgoingMessages), Error<R::Error>>
Gav's avatar
Gav committed
202
	where
203
		R: RelayChainContext,
204
205
		P: ParachainContext,
		P::ProduceCandidate: Send,
Gav's avatar
Gav committed
206
{
207
208
209
210
211
212
213
214
215
216
217
218
219
	let ingress = relay_context.unrouted_egress(local_id).await.map_err(Error::Polkadot)?;

	let (block_data, head_data, mut outgoing) = para_context.produce_candidate(
		relay_parent,
		parachain_status,
		ingress.0.iter().flat_map(|&(id, ref msgs)| msgs.iter().cloned().map(move |msg| (id, msg)))
	).map_err(Error::Collator).await?;

	let block_data_hash = block_data.hash();
	let signature = key.sign(block_data_hash.as_ref());
	let egress_queue_roots =
		polkadot_validation::egress_roots(&mut outgoing.outgoing_messages);

220
	let info = parachain::CollationInfo {
221
222
223
224
		parachain_index: local_id,
		collator: key.public(),
		signature,
		egress_queue_roots,
225
		head_data,
226
227
228
229
230
		block_data_hash,
		upward_messages: Vec::new(),
	};

	let collation = parachain::Collation {
231
		info,
232
233
234
235
236
237
238
		pov: PoVBlock {
			block_data,
			ingress,
		},
	};

	Ok((collation, outgoing))
Gav's avatar
Gav committed
239
240
}

241
/// Polkadot-api context.
242
struct ApiContext<P, E, SP> {
243
	network: Arc<ValidationNetwork<P, E, SP>>,
244
	parent_hash: Hash,
245
	validators: Vec<ValidatorId>,
246
}
247

248
impl<P: 'static, E: 'static, SP: 'static> RelayChainContext for ApiContext<P, E, SP> where
249
	P: ProvideRuntimeApi<Block> + Send + Sync,
250
	P::Api: ParachainHost<Block>,
Gavin Wood's avatar
Gavin Wood committed
251
	E: futures::Future<Output=()> + Clone + Send + Sync + 'static,
252
	SP: Spawn + Clone + Send + Sync
253
254
{
	type Error = String;
255
	type FutureEgress = Pin<Box<dyn Future<Output=Result<ConsolidatedIngress, String>> + Send>>;
256

257
	fn unrouted_egress(&self, _id: ParaId) -> Self::FutureEgress {
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
		let network = self.network.clone();
		let parent_hash = self.parent_hash;
		let authorities = self.validators.clone();

		async move {
			// TODO: https://github.com/paritytech/polkadot/issues/253
			//
			// Fetch ingress and accumulate all unrounted egress
			let _session = network.instantiate_leaf_work(LeafWorkParams {
				local_session_key: None,
				parent_hash,
				authorities,
			})
				.map_err(|e| format!("unable to instantiate validation session: {:?}", e));

			Ok(ConsolidatedIngress(Vec::new()))
		}.boxed()
275
276
277
	}
}

278
/// Run the collator node using the given `service`.
279
fn run_collator_node<S, E, P, Extrinsic>(
280
	service: S,
281
282
	exit: E,
	para_id: ParaId,
283
	key: Arc<CollatorPair>,
284
285
286
287
	build_parachain_context: P,
) -> polkadot_cli::error::Result<()>
	where
		S: AbstractService<Block = service::Block, NetworkSpecialization = service::PolkadotProtocol>,
288
289
		sc_client::Client<S::Backend, S::CallExecutor, service::Block, S::RuntimeApi>: ProvideRuntimeApi<Block>,
		<sc_client::Client<S::Backend, S::CallExecutor, service::Block, S::RuntimeApi> as ProvideRuntimeApi<Block>>::Api:
290
			RuntimeApiCollection<
291
292
293
294
				Extrinsic,
				Error = sp_blockchain::Error,
				StateBackend = sc_client_api::StateBackendFor<S::Backend, Block>
			>,
295
		// Rust bug: https://github.com/rust-lang/rust/issues/24159
296
		S::Backend: service::Backend<service::Block>,
297
		// Rust bug: https://github.com/rust-lang/rust/issues/24159
298
299
300
301
		<S::Backend as service::Backend<service::Block>>::State:
			sp_api::StateBackend<sp_runtime::traits::HasherFor<Block>>,
		// Rust bug: https://github.com/rust-lang/rust/issues/24159
		S::CallExecutor: service::CallExecutor<service::Block>,
302
303
304
305
306
307
		// Rust bug: https://github.com/rust-lang/rust/issues/24159
		S::SelectChain: service::SelectChain<service::Block>,
		E: futures::Future<Output=()> + Clone + Unpin + Send + Sync + 'static,
		P: BuildParachainContext,
		P::ParachainContext: Send + 'static,
		<P::ParachainContext as ParachainContext>::ProduceCandidate: Send,
308
		Extrinsic: service::Codec + Send + Sync + 'static,
309
{
310
311
312
313
314
315
316
317
318
319
320
	let runtime = tokio::runtime::Runtime::new().map_err(|e| format!("{:?}", e))?;
	let spawner = WrappedExecutor(service.spawn_task_handle());

	let client = service.client();
	let network = service.network();
	let known_oracle = client.clone();
	let select_chain = if let Some(select_chain) = service.select_chain() {
		select_chain
	} else {
		return Err(polkadot_cli::error::Error::Other("The node cannot work because it can't select chain.".into()))
	};
321

322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
	let is_known = move |block_hash: &Hash| {
		use consensus_common::BlockStatus;
		use polkadot_network::gossip::Known;

		match known_oracle.block_status(&BlockId::hash(*block_hash)) {
			Err(_) | Ok(BlockStatus::Unknown) | Ok(BlockStatus::Queued) => None,
			Ok(BlockStatus::KnownBad) => Some(Known::Bad),
			Ok(BlockStatus::InChainWithState) | Ok(BlockStatus::InChainPruned) =>
				match select_chain.leaves() {
					Err(_) => None,
					Ok(leaves) => if leaves.contains(block_hash) {
						Some(Known::Leaf)
					} else {
						Some(Known::Old)
					},
				}
		}
	};
340

341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
	let message_validator = polkadot_network::gossip::register_validator(
		network.clone(),
		(is_known, client.clone()),
		&spawner,
	);

	let validation_network = Arc::new(ValidationNetwork::new(
		message_validator,
		exit.clone(),
		client.clone(),
		spawner.clone(),
	));

	let parachain_context = match build_parachain_context.build(
		client.clone(),
		spawner,
		validation_network.clone(),
	) {
		Ok(ctx) => ctx,
		Err(()) => {
			return Err(polkadot_cli::error::Error::Other("Could not build the parachain context!".into()))
		}
	};
364

365
366
367
368
369
370
371
372
373
374
	let inner_exit = exit.clone();
	let work = client.import_notification_stream()
		.for_each(move |notification| {
			macro_rules! try_fr {
				($e:expr) => {
					match $e {
						Ok(x) => x,
						Err(e) => return future::Either::Left(future::err(Error::Polkadot(
							format!("{:?}", e)
						))),
375
					}
376
				}
377
			}
378

379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
			let relay_parent = notification.hash;
			let id = BlockId::hash(relay_parent);

			let network = network.clone();
			let client = client.clone();
			let key = key.clone();
			let parachain_context = parachain_context.clone();
			let validation_network = validation_network.clone();
			let inner_exit_2 = inner_exit.clone();

			let work = future::lazy(move |_| {
				let api = client.runtime_api();
				let status = match try_fr!(api.parachain_status(&id, para_id)) {
					Some(status) => status,
					None => return future::Either::Left(future::ok(())),
				};

				let validators = try_fr!(api.validators(&id));

				let targets = compute_targets(
					para_id,
					validators.as_slice(),
					try_fr!(api.duty_roster(&id)),
				);

				let context = ApiContext {
					network: validation_network,
					parent_hash: relay_parent,
					validators,
				};

				let collation_work = collate(
					relay_parent,
					para_id,
					status,
					context,
					parachain_context,
					key,
				).map_ok(move |(collation, outgoing)| {
					network.with_spec(move |spec, ctx| {
						let res = spec.add_local_collation(
							ctx,
							relay_parent,
							targets,
							collation,
							outgoing,
						);

						let exit = inner_exit_2.clone();
428
						tokio::spawn(future::select(res.boxed(), exit).map(drop).map(|_| Ok(())).compat());
429
					})
430
				});
431

432
433
				future::Either::Right(collation_work)
			});
434

435
			let deadlined = future::select(
436
				work.then(|f| f).boxed(),
437
438
439
440
441
442
443
444
445
				futures_timer::Delay::new(COLLATION_TIMEOUT)
			);

			let silenced = deadlined
				.map(|either| {
					if let future::Either::Right(_) = either {
						warn!("Collation failure: timeout");
					}
				});
446
447
448

				let future = future::select(
					silenced,
Gavin Wood's avatar
Gavin Wood committed
449
					inner_exit.clone()
450
				).map(drop);
451

452
			tokio::spawn(future.map(|_| Ok(())).compat());
453
454
			future::ready(())
		});
455

456
	service.spawn_essential_task(work);
457

458
	polkadot_cli::run_until_exit(runtime, service, exit)
459
460
}

461
fn compute_targets(para_id: ParaId, session_keys: &[ValidatorId], roster: DutyRoster) -> HashSet<ValidatorId> {
462
463
464
465
466
467
468
469
470
	use polkadot_primitives::parachain::Chain;

	roster.validator_duty.iter().enumerate()
		.filter(|&(_, c)| c == &Chain::Parachain(para_id))
		.filter_map(|(i, _)| session_keys.get(i))
		.cloned()
		.collect()
}

471
472
473
474
475
/// Set the `collating_for` parameter of the configuration.
fn prepare_config(config: &mut Configuration, para_id: ParaId, key: &Arc<CollatorPair>) {
	config.custom.collating_for = Some((key.public(), para_id));
}

476
477
/// Run a collator node with the given `RelayChainContext` and `ParachainContext`
/// build by the given `BuildParachainContext` and arguments to the underlying polkadot node.
478
479
480
///
/// Provide a future which resolves when the node should exit.
/// This function blocks until done.
481
pub fn run_collator<P, E>(
482
	build_parachain_context: P,
483
484
	para_id: ParaId,
	exit: E,
485
	key: Arc<CollatorPair>,
486
	mut config: Configuration,
487
) -> polkadot_cli::error::Result<()> where
488
	P: BuildParachainContext,
489
	P::ParachainContext: Send + 'static,
490
	<P::ParachainContext as ParachainContext>::ProduceCandidate: Send,
Gavin Wood's avatar
Gavin Wood committed
491
	E: futures::Future<Output = ()> + Unpin + Send + Clone + Sync + 'static,
492
{
493
494
	prepare_config(&mut config, para_id, &key);

495
	match (config.chain_spec.is_kusama(), config.roles) {
496
497
498
499
500
501
502
503
504
		(true, Roles::LIGHT) =>
			run_collator_node(service::kusama_new_light(config)?, exit, para_id, key, build_parachain_context),
		(true, _) =>
			run_collator_node(service::kusama_new_full(config)?, exit, para_id, key, build_parachain_context),
		(false, Roles::LIGHT) =>
			run_collator_node(service::polkadot_new_light(config)?, exit, para_id, key, build_parachain_context),
		(false, _) =>
			run_collator_node(service::polkadot_new_full(config)?, exit, para_id, key, build_parachain_context),
	}
505
506
}

Gav's avatar
Gav committed
507
508
#[cfg(test)]
mod tests {
509
	use std::collections::HashMap;
510
	use polkadot_primitives::parachain::{TargetedMessage, FeeSchedule};
511
	use keyring::Sr25519Keyring;
Gav's avatar
Gav committed
512
513
	use super::*;

514
515
516
	#[derive(Default, Clone)]
	struct DummyRelayChainContext {
		ingress: HashMap<ParaId, ConsolidatedIngress>
Gav's avatar
Gav committed
517
518
	}

519
	impl RelayChainContext for DummyRelayChainContext {
Gav's avatar
Gav committed
520
		type Error = ();
521
		type FutureEgress = Box<dyn Future<Output=Result<ConsolidatedIngress,()>> + Unpin>;
Gav's avatar
Gav committed
522

523
524
525
		fn unrouted_egress(&self, para_id: ParaId) -> Self::FutureEgress {
			match self.ingress.get(&para_id) {
				Some(ingress) => Box::new(future::ok(ingress.clone())),
526
				None => Box::new(future::pending()),
527
			}
Gav's avatar
Gav committed
528
		}
529
	}
Gav's avatar
Gav committed
530

531
532
533
534
	#[derive(Clone)]
	struct DummyParachainContext;

	impl ParachainContext for DummyParachainContext {
535
		type ProduceCandidate = future::Ready<Result<(BlockData, HeadData, OutgoingMessages), InvalidHead>>;
536

537
		fn produce_candidate<I: IntoIterator<Item=(ParaId, Message)>>(
538
			&mut self,
539
			_relay_parent: Hash,
540
			_status: ParachainStatus,
541
			ingress: I,
542
		) -> Self::ProduceCandidate {
543
			// send messages right back.
544
			future::ok((
545
546
				BlockData(vec![1, 2, 3, 4, 5,]),
				HeadData(vec![9, 9, 9]),
547
548
				OutgoingMessages {
					outgoing_messages: ingress.into_iter().map(|(id, msg)| TargetedMessage {
549
550
551
552
553
						target: id,
						data: msg.0,
					}).collect(),
				}
			))
Gav's avatar
Gav committed
554
555
556
		}
	}

557
	#[test]
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
	fn collates_correct_queue_roots() {
		let mut context = DummyRelayChainContext::default();

		let id = ParaId::from(100);

		let a = ParaId::from(123);
		let b = ParaId::from(456);

		let messages_from_a = vec![
			Message(vec![1, 1, 1]),
			Message(b"helloworld".to_vec()),
		];
		let messages_from_b = vec![
			Message(b"dogglesworth".to_vec()),
			Message(b"buy_1_chili_con_carne_here_is_my_cash".to_vec()),
		];

		let root_a = ::polkadot_validation::message_queue_root(
			messages_from_a.iter().map(|msg| &msg.0)
		);

		let root_b = ::polkadot_validation::message_queue_root(
			messages_from_b.iter().map(|msg| &msg.0)
		);

		context.ingress.insert(id, ConsolidatedIngress(vec![
			(b, messages_from_b),
			(a, messages_from_a),
		]));

588
		let future = collate(
589
			Default::default(),
590
			id,
591
592
593
594
595
596
597
598
			ParachainStatus {
				head_data: HeadData(vec![5]),
				balance: 10,
				fee_schedule: FeeSchedule {
					base: 0,
					per_byte: 1,
				},
			},
599
600
			context.clone(),
			DummyParachainContext,
601
			Arc::new(Sr25519Keyring::Alice.pair().into()),
602
603
604
		);

		let collation = futures::executor::block_on(future).unwrap().0;
605
606

		// ascending order by root.
607
		assert_eq!(collation.info.egress_queue_roots, vec![(a, root_a), (b, root_b)]);
Gav's avatar
Gav committed
608
609
	}
}