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

Commit 397ce89

Browse files
andresilvagpestana
authored andcommitted
sp-consensus: remove unused error variants (#13495)
1 parent 8d78bee commit 397ce89

File tree

4 files changed

+15
-65
lines changed

4 files changed

+15
-65
lines changed

Cargo.lock

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/consensus/pow/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ where
331331
.select_chain
332332
.best_chain()
333333
.await
334-
.map_err(|e| format!("Fetch best chain failed via select chain: {}", e))?;
334+
.map_err(|e| format!("Fetch best chain failed via select chain: {}", e))
335+
.map_err(ConsensusError::ChainLookup)?;
335336
let best_hash = best_header.hash();
336337

337338
let parent_hash = *block.header.parent_hash();

primitives/consensus/common/Cargo.toml

-5
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,13 @@ targets = ["x86_64-unknown-linux-gnu"]
1515

1616
[dependencies]
1717
async-trait = "0.1.57"
18-
codec = { package = "parity-scale-codec", version = "3.2.2", features = [
19-
"derive",
20-
] }
2118
futures = { version = "0.3.21", features = ["thread-pool"] }
2219
log = "0.4.17"
2320
thiserror = "1.0.30"
2421
sp-core = { version = "7.0.0", path = "../../core" }
2522
sp-inherents = { version = "4.0.0-dev", path = "../../inherents" }
2623
sp-runtime = { version = "7.0.0", path = "../../runtime" }
2724
sp-state-machine = { version = "0.13.0", path = "../../state-machine" }
28-
sp-std = { version = "5.0.0", path = "../../std" }
29-
sp-version = { version = "5.0.0", path = "../../version" }
3025

3126
[dev-dependencies]
3227
futures = "0.3.21"

primitives/consensus/common/src/error.rs

+13-56
Original file line numberDiff line numberDiff line change
@@ -15,85 +15,42 @@
1515
// See the License for the specific language governing permissions and
1616
// limitations under the License.
1717

18-
//! Error types in Consensus
19-
use sp_core::ed25519::Public;
20-
use sp_version::RuntimeVersion;
21-
use std::error;
18+
//! Error types for consensus modules.
2219
2320
/// Result type alias.
2421
pub type Result<T> = std::result::Result<T, Error>;
2522

26-
/// Error type.
23+
/// The error type for consensus-related operations.
2724
#[derive(Debug, thiserror::Error)]
28-
#[non_exhaustive]
2925
pub enum Error {
3026
/// Missing state at block with given descriptor.
3127
#[error("State unavailable at block {0}")]
3228
StateUnavailable(String),
33-
/// I/O terminated unexpectedly
34-
#[error("I/O terminated unexpectedly.")]
35-
IoTerminated,
3629
/// Intermediate missing.
37-
#[error("Missing intermediate.")]
30+
#[error("Missing intermediate")]
3831
NoIntermediate,
3932
/// Intermediate is of wrong type.
40-
#[error("Invalid intermediate.")]
33+
#[error("Invalid intermediate")]
4134
InvalidIntermediate,
42-
/// Unable to schedule wake-up.
43-
#[error("Timer error: {0}")]
44-
FaultyTimer(#[from] std::io::Error),
45-
/// Error while working with inherent data.
46-
#[error("InherentData error: {0}")]
47-
InherentData(#[from] sp_inherents::Error),
48-
/// Unable to propose a block.
49-
#[error("Unable to create block proposal.")]
50-
CannotPropose,
51-
/// Error checking signature
52-
#[error("Message signature {0:?} by {1:?} is invalid.")]
35+
/// Error checking signature.
36+
#[error("Message signature {0:?} by {1:?} is invalid")]
5337
InvalidSignature(Vec<u8>, Vec<u8>),
5438
/// Invalid authorities set received from the runtime.
5539
#[error("Current state of blockchain has invalid authorities set")]
5640
InvalidAuthoritiesSet,
57-
/// Account is not an authority.
58-
#[error("Message sender {0:?} is not a valid authority")]
59-
InvalidAuthority(Public),
60-
/// Authoring interface does not match the runtime.
61-
#[error(
62-
"Authoring for current \
63-
runtime is not supported. Native ({native}) cannot author for on-chain ({on_chain})."
64-
)]
65-
IncompatibleAuthoringRuntime { native: RuntimeVersion, on_chain: RuntimeVersion },
66-
/// Authoring interface does not match the runtime.
67-
#[error("Authoring for current runtime is not supported since it has no version.")]
68-
RuntimeVersionMissing,
69-
/// Authoring interface does not match the runtime.
70-
#[error("Authoring in current build is not supported since it has no runtime.")]
71-
NativeRuntimeMissing,
7241
/// Justification requirements not met.
73-
#[error("Invalid justification.")]
42+
#[error("Invalid justification")]
7443
InvalidJustification,
75-
/// Some other error.
76-
#[error(transparent)]
77-
Other(#[from] Box<dyn error::Error + Sync + Send + 'static>),
78-
/// Error from the client while importing
44+
/// Error from the client while importing.
7945
#[error("Import failed: {0}")]
8046
ClientImport(String),
81-
/// Error from the client while importing
47+
/// Error from the client while fetching some data from the chain.
8248
#[error("Chain lookup failed: {0}")]
8349
ChainLookup(String),
84-
/// Signing failed
50+
/// Signing failed.
8551
#[error("Failed to sign using key: {0:?}. Reason: {1}")]
8652
CannotSign(Vec<u8>, String),
87-
}
88-
89-
impl From<Public> for Error {
90-
fn from(p: Public) -> Self {
91-
Self::InvalidAuthority(p)
92-
}
93-
}
94-
95-
impl From<String> for Error {
96-
fn from(s: String) -> Self {
97-
Self::StateUnavailable(s)
98-
}
53+
/// Some other error.
54+
#[error(transparent)]
55+
Other(#[from] Box<dyn std::error::Error + Sync + Send + 'static>),
9956
}

0 commit comments

Comments
 (0)