@@ -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,
@@ -290,21 +290,10 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
290
290
} else {
291
291
contract .Gas -= dynamicCost
292
292
}
293
+ }
293
294
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 {
295
+ // Do tracing before potential memory expansion
296
+ if debug {
308
297
if in .evm .Config .Tracer .OnGasChange != nil {
309
298
in .evm .Config .Tracer .OnGasChange (gasCopy , gasCopy - cost , tracing .GasChangeCallOpCode )
310
299
}
@@ -313,6 +302,9 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
313
302
logged = true
314
303
}
315
304
}
305
+ if memorySize > 0 {
306
+ mem .Resize (memorySize )
307
+ }
316
308
317
309
// execute the operation
318
310
res , err = operation .execute (& pc , in , callContext )
0 commit comments