Revert "Don't include :code by default in storage proofs (#5060)" (#5136)

This reverts commit 6ee39261c8.
This commit is contained in:
Arkadiy Paronyan
2020-03-05 10:55:05 +01:00
committed by GitHub
parent ff2a36d7cb
commit 9a1b3b53f2
31 changed files with 182 additions and 478 deletions
+3 -13
View File
@@ -41,7 +41,8 @@ use sp_runtime::{
use sp_state_machine::{
DBValue, Backend as StateBackend, ChangesTrieAnchorBlockId,
prove_read, prove_child_read, ChangesTrieRootsStorage, ChangesTrieStorage,
ChangesTrieConfigurationRange, key_changes, key_changes_proof,
ChangesTrieConfigurationRange, key_changes, key_changes_proof, StorageProof,
merge_storage_proofs,
};
use sc_executor::{RuntimeVersion, RuntimeInfo};
use sp_consensus::{
@@ -54,7 +55,6 @@ use sp_blockchain::{self as blockchain,
well_known_cache_keys::Id as CacheKeyId,
HeaderMetadata, CachedHeaderMetadata,
};
use sp_trie::StorageProof;
use sp_api::{
CallApiAt, ConstructRuntimeApi, Core as CoreApi, ApiExt, ApiRef, ProvideRuntimeApi,
@@ -482,19 +482,9 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
method: &str,
call_data: &[u8]
) -> sp_blockchain::Result<(Vec<u8>, StorageProof)> {
// Make sure we include the `:code` and `:heap_pages` in the execution proof to be
// backwards compatible.
//
// TODO: Remove when solved: https://github.com/paritytech/substrate/issues/5047
let code_proof = self.read_proof(
id,
&[well_known_keys::CODE.to_vec(), well_known_keys::HEAP_PAGES.to_vec()],
)?;
let state = self.state_at(id)?;
let header = self.prepare_environment_block(id)?;
prove_execution(state, header, &self.executor, method, call_data)
.map(|p| (p.0, StorageProof::merge(vec![p.1, code_proof])))
}
/// Reads given header and generates CHT-based header proof.
@@ -779,7 +769,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
Ok(())
}, ())?;
Ok(StorageProof::merge(proofs))
Ok(merge_storage_proofs(proofs))
}
/// Generates CHT-based proof for roots of changes tries at given blocks (that are part of single CHT).