Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Don't use Ext outside of runtime!!! (#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
gavofyork committed Sep 10, 2018
1 parent ded17fa commit 040ba00
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions substrate/client/src/call_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -143,12 +142,17 @@ where
fn runtime_version(&self, id: &BlockId<Block>) -> error::Result<RuntimeVersion> {
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())
}

Expand Down

0 comments on commit 040ba00

Please sign in to comment.