mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-24 18:21:08 +00:00
use thiserror instead of derive_more for error handling (#10696)
* use thiserror instead of derive_more for error handling Signed-off-by: koushiro <koushiro.cqx@gmail.com> * Update utils/prometheus/src/lib.rs * Update utils/prometheus/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Generated
+13
-17
@@ -520,7 +520,6 @@ version = "4.0.0-dev"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"beefy-gadget",
|
"beefy-gadget",
|
||||||
"beefy-primitives",
|
"beefy-primitives",
|
||||||
"derive_more",
|
|
||||||
"futures 0.3.16",
|
"futures 0.3.16",
|
||||||
"jsonrpc-core",
|
"jsonrpc-core",
|
||||||
"jsonrpc-core-client",
|
"jsonrpc-core-client",
|
||||||
@@ -4710,7 +4709,6 @@ name = "node-inspect"
|
|||||||
version = "0.9.0-dev"
|
version = "0.9.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap 3.0.7",
|
"clap 3.0.7",
|
||||||
"derive_more",
|
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"sc-cli",
|
"sc-cli",
|
||||||
"sc-client-api",
|
"sc-client-api",
|
||||||
@@ -4719,6 +4717,7 @@ dependencies = [
|
|||||||
"sp-blockchain",
|
"sp-blockchain",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
"sp-runtime",
|
"sp-runtime",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -7647,7 +7646,6 @@ name = "sc-authority-discovery"
|
|||||||
version = "0.10.0-dev"
|
version = "0.10.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"derive_more",
|
|
||||||
"futures 0.3.16",
|
"futures 0.3.16",
|
||||||
"futures-timer",
|
"futures-timer",
|
||||||
"ip_network",
|
"ip_network",
|
||||||
@@ -7669,6 +7667,7 @@ dependencies = [
|
|||||||
"sp-tracing",
|
"sp-tracing",
|
||||||
"substrate-prometheus-endpoint",
|
"substrate-prometheus-endpoint",
|
||||||
"substrate-test-runtime-client",
|
"substrate-test-runtime-client",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -7863,7 +7862,6 @@ name = "sc-consensus-aura"
|
|||||||
version = "0.10.0-dev"
|
version = "0.10.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"derive_more",
|
|
||||||
"futures 0.3.16",
|
"futures 0.3.16",
|
||||||
"getrandom 0.2.3",
|
"getrandom 0.2.3",
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
@@ -7894,6 +7892,7 @@ dependencies = [
|
|||||||
"substrate-prometheus-endpoint",
|
"substrate-prometheus-endpoint",
|
||||||
"substrate-test-runtime-client",
|
"substrate-test-runtime-client",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -7901,7 +7900,6 @@ name = "sc-consensus-babe"
|
|||||||
version = "0.10.0-dev"
|
version = "0.10.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"derive_more",
|
|
||||||
"fork-tree",
|
"fork-tree",
|
||||||
"futures 0.3.16",
|
"futures 0.3.16",
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
@@ -7944,13 +7942,13 @@ dependencies = [
|
|||||||
"substrate-prometheus-endpoint",
|
"substrate-prometheus-endpoint",
|
||||||
"substrate-test-runtime-client",
|
"substrate-test-runtime-client",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sc-consensus-babe-rpc"
|
name = "sc-consensus-babe-rpc"
|
||||||
version = "0.10.0-dev"
|
version = "0.10.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_more",
|
|
||||||
"futures 0.3.16",
|
"futures 0.3.16",
|
||||||
"jsonrpc-core",
|
"jsonrpc-core",
|
||||||
"jsonrpc-core-client",
|
"jsonrpc-core-client",
|
||||||
@@ -7973,6 +7971,7 @@ dependencies = [
|
|||||||
"sp-runtime",
|
"sp-runtime",
|
||||||
"substrate-test-runtime-client",
|
"substrate-test-runtime-client",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -7993,7 +7992,6 @@ version = "0.10.0-dev"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"assert_matches",
|
"assert_matches",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"derive_more",
|
|
||||||
"futures 0.3.16",
|
"futures 0.3.16",
|
||||||
"jsonrpc-core",
|
"jsonrpc-core",
|
||||||
"jsonrpc-core-client",
|
"jsonrpc-core-client",
|
||||||
@@ -8023,6 +8021,7 @@ dependencies = [
|
|||||||
"substrate-prometheus-endpoint",
|
"substrate-prometheus-endpoint",
|
||||||
"substrate-test-runtime-client",
|
"substrate-test-runtime-client",
|
||||||
"substrate-test-runtime-transaction-pool",
|
"substrate-test-runtime-transaction-pool",
|
||||||
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -8031,7 +8030,6 @@ name = "sc-consensus-pow"
|
|||||||
version = "0.10.0-dev"
|
version = "0.10.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"derive_more",
|
|
||||||
"futures 0.3.16",
|
"futures 0.3.16",
|
||||||
"futures-timer",
|
"futures-timer",
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
@@ -8048,6 +8046,7 @@ dependencies = [
|
|||||||
"sp-inherents",
|
"sp-inherents",
|
||||||
"sp-runtime",
|
"sp-runtime",
|
||||||
"substrate-prometheus-endpoint",
|
"substrate-prometheus-endpoint",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -8128,7 +8127,6 @@ dependencies = [
|
|||||||
name = "sc-executor-common"
|
name = "sc-executor-common"
|
||||||
version = "0.10.0-dev"
|
version = "0.10.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_more",
|
|
||||||
"environmental",
|
"environmental",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"sc-allocator",
|
"sc-allocator",
|
||||||
@@ -8184,7 +8182,6 @@ version = "0.10.0-dev"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"assert_matches",
|
"assert_matches",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"derive_more",
|
|
||||||
"dyn-clone",
|
"dyn-clone",
|
||||||
"finality-grandpa",
|
"finality-grandpa",
|
||||||
"fork-tree",
|
"fork-tree",
|
||||||
@@ -8219,6 +8216,7 @@ dependencies = [
|
|||||||
"substrate-prometheus-endpoint",
|
"substrate-prometheus-endpoint",
|
||||||
"substrate-test-runtime-client",
|
"substrate-test-runtime-client",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -8226,7 +8224,6 @@ dependencies = [
|
|||||||
name = "sc-finality-grandpa-rpc"
|
name = "sc-finality-grandpa-rpc"
|
||||||
version = "0.10.0-dev"
|
version = "0.10.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_more",
|
|
||||||
"finality-grandpa",
|
"finality-grandpa",
|
||||||
"futures 0.3.16",
|
"futures 0.3.16",
|
||||||
"jsonrpc-core",
|
"jsonrpc-core",
|
||||||
@@ -8247,6 +8244,7 @@ dependencies = [
|
|||||||
"sp-keyring",
|
"sp-keyring",
|
||||||
"sp-runtime",
|
"sp-runtime",
|
||||||
"substrate-test-runtime-client",
|
"substrate-test-runtime-client",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -8270,7 +8268,6 @@ name = "sc-keystore"
|
|||||||
version = "4.0.0-dev"
|
version = "4.0.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"derive_more",
|
|
||||||
"hex",
|
"hex",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.11.2",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -8278,6 +8275,7 @@ dependencies = [
|
|||||||
"sp-core",
|
"sp-core",
|
||||||
"sp-keystore",
|
"sp-keystore",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -8291,7 +8289,6 @@ dependencies = [
|
|||||||
"bitflags",
|
"bitflags",
|
||||||
"bytes 1.1.0",
|
"bytes 1.1.0",
|
||||||
"cid",
|
"cid",
|
||||||
"derive_more",
|
|
||||||
"either",
|
"either",
|
||||||
"fnv",
|
"fnv",
|
||||||
"fork-tree",
|
"fork-tree",
|
||||||
@@ -8762,7 +8759,6 @@ dependencies = [
|
|||||||
name = "sc-transaction-pool-api"
|
name = "sc-transaction-pool-api"
|
||||||
version = "4.0.0-dev"
|
version = "4.0.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_more",
|
|
||||||
"futures 0.3.16",
|
"futures 0.3.16",
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -9632,7 +9628,6 @@ name = "sp-keystore"
|
|||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"derive_more",
|
|
||||||
"futures 0.3.16",
|
"futures 0.3.16",
|
||||||
"merlin",
|
"merlin",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
@@ -9643,6 +9638,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
"sp-externalities",
|
"sp-externalities",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -10211,11 +10207,11 @@ name = "substrate-prometheus-endpoint"
|
|||||||
version = "0.10.0-dev"
|
version = "0.10.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"derive_more",
|
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hyper 0.14.16",
|
"hyper 0.14.16",
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
"prometheus",
|
"prometheus",
|
||||||
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -10312,7 +10308,6 @@ dependencies = [
|
|||||||
name = "substrate-test-runtime-transaction-pool"
|
name = "substrate-test-runtime-transaction-pool"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_more",
|
|
||||||
"futures 0.3.16",
|
"futures 0.3.16",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.11.2",
|
||||||
@@ -10321,6 +10316,7 @@ dependencies = [
|
|||||||
"sp-blockchain",
|
"sp-blockchain",
|
||||||
"sp-runtime",
|
"sp-runtime",
|
||||||
"substrate-test-runtime-client",
|
"substrate-test-runtime-client",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "3.0", features = ["derive"] }
|
clap = { version = "3.0", features = ["derive"] }
|
||||||
codec = { package = "parity-scale-codec", version = "2.0.0" }
|
codec = { package = "parity-scale-codec", version = "2.0.0" }
|
||||||
derive_more = "0.99"
|
thiserror = "1.0"
|
||||||
sc-cli = { version = "0.10.0-dev", path = "../../../client/cli" }
|
sc-cli = { version = "0.10.0-dev", path = "../../../client/cli" }
|
||||||
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
|
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
|
||||||
sc-executor = { version = "0.10.0-dev", path = "../../../client/executor" }
|
sc-executor = { version = "0.10.0-dev", path = "../../../client/executor" }
|
||||||
|
|||||||
@@ -78,26 +78,19 @@ impl<TBlock: Block> PrettyPrinter<TBlock> for DebugPrinter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Aggregated error for `Inspector` operations.
|
/// Aggregated error for `Inspector` operations.
|
||||||
#[derive(Debug, derive_more::From, derive_more::Display)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Could not decode Block or Extrinsic.
|
/// Could not decode Block or Extrinsic.
|
||||||
Codec(codec::Error),
|
#[error(transparent)]
|
||||||
|
Codec(#[from] codec::Error),
|
||||||
/// Error accessing blockchain DB.
|
/// Error accessing blockchain DB.
|
||||||
Blockchain(sp_blockchain::Error),
|
#[error(transparent)]
|
||||||
|
Blockchain(#[from] sp_blockchain::Error),
|
||||||
/// Given block has not been found.
|
/// Given block has not been found.
|
||||||
|
#[error("{0}")]
|
||||||
NotFound(String),
|
NotFound(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for Error {
|
|
||||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
|
||||||
match *self {
|
|
||||||
Self::Codec(ref e) => Some(e),
|
|
||||||
Self::Blockchain(ref e) => Some(e),
|
|
||||||
Self::NotFound(_) => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A helper trait to access block headers and bodies.
|
/// A helper trait to access block headers and bodies.
|
||||||
pub trait ChainAccess<TBlock: Block>: HeaderBackend<TBlock> + BlockBackend<TBlock> {}
|
pub trait ChainAccess<TBlock: Block>: HeaderBackend<TBlock> + BlockBackend<TBlock> {}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ prost-build = "0.9"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
codec = { package = "parity-scale-codec", default-features = false, version = "2.0.0" }
|
codec = { package = "parity-scale-codec", default-features = false, version = "2.0.0" }
|
||||||
derive_more = "0.99.16"
|
thiserror = "1.0"
|
||||||
futures = "0.3.9"
|
futures = "0.3.9"
|
||||||
futures-timer = "3.0.1"
|
futures-timer = "3.0.1"
|
||||||
ip_network = "0.4.1"
|
ip_network = "0.4.1"
|
||||||
|
|||||||
@@ -24,40 +24,56 @@ use sp_core::crypto::CryptoTypePublicPair;
|
|||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
/// Error type for the authority discovery module.
|
/// Error type for the authority discovery module.
|
||||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Received dht value found event with records with different keys.
|
#[error("Received dht value found event with records with different keys.")]
|
||||||
ReceivingDhtValueFoundEventWithDifferentKeys,
|
ReceivingDhtValueFoundEventWithDifferentKeys,
|
||||||
/// Received dht value found event with no records.
|
|
||||||
|
#[error("Received dht value found event with no records.")]
|
||||||
ReceivingDhtValueFoundEventWithNoRecords,
|
ReceivingDhtValueFoundEventWithNoRecords,
|
||||||
/// Failed to verify a dht payload with the given signature.
|
|
||||||
|
#[error("Failed to verify a dht payload with the given signature.")]
|
||||||
VerifyingDhtPayload,
|
VerifyingDhtPayload,
|
||||||
/// Failed to hash the authority id to be used as a dht key.
|
|
||||||
HashingAuthorityId(libp2p::core::multiaddr::multihash::Error),
|
#[error("Failed to hash the authority id to be used as a dht key.")]
|
||||||
/// Failed calling into the Substrate runtime.
|
HashingAuthorityId(#[from] libp2p::core::multiaddr::multihash::Error),
|
||||||
CallingRuntime(sp_blockchain::Error),
|
|
||||||
/// Received a dht record with a key that does not match any in-flight awaited keys.
|
#[error("Failed calling into the Substrate runtime.")]
|
||||||
|
CallingRuntime(#[from] sp_blockchain::Error),
|
||||||
|
|
||||||
|
#[error("Received a dht record with a key that does not match any in-flight awaited keys.")]
|
||||||
ReceivingUnexpectedRecord,
|
ReceivingUnexpectedRecord,
|
||||||
/// Failed to encode a protobuf payload.
|
|
||||||
EncodingProto(prost::EncodeError),
|
#[error("Failed to encode a protobuf payload.")]
|
||||||
/// Failed to decode a protobuf payload.
|
EncodingProto(#[from] prost::EncodeError),
|
||||||
DecodingProto(prost::DecodeError),
|
|
||||||
/// Failed to encode or decode scale payload.
|
#[error("Failed to decode a protobuf payload.")]
|
||||||
EncodingDecodingScale(codec::Error),
|
DecodingProto(#[from] prost::DecodeError),
|
||||||
/// Failed to parse a libp2p multi address.
|
|
||||||
ParsingMultiaddress(libp2p::core::multiaddr::Error),
|
#[error("Failed to encode or decode scale payload.")]
|
||||||
/// Failed to parse a libp2p key.
|
EncodingDecodingScale(#[from] codec::Error),
|
||||||
ParsingLibp2pIdentity(sc_network::DecodingError),
|
|
||||||
/// Failed to sign using a specific public key.
|
#[error("Failed to parse a libp2p multi address.")]
|
||||||
|
ParsingMultiaddress(#[from] libp2p::core::multiaddr::Error),
|
||||||
|
|
||||||
|
#[error("Failed to parse a libp2p key.")]
|
||||||
|
ParsingLibp2pIdentity(#[from] sc_network::DecodingError),
|
||||||
|
|
||||||
|
#[error("Failed to sign using a specific public key.")]
|
||||||
MissingSignature(CryptoTypePublicPair),
|
MissingSignature(CryptoTypePublicPair),
|
||||||
/// Failed to sign using all public keys.
|
|
||||||
|
#[error("Failed to sign using all public keys.")]
|
||||||
Signing,
|
Signing,
|
||||||
/// Failed to register Prometheus metric.
|
|
||||||
Prometheus(prometheus_endpoint::PrometheusError),
|
#[error("Failed to register Prometheus metric.")]
|
||||||
/// Received authority record that contains addresses with multiple peer ids
|
Prometheus(#[from] prometheus_endpoint::PrometheusError),
|
||||||
|
|
||||||
|
#[error("Received authority record that contains addresses with multiple peer ids")]
|
||||||
ReceivingDhtValueFoundEventWithDifferentPeerIds,
|
ReceivingDhtValueFoundEventWithDifferentPeerIds,
|
||||||
/// Received authority record without any addresses having a peer id
|
|
||||||
|
#[error("Received authority record without any addresses having a peer id")]
|
||||||
ReceivingDhtValueFoundEventWithNoPeerIds,
|
ReceivingDhtValueFoundEventWithNoPeerIds,
|
||||||
/// Received authority record without a valid signature for the remote peer id.
|
|
||||||
|
#[error("Received authority record without a valid signature for the remote peer id.")]
|
||||||
MissingPeerIdSignature,
|
MissingPeerIdSignature,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ repository = "https://github.com/paritytech/substrate"
|
|||||||
description = "RPC for the BEEFY Client gadget for substrate"
|
description = "RPC for the BEEFY Client gadget for substrate"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
derive_more = "0.99"
|
|
||||||
futures = "0.3.16"
|
futures = "0.3.16"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
parking_lot = "0.11"
|
parking_lot = "0.11"
|
||||||
|
|||||||
@@ -36,15 +36,15 @@ mod notification;
|
|||||||
|
|
||||||
type FutureResult<T> = jsonrpc_core::BoxFuture<Result<T, jsonrpc_core::Error>>;
|
type FutureResult<T> = jsonrpc_core::BoxFuture<Result<T, jsonrpc_core::Error>>;
|
||||||
|
|
||||||
#[derive(Debug, derive_more::Display, derive_more::From, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
/// Top-level error type for the RPC handler
|
/// Top-level error type for the RPC handler
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// The BEEFY RPC endpoint is not ready.
|
/// The BEEFY RPC endpoint is not ready.
|
||||||
#[display(fmt = "BEEFY RPC endpoint not ready")]
|
#[error("BEEFY RPC endpoint not ready")]
|
||||||
EndpointNotReady,
|
EndpointNotReady,
|
||||||
/// The BEEFY RPC background task failed to spawn.
|
/// The BEEFY RPC background task failed to spawn.
|
||||||
#[display(fmt = "BEEFY RPC background task failed to spawn")]
|
#[error("BEEFY RPC background task failed to spawn")]
|
||||||
RpcTaskFailure(SpawnError),
|
RpcTaskFailure(#[from] SpawnError),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The error codes returned by jsonrpc.
|
/// The error codes returned by jsonrpc.
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ codec = { package = "parity-scale-codec", version = "2.0.0" }
|
|||||||
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
|
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
|
||||||
sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" }
|
sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" }
|
||||||
sp-consensus-slots = { version = "0.10.0-dev", path = "../../../primitives/consensus/slots" }
|
sp-consensus-slots = { version = "0.10.0-dev", path = "../../../primitives/consensus/slots" }
|
||||||
derive_more = "0.99.16"
|
thiserror = "1.0"
|
||||||
futures = "0.3.9"
|
futures = "0.3.9"
|
||||||
sp-inherents = { version = "4.0.0-dev", path = "../../../primitives/inherents" }
|
sp-inherents = { version = "4.0.0-dev", path = "../../../primitives/inherents" }
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
|
|||||||
@@ -491,33 +491,34 @@ fn aura_err<B: BlockT>(error: Error<B>) -> Error<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Aura Errors
|
/// Aura Errors
|
||||||
#[derive(derive_more::Display, Debug)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error<B: BlockT> {
|
pub enum Error<B: BlockT> {
|
||||||
/// Multiple Aura pre-runtime headers
|
/// Multiple Aura pre-runtime headers
|
||||||
#[display(fmt = "Multiple Aura pre-runtime headers")]
|
#[error("Multiple Aura pre-runtime headers")]
|
||||||
MultipleHeaders,
|
MultipleHeaders,
|
||||||
/// No Aura pre-runtime digest found
|
/// No Aura pre-runtime digest found
|
||||||
#[display(fmt = "No Aura pre-runtime digest found")]
|
#[error("No Aura pre-runtime digest found")]
|
||||||
NoDigestFound,
|
NoDigestFound,
|
||||||
/// Header is unsealed
|
/// Header is unsealed
|
||||||
#[display(fmt = "Header {:?} is unsealed", _0)]
|
#[error("Header {0:?} is unsealed")]
|
||||||
HeaderUnsealed(B::Hash),
|
HeaderUnsealed(B::Hash),
|
||||||
/// Header has a bad seal
|
/// Header has a bad seal
|
||||||
#[display(fmt = "Header {:?} has a bad seal", _0)]
|
#[error("Header {0:?} has a bad seal")]
|
||||||
HeaderBadSeal(B::Hash),
|
HeaderBadSeal(B::Hash),
|
||||||
/// Slot Author not found
|
/// Slot Author not found
|
||||||
#[display(fmt = "Slot Author not found")]
|
#[error("Slot Author not found")]
|
||||||
SlotAuthorNotFound,
|
SlotAuthorNotFound,
|
||||||
/// Bad signature
|
/// Bad signature
|
||||||
#[display(fmt = "Bad signature on {:?}", _0)]
|
#[error("Bad signature on {0:?}")]
|
||||||
BadSignature(B::Hash),
|
BadSignature(B::Hash),
|
||||||
/// Client Error
|
/// Client Error
|
||||||
|
#[error(transparent)]
|
||||||
Client(sp_blockchain::Error),
|
Client(sp_blockchain::Error),
|
||||||
/// Unknown inherent error for identifier
|
/// Unknown inherent error for identifier
|
||||||
#[display(fmt = "Unknown inherent error for identifier: {}", "String::from_utf8_lossy(_0)")]
|
#[error("Unknown inherent error for identifier: {}", String::from_utf8_lossy(.0))]
|
||||||
UnknownInherentError(sp_inherents::InherentIdentifier),
|
UnknownInherentError(sp_inherents::InherentIdentifier),
|
||||||
#[display(fmt = "Inherent error: {}", _0)]
|
|
||||||
/// Inherents Error
|
/// Inherents Error
|
||||||
|
#[error("Inherent error: {0}")]
|
||||||
Inherent(sp_inherents::Error),
|
Inherent(sp_inherents::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ log = "0.4.8"
|
|||||||
schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated"] }
|
schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated"] }
|
||||||
rand = "0.7.2"
|
rand = "0.7.2"
|
||||||
merlin = "2.0"
|
merlin = "2.0"
|
||||||
derive_more = "0.99.16"
|
thiserror = "1.0"
|
||||||
retain_mut = "0.1.4"
|
retain_mut = "0.1.4"
|
||||||
async-trait = "0.1.50"
|
async-trait = "0.1.50"
|
||||||
|
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ jsonrpc-core = "18.0.0"
|
|||||||
jsonrpc-core-client = "18.0.0"
|
jsonrpc-core-client = "18.0.0"
|
||||||
jsonrpc-derive = "18.0.0"
|
jsonrpc-derive = "18.0.0"
|
||||||
sp-consensus-babe = { version = "0.10.0-dev", path = "../../../../primitives/consensus/babe" }
|
sp-consensus-babe = { version = "0.10.0-dev", path = "../../../../primitives/consensus/babe" }
|
||||||
serde = { version = "1.0.132", features=["derive"] }
|
serde = { version = "1.0.132", features = ["derive"] }
|
||||||
sp-blockchain = { version = "4.0.0-dev", path = "../../../../primitives/blockchain" }
|
sp-blockchain = { version = "4.0.0-dev", path = "../../../../primitives/blockchain" }
|
||||||
sp-runtime = { version = "4.1.0-dev", path = "../../../../primitives/runtime" }
|
sp-runtime = { version = "4.1.0-dev", path = "../../../../primitives/runtime" }
|
||||||
sc-consensus-epochs = { version = "0.10.0-dev", path = "../../epochs" }
|
sc-consensus-epochs = { version = "0.10.0-dev", path = "../../epochs" }
|
||||||
futures = "0.3.16"
|
futures = "0.3.16"
|
||||||
derive_more = "0.99.16"
|
thiserror = "1.0"
|
||||||
sp-api = { version = "4.0.0-dev", path = "../../../../primitives/api" }
|
sp-api = { version = "4.0.0-dev", path = "../../../../primitives/api" }
|
||||||
sp-consensus = { version = "0.10.0-dev", path = "../../../../primitives/consensus/common" }
|
sp-consensus = { version = "0.10.0-dev", path = "../../../../primitives/consensus/common" }
|
||||||
sp-core = { version = "4.1.0-dev", path = "../../../../primitives/core" }
|
sp-core = { version = "4.1.0-dev", path = "../../../../primitives/core" }
|
||||||
|
|||||||
@@ -166,11 +166,13 @@ pub struct EpochAuthorship {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Errors encountered by the RPC
|
/// Errors encountered by the RPC
|
||||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Consensus error
|
/// Consensus error
|
||||||
Consensus(ConsensusError),
|
#[error(transparent)]
|
||||||
|
Consensus(#[from] ConsensusError),
|
||||||
/// Errors that can be formatted as a String
|
/// Errors that can be formatted as a String
|
||||||
|
#[error("{0}")]
|
||||||
StringError(String),
|
StringError(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -217,95 +217,94 @@ impl Epoch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Errors encountered by the babe authorship task.
|
/// Errors encountered by the babe authorship task.
|
||||||
#[derive(derive_more::Display, Debug)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error<B: BlockT> {
|
pub enum Error<B: BlockT> {
|
||||||
/// Multiple BABE pre-runtime digests
|
/// Multiple BABE pre-runtime digests
|
||||||
#[display(fmt = "Multiple BABE pre-runtime digests, rejecting!")]
|
#[error("Multiple BABE pre-runtime digests, rejecting!")]
|
||||||
MultiplePreRuntimeDigests,
|
MultiplePreRuntimeDigests,
|
||||||
/// No BABE pre-runtime digest found
|
/// No BABE pre-runtime digest found
|
||||||
#[display(fmt = "No BABE pre-runtime digest found")]
|
#[error("No BABE pre-runtime digest found")]
|
||||||
NoPreRuntimeDigest,
|
NoPreRuntimeDigest,
|
||||||
/// Multiple BABE epoch change digests
|
/// Multiple BABE epoch change digests
|
||||||
#[display(fmt = "Multiple BABE epoch change digests, rejecting!")]
|
#[error("Multiple BABE epoch change digests, rejecting!")]
|
||||||
MultipleEpochChangeDigests,
|
MultipleEpochChangeDigests,
|
||||||
/// Multiple BABE config change digests
|
/// Multiple BABE config change digests
|
||||||
#[display(fmt = "Multiple BABE config change digests, rejecting!")]
|
#[error("Multiple BABE config change digests, rejecting!")]
|
||||||
MultipleConfigChangeDigests,
|
MultipleConfigChangeDigests,
|
||||||
/// Could not extract timestamp and slot
|
/// Could not extract timestamp and slot
|
||||||
#[display(fmt = "Could not extract timestamp and slot: {:?}", _0)]
|
#[error("Could not extract timestamp and slot: {0:?}")]
|
||||||
Extraction(sp_consensus::Error),
|
Extraction(sp_consensus::Error),
|
||||||
/// Could not fetch epoch
|
/// Could not fetch epoch
|
||||||
#[display(fmt = "Could not fetch epoch at {:?}", _0)]
|
#[error("Could not fetch epoch at {0:?}")]
|
||||||
FetchEpoch(B::Hash),
|
FetchEpoch(B::Hash),
|
||||||
/// Header rejected: too far in the future
|
/// Header rejected: too far in the future
|
||||||
#[display(fmt = "Header {:?} rejected: too far in the future", _0)]
|
#[error("Header {0:?} rejected: too far in the future")]
|
||||||
TooFarInFuture(B::Hash),
|
TooFarInFuture(B::Hash),
|
||||||
/// Parent unavailable. Cannot import
|
/// Parent unavailable. Cannot import
|
||||||
#[display(fmt = "Parent ({}) of {} unavailable. Cannot import", _0, _1)]
|
#[error("Parent ({0}) of {1} unavailable. Cannot import")]
|
||||||
ParentUnavailable(B::Hash, B::Hash),
|
ParentUnavailable(B::Hash, B::Hash),
|
||||||
/// Slot number must increase
|
/// Slot number must increase
|
||||||
#[display(fmt = "Slot number must increase: parent slot: {}, this slot: {}", _0, _1)]
|
#[error("Slot number must increase: parent slot: {0}, this slot: {1}")]
|
||||||
SlotMustIncrease(Slot, Slot),
|
SlotMustIncrease(Slot, Slot),
|
||||||
/// Header has a bad seal
|
/// Header has a bad seal
|
||||||
#[display(fmt = "Header {:?} has a bad seal", _0)]
|
#[error("Header {0:?} has a bad seal")]
|
||||||
HeaderBadSeal(B::Hash),
|
HeaderBadSeal(B::Hash),
|
||||||
/// Header is unsealed
|
/// Header is unsealed
|
||||||
#[display(fmt = "Header {:?} is unsealed", _0)]
|
#[error("Header {0:?} is unsealed")]
|
||||||
HeaderUnsealed(B::Hash),
|
HeaderUnsealed(B::Hash),
|
||||||
/// Slot author not found
|
/// Slot author not found
|
||||||
#[display(fmt = "Slot author not found")]
|
#[error("Slot author not found")]
|
||||||
SlotAuthorNotFound,
|
SlotAuthorNotFound,
|
||||||
/// Secondary slot assignments are disabled for the current epoch.
|
/// Secondary slot assignments are disabled for the current epoch.
|
||||||
#[display(fmt = "Secondary slot assignments are disabled for the current epoch.")]
|
#[error("Secondary slot assignments are disabled for the current epoch.")]
|
||||||
SecondarySlotAssignmentsDisabled,
|
SecondarySlotAssignmentsDisabled,
|
||||||
/// Bad signature
|
/// Bad signature
|
||||||
#[display(fmt = "Bad signature on {:?}", _0)]
|
#[error("Bad signature on {0:?}")]
|
||||||
BadSignature(B::Hash),
|
BadSignature(B::Hash),
|
||||||
/// Invalid author: Expected secondary author
|
/// Invalid author: Expected secondary author
|
||||||
#[display(fmt = "Invalid author: Expected secondary author: {:?}, got: {:?}.", _0, _1)]
|
#[error("Invalid author: Expected secondary author: {0:?}, got: {1:?}.")]
|
||||||
InvalidAuthor(AuthorityId, AuthorityId),
|
InvalidAuthor(AuthorityId, AuthorityId),
|
||||||
/// No secondary author expected.
|
/// No secondary author expected.
|
||||||
#[display(fmt = "No secondary author expected.")]
|
#[error("No secondary author expected.")]
|
||||||
NoSecondaryAuthorExpected,
|
NoSecondaryAuthorExpected,
|
||||||
/// VRF verification of block by author failed
|
/// VRF verification of block by author failed
|
||||||
#[display(
|
#[error("VRF verification of block by author {0:?} failed: threshold {1} exceeded")]
|
||||||
fmt = "VRF verification of block by author {:?} failed: threshold {} exceeded",
|
|
||||||
_0,
|
|
||||||
_1
|
|
||||||
)]
|
|
||||||
VRFVerificationOfBlockFailed(AuthorityId, u128),
|
VRFVerificationOfBlockFailed(AuthorityId, u128),
|
||||||
/// VRF verification failed
|
/// VRF verification failed
|
||||||
#[display(fmt = "VRF verification failed: {:?}", _0)]
|
#[error("VRF verification failed: {0:?}")]
|
||||||
VRFVerificationFailed(SignatureError),
|
VRFVerificationFailed(SignatureError),
|
||||||
/// Could not fetch parent header
|
/// Could not fetch parent header
|
||||||
#[display(fmt = "Could not fetch parent header: {:?}", _0)]
|
#[error("Could not fetch parent header: {0:?}")]
|
||||||
FetchParentHeader(sp_blockchain::Error),
|
FetchParentHeader(sp_blockchain::Error),
|
||||||
/// Expected epoch change to happen.
|
/// Expected epoch change to happen.
|
||||||
#[display(fmt = "Expected epoch change to happen at {:?}, s{}", _0, _1)]
|
#[error("Expected epoch change to happen at {0:?}, s{1}")]
|
||||||
ExpectedEpochChange(B::Hash, Slot),
|
ExpectedEpochChange(B::Hash, Slot),
|
||||||
/// Unexpected config change.
|
/// Unexpected config change.
|
||||||
#[display(fmt = "Unexpected config change")]
|
#[error("Unexpected config change")]
|
||||||
UnexpectedConfigChange,
|
UnexpectedConfigChange,
|
||||||
/// Unexpected epoch change
|
/// Unexpected epoch change
|
||||||
#[display(fmt = "Unexpected epoch change")]
|
#[error("Unexpected epoch change")]
|
||||||
UnexpectedEpochChange,
|
UnexpectedEpochChange,
|
||||||
/// Parent block has no associated weight
|
/// Parent block has no associated weight
|
||||||
#[display(fmt = "Parent block of {} has no associated weight", _0)]
|
#[error("Parent block of {0} has no associated weight")]
|
||||||
ParentBlockNoAssociatedWeight(B::Hash),
|
ParentBlockNoAssociatedWeight(B::Hash),
|
||||||
/// Check inherents error
|
/// Check inherents error
|
||||||
#[display(fmt = "Checking inherents failed: {}", _0)]
|
#[error("Checking inherents failed: {0}")]
|
||||||
CheckInherents(sp_inherents::Error),
|
CheckInherents(sp_inherents::Error),
|
||||||
/// Unhandled check inherents error
|
/// Unhandled check inherents error
|
||||||
#[display(fmt = "Checking inherents unhandled error: {}", "String::from_utf8_lossy(_0)")]
|
#[error("Checking inherents unhandled error: {}", String::from_utf8_lossy(.0))]
|
||||||
CheckInherentsUnhandled(sp_inherents::InherentIdentifier),
|
CheckInherentsUnhandled(sp_inherents::InherentIdentifier),
|
||||||
/// Create inherents error.
|
/// Create inherents error.
|
||||||
#[display(fmt = "Creating inherents failed: {}", _0)]
|
#[error("Creating inherents failed: {0}")]
|
||||||
CreateInherents(sp_inherents::Error),
|
CreateInherents(sp_inherents::Error),
|
||||||
/// Client error
|
/// Client error
|
||||||
|
#[error(transparent)]
|
||||||
Client(sp_blockchain::Error),
|
Client(sp_blockchain::Error),
|
||||||
/// Runtime Api error.
|
/// Runtime Api error.
|
||||||
|
#[error(transparent)]
|
||||||
RuntimeApi(sp_api::ApiError),
|
RuntimeApi(sp_api::ApiError),
|
||||||
/// Fork tree error
|
/// Fork tree error
|
||||||
|
#[error(transparent)]
|
||||||
ForkTree(Box<fork_tree::Error<sp_blockchain::Error>>),
|
ForkTree(Box<fork_tree::Error<sp_blockchain::Error>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ readme = "README.md"
|
|||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
derive_more = "0.99.16"
|
thiserror = "1.0"
|
||||||
futures = "0.3.9"
|
futures = "0.3.9"
|
||||||
jsonrpc-core = "18.0.0"
|
jsonrpc-core = "18.0.0"
|
||||||
jsonrpc-core-client = "18.0.0"
|
jsonrpc-core-client = "18.0.0"
|
||||||
|
|||||||
@@ -38,40 +38,52 @@ mod codes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// errors encountered by background block authorship task
|
/// errors encountered by background block authorship task
|
||||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// An error occurred while importing the block
|
/// An error occurred while importing the block
|
||||||
#[display(fmt = "Block import failed: {:?}", _0)]
|
#[error("Block import failed: {0:?}")]
|
||||||
BlockImportError(ImportResult),
|
BlockImportError(ImportResult),
|
||||||
/// Transaction pool is empty, cannot create a block
|
/// Transaction pool is empty, cannot create a block
|
||||||
#[display(fmt = "Transaction pool is empty, set create_empty to true,\
|
#[error(
|
||||||
if you want to create empty blocks")]
|
"Transaction pool is empty, set create_empty to true, if you want to create empty blocks"
|
||||||
|
)]
|
||||||
EmptyTransactionPool,
|
EmptyTransactionPool,
|
||||||
/// encountered during creation of Proposer.
|
/// encountered during creation of Proposer.
|
||||||
#[display(fmt = "Consensus Error: {}", _0)]
|
#[error("Consensus Error: {0}")]
|
||||||
ConsensusError(ConsensusError),
|
ConsensusError(#[from] ConsensusError),
|
||||||
/// Failed to create Inherents data
|
/// Failed to create Inherents data
|
||||||
#[display(fmt = "Inherents Error: {}", _0)]
|
#[error("Inherents Error: {0}")]
|
||||||
InherentError(InherentsError),
|
InherentError(#[from] InherentsError),
|
||||||
/// error encountered during finalization
|
/// error encountered during finalization
|
||||||
#[display(fmt = "Finalization Error: {}", _0)]
|
#[error("Finalization Error: {0}")]
|
||||||
BlockchainError(BlockchainError),
|
BlockchainError(#[from] BlockchainError),
|
||||||
/// Supplied parent_hash doesn't exist in chain
|
/// Supplied parent_hash doesn't exist in chain
|
||||||
#[display(fmt = "Supplied parent_hash: {} doesn't exist in chain", _0)]
|
#[error("Supplied parent_hash: {0} doesn't exist in chain")]
|
||||||
#[from(ignore)]
|
|
||||||
BlockNotFound(String),
|
BlockNotFound(String),
|
||||||
/// Some string error
|
/// Some string error
|
||||||
#[display(fmt = "{}", _0)]
|
#[error("{0}")]
|
||||||
StringError(String),
|
StringError(String),
|
||||||
/// send error
|
/// send error
|
||||||
#[display(fmt = "Consensus process is terminating")]
|
#[error("Consensus process is terminating")]
|
||||||
Canceled(oneshot::Canceled),
|
Canceled(#[from] oneshot::Canceled),
|
||||||
/// send error
|
/// send error
|
||||||
#[display(fmt = "Consensus process is terminating")]
|
#[error("Consensus process is terminating")]
|
||||||
SendError(SendError),
|
SendError(#[from] SendError),
|
||||||
/// Some other error.
|
/// Some other error.
|
||||||
#[display(fmt = "Other error: {}", _0)]
|
#[error("Other error: {0}")]
|
||||||
Other(Box<dyn std::error::Error + Send>),
|
Other(#[from] Box<dyn std::error::Error + Send>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ImportResult> for Error {
|
||||||
|
fn from(err: ImportResult) -> Self {
|
||||||
|
Error::BlockImportError(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<String> for Error {
|
||||||
|
fn from(s: String) -> Self {
|
||||||
|
Error::StringError(s)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
|
|||||||
@@ -28,6 +28,6 @@ log = "0.4.8"
|
|||||||
futures = "0.3.16"
|
futures = "0.3.16"
|
||||||
futures-timer = "3.0.1"
|
futures-timer = "3.0.1"
|
||||||
parking_lot = "0.11.2"
|
parking_lot = "0.11.2"
|
||||||
derive_more = "0.99.16"
|
thiserror = "1.0"
|
||||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus", version = "0.10.0-dev"}
|
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus", version = "0.10.0-dev"}
|
||||||
async-trait = "0.1.50"
|
async-trait = "0.1.50"
|
||||||
|
|||||||
@@ -72,45 +72,50 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(derive_more::Display, Debug)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error<B: BlockT> {
|
pub enum Error<B: BlockT> {
|
||||||
#[display(fmt = "Header uses the wrong engine {:?}", _0)]
|
#[error("Header uses the wrong engine {0:?}")]
|
||||||
WrongEngine([u8; 4]),
|
WrongEngine([u8; 4]),
|
||||||
#[display(fmt = "Header {:?} is unsealed", _0)]
|
#[error("Header {0:?} is unsealed")]
|
||||||
HeaderUnsealed(B::Hash),
|
HeaderUnsealed(B::Hash),
|
||||||
#[display(fmt = "PoW validation error: invalid seal")]
|
#[error("PoW validation error: invalid seal")]
|
||||||
InvalidSeal,
|
InvalidSeal,
|
||||||
#[display(fmt = "PoW validation error: preliminary verification failed")]
|
#[error("PoW validation error: preliminary verification failed")]
|
||||||
FailedPreliminaryVerify,
|
FailedPreliminaryVerify,
|
||||||
#[display(fmt = "Rejecting block too far in future")]
|
#[error("Rejecting block too far in future")]
|
||||||
TooFarInFuture,
|
TooFarInFuture,
|
||||||
#[display(fmt = "Fetching best header failed using select chain: {:?}", _0)]
|
#[error("Fetching best header failed using select chain: {0:?}")]
|
||||||
BestHeaderSelectChain(ConsensusError),
|
BestHeaderSelectChain(ConsensusError),
|
||||||
#[display(fmt = "Fetching best header failed: {:?}", _0)]
|
#[error("Fetching best header failed: {0:?}")]
|
||||||
BestHeader(sp_blockchain::Error),
|
BestHeader(sp_blockchain::Error),
|
||||||
#[display(fmt = "Best header does not exist")]
|
#[error("Best header does not exist")]
|
||||||
NoBestHeader,
|
NoBestHeader,
|
||||||
#[display(fmt = "Block proposing error: {:?}", _0)]
|
#[error("Block proposing error: {0:?}")]
|
||||||
BlockProposingError(String),
|
BlockProposingError(String),
|
||||||
#[display(fmt = "Fetch best hash failed via select chain: {:?}", _0)]
|
#[error("Fetch best hash failed via select chain: {0:?}")]
|
||||||
BestHashSelectChain(ConsensusError),
|
BestHashSelectChain(ConsensusError),
|
||||||
#[display(fmt = "Error with block built on {:?}: {:?}", _0, _1)]
|
#[error("Error with block built on {0:?}: {1:?}")]
|
||||||
BlockBuiltError(B::Hash, ConsensusError),
|
BlockBuiltError(B::Hash, ConsensusError),
|
||||||
#[display(fmt = "Creating inherents failed: {}", _0)]
|
#[error("Creating inherents failed: {0}")]
|
||||||
CreateInherents(sp_inherents::Error),
|
CreateInherents(sp_inherents::Error),
|
||||||
#[display(fmt = "Checking inherents failed: {}", _0)]
|
#[error("Checking inherents failed: {0}")]
|
||||||
CheckInherents(sp_inherents::Error),
|
CheckInherents(sp_inherents::Error),
|
||||||
#[display(
|
#[error(
|
||||||
fmt = "Checking inherents unknown error for identifier: {:?}",
|
"Checking inherents unknown error for identifier: {:?}",
|
||||||
"String::from_utf8_lossy(_0)"
|
String::from_utf8_lossy(.0)
|
||||||
)]
|
)]
|
||||||
CheckInherentsUnknownError(sp_inherents::InherentIdentifier),
|
CheckInherentsUnknownError(sp_inherents::InherentIdentifier),
|
||||||
#[display(fmt = "Multiple pre-runtime digests")]
|
#[error("Multiple pre-runtime digests")]
|
||||||
MultiplePreRuntimeDigests,
|
MultiplePreRuntimeDigests,
|
||||||
|
#[error(transparent)]
|
||||||
Client(sp_blockchain::Error),
|
Client(sp_blockchain::Error),
|
||||||
|
#[error(transparent)]
|
||||||
Codec(codec::Error),
|
Codec(codec::Error),
|
||||||
|
#[error("{0}")]
|
||||||
Environment(String),
|
Environment(String),
|
||||||
|
#[error("{0}")]
|
||||||
Runtime(RuntimeString),
|
Runtime(RuntimeString),
|
||||||
|
#[error("{0}")]
|
||||||
Other(String),
|
Other(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ readme = "README.md"
|
|||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
derive_more = "0.99.16"
|
|
||||||
wasm-instrument = "0.1"
|
wasm-instrument = "0.1"
|
||||||
codec = { package = "parity-scale-codec", version = "2.0.0" }
|
codec = { package = "parity-scale-codec", version = "2.0.0" }
|
||||||
wasmi = "0.9.1"
|
wasmi = "0.9.1"
|
||||||
|
|||||||
@@ -125,28 +125,38 @@ impl From<String> for Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Type for errors occurring during Wasm runtime construction.
|
/// Type for errors occurring during Wasm runtime construction.
|
||||||
#[derive(Debug, derive_more::Display)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub enum WasmError {
|
pub enum WasmError {
|
||||||
/// Code could not be read from the state.
|
#[error("Code could not be read from the state.")]
|
||||||
CodeNotFound,
|
CodeNotFound,
|
||||||
/// Failure to reinitialize runtime instance from snapshot.
|
|
||||||
|
#[error("Failure to reinitialize runtime instance from snapshot.")]
|
||||||
ApplySnapshotFailed,
|
ApplySnapshotFailed,
|
||||||
|
|
||||||
/// Failure to erase the wasm memory.
|
/// Failure to erase the wasm memory.
|
||||||
///
|
///
|
||||||
/// Depending on the implementation might mean failure of allocating memory.
|
/// Depending on the implementation might mean failure of allocating memory.
|
||||||
|
#[error("Failure to erase the wasm memory: {0}")]
|
||||||
ErasingFailed(String),
|
ErasingFailed(String),
|
||||||
/// Wasm code failed validation.
|
|
||||||
|
#[error("Wasm code failed validation.")]
|
||||||
InvalidModule,
|
InvalidModule,
|
||||||
/// Wasm code could not be deserialized.
|
|
||||||
|
#[error("Wasm code could not be deserialized.")]
|
||||||
CantDeserializeWasm,
|
CantDeserializeWasm,
|
||||||
/// The module does not export a linear memory named `memory`.
|
|
||||||
|
#[error("The module does not export a linear memory named `memory`.")]
|
||||||
InvalidMemory,
|
InvalidMemory,
|
||||||
/// The number of heap pages requested is disallowed by the module.
|
|
||||||
|
#[error("The number of heap pages requested is disallowed by the module.")]
|
||||||
InvalidHeapPages,
|
InvalidHeapPages,
|
||||||
|
|
||||||
/// Instantiation error.
|
/// Instantiation error.
|
||||||
|
#[error("{0}")]
|
||||||
Instantiation(String),
|
Instantiation(String),
|
||||||
|
|
||||||
/// Other error happenend.
|
/// Other error happenend.
|
||||||
|
#[error("{0}")]
|
||||||
Other(String),
|
Other(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for WasmError {}
|
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ readme = "README.md"
|
|||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
derive_more = "0.99.16"
|
thiserror = "1.0"
|
||||||
dyn-clone = "1.0"
|
dyn-clone = "1.0"
|
||||||
fork-tree = { version = "3.0.0", path = "../../utils/fork-tree" }
|
fork-tree = { version = "3.0.0", path = "../../utils/fork-tree" }
|
||||||
futures = "0.3.9"
|
futures = "0.3.9"
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ futures = "0.3.16"
|
|||||||
serde = { version = "1.0.105", features = ["derive"] }
|
serde = { version = "1.0.105", features = ["derive"] }
|
||||||
serde_json = "1.0.50"
|
serde_json = "1.0.50"
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
derive_more = "0.99.2"
|
thiserror = "1.0"
|
||||||
parity-scale-codec = { version = "2.0.0", features = ["derive"] }
|
parity-scale-codec = { version = "2.0.0", features = ["derive"] }
|
||||||
sc-client-api = { version = "4.0.0-dev", path = "../../api" }
|
sc-client-api = { version = "4.0.0-dev", path = "../../api" }
|
||||||
|
|
||||||
|
|||||||
@@ -16,21 +16,21 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#[derive(derive_more::Display, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
/// Top-level error type for the RPC handler
|
/// Top-level error type for the RPC handler
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// The GRANDPA RPC endpoint is not ready.
|
/// The GRANDPA RPC endpoint is not ready.
|
||||||
#[display(fmt = "GRANDPA RPC endpoint not ready")]
|
#[error("GRANDPA RPC endpoint not ready")]
|
||||||
EndpointNotReady,
|
EndpointNotReady,
|
||||||
/// GRANDPA reports the authority set id to be larger than 32-bits.
|
/// GRANDPA reports the authority set id to be larger than 32-bits.
|
||||||
#[display(fmt = "GRANDPA reports authority set id unreasonably large")]
|
#[error("GRANDPA reports authority set id unreasonably large")]
|
||||||
AuthoritySetIdReportedAsUnreasonablyLarge,
|
AuthoritySetIdReportedAsUnreasonablyLarge,
|
||||||
/// GRANDPA reports voter state with round id or weights larger than 32-bits.
|
/// GRANDPA reports voter state with round id or weights larger than 32-bits.
|
||||||
#[display(fmt = "GRANDPA reports voter state as unreasonably large")]
|
#[error("GRANDPA reports voter state as unreasonably large")]
|
||||||
VoterStateReportsUnreasonablyLargeNumbers,
|
VoterStateReportsUnreasonablyLargeNumbers,
|
||||||
/// GRANDPA prove finality failed.
|
/// GRANDPA prove finality failed.
|
||||||
#[display(fmt = "GRANDPA prove finality rpc failed: {}", _0)]
|
#[error("GRANDPA prove finality rpc failed: {0}")]
|
||||||
ProveFinalityFailed(sc_finality_grandpa::FinalityProofError),
|
ProveFinalityFailed(#[from] sc_finality_grandpa::FinalityProofError),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The error codes returned by jsonrpc.
|
/// The error codes returned by jsonrpc.
|
||||||
|
|||||||
@@ -32,23 +32,22 @@ use sp_finality_grandpa::{AuthorityId, AuthorityList};
|
|||||||
use crate::SetId;
|
use crate::SetId;
|
||||||
|
|
||||||
/// Error type returned on operations on the `AuthoritySet`.
|
/// Error type returned on operations on the `AuthoritySet`.
|
||||||
#[derive(Debug, derive_more::Display)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error<N, E> {
|
pub enum Error<N, E> {
|
||||||
#[display(fmt = "Invalid authority set, either empty or with an authority weight set to 0.")]
|
#[error("Invalid authority set, either empty or with an authority weight set to 0.")]
|
||||||
InvalidAuthoritySet,
|
InvalidAuthoritySet,
|
||||||
#[display(fmt = "Client error during ancestry lookup: {}", _0)]
|
#[error("Client error during ancestry lookup: {0}")]
|
||||||
Client(E),
|
Client(E),
|
||||||
#[display(fmt = "Duplicate authority set change.")]
|
#[error("Duplicate authority set change.")]
|
||||||
DuplicateAuthoritySetChange,
|
DuplicateAuthoritySetChange,
|
||||||
#[display(fmt = "Multiple pending forced authority set changes are not allowed.")]
|
#[error("Multiple pending forced authority set changes are not allowed.")]
|
||||||
MultiplePendingForcedAuthoritySetChanges,
|
MultiplePendingForcedAuthoritySetChanges,
|
||||||
#[display(
|
#[error(
|
||||||
fmt = "A pending forced authority set change could not be applied since it must be applied \
|
"A pending forced authority set change could not be applied since it must be applied \
|
||||||
after the pending standard change at #{}",
|
after the pending standard change at #{0}"
|
||||||
_0
|
|
||||||
)]
|
)]
|
||||||
ForcedAuthoritySetChangeDependencyUnsatisfied(N),
|
ForcedAuthoritySetChangeDependencyUnsatisfied(N),
|
||||||
#[display(fmt = "Invalid operation in the pending changes tree: {}", _0)]
|
#[error("Invalid operation in the pending changes tree: {0}")]
|
||||||
ForkTree(fork_tree::Error<E>),
|
ForkTree(fork_tree::Error<E>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,17 +132,18 @@ pub struct FinalityProof<Header: HeaderT> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Errors occurring when trying to prove finality
|
/// Errors occurring when trying to prove finality
|
||||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum FinalityProofError {
|
pub enum FinalityProofError {
|
||||||
/// The requested block has not yet been finalized.
|
/// The requested block has not yet been finalized.
|
||||||
#[display(fmt = "Block not yet finalized")]
|
#[error("Block not yet finalized")]
|
||||||
BlockNotYetFinalized,
|
BlockNotYetFinalized,
|
||||||
/// The requested block is not covered by authority set changes. Likely this means the block is
|
/// The requested block is not covered by authority set changes. Likely this means the block is
|
||||||
/// in the latest authority set, and the subscription API is more appropriate.
|
/// in the latest authority set, and the subscription API is more appropriate.
|
||||||
#[display(fmt = "Block not covered by authority set changes")]
|
#[error("Block not covered by authority set changes")]
|
||||||
BlockNotInAuthoritySetChanges,
|
BlockNotInAuthoritySetChanges,
|
||||||
/// Errors originating from the client.
|
/// Errors originating from the client.
|
||||||
Client(sp_blockchain::Error),
|
#[error(transparent)]
|
||||||
|
Client(#[from] sp_blockchain::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prove_finality<Block, B>(
|
fn prove_finality<Block, B>(
|
||||||
|
|||||||
@@ -34,26 +34,25 @@ use sp_runtime::{
|
|||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
|
|
||||||
/// Warp proof processing error.
|
/// Warp proof processing error.
|
||||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Decoding error.
|
/// Decoding error.
|
||||||
#[display(fmt = "Failed to decode block hash: {}.", _0)]
|
#[error("Failed to decode block hash: {0}.")]
|
||||||
DecodeScale(codec::Error),
|
DecodeScale(#[from] codec::Error),
|
||||||
/// Client backend error.
|
/// Client backend error.
|
||||||
Client(sp_blockchain::Error),
|
#[error("{0}")]
|
||||||
|
Client(#[from] sp_blockchain::Error),
|
||||||
/// Invalid request data.
|
/// Invalid request data.
|
||||||
#[from(ignore)]
|
#[error("{0}")]
|
||||||
InvalidRequest(String),
|
InvalidRequest(String),
|
||||||
/// Invalid warp proof.
|
/// Invalid warp proof.
|
||||||
#[from(ignore)]
|
#[error("{0}")]
|
||||||
InvalidProof(String),
|
InvalidProof(String),
|
||||||
/// Missing header or authority set change data.
|
/// Missing header or authority set change data.
|
||||||
#[display(fmt = "Missing required data to be able to answer request.")]
|
#[error("Missing required data to be able to answer request.")]
|
||||||
MissingData,
|
MissingData,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for Error {}
|
|
||||||
|
|
||||||
/// The maximum size in bytes of the `WarpSyncProof`.
|
/// The maximum size in bytes of the `WarpSyncProof`.
|
||||||
pub(super) const MAX_WARP_SYNC_PROOF_SIZE: usize = 8 * 1024 * 1024;
|
pub(super) const MAX_WARP_SYNC_PROOF_SIZE: usize = 8 * 1024 * 1024;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = "0.1.50"
|
async-trait = "0.1.50"
|
||||||
derive_more = "0.99.16"
|
thiserror = "1.0"
|
||||||
sp-application-crypto = { version = "4.0.0", path = "../../primitives/application-crypto" }
|
sp-application-crypto = { version = "4.0.0", path = "../../primitives/application-crypto" }
|
||||||
sp-core = { version = "4.1.0-dev", path = "../../primitives/core" }
|
sp-core = { version = "4.1.0-dev", path = "../../primitives/core" }
|
||||||
sp-keystore = { version = "0.10.0", path = "../../primitives/keystore" }
|
sp-keystore = { version = "0.10.0", path = "../../primitives/keystore" }
|
||||||
|
|||||||
@@ -28,29 +28,31 @@ mod local;
|
|||||||
pub use local::LocalKeystore;
|
pub use local::LocalKeystore;
|
||||||
|
|
||||||
/// Keystore error.
|
/// Keystore error.
|
||||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// IO error.
|
/// IO error.
|
||||||
Io(io::Error),
|
#[error(transparent)]
|
||||||
|
Io(#[from] io::Error),
|
||||||
/// JSON error.
|
/// JSON error.
|
||||||
Json(serde_json::Error),
|
#[error(transparent)]
|
||||||
|
Json(#[from] serde_json::Error),
|
||||||
/// Invalid password.
|
/// Invalid password.
|
||||||
#[display(
|
#[error(
|
||||||
fmt = "Requested public key and public key of the loaded private key do not match. \n
|
"Requested public key and public key of the loaded private key do not match. \n
|
||||||
This means either that the keystore password is incorrect or that the private key was stored under a wrong public key."
|
This means either that the keystore password is incorrect or that the private key was stored under a wrong public key."
|
||||||
)]
|
)]
|
||||||
PublicKeyMismatch,
|
PublicKeyMismatch,
|
||||||
/// Invalid BIP39 phrase
|
/// Invalid BIP39 phrase
|
||||||
#[display(fmt = "Invalid recovery phrase (BIP39) data")]
|
#[error("Invalid recovery phrase (BIP39) data")]
|
||||||
InvalidPhrase,
|
InvalidPhrase,
|
||||||
/// Invalid seed
|
/// Invalid seed
|
||||||
#[display(fmt = "Invalid seed")]
|
#[error("Invalid seed")]
|
||||||
InvalidSeed,
|
InvalidSeed,
|
||||||
/// Public key type is not supported
|
/// Public key type is not supported
|
||||||
#[display(fmt = "Key crypto type is not supported")]
|
#[error("Key crypto type is not supported")]
|
||||||
KeyNotSupported(KeyTypeId),
|
KeyNotSupported(KeyTypeId),
|
||||||
/// Keystore unavailable
|
/// Keystore unavailable
|
||||||
#[display(fmt = "Keystore unavailable")]
|
#[error("Keystore unavailable")]
|
||||||
Unavailable,
|
Unavailable,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,13 +71,3 @@ impl From<Error> for TraitError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for Error {
|
|
||||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
|
||||||
match self {
|
|
||||||
Error::Io(ref err) => Some(err),
|
|
||||||
Error::Json(ref err) => Some(err),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ bytes = "1"
|
|||||||
codec = { package = "parity-scale-codec", version = "2.0.0", features = [
|
codec = { package = "parity-scale-codec", version = "2.0.0", features = [
|
||||||
"derive",
|
"derive",
|
||||||
] }
|
] }
|
||||||
derive_more = "0.99.16"
|
|
||||||
either = "1.5.3"
|
either = "1.5.3"
|
||||||
fnv = "1.0.6"
|
fnv = "1.0.6"
|
||||||
fork-tree = { version = "3.0.0", path = "../../utils/fork-tree" }
|
fork-tree = { version = "3.0.0", path = "../../utils/fork-tree" }
|
||||||
@@ -57,7 +56,7 @@ sp-core = { version = "4.1.0-dev", path = "../../primitives/core" }
|
|||||||
sp-runtime = { version = "4.1.0-dev", path = "../../primitives/runtime" }
|
sp-runtime = { version = "4.1.0-dev", path = "../../primitives/runtime" }
|
||||||
sc-utils = { version = "4.0.0-dev", path = "../utils" }
|
sc-utils = { version = "4.0.0-dev", path = "../utils" }
|
||||||
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../primitives/finality-grandpa" }
|
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../primitives/finality-grandpa" }
|
||||||
thiserror = "1"
|
thiserror = "1.0"
|
||||||
unsigned-varint = { version = "0.6.0", features = [
|
unsigned-varint = { version = "0.6.0", features = [
|
||||||
"futures",
|
"futures",
|
||||||
"asynchronous_codec",
|
"asynchronous_codec",
|
||||||
|
|||||||
@@ -313,21 +313,29 @@ impl<B: BlockT> NetworkBehaviour for Bitswap<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Bitswap protocol error.
|
/// Bitswap protocol error.
|
||||||
#[derive(derive_more::Display, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum BitswapError {
|
pub enum BitswapError {
|
||||||
/// Protobuf decoding error.
|
/// Protobuf decoding error.
|
||||||
#[display(fmt = "Failed to decode request: {}.", _0)]
|
#[error("Failed to decode request: {0}.")]
|
||||||
DecodeProto(prost::DecodeError),
|
DecodeProto(#[from] prost::DecodeError),
|
||||||
|
|
||||||
/// Protobuf encoding error.
|
/// Protobuf encoding error.
|
||||||
#[display(fmt = "Failed to encode response: {}.", _0)]
|
#[error("Failed to encode response: {0}.")]
|
||||||
EncodeProto(prost::EncodeError),
|
EncodeProto(#[from] prost::EncodeError),
|
||||||
|
|
||||||
/// Client backend error.
|
/// Client backend error.
|
||||||
Client(sp_blockchain::Error),
|
#[error(transparent)]
|
||||||
|
Client(#[from] sp_blockchain::Error),
|
||||||
|
|
||||||
/// Error parsing CID
|
/// Error parsing CID
|
||||||
BadCid(cid::Error),
|
#[error(transparent)]
|
||||||
|
BadCid(#[from] cid::Error),
|
||||||
|
|
||||||
/// Packet read error.
|
/// Packet read error.
|
||||||
Read(io::Error),
|
#[error(transparent)]
|
||||||
|
Read(#[from] io::Error),
|
||||||
|
|
||||||
/// Error sending response.
|
/// Error sending response.
|
||||||
#[display(fmt = "Failed to send response.")]
|
#[error("Failed to send response.")]
|
||||||
SendResponse,
|
SendResponse,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -379,19 +379,20 @@ impl<B: BlockT> BlockRequestHandler<B> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(derive_more::Display, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
enum HandleRequestError {
|
enum HandleRequestError {
|
||||||
#[display(fmt = "Failed to decode request: {}.", _0)]
|
#[error("Failed to decode request: {0}.")]
|
||||||
DecodeProto(prost::DecodeError),
|
DecodeProto(#[from] prost::DecodeError),
|
||||||
#[display(fmt = "Failed to encode response: {}.", _0)]
|
#[error("Failed to encode response: {0}.")]
|
||||||
EncodeProto(prost::EncodeError),
|
EncodeProto(#[from] prost::EncodeError),
|
||||||
#[display(fmt = "Failed to decode block hash: {}.", _0)]
|
#[error("Failed to decode block hash: {0}.")]
|
||||||
DecodeScale(codec::Error),
|
DecodeScale(#[from] codec::Error),
|
||||||
#[display(fmt = "Missing `BlockRequest::from_block` field.")]
|
#[error("Missing `BlockRequest::from_block` field.")]
|
||||||
MissingFromField,
|
MissingFromField,
|
||||||
#[display(fmt = "Failed to parse BlockRequest::direction.")]
|
#[error("Failed to parse BlockRequest::direction.")]
|
||||||
ParseDirection,
|
ParseDirection,
|
||||||
Client(sp_blockchain::Error),
|
#[error(transparent)]
|
||||||
#[display(fmt = "Failed to send response.")]
|
Client(#[from] sp_blockchain::Error),
|
||||||
|
#[error("Failed to send response.")]
|
||||||
SendResponse,
|
SendResponse,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,18 +27,18 @@ use std::{borrow::Cow, fmt};
|
|||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
/// Error type for the network.
|
/// Error type for the network.
|
||||||
#[derive(derive_more::Display, derive_more::From)]
|
#[derive(thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Io error
|
/// Io error
|
||||||
Io(std::io::Error),
|
#[error(transparent)]
|
||||||
|
Io(#[from] std::io::Error),
|
||||||
|
|
||||||
/// Client error
|
/// Client error
|
||||||
Client(Box<sp_blockchain::Error>),
|
#[error(transparent)]
|
||||||
|
Client(#[from] Box<sp_blockchain::Error>),
|
||||||
/// The same bootnode (based on address) is registered with two different peer ids.
|
/// The same bootnode (based on address) is registered with two different peer ids.
|
||||||
#[display(
|
#[error(
|
||||||
fmt = "The same bootnode (`{}`) is registered with two different peer ids: `{}` and `{}`",
|
"The same bootnode (`{address}`) is registered with two different peer ids: `{first_id}` and `{second_id}`"
|
||||||
address,
|
|
||||||
first_id,
|
|
||||||
second_id
|
|
||||||
)]
|
)]
|
||||||
DuplicateBootnode {
|
DuplicateBootnode {
|
||||||
/// The address of the bootnode.
|
/// The address of the bootnode.
|
||||||
@@ -49,11 +49,11 @@ pub enum Error {
|
|||||||
second_id: PeerId,
|
second_id: PeerId,
|
||||||
},
|
},
|
||||||
/// Prometheus metrics error.
|
/// Prometheus metrics error.
|
||||||
Prometheus(prometheus_endpoint::PrometheusError),
|
#[error(transparent)]
|
||||||
|
Prometheus(#[from] prometheus_endpoint::PrometheusError),
|
||||||
/// The network addresses are invalid because they don't match the transport.
|
/// The network addresses are invalid because they don't match the transport.
|
||||||
#[display(
|
#[error(
|
||||||
fmt = "The following addresses are invalid because they don't match the transport: {:?}",
|
"The following addresses are invalid because they don't match the transport: {addresses:?}"
|
||||||
addresses
|
|
||||||
)]
|
)]
|
||||||
AddressesForAnotherTransport {
|
AddressesForAnotherTransport {
|
||||||
/// Transport used.
|
/// Transport used.
|
||||||
@@ -62,7 +62,7 @@ pub enum Error {
|
|||||||
addresses: Vec<Multiaddr>,
|
addresses: Vec<Multiaddr>,
|
||||||
},
|
},
|
||||||
/// The same request-response protocol has been registered multiple times.
|
/// The same request-response protocol has been registered multiple times.
|
||||||
#[display(fmt = "Request-response protocol registered multiple times: {}", protocol)]
|
#[error("Request-response protocol registered multiple times: {protocol}")]
|
||||||
DuplicateRequestResponseProtocol {
|
DuplicateRequestResponseProtocol {
|
||||||
/// Name of the protocol registered multiple times.
|
/// Name of the protocol registered multiple times.
|
||||||
protocol: Cow<'static, str>,
|
protocol: Cow<'static, str>,
|
||||||
@@ -75,16 +75,3 @@ impl fmt::Debug for Error {
|
|||||||
fmt::Display::fmt(self, f)
|
fmt::Display::fmt(self, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for Error {
|
|
||||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
|
||||||
match self {
|
|
||||||
Self::Io(ref err) => Some(err),
|
|
||||||
Self::Client(ref err) => Some(err),
|
|
||||||
Self::Prometheus(ref err) => Some(err),
|
|
||||||
Self::DuplicateBootnode { .. } |
|
|
||||||
Self::AddressesForAnotherTransport { .. } |
|
|
||||||
Self::DuplicateRequestResponseProtocol { .. } => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -284,20 +284,20 @@ impl<B: Block> LightClientRequestHandler<B> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(derive_more::Display, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
enum HandleRequestError {
|
enum HandleRequestError {
|
||||||
#[display(fmt = "Failed to decode request: {}.", _0)]
|
#[error("Failed to decode request: {0}.")]
|
||||||
DecodeProto(prost::DecodeError),
|
DecodeProto(#[from] prost::DecodeError),
|
||||||
#[display(fmt = "Failed to encode response: {}.", _0)]
|
#[error("Failed to encode response: {0}.")]
|
||||||
EncodeProto(prost::EncodeError),
|
EncodeProto(#[from] prost::EncodeError),
|
||||||
#[display(fmt = "Failed to send response.")]
|
#[error("Failed to send response.")]
|
||||||
SendResponse,
|
SendResponse,
|
||||||
/// A bad request has been received.
|
/// A bad request has been received.
|
||||||
#[display(fmt = "bad request: {}", _0)]
|
#[error("bad request: {0}")]
|
||||||
BadRequest(&'static str),
|
BadRequest(&'static str),
|
||||||
/// Encoding or decoding of some data failed.
|
/// Encoding or decoding of some data failed.
|
||||||
#[display(fmt = "codec error: {}", _0)]
|
#[error("codec error: {0}")]
|
||||||
Codec(codec::Error),
|
Codec(#[from] codec::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fmt_keys(first: Option<&Vec<u8>>, last: Option<&Vec<u8>>) -> String {
|
fn fmt_keys(first: Option<&Vec<u8>>, last: Option<&Vec<u8>>) -> String {
|
||||||
|
|||||||
@@ -457,9 +457,9 @@ impl<'a> Ready<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Error specific to the collection of protocols.
|
/// Error specific to the collection of protocols.
|
||||||
#[derive(Debug, derive_more::Display, derive_more::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum NotifsHandlerError {
|
pub enum NotifsHandlerError {
|
||||||
/// Channel of synchronous notifications is full.
|
#[error("Channel of synchronous notifications is full.")]
|
||||||
SyncNotificationsClogged,
|
SyncNotificationsClogged,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -457,13 +457,14 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Error generated by sending on a notifications out substream.
|
/// Error generated by sending on a notifications out substream.
|
||||||
#[derive(Debug, derive_more::From, derive_more::Display)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum NotificationsHandshakeError {
|
pub enum NotificationsHandshakeError {
|
||||||
/// I/O error on the substream.
|
/// I/O error on the substream.
|
||||||
Io(io::Error),
|
#[error(transparent)]
|
||||||
|
Io(#[from] io::Error),
|
||||||
|
|
||||||
/// Initial message or handshake was too large.
|
/// Initial message or handshake was too large.
|
||||||
#[display(fmt = "Initial message or handshake was too large: {}", requested)]
|
#[error("Initial message or handshake was too large: {requested}")]
|
||||||
TooLarge {
|
TooLarge {
|
||||||
/// Size requested by the remote.
|
/// Size requested by the remote.
|
||||||
requested: usize,
|
requested: usize,
|
||||||
@@ -472,7 +473,8 @@ pub enum NotificationsHandshakeError {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/// Error while decoding the variable-length integer.
|
/// Error while decoding the variable-length integer.
|
||||||
VarintDecode(unsigned_varint::decode::Error),
|
#[error(transparent)]
|
||||||
|
VarintDecode(#[from] unsigned_varint::decode::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<unsigned_varint::io::ReadError> for NotificationsHandshakeError {
|
impl From<unsigned_varint::io::ReadError> for NotificationsHandshakeError {
|
||||||
@@ -489,10 +491,11 @@ impl From<unsigned_varint::io::ReadError> for NotificationsHandshakeError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Error generated by sending on a notifications out substream.
|
/// Error generated by sending on a notifications out substream.
|
||||||
#[derive(Debug, derive_more::From, derive_more::Display)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum NotificationsOutError {
|
pub enum NotificationsOutError {
|
||||||
/// I/O error on the substream.
|
/// I/O error on the substream.
|
||||||
Io(io::Error),
|
#[error(transparent)]
|
||||||
|
Io(#[from] io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -884,34 +884,35 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Error when registering a protocol.
|
/// Error when registering a protocol.
|
||||||
#[derive(Debug, derive_more::Display, derive_more::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum RegisterError {
|
pub enum RegisterError {
|
||||||
/// A protocol has been specified multiple times.
|
/// A protocol has been specified multiple times.
|
||||||
DuplicateProtocol(#[error(ignore)] Cow<'static, str>),
|
#[error("{0}")]
|
||||||
|
DuplicateProtocol(Cow<'static, str>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error in a request.
|
/// Error in a request.
|
||||||
#[derive(Debug, derive_more::Display, derive_more::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub enum RequestFailure {
|
pub enum RequestFailure {
|
||||||
/// We are not currently connected to the requested peer.
|
#[error("We are not currently connected to the requested peer.")]
|
||||||
NotConnected,
|
NotConnected,
|
||||||
/// Given protocol hasn't been registered.
|
#[error("Given protocol hasn't been registered.")]
|
||||||
UnknownProtocol,
|
UnknownProtocol,
|
||||||
/// Remote has closed the substream before answering, thereby signaling that it considers the
|
#[error("Remote has closed the substream before answering, thereby signaling that it considers the request as valid, but refused to answer it.")]
|
||||||
/// request as valid, but refused to answer it.
|
|
||||||
Refused,
|
Refused,
|
||||||
/// The remote replied, but the local node is no longer interested in the response.
|
#[error("The remote replied, but the local node is no longer interested in the response.")]
|
||||||
Obsolete,
|
Obsolete,
|
||||||
/// Problem on the network.
|
/// Problem on the network.
|
||||||
#[display(fmt = "Problem on the network: {}", _0)]
|
#[error("Problem on the network: {0}")]
|
||||||
Network(OutboundFailure),
|
Network(OutboundFailure),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error when processing a request sent by a remote.
|
/// Error when processing a request sent by a remote.
|
||||||
#[derive(Debug, derive_more::Display, derive_more::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum ResponseFailure {
|
pub enum ResponseFailure {
|
||||||
/// Problem on the network.
|
/// Problem on the network.
|
||||||
#[display(fmt = "Problem on the network: {}", _0)]
|
#[error("Problem on the network: {0}")]
|
||||||
Network(InboundFailure),
|
Network(InboundFailure),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1391,7 +1391,7 @@ impl<'a> NotificationSenderReady<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Error returned by [`NetworkService::send_notification`].
|
/// Error returned by [`NetworkService::send_notification`].
|
||||||
#[derive(Debug, derive_more::Display, derive_more::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum NotificationSenderError {
|
pub enum NotificationSenderError {
|
||||||
/// The notification receiver has been closed, usually because the underlying connection
|
/// The notification receiver has been closed, usually because the underlying connection
|
||||||
/// closed.
|
/// closed.
|
||||||
@@ -1399,8 +1399,10 @@ pub enum NotificationSenderError {
|
|||||||
/// Some of the notifications most recently sent may not have been received. However,
|
/// Some of the notifications most recently sent may not have been received. However,
|
||||||
/// the peer may still be connected and a new `NotificationSender` for the same
|
/// the peer may still be connected and a new `NotificationSender` for the same
|
||||||
/// protocol obtained from [`NetworkService::notification_sender`].
|
/// protocol obtained from [`NetworkService::notification_sender`].
|
||||||
|
#[error("The notification receiver has been closed")]
|
||||||
Closed,
|
Closed,
|
||||||
/// Protocol name hasn't been registered.
|
/// Protocol name hasn't been registered.
|
||||||
|
#[error("Protocol name hasn't been registered")]
|
||||||
BadProtocol,
|
BadProtocol,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -241,15 +241,20 @@ impl<B: BlockT> StateRequestHandler<B> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(derive_more::Display, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
enum HandleRequestError {
|
enum HandleRequestError {
|
||||||
#[display(fmt = "Failed to decode request: {}.", _0)]
|
#[error("Failed to decode request: {0}.")]
|
||||||
DecodeProto(prost::DecodeError),
|
DecodeProto(#[from] prost::DecodeError),
|
||||||
#[display(fmt = "Failed to encode response: {}.", _0)]
|
|
||||||
EncodeProto(prost::EncodeError),
|
#[error("Failed to encode response: {0}.")]
|
||||||
#[display(fmt = "Failed to decode block hash: {}.", _0)]
|
EncodeProto(#[from] prost::EncodeError),
|
||||||
InvalidHash(codec::Error),
|
|
||||||
Client(sp_blockchain::Error),
|
#[error("Failed to decode block hash: {0}.")]
|
||||||
#[display(fmt = "Failed to send response.")]
|
InvalidHash(#[from] codec::Error),
|
||||||
|
|
||||||
|
#[error(transparent)]
|
||||||
|
Client(#[from] sp_blockchain::Error),
|
||||||
|
|
||||||
|
#[error("Failed to send response.")]
|
||||||
SendResponse,
|
SendResponse,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,18 +149,23 @@ impl<TBlock: BlockT> RequestHandler<TBlock> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
enum HandleRequestError {
|
enum HandleRequestError {
|
||||||
#[display(fmt = "Failed to decode request: {}.", _0)]
|
#[error("Failed to decode request: {0}.")]
|
||||||
DecodeProto(prost::DecodeError),
|
DecodeProto(#[from] prost::DecodeError),
|
||||||
#[display(fmt = "Failed to encode response: {}.", _0)]
|
|
||||||
EncodeProto(prost::EncodeError),
|
#[error("Failed to encode response: {0}.")]
|
||||||
#[display(fmt = "Failed to decode block hash: {}.", _0)]
|
EncodeProto(#[from] prost::EncodeError),
|
||||||
DecodeScale(codec::Error),
|
|
||||||
Client(sp_blockchain::Error),
|
#[error("Failed to decode block hash: {0}.")]
|
||||||
#[from(ignore)]
|
DecodeScale(#[from] codec::Error),
|
||||||
#[display(fmt = "Invalid request {}.", _0)]
|
|
||||||
InvalidRequest(Box<dyn std::error::Error + Send + Sync>),
|
#[error(transparent)]
|
||||||
#[display(fmt = "Failed to send response.")]
|
Client(#[from] sp_blockchain::Error),
|
||||||
|
|
||||||
|
#[error("Invalid request {0}.")]
|
||||||
|
InvalidRequest(#[from] Box<dyn std::error::Error + Send + Sync>),
|
||||||
|
|
||||||
|
#[error("Failed to send response.")]
|
||||||
SendResponse,
|
SendResponse,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,10 @@ repository = "https://github.com/paritytech/substrate/"
|
|||||||
description = "Transaction pool client facing API."
|
description = "Transaction pool client facing API."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
futures = { version = "0.3.1" }
|
futures = "0.3.1"
|
||||||
log = { version = "0.4.8" }
|
log = "0.4.8"
|
||||||
serde = { version = "1.0.132", features = ["derive"] }
|
serde = { version = "1.0.132", features = ["derive"] }
|
||||||
thiserror = { version = "1.0.30" }
|
thiserror = "1.0.30"
|
||||||
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../../../primitives/runtime" }
|
|
||||||
|
|
||||||
derive_more = { version = "0.99.16" }
|
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../../../primitives/runtime" }
|
||||||
sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" }
|
sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" }
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ use sp_runtime::transaction_validity::{
|
|||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
/// Transaction pool error type.
|
/// Transaction pool error type.
|
||||||
#[derive(Debug, thiserror::Error, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("Unknown transaction validity: {0:?}")]
|
#[error("Unknown transaction validity: {0:?}")]
|
||||||
@@ -64,7 +64,6 @@ pub enum Error {
|
|||||||
#[error("Transaction cannot be propagated and the local node does not author blocks")]
|
#[error("Transaction cannot be propagated and the local node does not author blocks")]
|
||||||
Unactionable,
|
Unactionable,
|
||||||
|
|
||||||
#[from(ignore)]
|
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
InvalidBlockId(String),
|
InvalidBlockId(String),
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ use std::{
|
|||||||
|
|
||||||
use graph::{ExtrinsicHash, IsValidator};
|
use graph::{ExtrinsicHash, IsValidator};
|
||||||
use sc_transaction_pool_api::{
|
use sc_transaction_pool_api::{
|
||||||
ChainEvent, ImportNotificationStream, MaintainedTransactionPool, PoolFuture, PoolStatus,
|
error::Error as TxPoolError, ChainEvent, ImportNotificationStream, MaintainedTransactionPool,
|
||||||
ReadyTransactions, TransactionFor, TransactionPool, TransactionSource,
|
PoolFuture, PoolStatus, ReadyTransactions, TransactionFor, TransactionPool, TransactionSource,
|
||||||
TransactionStatusStreamFor, TxHash,
|
TransactionStatusStreamFor, TxHash,
|
||||||
};
|
};
|
||||||
use sp_core::traits::SpawnEssentialNamed;
|
use sp_core::traits::SpawnEssentialNamed;
|
||||||
@@ -418,8 +418,8 @@ where
|
|||||||
.validate_transaction_blocking(at, TransactionSource::Local, xt.clone())?
|
.validate_transaction_blocking(at, TransactionSource::Local, xt.clone())?
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
Self::Error::Pool(match e {
|
Self::Error::Pool(match e {
|
||||||
TransactionValidityError::Invalid(i) => i.into(),
|
TransactionValidityError::Invalid(i) => TxPoolError::InvalidTransaction(i),
|
||||||
TransactionValidityError::Unknown(u) => u.into(),
|
TransactionValidityError::Unknown(u) => TxPoolError::UnknownTransaction(u),
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ targets = ["x86_64-unknown-linux-gnu"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = "0.1.50"
|
async-trait = "0.1.50"
|
||||||
derive_more = "0.99.16"
|
futures = "0.3.1"
|
||||||
|
parking_lot = { version = "0.11.2", default-features = false }
|
||||||
|
serde = { version = "1.0", optional = true }
|
||||||
|
thiserror = "1.0"
|
||||||
|
|
||||||
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
|
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
|
||||||
futures = { version = "0.3.1" }
|
|
||||||
schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated", "u64_backend"], default-features = false }
|
schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated", "u64_backend"], default-features = false }
|
||||||
merlin = { version = "2.0", default-features = false }
|
merlin = { version = "2.0", default-features = false }
|
||||||
parking_lot = { version = "0.11.2", default-features = false }
|
|
||||||
serde = { version = "1.0", optional = true}
|
|
||||||
sp-core = { version = "4.1.0-dev", path = "../core" }
|
sp-core = { version = "4.1.0-dev", path = "../core" }
|
||||||
sp-externalities = { version = "0.10.0", path = "../externalities", default-features = false }
|
sp-externalities = { version = "0.10.0", path = "../externalities", default-features = false }
|
||||||
|
|
||||||
@@ -28,7 +29,6 @@ sp-externalities = { version = "0.10.0", path = "../externalities", default-feat
|
|||||||
rand = "0.7.2"
|
rand = "0.7.2"
|
||||||
rand_chacha = "0.2.2"
|
rand_chacha = "0.2.2"
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
|
|||||||
@@ -29,19 +29,19 @@ use sp_core::{
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
/// CryptoStore error
|
/// CryptoStore error
|
||||||
#[derive(Debug, derive_more::Display)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Public key type is not supported
|
/// Public key type is not supported
|
||||||
#[display(fmt = "Key not supported: {:?}", _0)]
|
#[error("Key not supported: {0:?}")]
|
||||||
KeyNotSupported(KeyTypeId),
|
KeyNotSupported(KeyTypeId),
|
||||||
/// Validation error
|
/// Validation error
|
||||||
#[display(fmt = "Validation error: {}", _0)]
|
#[error("Validation error: {0}")]
|
||||||
ValidationError(String),
|
ValidationError(String),
|
||||||
/// Keystore unavailable
|
/// Keystore unavailable
|
||||||
#[display(fmt = "Keystore unavailable")]
|
#[error("Keystore unavailable")]
|
||||||
Unavailable,
|
Unavailable,
|
||||||
/// Programming errors
|
/// Programming errors
|
||||||
#[display(fmt = "An unknown keystore error occurred: {}", _0)]
|
#[error("An unknown keystore error occurred: {0}")]
|
||||||
Other(String),
|
Other(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,4 @@ sp-runtime = { version = "4.1.0-dev", path = "../../../primitives/runtime" }
|
|||||||
sc-transaction-pool = { version = "4.0.0-dev", path = "../../../client/transaction-pool" }
|
sc-transaction-pool = { version = "4.0.0-dev", path = "../../../client/transaction-pool" }
|
||||||
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../../../client/transaction-pool/api" }
|
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../../../client/transaction-pool/api" }
|
||||||
futures = "0.3.16"
|
futures = "0.3.16"
|
||||||
derive_more = "0.99.16"
|
thiserror = "1.0"
|
||||||
|
|||||||
@@ -40,8 +40,9 @@ use substrate_test_runtime_client::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Error type used by [`TestApi`].
|
/// Error type used by [`TestApi`].
|
||||||
#[derive(Debug, derive_more::From, derive_more::Display)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub struct Error(sc_transaction_pool_api::error::Error);
|
#[error(transparent)]
|
||||||
|
pub struct Error(#[from] sc_transaction_pool_api::error::Error);
|
||||||
|
|
||||||
impl sc_transaction_pool_api::error::IntoPoolError for Error {
|
impl sc_transaction_pool_api::error::IntoPoolError for Error {
|
||||||
fn into_pool_error(self) -> Result<sc_transaction_pool_api::error::Error, Self> {
|
fn into_pool_error(self) -> Result<sc_transaction_pool_api::error::Error, Self> {
|
||||||
@@ -49,12 +50,6 @@ impl sc_transaction_pool_api::error::IntoPoolError for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for Error {
|
|
||||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
|
||||||
Some(&self.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum IsBestBlock {
|
pub enum IsBestBlock {
|
||||||
Yes,
|
Yes,
|
||||||
No,
|
No,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
|||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
prometheus = { version = "0.13.0", default-features = false }
|
prometheus = { version = "0.13.0", default-features = false }
|
||||||
futures-util = { version = "0.3.19", default-features = false, features = ["io"] }
|
futures-util = { version = "0.3.19", default-features = false, features = ["io"] }
|
||||||
derive_more = "0.99"
|
thiserror = "1.0"
|
||||||
async-std = { version = "1.10.0", features = ["unstable"] }
|
async-std = { version = "1.10.0", features = ["unstable"] }
|
||||||
tokio = "1.15"
|
tokio = "1.15"
|
||||||
hyper = { version = "0.14.16", default-features = false, features = ["http1", "server", "tcp"] }
|
hyper = { version = "0.14.16", default-features = false, features = ["http1", "server", "tcp"] }
|
||||||
|
|||||||
@@ -47,27 +47,22 @@ pub fn register<T: Clone + Collector + 'static>(
|
|||||||
Ok(metric)
|
Ok(metric)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Hyper internal error.
|
/// Hyper internal error.
|
||||||
Hyper(hyper::Error),
|
#[error(transparent)]
|
||||||
/// Http request error.
|
Hyper(#[from] hyper::Error),
|
||||||
Http(hyper::http::Error),
|
|
||||||
/// i/o error.
|
|
||||||
Io(std::io::Error),
|
|
||||||
#[display(fmt = "Prometheus port {} already in use.", _0)]
|
|
||||||
PortInUse(SocketAddr),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::error::Error for Error {
|
/// Http request error.
|
||||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
#[error(transparent)]
|
||||||
match self {
|
Http(#[from] hyper::http::Error),
|
||||||
Error::Hyper(error) => Some(error),
|
|
||||||
Error::Http(error) => Some(error),
|
/// i/o error.
|
||||||
Error::Io(error) => Some(error),
|
#[error(transparent)]
|
||||||
Error::PortInUse(_) => None,
|
Io(#[from] std::io::Error),
|
||||||
}
|
|
||||||
}
|
#[error("Prometheus port {0} already in use.")]
|
||||||
|
PortInUse(SocketAddr),
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn request_metrics(req: Request<Body>, registry: Registry) -> Result<Response<Body>, Error> {
|
async fn request_metrics(req: Request<Body>, registry: Registry) -> Result<Response<Body>, Error> {
|
||||||
|
|||||||
Reference in New Issue
Block a user