-
Notifications
You must be signed in to change notification settings - Fork 375
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
eth_call
underspecified return error message
#463
Comments
Historically, JSON-RPC errors were reserved for protocol errors and not applied to EVM execution errors. If we want to maintain this pattern, then the JSON-RPC response would be a success with something in the As to what to put in the It does seem like there needs to be some way to indicate that the result was erroneous, and prepending some ASCII text to a hex encoded byte array feels like just about the worst way to achieve this. An ideal solution, if we were building something from the ground up, would be to have the JSON-RPC This would allow clients to discriminate on the |
100% agree since it forces clients to perform prefix/regex checks.
Servers can decode information from these error messages using well defined formats (see: https://docs.soliditylang.org/en/v0.8.22/control-structures.html#revert). Still, these formats are subject to change, so I think it should be considered an optional feature, maybe by including a For a failure case, the response would look something like: {
"success": false,
"reason": "Execution Reverted",
"message": "Contract check failed", // optional on a per-client basis (not enforced by spec)
"data": "0x..."
} while on success, it would look like: {
"success": true,
"gas": "0x123456"
} |
This is a great initiative to standardise this part of the JSON-RPC spec, and has been the source of many headaches.
Just confirming on the {
"success": true,
"gas": "0x123456",
"data": "0x..."
} |
I agree it'd be good to standardize this between clients, and not only this. The way I'd approach this is to add an error code for "execution reverted" and let clients flexible on the actual wording. But agree with adding a separate field for the decoded revert message. We can take this further by defining an error code for all failures that can happen as part of EVM execution, e.g. stack over/underflow. All clients necessarily will share the same failures because this is consensus-critical code. Only their error messages could be different. Adding an error code would allow for different messages (e.g. some clients might wish to add context like opcode information). For context, this is roughly the list of all these faults: const (
VMErrorCodeOutOfGas = 1 + iota
VMErrorCodeCodeStoreOutOfGas
VMErrorCodeDepth
VMErrorCodeInsufficientBalance
VMErrorCodeContractAddressCollision
VMErrorCodeExecutionReverted
VMErrorCodeMaxInitCodeSizeExceeded
VMErrorCodeMaxCodeSizeExceeded
VMErrorCodeInvalidJump
VMErrorCodeWriteProtection
VMErrorCodeReturnDataOutOfBounds
VMErrorCodeGasUintOverflow
VMErrorCodeInvalidCode
VMErrorCodeNonceUintOverflow
VMErrorCodeStackUnderflow
VMErrorCodeStackOverflow
VMErrorCodeInvalidOpCode
) |
We potentially have the opportunity to get this "right" with If we decide to implement this in {
success: true,
data: `0x${string}`,
} | {
success: false,
error_code: Omit<Errors, RevertedError>,
message: string,
} | {
success: false,
error_code: RevertedError,
message: string,
data?: `0x${string}`,
} In the success case, we would just include whatever the call returndata was. In the failure case, we would have an My preference would be to have the Note: The list provided by @s1na above doesn't include all possible per-transaction errors, like invalid signature and contract-caller. For |
I'm 100% on board with this, but would ask that we "objectize" success and revert rather than keying off the boolean success value to decide what fields are valid. So a successful call would have a {
// standard JSONRPC id etc elided
"result": {
"success": {
"data": "0x..",
"gas": "0x.."
}
}
} While a failed call would contain a {
// standard JSONRPC id etc elided
"result" {
"revert": {
"code": ...
"reason": ...
}
} (I'm not advocating for any specific keys in the This allows much cleaner schemas (both in the OpenRPC spec and in client and user code) since edit: and in the case of |
Recently, this problem has come up in go-ethereum issues several times. I would like to propose that we extend the spec to make error code We've been handling reverts like this in Geth for a good while, and it gives users all the information they could want. |
We discussed this topic on ACD today, and there was weakly positive feedback to PR #600, which adds error code 3 into the spec. |
Here I'm adding a new helper function that extracts the revert reason of a contract call. Unfortunately, this aspect of the API is underspecified. See these spec issues for more detail: - ethereum/execution-apis#232 - ethereum/execution-apis#463 - ethereum/execution-apis#523 The function added here only works with Geth-like servers that return error code `3`. We will not be able to support all possible servers. However, if there is a specific server implementation that makes it possible to extract the same info, we could add it in the same function as well. --------- Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Here I'm adding a new helper function that extracts the revert reason of a contract call. Unfortunately, this aspect of the API is underspecified. See these spec issues for more detail: - ethereum/execution-apis#232 - ethereum/execution-apis#463 - ethereum/execution-apis#523 The function added here only works with Geth-like servers that return error code `3`. We will not be able to support all possible servers. However, if there is a specific server implementation that makes it possible to extract the same info, we could add it in the same function as well. --------- Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
The
eth_call
method can result in a execution error when, for example, a contract uses arevert
operation. The current spec does not define how should the return error look like, making it hard for users to parse the execution failure cause.The following screenshot perfectly describes the current situation for users:
It would be great if all clients could agree in a single, standardized format for error messages.
The text was updated successfully, but these errors were encountered: