mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 03:31:10 +00:00
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:
@@ -46,6 +46,6 @@ where
|
||||
import_blocks(client, import_queue, reader, true, true)
|
||||
},
|
||||
Ok(None) => Box::pin(future::err("Unknown block".into())),
|
||||
Err(e) => Box::pin(future::err(format!("Error reading block: {:?}", e).into())),
|
||||
Err(e) => Box::pin(future::err(format!("Error reading block: {}", e).into())),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ where
|
||||
|
||||
for result in results {
|
||||
if let (Err(err), hash) = result {
|
||||
warn!("There was an error importing block with hash {:?}: {:?}", hash, err);
|
||||
warn!("There was an error importing block with hash {:?}: {}", hash, err);
|
||||
self.has_error = true;
|
||||
break
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ where
|
||||
state_runtime_code.runtime_code().map_err(sp_blockchain::Error::RuntimeCode)?;
|
||||
self.executor
|
||||
.runtime_version(&mut ext, &runtime_code)
|
||||
.map_err(|e| sp_blockchain::Error::VersionInvalid(format!("{:?}", e)).into())
|
||||
.map_err(|e| sp_blockchain::Error::VersionInvalid(e.to_string()).into())
|
||||
}
|
||||
|
||||
fn prove_execution(
|
||||
@@ -340,7 +340,7 @@ where
|
||||
Block: BlockT,
|
||||
{
|
||||
fn runtime_version(&self, at: &BlockId<Block>) -> Result<sp_version::RuntimeVersion, String> {
|
||||
CallExecutor::runtime_version(self, at).map_err(|e| format!("{:?}", e))
|
||||
CallExecutor::runtime_version(self, at).map_err(|e| e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1116,7 +1116,7 @@ where
|
||||
};
|
||||
let runtime_version =
|
||||
RuntimeVersionOf::runtime_version(executor, &mut ext, &runtime_code)
|
||||
.map_err(|e| sp_blockchain::Error::VersionInvalid(format!("{:?}", e)))?;
|
||||
.map_err(|e| sp_blockchain::Error::VersionInvalid(e.to_string()))?;
|
||||
Ok(runtime_version.state_version())
|
||||
} else {
|
||||
Err(sp_blockchain::Error::VersionInvalid(
|
||||
@@ -1719,7 +1719,7 @@ where
|
||||
|
||||
let storage_changes =
|
||||
match self.prepare_block_storage_changes(&mut import_block).map_err(|e| {
|
||||
warn!("Block prepare storage changes error:\n{:?}", e);
|
||||
warn!("Block prepare storage changes error: {}", e);
|
||||
ConsensusError::ClientImport(e.to_string())
|
||||
})? {
|
||||
PrepareStorageChangesResult::Discard(res) => return Ok(res),
|
||||
@@ -1730,7 +1730,7 @@ where
|
||||
self.apply_block(operation, import_block, new_cache, storage_changes)
|
||||
})
|
||||
.map_err(|e| {
|
||||
warn!("Block import error:\n{:?}", e);
|
||||
warn!("Block import error: {}", e);
|
||||
ConsensusError::ClientImport(e.to_string()).into()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ impl WasmOverride {
|
||||
hash: code_hash.into(),
|
||||
},
|
||||
)
|
||||
.map_err(|e| WasmOverrideError::VersionInvalid(format!("{:?}", e)).into())
|
||||
.map_err(|e| WasmOverrideError::VersionInvalid(e.to_string()).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -151,6 +151,6 @@ where
|
||||
let mut ext = BasicExternalities::default();
|
||||
executor
|
||||
.runtime_version(&mut ext, &code.runtime_code(None))
|
||||
.map_err(|e| WasmSubstituteError::VersionInvalid(format!("{:?}", e)).into())
|
||||
.map_err(|e| WasmSubstituteError::VersionInvalid(e.to_string()).into())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ where
|
||||
TransactionImport::Bad
|
||||
},
|
||||
Err(e) => {
|
||||
debug!("Error converting pool error: {:?}", e);
|
||||
debug!("Error converting pool error: {}", e);
|
||||
// it is not bad at least, just some internal node logic error, so peer is
|
||||
// innocent.
|
||||
TransactionImport::KnownGood
|
||||
|
||||
Reference in New Issue
Block a user