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
@@ -665,7 +665,7 @@ impl<B: BlockT> ChainSync<B> {
// There is nothing sync can get from the node that has no blockchain data.
match self.block_status(&best_hash) {
Err(e) => {
debug!(target:"sync", "Error reading blockchain: {:?}", e);
debug!(target:"sync", "Error reading blockchain: {}", e);
Err(BadPeer(who, rep::BLOCKCHAIN_READ_ERROR))
},
Ok(BlockStatus::KnownBad) => {
@@ -1192,7 +1192,7 @@ impl<B: BlockT> ChainSync<B> {
(_, Err(e)) => {
info!(
target: "sync",
"❌ Error answering legitimate blockchain query: {:?}",
"❌ Error answering legitimate blockchain query: {}",
e,
);
return Err(BadPeer(*who, rep::BLOCKCHAIN_READ_ERROR))
@@ -1629,7 +1629,7 @@ impl<B: BlockT> ChainSync<B> {
trace!(target: "sync", "Obsolete block {:?}", hash);
},
e @ Err(BlockImportError::UnknownParent) | e @ Err(BlockImportError::Other(_)) => {
warn!(target: "sync", "💔 Error importing block {:?}: {:?}", hash, e);
warn!(target: "sync", "💔 Error importing block {:?}: {}", hash, e.unwrap_err());
self.state_sync = None;
self.warp_sync = None;
output.extend(self.restart());
@@ -1683,7 +1683,7 @@ impl<B: BlockT> ChainSync<B> {
if let Err(err) = r {
warn!(
target: "sync",
"💔 Error cleaning up pending extra justification data requests: {:?}",
"💔 Error cleaning up pending extra justification data requests: {}",
err,
);
}
@@ -2081,7 +2081,7 @@ impl<B: BlockT> ChainSync<B> {
) -> impl Iterator<Item = Result<(PeerId, BlockRequest<B>), BadPeer>> + 'a {
self.blocks.clear();
if let Err(e) = self.reset_sync_start_point() {
warn!(target: "sync", "💔 Unable to restart sync. :{:?}", e);
warn!(target: "sync", "💔 Unable to restart sync: {}", e);
}
self.pending_requests.set_all();
debug!(target:"sync", "Restarted with {} ({})", self.best_queued_number, self.best_queued_hash);
@@ -108,7 +108,7 @@ impl<B: BlockT> ExtraRequests<B> {
// ignore the `Revert` error.
},
Err(err) => {
debug!(target: "sync", "Failed to insert request {:?} into tree: {:?}", request, err);
debug!(target: "sync", "Failed to insert request {:?} into tree: {}", request, err);
},
_ => (),
}
@@ -99,7 +99,7 @@ impl<B: BlockT> StateSync<B> {
Err(e) => {
debug!(
target: "sync",
"StateResponse failed proof verification: {:?}",
"StateResponse failed proof verification: {}",
e,
);
return ImportResult::BadResponse
@@ -88,7 +88,7 @@ impl<B: BlockT> WarpSync<B> {
Phase::WarpProof { set_id, authorities, last_hash } => {
match self.warp_sync_provider.verify(&response, *set_id, authorities.clone()) {
Err(e) => {
log::debug!(target: "sync", "Bad warp proof response: {:?}", e);
log::debug!(target: "sync", "Bad warp proof response: {}", e);
return WarpProofImportResult::BadResponse
},
Ok(VerificationResult::Partial(new_set_id, new_authorities, new_last_hash)) => {