Add a new host function for reporting fatal errors; make WASM backtraces readable when printing out errors (#10741)

* Add a new host function for reporting fatal errors

* Fix one of the wasmtime executor tests

* Have `#[runtime_interface(wasm_only)]` actually mean WASM-only, and not no_std-only

* Print out errors through `Display` instead of `Debug`

* Switch one more trait to require `Error` for its error instead of only `Debug`

* Align to review comments
This commit is contained in:
Koute
2022-02-09 18:12:55 +09:00
committed by GitHub
parent bd261d57c4
commit 9a31b2c341
68 changed files with 554 additions and 249 deletions
+12 -12
View File
@@ -84,24 +84,24 @@ pub enum Error<B: BlockT> {
FailedPreliminaryVerify,
#[error("Rejecting block too far in future")]
TooFarInFuture,
#[error("Fetching best header failed using select chain: {0:?}")]
#[error("Fetching best header failed using select chain: {0}")]
BestHeaderSelectChain(ConsensusError),
#[error("Fetching best header failed: {0:?}")]
#[error("Fetching best header failed: {0}")]
BestHeader(sp_blockchain::Error),
#[error("Best header does not exist")]
NoBestHeader,
#[error("Block proposing error: {0:?}")]
#[error("Block proposing error: {0}")]
BlockProposingError(String),
#[error("Fetch best hash failed via select chain: {0:?}")]
#[error("Fetch best hash failed via select chain: {0}")]
BestHashSelectChain(ConsensusError),
#[error("Error with block built on {0:?}: {1:?}")]
#[error("Error with block built on {0:?}: {1}")]
BlockBuiltError(B::Hash, ConsensusError),
#[error("Creating inherents failed: {0}")]
CreateInherents(sp_inherents::Error),
#[error("Checking inherents failed: {0}")]
CheckInherents(sp_inherents::Error),
#[error(
"Checking inherents unknown error for identifier: {:?}",
"Checking inherents unknown error for identifier: {}",
String::from_utf8_lossy(.0)
)]
CheckInherentsUnknownError(sp_inherents::InherentIdentifier),
@@ -350,7 +350,7 @@ where
.select_chain
.best_chain()
.await
.map_err(|e| format!("Fetch best chain failed via select chain: {:?}", e))?;
.map_err(|e| format!("Fetch best chain failed via select chain: {}", e))?;
let best_hash = best_header.hash();
let parent_hash = *block.header.parent_hash();
@@ -565,7 +565,7 @@ where
warn!(
target: "pow",
"Unable to pull new block for authoring. \
Select best chain error: {:?}",
Select best chain error: {}",
err
);
continue
@@ -596,7 +596,7 @@ where
warn!(
target: "pow",
"Unable to propose new block for authoring. \
Fetch difficulty failed: {:?}",
Fetch difficulty failed: {}",
err,
);
continue
@@ -612,7 +612,7 @@ where
warn!(
target: "pow",
"Unable to propose new block for authoring. \
Creating inherent data providers failed: {:?}",
Creating inherent data providers failed: {}",
err,
);
continue
@@ -625,7 +625,7 @@ where
warn!(
target: "pow",
"Unable to propose new block for authoring. \
Creating inherent data failed: {:?}",
Creating inherent data failed: {}",
e,
);
continue
@@ -661,7 +661,7 @@ where
warn!(
target: "pow",
"Unable to propose new block for authoring. \
Creating proposal failed: {:?}",
Creating proposal failed: {}",
err,
);
continue
+2 -2
View File
@@ -169,7 +169,7 @@ where
Err(err) => {
warn!(
target: "pow",
"Unable to import mined block: {:?}",
"Unable to import mined block: {}",
err,
);
return false
@@ -238,7 +238,7 @@ where
Err(err) => {
warn!(
target: "pow",
"Unable to import mined block: {:?}",
"Unable to import mined block: {}",
err,
);
false