Skip to content
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

AbiCoder: decode revert errors #596

Closed
sohkai opened this issue Sep 1, 2019 · 5 comments
Closed

AbiCoder: decode revert errors #596

sohkai opened this issue Sep 1, 2019 · 5 comments
Labels
discussion Questions, feedback and general information.

Comments

@sohkai
Copy link

sohkai commented Sep 1, 2019

Related to #368, web3/web3.js#1707.

Even though transaction receipts do not give us revert error strings, eth_calls do, and it would be nice if the AbiCoder knew how to decode them (and likely, throw an error with the string).

In particular, there was a situation where I wanted to query a contract for boolean value. Some times, this check reverts (perhaps the contract is not completely done being set up yet), but ethers' AbiCoder takes the 0x08c379a0...<revert string> result from the eth_call and says, yes, that's a boolean (and a true one at that!).

@ricmoo
Copy link
Member

ricmoo commented Sep 1, 2019

This shouldn’t be handled by the ABI library, but by the Contract library (which performs the eth_call). The ABI library cannot know what the underlying data represents. The result of the call will be a bytes of length congruent to 4 mod 32, and the ABI coder doesn’t work with signature prefixed data.

Is the contract using the standard “Error(string)” for its revert? If so, you should have got a CALL_REVERT error with the error message already parsed. How are you calling the contract?

@ricmoo ricmoo added the discussion Questions, feedback and general information. label Sep 1, 2019
@sohkai
Copy link
Author

sohkai commented Sep 2, 2019

Is the contract using the standard “Error(string)” for its revert?

Yes.

If so, you should have got a CALL_REVERT error with the error message already parsed. How are you calling the contract?

I'm using [email protected], so then the problem may lie there. web3's contract module just passes the output data into ethers' AbiCoder for output, but perhaps it should first detect and decode these errors before trying to abi decode the output?

@ricmoo
Copy link
Member

ricmoo commented Oct 19, 2019

Yes, the Web3 caller should detect that the return value has a length congruent to 4 modulo 32, which indicates it is an error condition (with the leading 4-bytes indicating the error signature).

Pinging @nivida; is this still a problem? I know you've been fixing a bunch of things. :)

@nivida
Copy link

nivida commented Oct 19, 2019

@ricmoo
We haven't implemented the revert handling at all in web3.js. I will prioritize this open task higher.

Btw.: 1.2.1 is also not using the latest version of the AbiCoder but it's on our todo list (we have to update all the ABI related test cases and some utility functions (adding of the correct padding)).

@ricmoo
Copy link
Member

ricmoo commented Nov 20, 2019

I'm going to close this now, as it isn't related to ethers, I don't believe. But please feel free to re-open. :)

Thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Questions, feedback and general information.
Projects
None yet
Development

No branches or pull requests

3 participants