@@ -258,9 +258,9 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
258
258
contract .Gas -= cost
259
259
}
260
260
261
+ // All ops with a dynamic memory usage also has a dynamic gas cost.
262
+ var memorySize uint64
261
263
if operation .dynamicGas != nil {
262
- // All ops with a dynamic memory usage also has a dynamic gas cost.
263
- var memorySize uint64
264
264
// calculate the new memory size and expand the memory to fit
265
265
// the operation
266
266
// Memory check needs to be done prior to evaluating the dynamic gas portion,
@@ -291,20 +291,10 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
291
291
contract .Gas -= dynamicCost
292
292
}
293
293
294
- // Do tracing before memory expansion
295
- if debug {
296
- if in .evm .Config .Tracer .OnGasChange != nil {
297
- in .evm .Config .Tracer .OnGasChange (gasCopy , gasCopy - cost , tracing .GasChangeCallOpCode )
298
- }
299
- if in .evm .Config .Tracer .OnOpcode != nil {
300
- in .evm .Config .Tracer .OnOpcode (pc , byte (op ), gasCopy , cost , callContext , in .returnData , in .evm .depth , VMErrorFromErr (err ))
301
- logged = true
302
- }
303
- }
304
- if memorySize > 0 {
305
- mem .Resize (memorySize )
306
- }
307
- } else if debug {
294
+
295
+ }
296
+ // Do tracing before memory expansion
297
+ if debug {
308
298
if in .evm .Config .Tracer .OnGasChange != nil {
309
299
in .evm .Config .Tracer .OnGasChange (gasCopy , gasCopy - cost , tracing .GasChangeCallOpCode )
310
300
}
@@ -313,6 +303,9 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
313
303
logged = true
314
304
}
315
305
}
306
+ if memorySize > 0 {
307
+ mem .Resize (memorySize )
308
+ }
316
309
317
310
// execute the operation
318
311
res , err = operation .execute (& pc , in , callContext )
0 commit comments