@@ -162,6 +162,7 @@ impl<DB: Database> EvmContext<DB> {
162
162
}
163
163
164
164
/// Sets precompiles
165
+ #[ inline]
165
166
pub fn set_precompiles ( & mut self , precompiles : Precompiles ) {
166
167
self . journaled_state . warm_preloaded_addresses =
167
168
precompiles. addresses ( ) . copied ( ) . collect :: < HashSet < _ > > ( ) ;
@@ -172,6 +173,7 @@ impl<DB: Database> EvmContext<DB> {
172
173
///
173
174
/// Loading of accounts/storages is needed to make them warm.
174
175
#[ inline]
176
+ #[ must_use]
175
177
pub fn load_access_list ( & mut self ) -> Result < ( ) , EVMError < DB :: Error > > {
176
178
for ( address, slots) in self . env . tx . access_list . iter ( ) {
177
179
self . journaled_state
@@ -182,11 +184,14 @@ impl<DB: Database> EvmContext<DB> {
182
184
}
183
185
184
186
/// Return environment.
187
+ #[ inline]
185
188
pub fn env ( & mut self ) -> & mut Env {
186
189
& mut self . env
187
190
}
188
191
189
192
/// Fetch block hash from database.
193
+ #[ inline]
194
+ #[ must_use]
190
195
pub fn block_hash ( & mut self , number : U256 ) -> Option < B256 > {
191
196
self . db
192
197
. block_hash ( number)
@@ -195,6 +200,8 @@ impl<DB: Database> EvmContext<DB> {
195
200
}
196
201
197
202
/// Load account and return flags (is_cold, exists)
203
+ #[ inline]
204
+ #[ must_use]
198
205
pub fn load_account ( & mut self , address : Address ) -> Option < ( bool , bool ) > {
199
206
self . journaled_state
200
207
. load_account_exist ( address, & mut self . db )
@@ -203,6 +210,8 @@ impl<DB: Database> EvmContext<DB> {
203
210
}
204
211
205
212
/// Return account balance and is_cold flag.
213
+ #[ inline]
214
+ #[ must_use]
206
215
pub fn balance ( & mut self , address : Address ) -> Option < ( U256 , bool ) > {
207
216
self . journaled_state
208
217
. load_account ( address, & mut self . db )
@@ -212,6 +221,8 @@ impl<DB: Database> EvmContext<DB> {
212
221
}
213
222
214
223
/// Return account code and if address is cold loaded.
224
+ #[ inline]
225
+ #[ must_use]
215
226
pub fn code ( & mut self , address : Address ) -> Option < ( Bytecode , bool ) > {
216
227
let ( acc, is_cold) = self
217
228
. journaled_state
@@ -222,6 +233,8 @@ impl<DB: Database> EvmContext<DB> {
222
233
}
223
234
224
235
/// Get code hash of address.
236
+ #[ inline]
237
+ #[ must_use]
225
238
pub fn code_hash ( & mut self , address : Address ) -> Option < ( B256 , bool ) > {
226
239
let ( acc, is_cold) = self
227
240
. journaled_state
@@ -236,6 +249,8 @@ impl<DB: Database> EvmContext<DB> {
236
249
}
237
250
238
251
/// Load storage slot, if storage is not present inside the account then it will be loaded from database.
252
+ #[ inline]
253
+ #[ must_use]
239
254
pub fn sload ( & mut self , address : Address , index : U256 ) -> Option < ( U256 , bool ) > {
240
255
// account is always warm. reference on that statement https://eips.ethereum.org/EIPS/eip-2929 see `Note 2:`
241
256
self . journaled_state
@@ -245,6 +260,8 @@ impl<DB: Database> EvmContext<DB> {
245
260
}
246
261
247
262
/// Storage change of storage slot, before storing `sload` will be called for that slot.
263
+ #[ inline]
264
+ #[ must_use]
248
265
pub fn sstore (
249
266
& mut self ,
250
267
address : Address ,
@@ -258,16 +275,20 @@ impl<DB: Database> EvmContext<DB> {
258
275
}
259
276
260
277
/// Returns transient storage value.
278
+ #[ inline]
261
279
pub fn tload ( & mut self , address : Address , index : U256 ) -> U256 {
262
280
self . journaled_state . tload ( address, index)
263
281
}
264
282
265
283
/// Stores transient storage value.
284
+ #[ inline]
266
285
pub fn tstore ( & mut self , address : Address , index : U256 , value : U256 ) {
267
286
self . journaled_state . tstore ( address, index, value)
268
287
}
269
288
270
289
/// Make create frame.
290
+ #[ inline]
291
+ #[ must_use]
271
292
pub fn make_create_frame ( & mut self , spec_id : SpecId , inputs : & CreateInputs ) -> FrameOrResult {
272
293
// Prepare crate.
273
294
let gas = Gas :: new ( inputs. gas_limit ) ;
@@ -358,6 +379,8 @@ impl<DB: Database> EvmContext<DB> {
358
379
}
359
380
360
381
/// Make call frame
382
+ #[ inline]
383
+ #[ must_use]
361
384
pub fn make_call_frame ( & mut self , inputs : & CallInputs ) -> FrameOrResult {
362
385
let gas = Gas :: new ( inputs. gas_limit ) ;
363
386
@@ -395,7 +418,9 @@ impl<DB: Database> EvmContext<DB> {
395
418
396
419
// Touch address. For "EIP-158 State Clear", this will erase empty accounts.
397
420
if inputs. transfer . value == U256 :: ZERO {
398
- self . load_account ( inputs. context . address ) ;
421
+ if self . load_account ( inputs. context . address ) . is_none ( ) {
422
+ return return_result ( InstructionResult :: FatalExternalError ) ;
423
+ } ;
399
424
self . journaled_state . touch ( & inputs. context . address ) ;
400
425
}
401
426
@@ -438,6 +463,7 @@ impl<DB: Database> EvmContext<DB> {
438
463
}
439
464
440
465
/// Call precompile contract
466
+ #[ inline]
441
467
fn call_precompile (
442
468
& mut self ,
443
469
precompile : Precompile ,
0 commit comments