referrerpolicy=no-referrer-when-downgrade

polkadot_statement_distribution/
error.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
18//! Error handling related code and Error/Result definitions.
19
20use polkadot_node_network_protocol::PeerId;
21use polkadot_node_subsystem::{RuntimeApiError, SubsystemError};
22use polkadot_node_subsystem_util::{
23	backing_implicit_view::FetchError as ImplicitViewFetchError, runtime,
24};
25use polkadot_primitives::{CandidateHash, Hash, Id as ParaId};
26
27use futures::channel::oneshot;
28
29/// General result.
30pub type Result<T> = std::result::Result<T, Error>;
31/// Result for non-fatal only failures.
32pub type JfyiErrorResult<T> = std::result::Result<T, JfyiError>;
33/// Result for fatal only failures.
34pub type FatalResult<T> = std::result::Result<T, FatalError>;
35
36#[allow(missing_docs)]
37#[fatality::fatality(splitable)]
38pub enum Error {
39	#[fatal]
40	#[error("Requester receiver stream finished")]
41	RequesterReceiverFinished,
42
43	#[fatal]
44	#[error("Responder receiver stream finished")]
45	ResponderReceiverFinished,
46
47	#[fatal]
48	#[error("Spawning subsystem task failed")]
49	SpawnTask(#[source] SubsystemError),
50
51	#[fatal]
52	#[error("Receiving message from overseer failed")]
53	SubsystemReceive(#[source] SubsystemError),
54
55	#[fatal(forward)]
56	#[error("Error while accessing runtime information")]
57	Runtime(#[from] runtime::Error),
58
59	#[error("RuntimeAPISubsystem channel closed before receipt")]
60	RuntimeApiUnavailable(#[source] oneshot::Canceled),
61
62	#[error("Fetching persisted validation data for para {0:?}, {1:?}")]
63	FetchPersistedValidationData(ParaId, RuntimeApiError),
64
65	#[error("Fetching session index failed {0:?}")]
66	FetchSessionIndex(RuntimeApiError),
67
68	#[error("Fetching session info failed {0:?}")]
69	FetchSessionInfo(RuntimeApiError),
70
71	#[error("Fetching disabled validators failed {0:?}")]
72	FetchDisabledValidators(RuntimeApiError),
73
74	#[error("Fetching validator groups failed {0:?}")]
75	FetchValidatorGroups(RuntimeApiError),
76
77	#[error("Fetching claim queue failed {0:?}")]
78	FetchClaimQueue(RuntimeApiError),
79
80	#[error("Fetching minimum backing votes failed {0:?}")]
81	FetchMinimumBackingVotes(RuntimeApiError),
82
83	#[error("Fetching node features failed {0:?}")]
84	FetchNodeFeatures(RuntimeApiError),
85
86	#[error("Attempted to share statement when not a validator or not assigned")]
87	InvalidShare,
88
89	#[error("Relay parent could not be found in active heads")]
90	NoSuchHead(Hash),
91
92	#[error("Message from not connected peer")]
93	NoSuchPeer(PeerId),
94
95	#[error("Peer requested data for candidate it never received a notification for (malicious?)")]
96	RequestedUnannouncedCandidate(PeerId, CandidateHash),
97
98	// A large statement status was requested, which could not be found.
99	#[error("Statement status does not exist")]
100	NoSuchLargeStatementStatus(Hash, CandidateHash),
101
102	// A fetched large statement was requested, but could not be found.
103	#[error("Fetched large statement does not exist")]
104	NoSuchFetchedLargeStatement(Hash, CandidateHash),
105
106	// Responder no longer waits for our data. (Should not happen right now.)
107	#[error("Oneshot `GetData` channel closed")]
108	ResponderGetDataCanceled,
109
110	// Failed to activate leaf due to a fetch error.
111	#[error("Implicit view failure while activating leaf")]
112	ActivateLeafFailure(ImplicitViewFetchError),
113}