referrerpolicy=no-referrer-when-downgrade

polkadot_node_subsystem_types/
messages.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
16
17//! Message types for the overseer and subsystems.
18//!
19//! These messages are intended to define the protocol by which different subsystems communicate
20//! with each other and signals that they receive from an overseer to coordinate their work.
21//! This is intended for use with the `polkadot-overseer` crate.
22//!
23//! Subsystems' APIs are defined separately from their implementation, leading to easier mocking.
24
25use futures::channel::oneshot;
26use sc_network::{Multiaddr, ReputationChange};
27use sp_runtime::{traits::ConstU32, BoundedVec};
28use thiserror::Error;
29
30pub use sc_network::IfDisconnected;
31
32use polkadot_node_network_protocol::{
33	self as net_protocol, peer_set::PeerSet, request_response::Requests, PeerId,
34};
35use polkadot_node_primitives::{
36	approval::{
37		v1::{BlockApprovalMeta, DelayTranche},
38		v2::{CandidateBitfield, IndirectAssignmentCertV2, IndirectSignedApprovalVoteV2},
39	},
40	AvailableData, BabeEpoch, BlockWeight, CandidateVotes, CollationGenerationConfig,
41	DisputeMessage, DisputeStatus, ErasureChunk, PoV, SignedDisputeStatement, SignedFullStatement,
42	SignedFullStatementWithPVD, SubmitSegmentParams, ValidationResult, MAX_SEGMENT_LEN,
43};
44use polkadot_primitives::{
45	self,
46	async_backing::{self, Constraints},
47	slashing,
48	vstaging::RelayParentInfo,
49	ApprovalVotingParams, AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateCommitments,
50	CandidateEvent, CandidateHash, CandidateIndex, CandidateReceiptV2 as CandidateReceipt,
51	CoalescedApprovalCandidateHashes, CommittedCandidateReceiptV2 as CommittedCandidateReceipt,
52	CoreIndex, CoreState, DisputeState, ExecutorParams, GroupIndex, GroupRotationInfo, Hash,
53	HeadData, Header as BlockHeader, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage,
54	MultiDisputeStatementSet, NodeFeatures, OccupiedCoreAssumption, PersistedValidationData,
55	PvfCheckStatement, PvfExecKind as RuntimePvfExecKind, SessionIndex, SessionInfo,
56	SignedAvailabilityBitfield, SignedAvailabilityBitfields, ValidationCode, ValidationCodeHash,
57	ValidatorId, ValidatorIndex, ValidatorSignature,
58};
59use polkadot_statement_table::v2::Misbehavior;
60use std::{
61	collections::{BTreeMap, HashMap, HashSet, VecDeque},
62	sync::Arc,
63};
64
65/// Network events as transmitted to other subsystems, wrapped in their message types.
66pub mod network_bridge_event;
67pub use network_bridge_event::NetworkBridgeEvent;
68
69/// A request to the candidate backing subsystem to check whether
70/// we can second this candidate.
71#[derive(Debug, Copy, Clone, PartialEq)]
72pub struct CanSecondRequest {
73	/// Para id of the candidate.
74	pub candidate_para_id: ParaId,
75	/// The scheduling parent of the candidate (for V3, may differ from execution relay_parent).
76	pub candidate_scheduling_parent: Hash,
77	/// Hash of the candidate.
78	pub candidate_hash: CandidateHash,
79	/// Parent head data hash.
80	pub parent_head_data_hash: Hash,
81}
82
83/// A reference to a backable candidate along with its scheduling parent.
84///
85/// The scheduling parent determines which validator group is responsible
86/// for backing this candidate and is used to look up per-scheduling-parent state.
87///
88/// This is distinct from `BackedCandidate` which includes the full candidate
89/// data and backing signatures.
90#[derive(Debug, Clone, Copy, PartialEq, Eq)]
91pub struct BackableCandidateRef {
92	/// The hash of the candidate that can be backed.
93	pub candidate_hash: CandidateHash,
94	/// The scheduling parent hash used for validator group assignment.
95	/// For V3 candidates, this may differ from the candidate's relay_parent.
96	/// For V1/V2 candidates, this equals the relay_parent.
97	pub scheduling_parent: Hash,
98}
99
100/// Messages received by the Candidate Backing subsystem.
101#[derive(Debug)]
102pub enum CandidateBackingMessage {
103	/// Requests a set of backable candidates attested by the subsystem.
104	///
105	/// The input is a map from `ParaId` to a vector of backable candidate references.
106	/// Each reference contains the candidate hash and its scheduling parent (used for
107	/// validator group assignment).
108	///
109	/// The order of candidates of the same para must be preserved in the response.
110	/// If a backed candidate of a para cannot be retrieved, the response should not contain any
111	/// candidates of the same para that follow it in the input vector. In other words, assuming
112	/// candidates are supplied in dependency order, we must ensure that this dependency order is
113	/// preserved.
114	GetBackableCandidates {
115		/// Map from para ID to backable candidate references with their scheduling parents.
116		candidates: HashMap<ParaId, Vec<BackableCandidateRef>>,
117		/// Channel to send the backed candidates (with full signatures).
118		sender: oneshot::Sender<HashMap<ParaId, Vec<BackedCandidate>>>,
119	},
120	/// Request the subsystem to check whether it's allowed to second given candidate.
121	/// The rule is to only fetch collations that can either be directly chained to any
122	/// FragmentChain in the view or there is at least one FragmentChain where this candidate is a
123	/// potentially unconnected candidate (we predict that it may become connected to a
124	/// FragmentChain in the future).
125	///
126	/// Always responds with `false` if async backing is disabled for candidate's relay
127	/// parent.
128	CanSecond(CanSecondRequest, oneshot::Sender<bool>),
129	/// Note that the Candidate Backing subsystem should second the given candidate in the context
130	/// of the given scheduling parent (ref. by hash). This candidate must be validated.
131	Second {
132		/// The scheduling parent hash (determines validator group assignment).
133		/// TODO: Once node feature is assumed to be enabled, remove this redundant field and use
134		/// scheduling_parent of the descriptor directly: <https://github.com/paritytech/polkadot-sdk/issues/10883#issue-3844123650>
135		scheduling_parent: Hash,
136		/// The candidate to second.
137		candidate: CandidateReceipt,
138		/// Persisted validation data.
139		pvd: PersistedValidationData,
140		/// Proof of validity.
141		pov: PoV,
142	},
143	/// Note a validator's statement about a particular candidate in the context of the given
144	/// scheduling parent. Disagreements about validity must be escalated to a broader check by the
145	/// Disputes Subsystem, though that escalation is deferred until the approval voting stage to
146	/// guarantee availability. Agreements are simply tallied until a quorum is reached.
147	Statement {
148		/// The scheduling parent hash (determines validator group context).
149		scheduling_parent: Hash,
150		/// The signed statement with persisted validation data.
151		statement: SignedFullStatementWithPVD,
152	},
153}
154
155/// Blanket error for validation failing for internal reasons.
156#[derive(Debug, Error)]
157#[error("Validation failed with {0:?}")]
158pub struct ValidationFailed(pub String);
159
160/// The outcome of the candidate-validation's PVF pre-check request.
161#[derive(Debug, PartialEq)]
162pub enum PreCheckOutcome {
163	/// The PVF has been compiled successfully within the given constraints.
164	Valid,
165	/// The PVF could not be compiled. This variant is used when the candidate-validation subsystem
166	/// can be sure that the PVF is invalid. To give a couple of examples: a PVF that cannot be
167	/// decompressed or that does not represent a structurally valid WebAssembly file.
168	Invalid,
169	/// This variant is used when the PVF cannot be compiled but for other reasons that are not
170	/// included into [`PreCheckOutcome::Invalid`]. This variant can indicate that the PVF in
171	/// question is invalid, however it is not necessary that PVF that received this judgement
172	/// is invalid.
173	///
174	/// For example, if during compilation the preparation worker was killed we cannot be sure why
175	/// it happened: because the PVF was malicious made the worker to use too much memory or its
176	/// because the host machine is under severe memory pressure and it decided to kill the worker.
177	Failed,
178}
179
180/// Messages received by the Validation subsystem.
181///
182/// ## Validation Requests
183///
184/// Validation requests made to the subsystem should return an error only on internal error.
185/// Otherwise, they should return either `Ok(ValidationResult::Valid(_))`
186/// or `Ok(ValidationResult::Invalid)`.
187#[derive(Debug)]
188pub enum CandidateValidationMessage {
189	/// Validate a candidate with provided, exhaustive parameters for validation.
190	///
191	/// Explicitly provide the `PersistedValidationData` and `ValidationCode` so this can do full
192	/// validation without needing to access the state of the relay-chain.
193	///
194	/// This request doesn't involve acceptance criteria checking, therefore only useful for the
195	/// cases where the validity of the candidate is established. This is the case for the typical
196	/// use-case: secondary checkers would use this request relying on the full prior checks
197	/// performed by the relay-chain.
198	ValidateFromExhaustive {
199		/// Persisted validation data
200		validation_data: PersistedValidationData,
201		/// Validation code
202		validation_code: ValidationCode,
203		/// The candidate receipt
204		candidate_receipt: CandidateReceipt,
205		/// The proof-of-validity
206		pov: Arc<PoV>,
207		/// Scheduling session index for this candidate. For V1 descriptors this
208		/// equals the relay-parent session and serves as fallback for both
209		/// execution and scheduling session. For V2+, sessions are in the
210		/// descriptor and this field is ignored. Can be removed once V1 support
211		/// is dropped.
212		scheduling_session_index: SessionIndex,
213		/// Execution kind, used for timeouts and retries (backing/approvals)
214		exec_kind: PvfExecKind,
215		/// The sending side of the response channel
216		response_sender: oneshot::Sender<Result<ValidationResult, ValidationFailed>>,
217	},
218	/// Try to compile the given validation code and send back
219	/// the outcome.
220	///
221	/// The validation code is specified by the hash and will be queried from the runtime API at
222	/// the given relay-parent.
223	PreCheck {
224		/// Relay-parent
225		relay_parent: Hash,
226		/// Validation code hash
227		validation_code_hash: ValidationCodeHash,
228		/// The sending side of the response channel
229		response_sender: oneshot::Sender<PreCheckOutcome>,
230	},
231}
232
233/// Extends primitives::PvfExecKind, which is a runtime parameter we don't want to change,
234/// to separate and prioritize execution jobs by request type.
235#[derive(Debug, Clone, Copy, PartialEq, Eq)]
236pub enum PvfExecKind {
237	/// For dispute requests
238	Dispute,
239	/// For approval requests
240	Approval,
241	/// For backing requests from system parachains. With relay parent hash
242	BackingSystemParas(Hash),
243	/// For backing requests. With relay parent hash
244	Backing(Hash),
245}
246
247impl PvfExecKind {
248	/// Converts priority level to &str
249	pub fn as_str(&self) -> &str {
250		match *self {
251			Self::Dispute => "dispute",
252			Self::Approval => "approval",
253			Self::BackingSystemParas(_) => "backing_system_paras",
254			Self::Backing(_) => "backing",
255		}
256	}
257}
258
259impl From<PvfExecKind> for RuntimePvfExecKind {
260	fn from(exec: PvfExecKind) -> Self {
261		match exec {
262			PvfExecKind::Dispute => RuntimePvfExecKind::Approval,
263			PvfExecKind::Approval => RuntimePvfExecKind::Approval,
264			PvfExecKind::BackingSystemParas(_) => RuntimePvfExecKind::Backing,
265			PvfExecKind::Backing(_) => RuntimePvfExecKind::Backing,
266		}
267	}
268}
269
270/// A fully built segment entry.
271/// The collator protocol assembles a `CandidateReceipt` from these
272/// fields and the segment level commons.
273#[derive(Debug)]
274pub struct SegmentEntry {
275	/// Relay parent the candidate builds on.
276	pub relay_parent: Hash,
277	/// The relay parent's session index.
278	pub session_index: SessionIndex,
279	/// Hash of the validation code the candidate is validated against.
280	pub validation_code_hash: ValidationCodeHash,
281	/// Hash of the candidate's persisted validation data.
282	pub persisted_validation_data_hash: Hash,
283	/// Erasure root of the candidate's available data.
284	pub erasure_root: Hash,
285	/// Hash of the candidate commitments.
286	pub commitments_hash: Hash,
287	/// Hash of the parachain head data produced by the candidate. Stable
288	/// across resubmissions; doubles as the fingerprint identity and the
289	/// collation storage key.
290	pub output_head_data_hash: Hash,
291	/// Proof of validity for the candidate.
292	pub pov: PoV,
293	/// Parachain head data before candidate execution.
294	pub parent_head_data: HeadData,
295}
296
297/// The candidates of one `DistributeSegment` message, shaped by descriptor
298/// version.
299#[derive(Debug)]
300pub enum Segment {
301	/// A V2-descriptor segment: exactly one candidate, always built. The
302	/// entry's `relay_parent` doubles as the scheduling parent.
303	V2(SegmentEntry),
304	/// A V3-descriptor segment: candidates ordered by age, sharing one
305	/// scheduling parent.
306	V3 {
307		/// The scheduling parent shared by all candidates in the segment.
308		scheduling_parent: Hash,
309		/// The scheduling parent's session index.
310		scheduling_session: SessionIndex,
311		/// Ordered candidates; the list may have gaps. Every entry is fully
312		/// built. When on-demand candidate building lands, entries become
313		/// fingerprint advertisements materialized at fetch time, and
314		/// `SegmentEntry` leaves this message entirely.
315		candidates: BoundedVec<SegmentEntry, ConstU32<MAX_SEGMENT_LEN>>,
316	},
317}
318
319/// Messages received by the Collator Protocol subsystem.
320#[derive(Debug, derive_more::From)]
321pub enum CollatorProtocolMessage {
322	/// Signal to the collator protocol that it should connect to validators with the expectation
323	/// of collating on the given para. This is only expected to be called once, early on, if at
324	/// all, and only by the Collation Generation subsystem. As such, it will overwrite the value
325	/// of the previous signal.
326	///
327	/// This should be sent before any `DistributeSegment` message.
328	CollateOn(ParaId),
329	/// Provide an ordered list of collations to the validators.
330	DistributeSegment {
331		/// Core index on which every candidate is to be backed on.
332		core_index: CoreIndex,
333		/// Id of the parachain the candidates are for
334		para_id: ParaId,
335		/// The segment: scheduling context and candidates, shaped by
336		/// descriptor version.
337		segment: Segment,
338	},
339	/// Get a network bridge update.
340	#[from]
341	NetworkBridgeUpdate(NetworkBridgeEvent<net_protocol::CollatorProtocolMessage>),
342	/// We recommended a particular candidate to be seconded, but it was invalid; penalize the
343	/// collator.
344	///
345	/// The hash is the scheduling parent.
346	Invalid(Hash, CandidateReceipt),
347	/// The candidate we recommended to be seconded was validated successfully.
348	///
349	/// The hash is the relay parent.
350	Seconded(Hash, SignedFullStatement),
351	/// A message sent by Cumulus consensus engine to the collator protocol to
352	/// pre-connect to backing groups at all allowed relay parents.
353	ConnectToBackingGroups,
354	/// A message sent by Cumulus consensus engine to the collator protocol to
355	/// disconnect from backing groups.
356	DisconnectFromBackingGroups,
357}
358
359impl Default for CollatorProtocolMessage {
360	fn default() -> Self {
361		Self::CollateOn(Default::default())
362	}
363}
364
365/// Messages received by the dispute coordinator subsystem.
366///
367/// NOTE: Any response oneshots might get cancelled if the `DisputeCoordinator` was not yet
368/// properly initialized for some reason.
369#[derive(Debug)]
370pub enum DisputeCoordinatorMessage {
371	/// Import statements by validators about a candidate.
372	///
373	/// The subsystem will silently discard ancient statements or sets of only dispute-specific
374	/// statements for candidates that are previously unknown to the subsystem. The former is
375	/// simply because ancient data is not relevant and the latter is as a DoS prevention
376	/// mechanism. Both backing and approval statements already undergo anti-DoS procedures in
377	/// their respective subsystems, but statements cast specifically for disputes are not
378	/// necessarily relevant to any candidate the system is already aware of and thus present a DoS
379	/// vector. Our expectation is that nodes will notify each other of disputes over the network
380	/// by providing (at least) 2 conflicting statements, of which one is either a backing or
381	/// validation statement.
382	///
383	/// This does not do any checking of the message signature.
384	ImportStatements {
385		/// The candidate receipt itself.
386		candidate_receipt: CandidateReceipt,
387		/// The session the candidate appears in.
388		session: SessionIndex,
389		/// Statements, with signatures checked, by validators participating in disputes.
390		///
391		/// The validator index passed alongside each statement should correspond to the index
392		/// of the validator in the set.
393		statements: Vec<(SignedDisputeStatement, ValidatorIndex)>,
394		/// Inform the requester once we finished importing (if a sender was provided).
395		///
396		/// This is:
397		/// - we discarded the votes because
398		/// 		- they were ancient or otherwise invalid (result: `InvalidImport`)
399		/// 		- or we were not able to recover availability for an unknown candidate (result:
400		/// 		`InvalidImport`)
401		/// 		- or were known already (in that case the result will still be `ValidImport`)
402		/// - or we recorded them because (`ValidImport`)
403		/// 		- we cast our own vote already on that dispute
404		/// 		- or we have approval votes on that candidate
405		/// 		- or other explicit votes on that candidate already recorded
406		/// 		- or recovered availability for the candidate
407		/// 		- or the imported statements are backing/approval votes, which are always accepted.
408		pending_confirmation: Option<oneshot::Sender<ImportStatementsResult>>,
409	},
410	/// Fetch a list of all recent disputes the coordinator is aware of.
411	/// These are disputes which have occurred any time in recent sessions,
412	/// and which may have already concluded.
413	RecentDisputes(oneshot::Sender<BTreeMap<(SessionIndex, CandidateHash), DisputeStatus>>),
414	/// Fetch a list of all active disputes that the coordinator is aware of.
415	/// These disputes are either not yet concluded or recently concluded.
416	ActiveDisputes(oneshot::Sender<BTreeMap<(SessionIndex, CandidateHash), DisputeStatus>>),
417	/// Get candidate votes for a candidate.
418	QueryCandidateVotes(
419		Vec<(SessionIndex, CandidateHash)>,
420		oneshot::Sender<Vec<(SessionIndex, CandidateHash, CandidateVotes)>>,
421	),
422	/// Sign and issue local dispute votes. A value of `true` indicates validity, and `false`
423	/// invalidity.
424	IssueLocalStatement(SessionIndex, CandidateHash, CandidateReceipt, bool),
425	/// Determine the highest undisputed block within the given chain, based on where candidates
426	/// were included. If even the base block should not be finalized due to a dispute,
427	/// then `None` should be returned on the channel.
428	///
429	/// The block descriptions begin counting upwards from the block after the given `base_number`.
430	/// The `base_number` is typically the number of the last finalized block but may be slightly
431	/// higher. This block is inevitably going to be finalized so it is not accounted for by this
432	/// function.
433	DetermineUndisputedChain {
434		/// The lowest possible block to vote on.
435		base: (BlockNumber, Hash),
436		/// Descriptions of all the blocks counting upwards from the block after the base number
437		block_descriptions: Vec<BlockDescription>,
438		/// The block to vote on, might be base in case there is no better.
439		tx: oneshot::Sender<(BlockNumber, Hash)>,
440	},
441}
442
443/// The result of `DisputeCoordinatorMessage::ImportStatements`.
444#[derive(Copy, Clone, Debug, PartialEq, Eq)]
445pub enum ImportStatementsResult {
446	/// Import was invalid (candidate was not available)  and the sending peer should get banned.
447	InvalidImport,
448	/// Import was valid and can be confirmed to peer.
449	ValidImport,
450}
451
452/// Messages going to the dispute distribution subsystem.
453#[derive(Debug)]
454pub enum DisputeDistributionMessage {
455	/// Tell dispute distribution to distribute an explicit dispute statement to
456	/// validators.
457	SendDispute(DisputeMessage),
458}
459
460/// Messages received from other subsystems.
461#[derive(Debug)]
462pub enum NetworkBridgeRxMessage {
463	/// Inform the distribution subsystems about the new
464	/// gossip network topology formed.
465	///
466	/// The only reason to have this here, is the availability of the
467	/// authority discovery service, otherwise, the `GossipSupport`
468	/// subsystem would make more sense.
469	NewGossipTopology {
470		/// The session info this gossip topology is concerned with.
471		session: SessionIndex,
472		/// Our validator index in the session, if any.
473		local_index: Option<ValidatorIndex>,
474		/// The canonical shuffling of validators for the session.
475		canonical_shuffling: Vec<(AuthorityDiscoveryId, ValidatorIndex)>,
476		/// The reverse mapping of `canonical_shuffling`: from validator index
477		/// to the index in `canonical_shuffling`
478		shuffled_indices: Vec<usize>,
479	},
480	/// Inform the distribution subsystems about `AuthorityDiscoveryId` key rotations.
481	UpdatedAuthorityIds {
482		/// The `PeerId` of the peer that updated its `AuthorityDiscoveryId`s.
483		peer_id: PeerId,
484		/// The updated authority discovery keys of the peer.
485		authority_ids: HashSet<AuthorityDiscoveryId>,
486	},
487}
488
489/// Type of peer reporting
490#[derive(Debug)]
491pub enum ReportPeerMessage {
492	/// Single peer report about malicious actions which should be sent right away
493	Single(PeerId, ReputationChange),
494	/// Delayed report for other actions.
495	Batch(HashMap<PeerId, i32>),
496}
497
498/// Messages received from other subsystems by the network bridge subsystem.
499#[derive(Debug)]
500pub enum NetworkBridgeTxMessage {
501	/// Report a peer for their actions.
502	ReportPeer(ReportPeerMessage),
503
504	/// Disconnect peers from the given peer-set without affecting their reputation.
505	DisconnectPeers(Vec<PeerId>, PeerSet),
506
507	/// Send a message to one or more peers on the validation peer-set.
508	SendValidationMessage(Vec<PeerId>, net_protocol::VersionedValidationProtocol),
509
510	/// Send a message to one or more peers on the collation peer-set.
511	SendCollationMessage(Vec<PeerId>, net_protocol::VersionedCollationProtocol),
512
513	/// Send a batch of validation messages.
514	///
515	/// NOTE: Messages will be processed in order (at least statement distribution relies on this).
516	SendValidationMessages(Vec<(Vec<PeerId>, net_protocol::VersionedValidationProtocol)>),
517
518	/// Send a batch of collation messages.
519	///
520	/// NOTE: Messages will be processed in order.
521	SendCollationMessages(Vec<(Vec<PeerId>, net_protocol::VersionedCollationProtocol)>),
522
523	/// Send requests via substrate request/response.
524	/// Second parameter, tells what to do if we are not yet connected to the peer.
525	SendRequests(Vec<Requests>, IfDisconnected),
526
527	/// Connect to peers who represent the given `validator_ids`.
528	///
529	/// Also ask the network to stay connected to these peers at least
530	/// until a new request is issued.
531	///
532	/// Because it overrides the previous request, it must be ensured
533	/// that `validator_ids` include all peers the subsystems
534	/// are interested in (per `PeerSet`).
535	///
536	/// A caller can learn about validator connections by listening to the
537	/// `PeerConnected` events from the network bridge.
538	ConnectToValidators {
539		/// Ids of the validators to connect to.
540		validator_ids: Vec<AuthorityDiscoveryId>,
541		/// The underlying protocol to use for this request.
542		peer_set: PeerSet,
543		/// Sends back the number of `AuthorityDiscoveryId`s which
544		/// authority discovery has failed to resolve.
545		failed: oneshot::Sender<usize>,
546	},
547	/// Alternative to `ConnectToValidators` in case you already know the `Multiaddrs` you want to
548	/// be connected to.
549	ConnectToResolvedValidators {
550		/// Each entry corresponds to the addresses of an already resolved validator.
551		validator_addrs: Vec<HashSet<Multiaddr>>,
552		/// The peer set we want the connection on.
553		peer_set: PeerSet,
554	},
555
556	/// Extends the known validators set with new peers we already know the `Multiaddrs`, this is
557	/// usually needed for validators that change their address mid-session. It is usually called
558	/// after a ConnectToResolvedValidators at the beginning of the session.
559	AddToResolvedValidators {
560		/// Each entry corresponds to the addresses of an already resolved validator.
561		validator_addrs: Vec<HashSet<Multiaddr>>,
562		/// The peer set we want the connection on.
563		peer_set: PeerSet,
564	},
565}
566
567/// Availability Distribution Message.
568#[derive(Debug)]
569pub enum AvailabilityDistributionMessage {
570	/// Instruct availability distribution to fetch a remote PoV.
571	///
572	/// NOTE: The result of this fetch is not yet locally validated and could be bogus.
573	FetchPoV {
574		/// The relay parent giving the necessary context.
575		relay_parent: Hash,
576		/// Validator to fetch the PoV from.
577		from_validator: ValidatorIndex,
578		/// The id of the parachain that produced this PoV.
579		/// This field is only used to provide more context when logging errors
580		/// from the `AvailabilityDistribution` subsystem.
581		para_id: ParaId,
582		/// Candidate hash to fetch the PoV for.
583		candidate_hash: CandidateHash,
584		/// Expected hash of the PoV, a PoV not matching this hash will be rejected.
585		pov_hash: Hash,
586		/// Sender for getting back the result of this fetch.
587		///
588		/// The sender will be canceled if the fetching failed for some reason.
589		tx: oneshot::Sender<PoV>,
590	},
591}
592
593/// Availability Recovery Message.
594#[derive(Debug, derive_more::From)]
595pub enum AvailabilityRecoveryMessage {
596	/// Recover available data from validators on the network.
597	RecoverAvailableData(
598		CandidateReceipt,
599		SessionIndex,
600		Option<GroupIndex>, // Optional backing group to request from first.
601		Option<CoreIndex>,  /* A `CoreIndex` needs to be specified for the recovery process to
602		                     * prefer systematic chunk recovery. */
603		oneshot::Sender<Result<AvailableData, crate::errors::RecoveryError>>,
604	),
605}
606
607/// Bitfield distribution message.
608#[derive(Debug, derive_more::From)]
609pub enum BitfieldDistributionMessage {
610	/// Distribute a bitfield via gossip to other validators.
611	DistributeBitfield(Hash, SignedAvailabilityBitfield),
612
613	/// Event from the network bridge.
614	#[from]
615	NetworkBridgeUpdate(NetworkBridgeEvent<net_protocol::BitfieldDistributionMessage>),
616}
617
618/// Availability store subsystem message.
619#[derive(Debug)]
620pub enum AvailabilityStoreMessage {
621	/// Query a `AvailableData` from the AV store.
622	QueryAvailableData(CandidateHash, oneshot::Sender<Option<AvailableData>>),
623
624	/// Query whether a `AvailableData` exists within the AV Store.
625	///
626	/// This is useful in cases when existence
627	/// matters, but we don't want to necessarily pass around multiple
628	/// megabytes of data to get a single bit of information.
629	QueryDataAvailability(CandidateHash, oneshot::Sender<bool>),
630
631	/// Query an `ErasureChunk` from the AV store by the candidate hash and validator index.
632	QueryChunk(CandidateHash, ValidatorIndex, oneshot::Sender<Option<ErasureChunk>>),
633
634	/// Get the size of an `ErasureChunk` from the AV store by the candidate hash.
635	QueryChunkSize(CandidateHash, oneshot::Sender<Option<usize>>),
636
637	/// Query all chunks that we have for the given candidate hash.
638	QueryAllChunks(CandidateHash, oneshot::Sender<Vec<(ValidatorIndex, ErasureChunk)>>),
639
640	/// Query whether an `ErasureChunk` exists within the AV Store.
641	///
642	/// This is useful in cases like bitfield signing, when existence
643	/// matters, but we don't want to necessarily pass around large
644	/// quantities of data to get a single bit of information.
645	QueryChunkAvailability(CandidateHash, ValidatorIndex, oneshot::Sender<bool>),
646
647	/// Store an `ErasureChunk` in the AV store.
648	///
649	/// Return `Ok(())` if the store operation succeeded, `Err(())` if it failed.
650	StoreChunk {
651		/// A hash of the candidate this chunk belongs to.
652		candidate_hash: CandidateHash,
653		/// Validator index. May not be equal to the chunk index.
654		validator_index: ValidatorIndex,
655		/// The chunk itself.
656		chunk: ErasureChunk,
657		/// Sending side of the channel to send result to.
658		tx: oneshot::Sender<Result<(), ()>>,
659	},
660
661	/// Computes and checks the erasure root of `AvailableData` before storing all of its chunks in
662	/// the AV store.
663	///
664	/// Return `Ok(())` if the store operation succeeded, `Err(StoreAvailableData)` if it failed.
665	StoreAvailableData {
666		/// A hash of the candidate this `available_data` belongs to.
667		candidate_hash: CandidateHash,
668		/// The number of validators in the session.
669		n_validators: u32,
670		/// The `AvailableData` itself.
671		available_data: AvailableData,
672		/// Erasure root we expect to get after chunking.
673		expected_erasure_root: Hash,
674		/// Core index where the candidate was backed.
675		core_index: CoreIndex,
676		/// Node features at the candidate relay parent. Used for computing the validator->chunk
677		/// mapping.
678		node_features: NodeFeatures,
679		/// Sending side of the channel to send result to.
680		tx: oneshot::Sender<Result<(), StoreAvailableDataError>>,
681	},
682}
683
684/// The error result type of a [`AvailabilityStoreMessage::StoreAvailableData`] request.
685#[derive(Error, Debug, Clone, PartialEq, Eq)]
686#[allow(missing_docs)]
687pub enum StoreAvailableDataError {
688	#[error("The computed erasure root did not match expected one")]
689	InvalidErasureRoot,
690}
691
692/// A response channel for the result of a chain API request.
693pub type ChainApiResponseChannel<T> = oneshot::Sender<Result<T, crate::errors::ChainApiError>>;
694
695/// Chain API request subsystem message.
696#[derive(Debug)]
697pub enum ChainApiMessage {
698	/// Request the block number by hash.
699	/// Returns `None` if a block with the given hash is not present in the db.
700	BlockNumber(Hash, ChainApiResponseChannel<Option<BlockNumber>>),
701	/// Request the block header by hash.
702	/// Returns `None` if a block with the given hash is not present in the db.
703	BlockHeader(Hash, ChainApiResponseChannel<Option<BlockHeader>>),
704	/// Get the cumulative weight of the given block, by hash.
705	/// If the block or weight is unknown, this returns `None`.
706	///
707	/// Note: this is the weight within the low-level fork-choice rule,
708	/// not the high-level one implemented in the chain-selection subsystem.
709	///
710	/// Weight is used for comparing blocks in a fork-choice rule.
711	BlockWeight(Hash, ChainApiResponseChannel<Option<BlockWeight>>),
712	/// Request the finalized block hash by number.
713	/// Returns `None` if a block with the given number is not present in the db.
714	/// Note: the caller must ensure the block is finalized.
715	FinalizedBlockHash(BlockNumber, ChainApiResponseChannel<Option<Hash>>),
716	/// Request the last finalized block number.
717	/// This request always succeeds.
718	FinalizedBlockNumber(ChainApiResponseChannel<BlockNumber>),
719	/// Request the `k` ancestor block hashes of a block with the given hash.
720	/// The response channel may return a `Vec` of size up to `k`
721	/// filled with ancestors hashes with the following order:
722	/// `parent`, `grandparent`, ... up to the hash of genesis block
723	/// with number 0, including it.
724	Ancestors {
725		/// The hash of the block in question.
726		hash: Hash,
727		/// The number of ancestors to request.
728		k: usize,
729		/// The response channel.
730		response_channel: ChainApiResponseChannel<Vec<Hash>>,
731	},
732}
733
734/// Chain selection subsystem messages
735#[derive(Debug)]
736pub enum ChainSelectionMessage {
737	/// Signal to the chain selection subsystem that a specific block has been approved.
738	Approved(Hash),
739	/// Request the leaves in descending order by score.
740	Leaves(oneshot::Sender<Vec<Hash>>),
741	/// Request the best leaf containing the given block in its ancestry. Return `None` if
742	/// there is no such leaf.
743	BestLeafContaining(Hash, oneshot::Sender<Option<Hash>>),
744	/// The passed blocks must be marked as reverted, and their children must be marked
745	/// as non-viable.
746	RevertBlocks(Vec<(BlockNumber, Hash)>),
747}
748
749/// A sender for the result of a runtime API request.
750pub type RuntimeApiSender<T> = oneshot::Sender<Result<T, crate::errors::RuntimeApiError>>;
751
752/// A request to the Runtime API subsystem.
753#[derive(Debug)]
754pub enum RuntimeApiRequest {
755	/// Get the version of the runtime API, if any.
756	Version(RuntimeApiSender<u32>),
757	/// Get the next, current and some previous authority discovery set deduplicated.
758	Authorities(RuntimeApiSender<Vec<AuthorityDiscoveryId>>),
759	/// Get the current validator set.
760	Validators(RuntimeApiSender<Vec<ValidatorId>>),
761	/// Get the validator groups and group rotation info.
762	ValidatorGroups(RuntimeApiSender<(Vec<Vec<ValidatorIndex>>, GroupRotationInfo)>),
763	/// Get information on all availability cores.
764	AvailabilityCores(RuntimeApiSender<Vec<CoreState>>),
765	/// Get the persisted validation data for a particular para, taking the given
766	/// `OccupiedCoreAssumption`, which will inform on how the validation data should be computed
767	/// if the para currently occupies a core.
768	PersistedValidationData(
769		ParaId,
770		OccupiedCoreAssumption,
771		RuntimeApiSender<Option<PersistedValidationData>>,
772	),
773	/// Get the persisted validation data for a particular para along with the current validation
774	/// code hash, matching the data hash against an expected one.
775	AssumedValidationData(
776		ParaId,
777		Hash,
778		RuntimeApiSender<Option<(PersistedValidationData, ValidationCodeHash)>>,
779	),
780	/// Sends back `true` if the validation outputs pass all acceptance criteria checks.
781	CheckValidationOutputs(
782		ParaId,
783		polkadot_primitives::CandidateCommitments,
784		RuntimeApiSender<bool>,
785	),
786	/// Get the session index that a child of the block will have.
787	SessionIndexForChild(RuntimeApiSender<SessionIndex>),
788	/// Get the validation code for a para, taking the given `OccupiedCoreAssumption`, which
789	/// will inform on how the validation data should be computed if the para currently
790	/// occupies a core.
791	ValidationCode(ParaId, OccupiedCoreAssumption, RuntimeApiSender<Option<ValidationCode>>),
792	/// Get validation code by its hash, either past, current or future code can be returned, as
793	/// long as state is still available.
794	ValidationCodeByHash(ValidationCodeHash, RuntimeApiSender<Option<ValidationCode>>),
795	/// Get the candidate pending availability for a particular parachain by parachain / core
796	/// index
797	CandidatePendingAvailability(ParaId, RuntimeApiSender<Option<CommittedCandidateReceipt>>),
798	/// Get all events concerning candidates (backing, inclusion, time-out) in the parent of
799	/// the block in whose state this request is executed.
800	CandidateEvents(RuntimeApiSender<Vec<CandidateEvent>>),
801	/// Get the execution environment parameter set by session index
802	SessionExecutorParams(SessionIndex, RuntimeApiSender<Option<ExecutorParams>>),
803	/// Get the session info for the given session, if stored.
804	SessionInfo(SessionIndex, RuntimeApiSender<Option<SessionInfo>>),
805	/// Get all the pending inbound messages in the downward message queue for a para.
806	DmqContents(ParaId, RuntimeApiSender<Vec<InboundDownwardMessage<BlockNumber>>>),
807	/// Get the contents of all channels addressed to the given recipient. Channels that have no
808	/// messages in them are also included.
809	InboundHrmpChannelsContents(
810		ParaId,
811		RuntimeApiSender<BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>>>,
812	),
813	/// Get information about the BABE epoch the block was included in.
814	CurrentBabeEpoch(RuntimeApiSender<BabeEpoch>),
815	/// Get all disputes in relation to a relay parent.
816	FetchOnChainVotes(RuntimeApiSender<Option<polkadot_primitives::ScrapedOnChainVotes>>),
817	/// Submits a PVF pre-checking statement into the transaction pool.
818	SubmitPvfCheckStatement(PvfCheckStatement, ValidatorSignature, RuntimeApiSender<()>),
819	/// Returns code hashes of PVFs that require pre-checking by validators in the active set.
820	PvfsRequirePrecheck(RuntimeApiSender<Vec<ValidationCodeHash>>),
821	/// Get the validation code used by the specified para, taking the given
822	/// `OccupiedCoreAssumption`, which will inform on how the validation data should be computed
823	/// if the para currently occupies a core.
824	ValidationCodeHash(
825		ParaId,
826		OccupiedCoreAssumption,
827		RuntimeApiSender<Option<ValidationCodeHash>>,
828	),
829	/// Returns all on-chain disputes at given block number. Available in `v3`.
830	Disputes(RuntimeApiSender<Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)>>),
831	/// Returns a list of validators that lost a past session dispute and need to be slashed.
832	/// `V5`
833	UnappliedSlashes(
834		RuntimeApiSender<Vec<(SessionIndex, CandidateHash, slashing::LegacyPendingSlashes)>>,
835	),
836	/// Returns a merkle proof of a validator session key.
837	/// `V5`
838	KeyOwnershipProof(ValidatorId, RuntimeApiSender<Option<slashing::OpaqueKeyOwnershipProof>>),
839	/// Submits an unsigned extrinsic to slash validator who lost a past session dispute.
840	/// `V5`
841	SubmitReportDisputeLost(
842		slashing::DisputeProof,
843		slashing::OpaqueKeyOwnershipProof,
844		RuntimeApiSender<Option<()>>,
845	),
846	/// Get the minimum required backing votes.
847	MinimumBackingVotes(SessionIndex, RuntimeApiSender<u32>),
848	/// Returns all disabled validators at a given block height.
849	DisabledValidators(RuntimeApiSender<Vec<ValidatorIndex>>),
850	/// Get the backing state of the given para.
851	ParaBackingState(ParaId, RuntimeApiSender<Option<async_backing::BackingState>>),
852	/// Get candidate's acceptance limitations for asynchronous backing for a relay parent.
853	///
854	/// If it's not supported by the Runtime, the async backing is said to be disabled.
855	AsyncBackingParams(RuntimeApiSender<async_backing::AsyncBackingParams>),
856	/// Get the node features.
857	NodeFeatures(SessionIndex, RuntimeApiSender<NodeFeatures>),
858	/// Approval voting params
859	/// `V10`
860	ApprovalVotingParams(SessionIndex, RuntimeApiSender<ApprovalVotingParams>),
861	/// Fetch the `ClaimQueue` from scheduler pallet
862	/// `V11`
863	ClaimQueue(RuntimeApiSender<BTreeMap<CoreIndex, VecDeque<ParaId>>>),
864	/// Get the candidates pending availability for a particular parachain
865	/// `V11`
866	CandidatesPendingAvailability(ParaId, RuntimeApiSender<Vec<CommittedCandidateReceipt>>),
867	/// Get the backing constraints for a particular parachain.
868	/// `V12`
869	BackingConstraints(ParaId, RuntimeApiSender<Option<Constraints>>),
870	/// Get the lookahead from the scheduler params.
871	/// `V12`
872	SchedulingLookahead(SessionIndex, RuntimeApiSender<u32>),
873	/// Get the maximum uncompressed code size.
874	/// `V12`
875	ValidationCodeBombLimit(SessionIndex, RuntimeApiSender<u32>),
876	/// Get the paraids at the relay parent.
877	/// `V14`
878	ParaIds(SessionIndex, RuntimeApiSender<Vec<ParaId>>),
879	/// Returns a list of validators that lost a past session dispute and need to be slashed (v2).
880	/// `V15`
881	UnappliedSlashesV2(
882		RuntimeApiSender<Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)>>,
883	),
884	/// Get the maximum relay parent session age allowed for parachain blocks.
885	/// `V16`
886	MaxRelayParentSessionAge(SessionIndex, RuntimeApiSender<u32>),
887	/// Look up relay parent info for an **ancestor** block. A block is not in its
888	/// own `AllowedRelayParents`, so querying a block about itself returns `None`.
889	/// Use the node-side `check_relay_parent_session` utility for the general case. `V16`
890	AncestorRelayParentInfo(
891		SessionIndex,
892		Hash,
893		RuntimeApiSender<Option<RelayParentInfo<Hash, BlockNumber>>>,
894	),
895}
896
897impl RuntimeApiRequest {
898	/// Runtime version requirements for each message
899
900	/// `Disputes`
901	pub const DISPUTES_RUNTIME_REQUIREMENT: u32 = 3;
902
903	/// `ExecutorParams`
904	pub const EXECUTOR_PARAMS_RUNTIME_REQUIREMENT: u32 = 4;
905
906	/// `UnappliedSlashes`
907	pub const UNAPPLIED_SLASHES_RUNTIME_REQUIREMENT: u32 = 5;
908
909	/// `KeyOwnershipProof`
910	pub const KEY_OWNERSHIP_PROOF_RUNTIME_REQUIREMENT: u32 = 5;
911
912	/// `SubmitReportDisputeLost`
913	pub const SUBMIT_REPORT_DISPUTE_LOST_RUNTIME_REQUIREMENT: u32 = 5;
914
915	/// `MinimumBackingVotes`
916	pub const MINIMUM_BACKING_VOTES_RUNTIME_REQUIREMENT: u32 = 6;
917
918	/// Minimum version to enable asynchronous backing: `AsyncBackingParams` and `ParaBackingState`.
919	pub const ASYNC_BACKING_STATE_RUNTIME_REQUIREMENT: u32 = 7;
920
921	/// `DisabledValidators`
922	pub const DISABLED_VALIDATORS_RUNTIME_REQUIREMENT: u32 = 8;
923
924	/// `Node features`
925	pub const NODE_FEATURES_RUNTIME_REQUIREMENT: u32 = 9;
926
927	/// `approval_voting_params`
928	pub const APPROVAL_VOTING_PARAMS_REQUIREMENT: u32 = 10;
929
930	/// `ClaimQueue`
931	pub const CLAIM_QUEUE_RUNTIME_REQUIREMENT: u32 = 11;
932
933	/// `candidates_pending_availability`
934	pub const CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT: u32 = 11;
935
936	/// `ValidationCodeBombLimit`
937	pub const VALIDATION_CODE_BOMB_LIMIT_RUNTIME_REQUIREMENT: u32 = 12;
938
939	/// `backing_constraints`
940	pub const CONSTRAINTS_RUNTIME_REQUIREMENT: u32 = 13;
941
942	/// `SchedulingLookahead`
943	pub const SCHEDULING_LOOKAHEAD_RUNTIME_REQUIREMENT: u32 = 13;
944
945	/// `ParaIds`
946	pub const PARAIDS_RUNTIME_REQUIREMENT: u32 = 14;
947
948	/// `UnappliedSlashesV2`
949	pub const UNAPPLIED_SLASHES_V2_RUNTIME_REQUIREMENT: u32 = 15;
950
951	/// `MaxRelayParentSessionAge`
952	pub const MAX_RELAY_PARENT_SESSION_AGE_RUNTIME_REQUIREMENT: u32 = 16;
953
954	/// `AncestorRelayParentInfo`
955	pub const ANCESTOR_RELAY_PARENT_INFO_RUNTIME_REQUIREMENT: u32 = 16;
956}
957
958/// A message to the Runtime API subsystem.
959#[derive(Debug)]
960pub enum RuntimeApiMessage {
961	/// Make a request of the runtime API against the post-state of the given relay-parent.
962	Request(Hash, RuntimeApiRequest),
963}
964
965/// Statement distribution message.
966#[derive(Debug, derive_more::From)]
967pub enum StatementDistributionMessage {
968	/// We have originated a signed statement in the context of
969	/// given relay-parent hash and it should be distributed to other validators.
970	Share(Hash, SignedFullStatementWithPVD),
971	/// The candidate received enough validity votes from the backing group.
972	///
973	/// If the candidate is backed as a result of a local statement, this message MUST
974	/// be preceded by a `Share` message for that statement. This ensures that Statement
975	/// Distribution is always aware of full candidates prior to receiving the `Backed`
976	/// notification, even when the group size is 1 and the candidate is seconded locally.
977	Backed(CandidateHash),
978	/// Event from the network bridge.
979	#[from]
980	NetworkBridgeUpdate(NetworkBridgeEvent<net_protocol::StatementDistributionMessage>),
981}
982
983/// This data becomes intrinsics or extrinsics which should be included in a future relay chain
984/// block.
985// It needs to be clonable because multiple potential block authors can request copies.
986#[derive(Debug, Clone)]
987pub enum ProvisionableData {
988	/// This bitfield indicates the availability of various candidate blocks.
989	Bitfield(Hash, SignedAvailabilityBitfield),
990	/// Misbehavior reports are self-contained proofs of validator misbehavior.
991	MisbehaviorReport(Hash, ValidatorIndex, Misbehavior),
992	/// Disputes trigger a broad dispute resolution process.
993	Dispute(Hash, ValidatorSignature),
994}
995
996/// Inherent data returned by the provisioner
997#[derive(Debug, Clone)]
998pub struct ProvisionerInherentData {
999	/// Signed bitfields.
1000	pub bitfields: SignedAvailabilityBitfields,
1001	/// Backed candidates.
1002	pub backed_candidates: Vec<BackedCandidate>,
1003	/// Dispute statement sets.
1004	pub disputes: MultiDisputeStatementSet,
1005}
1006
1007/// Message to the Provisioner.
1008///
1009/// In all cases, the Hash is that of the relay parent.
1010#[derive(Debug)]
1011pub enum ProvisionerMessage {
1012	/// This message allows external subsystems to request the set of bitfields and backed
1013	/// candidates associated with a particular potential block hash.
1014	///
1015	/// This is expected to be used by a proposer, to inject that information into the
1016	/// `InherentData` where it can be assembled into the `ParaInherent`.
1017	RequestInherentData(Hash, oneshot::Sender<ProvisionerInherentData>),
1018	/// This data should become part of a relay chain block
1019	ProvisionableData(Hash, ProvisionableData),
1020}
1021
1022/// Message to the Collation Generation subsystem.
1023#[derive(Debug)]
1024pub enum CollationGenerationMessage {
1025	/// Initialize the collation generation subsystem.
1026	Initialize(CollationGenerationConfig),
1027	/// Reinitialize the collation generation subsystem, overriding the existing config.
1028	Reinitialize(CollationGenerationConfig),
1029	/// Submit a segment of collations that share a scheduling parent and target core. Each
1030	/// collation is packaged into a signed [`CommittedCandidateReceipt`] and distributed to
1031	/// validators, in the order they appear in [`SubmitSegmentParams::collations`].
1032	///
1033	/// If sent before `Initialize`, this will be ignored.
1034	SubmitSegment(SubmitSegmentParams),
1035}
1036
1037/// The result type of [`ApprovalVotingMessage::ImportAssignment`] request.
1038#[derive(Debug, Clone, PartialEq, Eq)]
1039pub enum AssignmentCheckResult {
1040	/// The vote was accepted and should be propagated onwards.
1041	Accepted,
1042	/// The vote was valid but duplicate and should not be propagated onwards.
1043	AcceptedDuplicate,
1044	/// The vote was valid but too far in the future to accept right now.
1045	TooFarInFuture,
1046	/// The vote was bad and should be ignored, reporting the peer who propagated it.
1047	Bad(AssignmentCheckError),
1048}
1049
1050/// The error result type of [`ApprovalVotingMessage::ImportAssignment`] request.
1051#[derive(Error, Debug, Clone, PartialEq, Eq)]
1052#[allow(missing_docs)]
1053pub enum AssignmentCheckError {
1054	#[error("Unknown block: {0:?}")]
1055	UnknownBlock(Hash),
1056	#[error("Unknown session index: {0}")]
1057	UnknownSessionIndex(SessionIndex),
1058	#[error("Invalid candidate index: {0}")]
1059	InvalidCandidateIndex(CandidateIndex),
1060	#[error("Invalid candidate {0}: {1:?}")]
1061	InvalidCandidate(CandidateIndex, CandidateHash),
1062	#[error("Invalid cert: {0:?}, reason: {1}")]
1063	InvalidCert(ValidatorIndex, String),
1064	#[error("Internal state mismatch: {0:?}, {1:?}")]
1065	Internal(Hash, CandidateHash),
1066	#[error("Oversized candidate or core bitfield >= {0}")]
1067	InvalidBitfield(usize),
1068}
1069
1070/// The result type of [`ApprovalVotingMessage::ImportApproval`] request.
1071#[derive(Debug, Clone, PartialEq, Eq)]
1072pub enum ApprovalCheckResult {
1073	/// The vote was accepted and should be propagated onwards.
1074	Accepted,
1075	/// The vote was bad and should be ignored, reporting the peer who propagated it.
1076	Bad(ApprovalCheckError),
1077}
1078
1079/// The error result type of [`ApprovalVotingMessage::ImportApproval`] request.
1080#[derive(Error, Debug, Clone, PartialEq, Eq)]
1081#[allow(missing_docs)]
1082pub enum ApprovalCheckError {
1083	#[error("Unknown block: {0:?}")]
1084	UnknownBlock(Hash),
1085	#[error("Unknown session index: {0}")]
1086	UnknownSessionIndex(SessionIndex),
1087	#[error("Invalid candidate index: {0}")]
1088	InvalidCandidateIndex(CandidateIndex),
1089	#[error("Invalid validator index: {0:?}")]
1090	InvalidValidatorIndex(ValidatorIndex),
1091	#[error("Invalid candidate {0}: {1:?}")]
1092	InvalidCandidate(CandidateIndex, CandidateHash),
1093	#[error("Invalid signature: {0:?}")]
1094	InvalidSignature(ValidatorIndex),
1095	#[error("No assignment for {0:?}")]
1096	NoAssignment(ValidatorIndex),
1097	#[error("Internal state mismatch: {0:?}, {1:?}")]
1098	Internal(Hash, CandidateHash),
1099}
1100
1101/// Describes a relay-chain block by the para-chain candidates
1102/// it includes.
1103#[derive(Clone, Debug)]
1104pub struct BlockDescription {
1105	/// The relay-chain block hash.
1106	pub block_hash: Hash,
1107	/// The session index of this block.
1108	pub session: SessionIndex,
1109	/// The set of para-chain candidates.
1110	pub candidates: Vec<CandidateHash>,
1111}
1112
1113/// Message to the approval voting parallel subsystem running both approval-distribution and
1114/// approval-voting logic in parallel. This is a combination of all the messages ApprovalVoting and
1115/// ApprovalDistribution subsystems can receive.
1116///
1117/// The reason this exists is, so that we can keep both modes of running in the same polkadot
1118/// binary, based on the value of `--approval-voting-parallel-enabled`, we decide if we run with two
1119/// different subsystems for approval-distribution and approval-voting or run the approval-voting
1120/// parallel which has several parallel workers for the approval-distribution and a worker for
1121/// approval-voting.
1122///
1123/// This is meant to be a temporary state until we can safely remove running the two subsystems
1124/// individually.
1125#[derive(Debug, derive_more::From)]
1126pub enum ApprovalVotingParallelMessage {
1127	/// Gets mapped into `ApprovalVotingMessage::ApprovedAncestor`
1128	ApprovedAncestor(Hash, BlockNumber, oneshot::Sender<Option<HighestApprovedAncestorBlock>>),
1129
1130	/// Gets mapped into `ApprovalVotingMessage::GetApprovalSignaturesForCandidate`
1131	GetApprovalSignaturesForCandidate(
1132		CandidateHash,
1133		oneshot::Sender<
1134			HashMap<ValidatorIndex, (CoalescedApprovalCandidateHashes, ValidatorSignature)>,
1135		>,
1136	),
1137	/// Gets mapped into `ApprovalDistributionMessage::NewBlocks`
1138	NewBlocks(Vec<BlockApprovalMeta>),
1139	/// Gets mapped into `ApprovalDistributionMessage::DistributeAssignment`
1140	DistributeAssignment(IndirectAssignmentCertV2, CandidateBitfield),
1141	/// Gets mapped into `ApprovalDistributionMessage::DistributeApproval`
1142	DistributeApproval(IndirectSignedApprovalVoteV2),
1143	/// An update from the network bridge, gets mapped into
1144	/// `ApprovalDistributionMessage::NetworkBridgeUpdate`
1145	#[from]
1146	NetworkBridgeUpdate(NetworkBridgeEvent<net_protocol::ApprovalDistributionMessage>),
1147
1148	/// Gets mapped into `ApprovalDistributionMessage::GetApprovalSignatures`
1149	GetApprovalSignatures(
1150		HashSet<(Hash, CandidateIndex)>,
1151		oneshot::Sender<HashMap<ValidatorIndex, (Hash, Vec<CandidateIndex>, ValidatorSignature)>>,
1152	),
1153	/// Gets mapped into `ApprovalDistributionMessage::ApprovalCheckingLagUpdate`
1154	ApprovalCheckingLagUpdate(BlockNumber),
1155}
1156
1157impl TryFrom<ApprovalVotingParallelMessage> for ApprovalVotingMessage {
1158	type Error = ();
1159
1160	fn try_from(msg: ApprovalVotingParallelMessage) -> Result<Self, Self::Error> {
1161		match msg {
1162			ApprovalVotingParallelMessage::ApprovedAncestor(hash, number, tx) => {
1163				Ok(ApprovalVotingMessage::ApprovedAncestor(hash, number, tx))
1164			},
1165			ApprovalVotingParallelMessage::GetApprovalSignaturesForCandidate(candidate, tx) => {
1166				Ok(ApprovalVotingMessage::GetApprovalSignaturesForCandidate(candidate, tx))
1167			},
1168			_ => Err(()),
1169		}
1170	}
1171}
1172
1173impl TryFrom<ApprovalVotingParallelMessage> for ApprovalDistributionMessage {
1174	type Error = ();
1175
1176	fn try_from(msg: ApprovalVotingParallelMessage) -> Result<Self, Self::Error> {
1177		match msg {
1178			ApprovalVotingParallelMessage::NewBlocks(blocks) => {
1179				Ok(ApprovalDistributionMessage::NewBlocks(blocks))
1180			},
1181			ApprovalVotingParallelMessage::DistributeAssignment(assignment, claimed_cores) => {
1182				Ok(ApprovalDistributionMessage::DistributeAssignment(assignment, claimed_cores))
1183			},
1184			ApprovalVotingParallelMessage::DistributeApproval(vote) => {
1185				Ok(ApprovalDistributionMessage::DistributeApproval(vote))
1186			},
1187			ApprovalVotingParallelMessage::NetworkBridgeUpdate(msg) => {
1188				Ok(ApprovalDistributionMessage::NetworkBridgeUpdate(msg))
1189			},
1190			ApprovalVotingParallelMessage::GetApprovalSignatures(candidate_indicies, tx) => {
1191				Ok(ApprovalDistributionMessage::GetApprovalSignatures(candidate_indicies, tx))
1192			},
1193			ApprovalVotingParallelMessage::ApprovalCheckingLagUpdate(lag) => {
1194				Ok(ApprovalDistributionMessage::ApprovalCheckingLagUpdate(lag))
1195			},
1196			_ => Err(()),
1197		}
1198	}
1199}
1200
1201impl From<ApprovalDistributionMessage> for ApprovalVotingParallelMessage {
1202	fn from(msg: ApprovalDistributionMessage) -> Self {
1203		match msg {
1204			ApprovalDistributionMessage::NewBlocks(blocks) => {
1205				ApprovalVotingParallelMessage::NewBlocks(blocks)
1206			},
1207			ApprovalDistributionMessage::DistributeAssignment(cert, bitfield) => {
1208				ApprovalVotingParallelMessage::DistributeAssignment(cert, bitfield)
1209			},
1210			ApprovalDistributionMessage::DistributeApproval(vote) => {
1211				ApprovalVotingParallelMessage::DistributeApproval(vote)
1212			},
1213			ApprovalDistributionMessage::NetworkBridgeUpdate(msg) => {
1214				ApprovalVotingParallelMessage::NetworkBridgeUpdate(msg)
1215			},
1216			ApprovalDistributionMessage::GetApprovalSignatures(candidate_indicies, tx) => {
1217				ApprovalVotingParallelMessage::GetApprovalSignatures(candidate_indicies, tx)
1218			},
1219			ApprovalDistributionMessage::ApprovalCheckingLagUpdate(lag) => {
1220				ApprovalVotingParallelMessage::ApprovalCheckingLagUpdate(lag)
1221			},
1222		}
1223	}
1224}
1225
1226/// Response type to `ApprovalVotingMessage::ApprovedAncestor`.
1227#[derive(Clone, Debug)]
1228pub struct HighestApprovedAncestorBlock {
1229	/// The block hash of the highest viable ancestor.
1230	pub hash: Hash,
1231	/// The block number of the highest viable ancestor.
1232	pub number: BlockNumber,
1233	/// Block descriptions in the direct path between the
1234	/// initially provided hash and the highest viable ancestor.
1235	/// Primarily for use with `DetermineUndisputedChain`.
1236	/// Must be sorted from lowest to highest block number.
1237	pub descriptions: Vec<BlockDescription>,
1238}
1239
1240/// A checked indirect assignment, the crypto for the cert has been validated
1241/// and the `candidate_bitfield` is correctly claimed at `delay_tranche`.
1242#[derive(Debug)]
1243pub struct CheckedIndirectAssignment {
1244	assignment: IndirectAssignmentCertV2,
1245	candidate_indices: CandidateBitfield,
1246	tranche: DelayTranche,
1247}
1248
1249impl CheckedIndirectAssignment {
1250	/// Builds a checked assignment from an assignment that was checked to be valid for the
1251	/// `claimed_candidate_indices` at the give tranche
1252	pub fn from_checked(
1253		assignment: IndirectAssignmentCertV2,
1254		claimed_candidate_indices: CandidateBitfield,
1255		tranche: DelayTranche,
1256	) -> Self {
1257		Self { assignment, candidate_indices: claimed_candidate_indices, tranche }
1258	}
1259
1260	/// Returns the indirect assignment.
1261	pub fn assignment(&self) -> &IndirectAssignmentCertV2 {
1262		&self.assignment
1263	}
1264
1265	/// Returns the candidate bitfield claimed by the assignment.
1266	pub fn candidate_indices(&self) -> &CandidateBitfield {
1267		&self.candidate_indices
1268	}
1269
1270	/// Returns the tranche this assignment is claimed at.
1271	pub fn tranche(&self) -> DelayTranche {
1272		self.tranche
1273	}
1274}
1275
1276/// A checked indirect signed approval vote.
1277///
1278/// The crypto for the vote has been validated and the signature can be trusted as being valid and
1279/// to correspond to the `validator_index` inside the structure.
1280#[derive(Debug, derive_more::Deref, derive_more::Into)]
1281pub struct CheckedIndirectSignedApprovalVote(IndirectSignedApprovalVoteV2);
1282
1283impl CheckedIndirectSignedApprovalVote {
1284	/// Builds a checked vote from a vote that was checked to be valid and correctly signed.
1285	pub fn from_checked(vote: IndirectSignedApprovalVoteV2) -> Self {
1286		Self(vote)
1287	}
1288}
1289
1290/// Message to the Approval Voting subsystem.
1291#[derive(Debug)]
1292pub enum ApprovalVotingMessage {
1293	/// Import an assignment into the approval-voting database.
1294	///
1295	/// Should not be sent unless the block hash is known and the VRF assignment checks out.
1296	ImportAssignment(CheckedIndirectAssignment, Option<oneshot::Sender<AssignmentCheckResult>>),
1297	/// Import an approval vote into approval-voting database
1298	///
1299	/// Should not be sent unless the block hash within the indirect vote is known, vote is
1300	/// correctly signed and we had a previous assignment for the candidate.
1301	ImportApproval(CheckedIndirectSignedApprovalVote, Option<oneshot::Sender<ApprovalCheckResult>>),
1302	/// Returns the highest possible ancestor hash of the provided block hash which is
1303	/// acceptable to vote on finality for.
1304	/// The `BlockNumber` provided is the number of the block's ancestor which is the
1305	/// earliest possible vote.
1306	///
1307	/// It can also return the same block hash, if that is acceptable to vote upon.
1308	/// Return `None` if the input hash is unrecognized.
1309	ApprovedAncestor(Hash, BlockNumber, oneshot::Sender<Option<HighestApprovedAncestorBlock>>),
1310
1311	/// Retrieve all available approval signatures for a candidate from approval-voting.
1312	///
1313	/// This message involves a linear search for candidates on each relay chain fork and also
1314	/// requires calling into `approval-distribution`: Calls should be infrequent and bounded.
1315	GetApprovalSignaturesForCandidate(
1316		CandidateHash,
1317		oneshot::Sender<
1318			HashMap<ValidatorIndex, (CoalescedApprovalCandidateHashes, ValidatorSignature)>,
1319		>,
1320	),
1321}
1322
1323/// Message to the Approval Distribution subsystem.
1324#[derive(Debug, derive_more::From)]
1325pub enum ApprovalDistributionMessage {
1326	/// Notify the `ApprovalDistribution` subsystem about new blocks
1327	/// and the candidates contained within them.
1328	NewBlocks(Vec<BlockApprovalMeta>),
1329	/// Distribute an assignment cert from the local validator. The cert is assumed
1330	/// to be valid, relevant, and for the given relay-parent and validator index.
1331	DistributeAssignment(IndirectAssignmentCertV2, CandidateBitfield),
1332	/// Distribute an approval vote for the local validator. The approval vote is assumed to be
1333	/// valid, relevant, and the corresponding approval already issued.
1334	/// If not, the subsystem is free to drop the message.
1335	DistributeApproval(IndirectSignedApprovalVoteV2),
1336	/// An update from the network bridge.
1337	#[from]
1338	NetworkBridgeUpdate(NetworkBridgeEvent<net_protocol::ApprovalDistributionMessage>),
1339
1340	/// Get all approval signatures for all chains a candidate appeared in.
1341	GetApprovalSignatures(
1342		HashSet<(Hash, CandidateIndex)>,
1343		oneshot::Sender<HashMap<ValidatorIndex, (Hash, Vec<CandidateIndex>, ValidatorSignature)>>,
1344	),
1345	/// Approval checking lag update measured in blocks.
1346	ApprovalCheckingLagUpdate(BlockNumber),
1347}
1348
1349/// Message to the Gossip Support subsystem.
1350#[derive(Debug, derive_more::From)]
1351pub enum GossipSupportMessage {
1352	/// Dummy constructor, so we can receive networking events.
1353	#[from]
1354	NetworkBridgeUpdate(NetworkBridgeEvent<net_protocol::GossipSupportNetworkMessage>),
1355}
1356
1357/// Request introduction of a seconded candidate into the prospective parachains subsystem.
1358#[derive(Debug, PartialEq, Eq, Clone)]
1359pub struct IntroduceSecondedCandidateRequest {
1360	/// The para-id of the candidate.
1361	pub candidate_para: ParaId,
1362	/// The candidate receipt itself.
1363	pub candidate_receipt: CommittedCandidateReceipt,
1364	/// The persisted validation data of the candidate.
1365	pub persisted_validation_data: PersistedValidationData,
1366}
1367
1368/// A hypothetical candidate to be evaluated for potential/actual membership
1369/// in the prospective parachains subsystem.
1370///
1371/// Hypothetical candidates are either complete or incomplete.
1372/// Complete candidates have already had their (potentially heavy)
1373/// candidate receipt fetched, while incomplete candidates are simply
1374/// claims about properties that a fetched candidate would have.
1375///
1376/// Complete candidates can be evaluated more strictly than incomplete candidates.
1377#[derive(Debug, PartialEq, Eq, Clone)]
1378pub enum HypotheticalCandidate {
1379	/// A complete candidate.
1380	Complete {
1381		/// The hash of the candidate.
1382		candidate_hash: CandidateHash,
1383		/// The receipt of the candidate.
1384		receipt: Arc<CommittedCandidateReceipt>,
1385		/// The persisted validation data of the candidate.
1386		persisted_validation_data: PersistedValidationData,
1387	},
1388	/// An incomplete candidate.
1389	Incomplete {
1390		/// The claimed hash of the candidate.
1391		candidate_hash: CandidateHash,
1392		/// The claimed para-ID of the candidate.
1393		candidate_para: ParaId,
1394		/// The claimed head-data hash of the candidate.
1395		parent_head_data_hash: Hash,
1396		/// The claimed scheduling parent of the candidate.
1397		candidate_scheduling_parent: Hash,
1398	},
1399}
1400
1401impl HypotheticalCandidate {
1402	/// Get the `CandidateHash` of the hypothetical candidate.
1403	pub fn candidate_hash(&self) -> CandidateHash {
1404		match *self {
1405			HypotheticalCandidate::Complete { candidate_hash, .. } => candidate_hash,
1406			HypotheticalCandidate::Incomplete { candidate_hash, .. } => candidate_hash,
1407		}
1408	}
1409
1410	/// Get the `ParaId` of the hypothetical candidate.
1411	pub fn candidate_para(&self) -> ParaId {
1412		match *self {
1413			HypotheticalCandidate::Complete { ref receipt, .. } => receipt.descriptor.para_id(),
1414			HypotheticalCandidate::Incomplete { candidate_para, .. } => candidate_para,
1415		}
1416	}
1417
1418	/// Get parent head data hash of the hypothetical candidate.
1419	pub fn parent_head_data_hash(&self) -> Hash {
1420		match *self {
1421			HypotheticalCandidate::Complete { ref persisted_validation_data, .. } => {
1422				persisted_validation_data.parent_head.hash()
1423			},
1424			HypotheticalCandidate::Incomplete { parent_head_data_hash, .. } => {
1425				parent_head_data_hash
1426			},
1427		}
1428	}
1429
1430	/// Get candidate's scheduling parent.
1431	///
1432	/// For `Complete` candidates, this is the scheduling parent from the descriptor
1433	/// (which equals relay_parent for V1/V2 descriptors).
1434	/// For `Incomplete` candidates, this is the claimed scheduling parent.
1435	pub fn scheduling_parent(&self) -> Hash {
1436		match *self {
1437			HypotheticalCandidate::Complete { ref receipt, .. } => {
1438				receipt.descriptor.scheduling_parent()
1439			},
1440			HypotheticalCandidate::Incomplete { candidate_scheduling_parent, .. } => {
1441				candidate_scheduling_parent
1442			},
1443		}
1444	}
1445
1446	/// Get the output head data hash, if the candidate is complete.
1447	pub fn output_head_data_hash(&self) -> Option<Hash> {
1448		match *self {
1449			HypotheticalCandidate::Complete { ref receipt, .. } => {
1450				Some(receipt.descriptor.para_head())
1451			},
1452			HypotheticalCandidate::Incomplete { .. } => None,
1453		}
1454	}
1455
1456	/// Get the candidate commitments, if the candidate is complete.
1457	pub fn commitments(&self) -> Option<&CandidateCommitments> {
1458		match *self {
1459			HypotheticalCandidate::Complete { ref receipt, .. } => Some(&receipt.commitments),
1460			HypotheticalCandidate::Incomplete { .. } => None,
1461		}
1462	}
1463
1464	/// Get the persisted validation data, if the candidate is complete.
1465	pub fn persisted_validation_data(&self) -> Option<&PersistedValidationData> {
1466		match *self {
1467			HypotheticalCandidate::Complete { ref persisted_validation_data, .. } => {
1468				Some(persisted_validation_data)
1469			},
1470			HypotheticalCandidate::Incomplete { .. } => None,
1471		}
1472	}
1473
1474	/// Get the validation code hash, if the candidate is complete.
1475	pub fn validation_code_hash(&self) -> Option<ValidationCodeHash> {
1476		match *self {
1477			HypotheticalCandidate::Complete { ref receipt, .. } => {
1478				Some(receipt.descriptor.validation_code_hash())
1479			},
1480			HypotheticalCandidate::Incomplete { .. } => None,
1481		}
1482	}
1483}
1484
1485/// Request specifying which candidates are either already included
1486/// or might become included in fragment chain under a given active leaf (or any active leaf if
1487/// `fragment_chain_relay_parent` is `None`).
1488#[derive(Debug, PartialEq, Eq, Clone)]
1489pub struct HypotheticalMembershipRequest {
1490	/// Candidates, in arbitrary order, which should be checked for
1491	/// hypothetical/actual membership in fragment chains.
1492	pub candidates: Vec<HypotheticalCandidate>,
1493	/// Either a specific fragment chain to check, otherwise all.
1494	pub fragment_chain_relay_parent: Option<Hash>,
1495}
1496
1497/// A request for the persisted validation data stored in the prospective
1498/// parachains subsystem.
1499#[derive(Debug)]
1500pub struct ProspectiveValidationDataRequest {
1501	/// The para-id of the candidate.
1502	pub para_id: ParaId,
1503	/// The relay-parent of the candidate.
1504	pub candidate_relay_parent: Hash,
1505	/// The session index of the candidate's relay parent
1506	pub session_index: SessionIndex,
1507	/// The parent head-data.
1508	pub parent_head_data: ParentHeadData,
1509}
1510
1511/// The parent head-data hash with optional data itself.
1512#[derive(Debug, Clone)]
1513pub enum ParentHeadData {
1514	/// Parent head-data hash.
1515	OnlyHash(Hash),
1516	/// Parent head-data along with its hash.
1517	WithData {
1518		/// This will be provided for collations with elastic scaling enabled.
1519		head_data: HeadData,
1520		/// Parent head-data hash.
1521		hash: Hash,
1522	},
1523}
1524
1525impl ParentHeadData {
1526	/// Return the hash of the parent head-data.
1527	pub fn hash(&self) -> Hash {
1528		match self {
1529			ParentHeadData::OnlyHash(hash) => *hash,
1530			ParentHeadData::WithData { hash, .. } => *hash,
1531		}
1532	}
1533}
1534
1535/// Indicates the relay-parents whose fragment chain a candidate
1536/// is present in or can be added in (right now or in the future).
1537pub type HypotheticalMembership = Vec<Hash>;
1538
1539/// A collection of ancestor candidates of a parachain.
1540pub type Ancestors = HashSet<CandidateHash>;
1541
1542/// Messages sent to the Prospective Parachains subsystem.
1543#[derive(Debug)]
1544pub enum ProspectiveParachainsMessage {
1545	/// Inform the Prospective Parachains Subsystem of a new seconded candidate.
1546	///
1547	/// The response sender returns false if the candidate was rejected by prospective parachains,
1548	/// true otherwise (if it was accepted or already present)
1549	IntroduceSecondedCandidate(IntroduceSecondedCandidateRequest, oneshot::Sender<bool>),
1550	/// Inform the Prospective Parachains Subsystem that a previously introduced candidate
1551	/// has been backed. This requires that the candidate was successfully introduced in
1552	/// the past.
1553	CandidateBacked(ParaId, CandidateHash),
1554	/// Get N backable candidate references with their scheduling parents for the given
1555	/// parachain, under the given relay chain leaf hash.
1556	///
1557	/// Timed out ancestors should not be included in the collection.
1558	/// N should represent the number of scheduled cores of this ParaId.
1559	/// A timed out ancestor frees the cores of all of its descendants, so if there's a hole in the
1560	/// supplied ancestor path, we'll get candidates that backfill those timed out slots first. It
1561	/// may also return less/no candidates, if there aren't enough backable candidates recorded.
1562	GetBackableCandidates {
1563		/// The relay chain leaf hash under which to query. Must be an active leaf.
1564		leaf: Hash,
1565		/// The parachain to get backable candidates for.
1566		para_id: ParaId,
1567		/// The maximum number of candidates to return.
1568		count: u32,
1569		/// Required ancestor path for the candidates.
1570		ancestors: Ancestors,
1571		/// Channel to send the result.
1572		sender: oneshot::Sender<Vec<BackableCandidateRef>>,
1573	},
1574	/// Get the hypothetical or actual membership of candidates with the given properties
1575	/// under the specified active leave's fragment chain.
1576	///
1577	/// For each candidate, we return a vector of leaves where the candidate is present or could be
1578	/// added. "Could be added" either means that the candidate can be added to the chain right now
1579	/// or could be added in the future (we may not have its ancestors yet).
1580	/// Note that even if we think it could be added in the future, we may find out that it was
1581	/// invalid, as time passes.
1582	/// If an active leaf is not in the vector, it means that there's no
1583	/// chance this candidate will become valid under that leaf in the future.
1584	///
1585	/// If `fragment_chain_relay_parent` in the request is `Some()`, the return vector can only
1586	/// contain this relay parent (or none).
1587	GetHypotheticalMembership(
1588		HypotheticalMembershipRequest,
1589		oneshot::Sender<Vec<(HypotheticalCandidate, HypotheticalMembership)>>,
1590	),
1591	/// Get the validation data of some prospective candidate. The candidate doesn't need
1592	/// to be part of any fragment chain, but this only succeeds if the parent head-data and
1593	/// relay-parent are part of the `CandidateStorage` (meaning that it's a candidate which is
1594	/// part of some fragment chain or which prospective-parachains predicted will become part of
1595	/// some fragment chain).
1596	GetProspectiveValidationData(
1597		ProspectiveValidationDataRequest,
1598		oneshot::Sender<Option<PersistedValidationData>>,
1599	),
1600}