Introduce original_storage and original_storage_hash (#2211)

Both functions will ignore any overlayed changes and access the backend
directly.
This commit is contained in:
Bastian Köcher
2019-04-04 16:56:16 +02:00
committed by Gav Wood
parent cb7a8161f5
commit 6920b169cd
5 changed files with 30 additions and 3 deletions
@@ -54,13 +54,13 @@ fn fetch_cached_runtime_version<'a, E: Externalities<Blake2Hasher>>(
default_heap_pages: Option<u64>,
) -> Result<(&'a WasmModuleInstanceRef, &'a Option<RuntimeVersion>)> {
let code_hash = match ext.storage_hash(well_known_keys::CODE) {
let code_hash = match ext.original_storage_hash(well_known_keys::CODE) {
Some(code_hash) => code_hash,
None => return Err(ErrorKind::InvalidCode(vec![]).into()),
};
let maybe_runtime_preproc = cache.borrow_mut().entry(code_hash.into())
.or_insert_with(|| {
let code = match ext.storage(well_known_keys::CODE) {
let code = match ext.original_storage(well_known_keys::CODE) {
Some(code) => code,
None => return RuntimePreproc::InvalidCode,
};
@@ -86,7 +86,7 @@ fn fetch_cached_runtime_version<'a, E: Externalities<Blake2Hasher>>(
});
match maybe_runtime_preproc {
RuntimePreproc::InvalidCode => {
let code = ext.storage(well_known_keys::CODE).unwrap_or(vec![]);
let code = ext.original_storage(well_known_keys::CODE).unwrap_or(vec![]);
Err(ErrorKind::InvalidCode(code).into())
},
RuntimePreproc::ValidCode(m, v) => {