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

Commit 040ba00

Browse files
authored
Don't use Ext outside of runtime!!! (#704)
1 parent ded17fa commit 040ba00

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

substrate/client/src/call_executor.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use runtime_primitives::generic::BlockId;
2020
use runtime_primitives::traits::Block as BlockT;
2121
use state_machine::{self, OverlayedChanges, Ext,
2222
CodeExecutor, ExecutionManager, native_when_possible};
23-
use runtime_io::Externalities;
2423
use executor::{RuntimeVersion, RuntimeInfo};
2524
use patricia_trie::NodeCodec;
2625
use hashdb::Hasher;
@@ -143,12 +142,17 @@ where
143142
fn runtime_version(&self, id: &BlockId<Block>) -> error::Result<RuntimeVersion> {
144143
let mut overlay = OverlayedChanges::default();
145144
let state = self.backend.state_at(*id)?;
146-
let mut externalities = Ext::new(&mut overlay, &state);
147-
let code = externalities.storage(b":code").ok_or(error::ErrorKind::VersionInvalid)?
145+
use state_machine::Backend;
146+
let code = state.storage(b":code")
147+
.map_err(|e| error::ErrorKind::Execution(Box::new(e)))?
148+
.ok_or(error::ErrorKind::VersionInvalid)?
148149
.to_vec();
149-
let heap_pages = externalities.storage(b":heappages").and_then(|v| u64::decode(&mut &v[..])).unwrap_or(8) as usize;
150+
let heap_pages = state.storage(b":heappages")
151+
.map_err(|e| error::ErrorKind::Execution(Box::new(e)))?
152+
.and_then(|v| u64::decode(&mut &v[..]))
153+
.unwrap_or(8) as usize;
150154

151-
self.executor.runtime_version(&mut externalities, heap_pages, &code)
155+
self.executor.runtime_version(&mut Ext::new(&mut overlay, &state), heap_pages, &code)
152156
.ok_or(error::ErrorKind::VersionInvalid.into())
153157
}
154158

0 commit comments

Comments
 (0)