ethapi, vm: detect and return error on eth_call when call times out, fixes #19186

This commit is contained in:
Martin Holst Swende 2019-06-19 12:44:20 +02:00
parent 96f8be36ad
commit f3bfaaf967
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
2 changed files with 9 additions and 0 deletions

View file

@ -169,6 +169,11 @@ func (evm *EVM) Cancel() {
atomic.StoreInt32(&evm.abort, 1)
}
// Cancelled returns true if Cancel has been called
func (evm *EVM) Cancelled() bool {
return atomic.LoadInt32(&evm.abort) == 1
}
// Interpreter returns the current interpreter
func (evm *EVM) Interpreter() Interpreter {
return evm.interpreter

View file

@ -802,6 +802,10 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNr rpc.BlockNumb
if err := vmError(); err != nil {
return nil, 0, false, err
}
// If the timer caused an abort, return an appropriate error message
if evm.Cancelled() {
return nil, 0, false, fmt.Errorf("execution aborted (timeout = %v)", timeout)
}
return res, gas, failed, err
}