Conversation
ehildenb
left a comment
There was a problem hiding this comment.
Looks good, I think the new order makes more sense.
include/evmc.h
Outdated
| * | ||
| * An example is RETURNDATACOPY reading past the available buffer. | ||
| */ | ||
| EVMC_INVALID_MEMORY_ACCESS = 10, |
There was a problem hiding this comment.
I think this should come before static mode.
There was a problem hiding this comment.
I think a logical order would be:
- invalid/unknown instructions
- invalid number of arguments for instructions
- invalid arguments (bad jump, invalid memory access)
- invalid state (static mode violation)
There was a problem hiding this comment.
No comment on this nice ordered list? 😉
There was a problem hiding this comment.
EVMC_INVALID_MEMORY_ACCESS = 9,
EVMC_CALL_DEPTH_EXCEDED = 10,
EVMC_STATIC_MODE_VIOLATION = 11,
What am I missing?
There was a problem hiding this comment.
This part:
- invalid/unknown instructions
- invalid number of arguments for instructions
- invalid arguments (bad jump)
The order now is argument count, bad jump, invalid/unknown, etc.
include/evmc.h
Outdated
| * Successful execution is represented by ::EVMC_SUCCESS having value 0. | ||
| * Positive values represent failures defined by VM specifications with generic | ||
| * ::EVMC_FAILURE code of value 1. | ||
| * Negative values represent VM internal errors and might be not recoverable. |
There was a problem hiding this comment.
Should mention the special REJECTED here I think.
| * For example, the Client tries running a code in the EVM 1.5. If the | ||
| * code is not supported there, the execution falls back to the EVM 1.0. | ||
| */ | ||
| EVMC_REJECTED = -2, |
There was a problem hiding this comment.
What is the reason for swapping these two?
There was a problem hiding this comment.
The generic first, the specific after.
There was a problem hiding this comment.
I a bit torn on this, since REJECTED is a special one and I am not sure it is an internal error. It is certainly recoverable.
There was a problem hiding this comment.
It's internal in sense it should not be passed back to the caller.
Yes, it's recoverable if the client supports it and has a backup VM. I will extend the description of evmc_status_code to mention this as suggested.
f9ecca2 to
3817ac8
Compare
| * (see e.g. ::EVMC_REJECTED), otherwise internal errors are not recoverable. | ||
| * The generic representant of errors is ::EVMC_INTERNAL_ERROR but | ||
| * an EVM implementation MAY return negative status codes that are not defined | ||
| * in the EVMC documentation. |
There was a problem hiding this comment.
Should probably leave a comment here along the lines of "should you need more error codes, please create an issue on the evmc repo to discuss" to facilitate discussion.
750b35b to
69ba561
Compare
|
I might be good to start a convention along the lines of:
this way we don't have to re-organize the entire error-code space every time we add codes. Perhaps we make them hexadecimal numbers to allow for at least 16 codes in each category. Notice that the KEVM formalization of this: https://github.com/kframework/evm-semantics/blob/typed-exceptions/network.md |
|
I don't mind categories, but I'm capable of doing good clusterization myself. If that will follow external reference I'm ok if having this here. Personally, I believe it will just look nice here, with not benefits for implementations. I'd like to keep internal errors with negative values. This way you can specify that I would also avoid hex, because the number would like different in this header (e.g. What do you think @axic? |
This seems to be a reasonable idea. I wouldn't bother too much about this, I think 0.2.0 will come soon after all these different implementers experience the first problems and we can fix it there. |
I'm a bit inclined not to overdesign it now. |
include/evmc/evmc.h
Outdated
| EVMC_INVALID_MEMORY_ACCESS = 9, | ||
|
|
||
| /** Call depth has exceeded the limit (if any) */ | ||
| EVMC_CALL_DEPTH_EXCEDED = 10, |
There was a problem hiding this comment.
This still has the typo (exceded vs. exceeded).
There was a problem hiding this comment.
Oops, I only fixed the comment.
69ba561 to
a66a89e
Compare
a66a89e to
9938b3b
Compare
|
|
||
| /** | ||
| * The execution has attempted to put more items on the EVM stack | ||
| * than the specified limit. |
There was a problem hiding this comment.
Was the EVM stack limit 1024? If it is not going to change in the future, then it may be of use to include that number here (in the comments) 😁 @chfast
There was a problem hiding this comment.
Both limits for stack and call depth are 1024 and have never changed.
There was a problem hiding this comment.
It may make sense including in the description but not in the error name. We can consider it when a hardfork is introduced changing those :)
There was a problem hiding this comment.
I will leave it for another time...
| */ | ||
| EVMC_INVALID_MEMORY_ACCESS = 9, | ||
|
|
||
| /** Call depth has exceeded the limit (if any) */ |
| * For example, the Client tries running a code in the EVM 1.5. If the | ||
| * code is not supported there, the execution falls back to the EVM 1.0. | ||
| */ | ||
| EVMC_REJECTED = -2, |
There was a problem hiding this comment.
In my opinion (for what it is worth) a more descriptive name would be EVMC_INCOMPATIBILE_VERSION or EVMC_INVALID_VERSION
There was a problem hiding this comment.
The provided example is not the only case we are using it even now. You can configure EVMJIT to jit only popular codes (measured by hit count). It will return EVMC_REJECTED if the hit count for requested code is below the threshold.
Fixes #21.