-
Notifications
You must be signed in to change notification settings - Fork 314
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
Reorder status codes #23
Conversation
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.
Looks good, I think the new order makes more sense.
include/evmc.h
Outdated
* Tried to read outside memory bounds. | ||
* | ||
* An example is RETURNDATACOPY reading past the available buffer. | ||
*/ | ||
EVMC_INVALID_MEMORY_ACCESS = 10, |
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.
I think this should come before static mode
.
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.
Why?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No comment on this nice ordered list? 😉
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.
I did it this way...
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.
I don't think so :)
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
Reordered again then.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should mention the special REJECTED
here I think.
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.
Mentioned.
include/evmc.h
Outdated
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for swapping these two?
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.
The generic first, the specific after.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
include/evmc.h
Outdated
* (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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
Added.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still has the typo (exceded
vs. exceeded
).
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both limits for stack and call depth are 1024 and have never changed.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will leave it for another time...
*/ | ||
EVMC_INVALID_MEMORY_ACCESS = 9, | ||
|
||
/** Call depth has exceeded the limit (if any) */ |
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.
Was the call depth limit, also 1024?
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.
English looks good to me!
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.