@@ -20,7 +20,6 @@ use runtime_primitives::generic::BlockId;
2020use runtime_primitives:: traits:: Block as BlockT ;
2121use state_machine:: { self , OverlayedChanges , Ext ,
2222 CodeExecutor , ExecutionManager , native_when_possible} ;
23- use runtime_io:: Externalities ;
2423use executor:: { RuntimeVersion , RuntimeInfo } ;
2524use patricia_trie:: NodeCodec ;
2625use 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