-
Notifications
You must be signed in to change notification settings - Fork 20.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect and return error on eth_call on timeout #19737
Conversation
Might also close #19145 |
@@ -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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I guess there's a tiny data race here, whereby it could happen that a call finishes successfully, but then the timeout triggers before this line and a failure is returned... but that seems both improbable and not an issue (it's like winning the lottery, would have timed out for real most of the time).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I know:
This PR addresses thsi in a somewhat opportunistic way, since the timeout happens async in another goroutine. When we return from the actuall call, we check if the Cancel has been called on the evm. There is a tiny chance that the cancel was called after the execution finished correctly, but it's bettter to error on the safe side than how we do it now (and the chances of that happening are really quite slim).
Basically, the data-race is 'benevolent'. The worst that can happen is that it falsely says it was aborted, which is better than the other way around
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR fixes #19186
Problem: on
eth_call
and derivates using the same mechansm, there's a timeout that can trigger at any time. We currently do not signal this to the user, thus returning erroneous values when execution is aborted.This PR addresses thsi in a somewhat opportunistic way, since the timeout happens async in another goroutine. When we return from the actuall call, we check if the
Cancel
has been called on theevm
. There is a tiny chance that the cancel was called after the execution finished correctly, but it's bettter to error on the safe side than how we do it now (and the chances of that happening are really quite slim).Example when running this PR in
geth --dev console
, using an eternal loop (jumpdest; push 0, jump
):Without this PR: