error rework, for polkadot convenience (#7446)

Co-authored-by: Bernhard Schuster <bernhard@parity.io>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Bernhard Schuster
2020-10-28 15:04:56 +01:00
committed by GitHub
parent 1679919830
commit 9687759774
17 changed files with 152 additions and 128 deletions
+1 -2
View File
@@ -114,8 +114,7 @@ pub trait CallExecutor<B: BlockT> {
) -> Result<(Vec<u8>, StorageProof), sp_blockchain::Error> {
let trie_state = state.as_trie_backend()
.ok_or_else(||
Box::new(sp_state_machine::ExecutionError::UnableToGenerateProof)
as Box<dyn sp_state_machine::Error>
sp_blockchain::Error::from_state(Box::new(sp_state_machine::ExecutionError::UnableToGenerateProof) as Box<_>)
)?;
self.prove_at_trie_state(trie_state, overlay, method, call_data)
}
+3 -3
View File
@@ -122,7 +122,7 @@ pub fn build_proof<Header, Hasher, BlocksI, HashesI>(
prove_read_on_trie_backend(
trie_storage,
blocks.into_iter().map(|number| encode_cht_key(number)),
).map_err(ClientError::Execution)
).map_err(ClientError::from_state)
}
/// Check CHT-based header proof.
@@ -150,7 +150,7 @@ pub fn check_proof<Header, Hasher>(
.map(|mut map| map
.remove(local_cht_key)
.expect("checked proof of local_cht_key; qed"))
.map_err(|e| ClientError::from(e)),
.map_err(ClientError::from_state),
)
}
@@ -174,7 +174,7 @@ pub fn check_proof_on_proving_backend<Header, Hasher>(
read_proof_check_on_proving_backend::<Hasher>(
proving_backend,
local_cht_key,
).map_err(|e| ClientError::from(e)),
).map_err(ClientError::from_state),
)
}