Open axic opened 3 years ago
Since 0.8.4 there are also custom errors (with their own selector), fitting the same architecture. Supporting both would be nice.
One of the issues with custom errors and Ganache is that Ganache is completely agnostic to ABIs at the moment, so it won't be able to parse/decode them. I guess it's Web3.js that should parse them, but I'm not sure if it's possible to implement it at that level right now because I don't know if Ganache forwards the full returndata.
Bumping this. Now that Ganache v7 has been released may be a good time to revisit and think how it could be implemented. We are all eager to use custom errors but Ganache is still lacking support.
Ganache does forward the whole return data as hex on responses for eth_call.
@haltman-at does Truffle decode these? This seems like a Truffle-side thing.
If so, that's great. For Truffle that would be Web3.js, the new version of which is in development and would include support for custom errors.
Truffle Contract currently does not decode panic codes or custom errors; I was thinking that would probably wait until the Contract rewrite, although that seems to have gotten rather delayed. But we could add support for panic codes into it if people think that should happen sooner? Custom errors would be more difficult and would likely have to wait, either until the contract rewrite or until this new web3.js version.
Truffle Decoder and Truffle Debugger can handle panic codes and custom errors, of course, but I'm assuming Truffle Contract was what you were talking about. :)
Yes, I was talking about Truffle Contract, specifically about the Error
that is thrown when the contract reverts with a custom error.
@haltman-at Should we move this issue to the truffle repo? I don't think there is anything useful Ganache can do, right? (since we return the raw revert hex string already)
There's actually something of an open issue for this already, actually: https://github.com/trufflesuite/truffle/issues/3873. It got marked not very high priority because custom errors are hard and we'll handle them in the rewrite, right? That said, panic codes aren't that hard, and the rewrite has gotten delayed, so it might be worth re-upping that. You want to move discussion over to that?
Just realized this may be related to some changes plan to make to our eth_call error message strings that would provide additional information over what we give now. @MicaiahReid, I couldn't find an issue for the new error strings we were talking about adding; they might all map to these specific panic codes.
Here revert reasons are processed. This currently only understands the revert strings (which have a signature of
Error(string)
). It would be nice to also support panic codes (with a signature ofPanic(uint256)
).See https://docs.soliditylang.org/en/v0.8.0/control-structures.html#panic-via-assert-and-error-via-require for more information.
I think ganache should return panic codes as a numeric value for the moment.