mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
remove error wrapper type (#1871)
* get rid of glue wrapper error type * cargo update -p sp-io * cargo update -p sp-io * "Update Substrate" Co-authored-by: Andronik Ordian <write@reusable.software> Co-authored-by: parity-processbot <>
This commit is contained in:
committed by
GitHub
parent
bbf7fc8d0b
commit
8a305ac963
@@ -17,6 +17,7 @@ sp-wasm-interface = { git = "https://github.com/paritytech/substrate", branch =
|
||||
polkadot-core-primitives = { path = "../core-primitives", default-features = false }
|
||||
|
||||
# all optional crates.
|
||||
thiserror = { version = "1.0.21", optional = true }
|
||||
derive_more = { version = "0.99.11", optional = true }
|
||||
serde = { version = "1.0.102", default-features = false, features = [ "derive" ], optional = true }
|
||||
sp-externalities = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
|
||||
@@ -34,6 +35,7 @@ default = ["std"]
|
||||
wasm-api = []
|
||||
std = [
|
||||
"codec/std",
|
||||
"thiserror",
|
||||
"derive_more",
|
||||
"serde/std",
|
||||
"sp-std/std",
|
||||
|
||||
@@ -81,63 +81,61 @@ pub enum ExecutionMode {
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
/// Candidate validation error.
|
||||
pub enum ValidationError {
|
||||
/// Validation failed due to internal reasons. The candidate might still be valid.
|
||||
Internal(InternalError),
|
||||
#[error(transparent)]
|
||||
Internal(#[from] InternalError),
|
||||
/// Candidate is invalid.
|
||||
InvalidCandidate(InvalidCandidate),
|
||||
#[error(transparent)]
|
||||
InvalidCandidate(#[from] InvalidCandidate),
|
||||
}
|
||||
|
||||
/// Error type that indicates invalid candidate.
|
||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum InvalidCandidate {
|
||||
/// Wasm executor error.
|
||||
#[display(fmt = "WASM executor error: {:?}", _0)]
|
||||
WasmExecutor(sc_executor::error::Error),
|
||||
#[error("WASM executor error")]
|
||||
WasmExecutor(#[from] sc_executor::error::Error),
|
||||
/// Call data is too large.
|
||||
#[display(fmt = "Validation parameters are {} bytes, max allowed is {}", _0, MAX_RUNTIME_MEM)]
|
||||
#[from(ignore)]
|
||||
#[error("Validation parameters are {0} bytes, max allowed is {}", MAX_RUNTIME_MEM)]
|
||||
ParamsTooLarge(usize),
|
||||
/// Code size it too large.
|
||||
#[display(fmt = "WASM code is {} bytes, max allowed is {}", _0, MAX_CODE_MEM)]
|
||||
#[error("WASM code is {0} bytes, max allowed is {}", MAX_CODE_MEM)]
|
||||
CodeTooLarge(usize),
|
||||
/// Error decoding returned data.
|
||||
#[display(fmt = "Validation function returned invalid data.")]
|
||||
#[error("Validation function returned invalid data.")]
|
||||
BadReturn,
|
||||
#[display(fmt = "Validation function timeout.")]
|
||||
#[error("Validation function timeout.")]
|
||||
Timeout,
|
||||
#[display(fmt = "External WASM execution error: {}", _0)]
|
||||
#[error("External WASM execution error: {0}")]
|
||||
ExternalWasmExecutor(String),
|
||||
}
|
||||
|
||||
impl core::convert::From<String> for InvalidCandidate {
|
||||
fn from(s: String) -> Self {
|
||||
Self::ExternalWasmExecutor(s)
|
||||
}
|
||||
}
|
||||
|
||||
/// Host error during candidate validation. This does not indicate an invalid candidate.
|
||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum InternalError {
|
||||
#[display(fmt = "IO error: {}", _0)]
|
||||
Io(std::io::Error),
|
||||
#[display(fmt = "System error: {}", _0)]
|
||||
System(Box<dyn std::error::Error + Send>),
|
||||
#[display(fmt = "Shared memory error: {}", _0)]
|
||||
#[error("IO error: {0}")]
|
||||
Io(#[from] std::io::Error),
|
||||
|
||||
#[error("System error: {0}")]
|
||||
System(#[from] Box<dyn std::error::Error + Send + Sync + 'static>),
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "unknown")))]
|
||||
SharedMem(shared_memory::SharedMemError),
|
||||
#[display(fmt = "WASM worker error: {}", _0)]
|
||||
#[error("Shared memory error: {0}")]
|
||||
SharedMem(#[from] shared_memory::SharedMemError),
|
||||
|
||||
#[error("WASM worker error: {0}")]
|
||||
WasmWorker(String),
|
||||
}
|
||||
|
||||
impl std::error::Error for ValidationError {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
match self {
|
||||
ValidationError::Internal(InternalError::Io(ref err)) => Some(err),
|
||||
ValidationError::Internal(InternalError::System(ref err)) => Some(&**err),
|
||||
#[cfg(not(any(target_os = "android", target_os = "unknown")))]
|
||||
ValidationError::Internal(InternalError::SharedMem(ref err)) => Some(err),
|
||||
ValidationError::InvalidCandidate(InvalidCandidate::WasmExecutor(ref err)) => Some(err),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Validate a candidate under the given validation code.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user