-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Properly handle eth-tester exception messages #2783
Properly handle eth-tester exception messages #2783
Conversation
web3/providers/eth_tester/main.py
Outdated
raw_error_msg = ( | ||
first_arg if not isinstance(first_arg, Exception) else first_arg.args[0] | ||
) | ||
reason = abi.decode(["string"], raw_error_msg[4:])[0] |
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 biggest change, since this refactor doesn't show it too well, is this line. Parentheses removed here:
["(string)"] -> ["string"]
aa194b4
to
c8dc81b
Compare
raw_error_msg = ( | ||
first_arg if not isinstance(first_arg, Exception) else first_arg.args[0] | ||
) | ||
reason = ( |
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.
Also new... if the reason is bytes, decode as string, else use the raw message. Previously, we just assumed it was bytes which is probably always true... but this is an added check.
first_arg = e.args[0] | ||
try: | ||
# sometimes eth-tester wraps an exception in another exception | ||
raw_error_msg = ( |
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 case eth-tester
isn't wrapping one exception in another... check to see if we have a wrapped exception, otherwise take the first arg as the raw error message. This was previously vaguely handled by catching an AttributeError
.
- After switching to ``abi.encode()```, ``eth-tester`` messages were not properly decoded
76724e9
to
2d65236
Compare
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 PR looks good to me. Is the wrapping something we should fix in eth-tester
? It seems less than ideal to wrap an exception in an exception, but I'm not sure why it was added in the first place.
Yeah, specifically here. I wonder if it was originally done to catch just one type of general exception from |
What was wrong?
abi.encode()
across the code base, someeth-tester
messages were not properly decoded.context:
eth-tester
wraps some exceptions in other exceptions. This parsing needs to be accounted for as it was broken when we switched frometh-abi
'sencode_single
toabi.encode
.How was it fixed?
Properly parse encoded messages from wrapped exceptions coming from
eth-tester
Todo:
Cute Animal Picture