Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of #3712
Excerpt from
evm/errors.ts
:This is a Proof-of-Concept (I still need to do some cycles to clean this up though) which shows that we now have two EVM error types: a
UNSUPPORTED_FEATURE
or aRUNTIME_ERROR
. In case of aRUNTIME_ERROR
, typescript now demands areason
field in the error (this could for instance be "stack overflow", "stack underflow", etc.What is nice: for the
REVERT
reason it demands arevertBytes
field, which is actually the reverted bytes in case the EVM runs into a revert (from these bytes error messages can be derived, such as solidity revert strings!).Errors now look like this:
(I had added the
error.code
field but I think we should keep it aterror.type.code
).The error handler (taken / inspired from lodestar: https://github.com/ChainSafe/lodestar/blob/unstable/packages/utils/src/errors.ts) allows to add custom error classes (see
EvmError
class in this case, can add extra constructor arguments for environment situation), and also has amessage
argument which allows for custom message strings.Note: super WIP. I am not completely satisfied yet with the results, because now EVM has a huge code bloat due to instantiating these error messages. I have to find a way to go back to the "old versions" (
trap(ERROR.OUT_OF_GAS)
) but still remaining type-safety (for the REVERT error string for instance).Note, tests will likely fail because of the updated error format.