@@ -121,8 +121,7 @@ type EVM struct {
121
121
// used throughout the execution of the tx.
122
122
interpreter * EVMInterpreter
123
123
// abort is used to abort the EVM calling operations
124
- // NOTE: must be set atomically
125
- abort int32
124
+ abort atomic.Bool
126
125
// callGasTemp holds the gas available for the current call. This is needed because the
127
126
// available gas is calculated in gasCall* according to the 63/64 rule and later
128
127
// applied in opCall*.
@@ -156,12 +155,12 @@ func (evm *EVM) Reset(txCtx TxContext, statedb StateDB) {
156
155
// Cancel cancels any running EVM operation. This may be called concurrently and
157
156
// it's safe to be called multiple times.
158
157
func (evm * EVM ) Cancel () {
159
- atomic . StoreInt32 ( & evm .abort , 1 )
158
+ evm .abort . Store ( true )
160
159
}
161
160
162
161
// Cancelled returns true if Cancel has been called
163
162
func (evm * EVM ) Cancelled () bool {
164
- return atomic . LoadInt32 ( & evm .abort ) == 1
163
+ return evm .abort . Load ()
165
164
}
166
165
167
166
// Interpreter returns the current interpreter
@@ -190,11 +189,12 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
190
189
}
191
190
snapshot := evm .StateDB .Snapshot ()
192
191
p , isPrecompile := evm .precompile (addr )
192
+ debug := evm .Config .Tracer != nil
193
193
194
194
if ! evm .StateDB .Exist (addr ) {
195
195
if ! isPrecompile && evm .chainRules .IsEIP158 && value .Sign () == 0 {
196
196
// Calling a non existing account, don't do anything, but ping the tracer
197
- if evm . Config . Debug {
197
+ if debug {
198
198
if evm .depth == 0 {
199
199
evm .Config .Tracer .CaptureStart (evm , caller .Address (), addr , false , input , gas , value )
200
200
evm .Config .Tracer .CaptureEnd (ret , 0 , 0 , nil )
@@ -210,7 +210,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
210
210
evm .Context .Transfer (evm .StateDB , caller .Address (), addr , value )
211
211
212
212
// Capture the tracer start/end events in debug mode
213
- if evm . Config . Debug {
213
+ if debug {
214
214
if evm .depth == 0 {
215
215
evm .Config .Tracer .CaptureStart (evm , caller .Address (), addr , false , input , gas , value )
216
216
@@ -281,7 +281,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
281
281
var snapshot = evm .StateDB .Snapshot ()
282
282
283
283
// Invoke tracer hooks that signal entering/exiting a call frame
284
- if evm .Config .Debug {
284
+ if evm .Config .Tracer != nil {
285
285
evm .Config .Tracer .CaptureEnter (CALLCODE , caller .Address (), addr , input , gas , value )
286
286
defer func (startGas uint64 ) {
287
287
evm .Config .Tracer .CaptureExit (ret , startGas - gas , err )
@@ -322,7 +322,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
322
322
var snapshot = evm .StateDB .Snapshot ()
323
323
324
324
// Invoke tracer hooks that signal entering/exiting a call frame
325
- if evm .Config .Debug {
325
+ if evm .Config .Tracer != nil {
326
326
evm .Config .Tracer .CaptureEnter (DELEGATECALL , caller .Address (), addr , input , gas , nil )
327
327
defer func (startGas uint64 ) {
328
328
evm .Config .Tracer .CaptureExit (ret , startGas - gas , err )
@@ -372,7 +372,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
372
372
evm .StateDB .AddBalance (addr , big0 )
373
373
374
374
// Invoke tracer hooks that signal entering/exiting a call frame
375
- if evm .Config .Debug {
375
+ if evm .Config .Tracer != nil {
376
376
evm .Config .Tracer .CaptureEnter (STATICCALL , caller .Address (), addr , input , gas , nil )
377
377
defer func (startGas uint64 ) {
378
378
evm .Config .Tracer .CaptureExit (ret , startGas - gas , err )
@@ -456,7 +456,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
456
456
contract := NewContract (caller , AccountRef (address ), value , gas )
457
457
contract .SetCodeOptionalHash (& address , codeAndHash )
458
458
459
- if evm .Config .Debug {
459
+ if evm .Config .Tracer != nil {
460
460
if evm .depth == 0 {
461
461
evm .Config .Tracer .CaptureStart (evm , caller .Address (), address , true , codeAndHash .code , gas , value )
462
462
} else {
@@ -500,7 +500,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
500
500
}
501
501
}
502
502
503
- if evm .Config .Debug {
503
+ if evm .Config .Tracer != nil {
504
504
if evm .depth == 0 {
505
505
evm .Config .Tracer .CaptureEnd (ret , gas - contract .Gas , time .Since (start ), err )
506
506
} else {
0 commit comments