diff --git a/substrate/client/src/call_executor.rs b/substrate/client/src/call_executor.rs index c50b68d693967..cbb0830615160 100644 --- a/substrate/client/src/call_executor.rs +++ b/substrate/client/src/call_executor.rs @@ -20,7 +20,6 @@ use runtime_primitives::generic::BlockId; use runtime_primitives::traits::Block as BlockT; use state_machine::{self, OverlayedChanges, Ext, CodeExecutor, ExecutionManager, native_when_possible}; -use runtime_io::Externalities; use executor::{RuntimeVersion, RuntimeInfo}; use patricia_trie::NodeCodec; use hashdb::Hasher; @@ -143,12 +142,17 @@ where fn runtime_version(&self, id: &BlockId) -> error::Result { let mut overlay = OverlayedChanges::default(); let state = self.backend.state_at(*id)?; - let mut externalities = Ext::new(&mut overlay, &state); - let code = externalities.storage(b":code").ok_or(error::ErrorKind::VersionInvalid)? + use state_machine::Backend; + let code = state.storage(b":code") + .map_err(|e| error::ErrorKind::Execution(Box::new(e)))? + .ok_or(error::ErrorKind::VersionInvalid)? .to_vec(); - let heap_pages = externalities.storage(b":heappages").and_then(|v| u64::decode(&mut &v[..])).unwrap_or(8) as usize; + let heap_pages = state.storage(b":heappages") + .map_err(|e| error::ErrorKind::Execution(Box::new(e)))? + .and_then(|v| u64::decode(&mut &v[..])) + .unwrap_or(8) as usize; - self.executor.runtime_version(&mut externalities, heap_pages, &code) + self.executor.runtime_version(&mut Ext::new(&mut overlay, &state), heap_pages, &code) .ok_or(error::ErrorKind::VersionInvalid.into()) }