mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 19:51:05 +00:00
Don't use Ext outside of runtime!!! (#704)
This commit is contained in:
@@ -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<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())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user