Skip to content

Commit f578d41

Browse files
holimankaralabe
authored andcommitted
core/vm, internal/ethapi: fail on eth_call when it times out, fixes #19186 (#19737)
1 parent cdadf57 commit f578d41

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎core/vm/evm.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ func (evm *EVM) Cancel() {
169169
atomic.StoreInt32(&evm.abort, 1)
170170
}
171171

172+
// Cancelled returns true if Cancel has been called
173+
func (evm *EVM) Cancelled() bool {
174+
return atomic.LoadInt32(&evm.abort) == 1
175+
}
176+
172177
// Interpreter returns the current interpreter
173178
func (evm *EVM) Interpreter() Interpreter {
174179
return evm.interpreter

‎internal/ethapi/api.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,10 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNr rpc.BlockNumb
802802
if err := vmError(); err != nil {
803803
return nil, 0, false, err
804804
}
805+
// If the timer caused an abort, return an appropriate error message
806+
if evm.Cancelled() {
807+
return nil, 0, false, fmt.Errorf("execution aborted (timeout = %v)", timeout)
808+
}
805809
return res, gas, failed, err
806810
}
807811

0 commit comments

Comments
 (0)