Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Support Solidity panic codes in the RuntimeError class #758

Open
axic opened this issue Jan 29, 2021 · 11 comments
Open

Support Solidity panic codes in the RuntimeError class #758

axic opened this issue Jan 29, 2021 · 11 comments

Comments

@axic
Copy link
Contributor

axic commented Jan 29, 2021

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 of Panic(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.

@axic
Copy link
Contributor Author

axic commented Jun 17, 2021

Since 0.8.4 there are also custom errors (with their own selector), fitting the same architecture. Supporting both would be nice.

@frangio
Copy link

frangio commented Jun 22, 2021

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.

@frangio
Copy link

frangio commented Feb 9, 2022

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.

@davidmurdoch
Copy link
Member

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.

@frangio
Copy link

frangio commented Feb 10, 2022

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.

@haltman-at
Copy link
Contributor

haltman-at commented Feb 10, 2022

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. :)

@frangio
Copy link

frangio commented Feb 10, 2022

Yes, I was talking about Truffle Contract, specifically about the Error that is thrown when the contract reverts with a custom error.

@davidmurdoch
Copy link
Member

@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)

@haltman-at
Copy link
Contributor

haltman-at commented Feb 10, 2022

There's actually something of an open issue for this already, actually: trufflesuite/truffle#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?

@davidmurdoch
Copy link
Member

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.

@haltman-at
Copy link
Contributor

FWIW, here's the Solidity documentation of the panic codes, and here's the table of panic codes that the debugger uses for interpreting them. :) (And which Truffle Contract would presumably also use if we added support for that there...)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Backlog
Development

No branches or pull requests

5 participants