-
Notifications
You must be signed in to change notification settings - Fork 39
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
ipc-cli: on transaction/call failure, print out the revert reason and attempt to match it against known ABI errors #944
Comments
Notes from @snissn Part One According to this open ticket on the javascript (not rust) ethers repo there is a long standing issue wth error messages not properly propagating: ethers-io/ethers.js#2849 I've sanity checked that the rust ethers ipc code is doing a reasonable job at using the ethers library to reproduce error messages. Here is a code snippet I added to the subnet join command that still only prints out Simulation failed, transaction would fail with error: Revert(Bytes(0x)) let result = txn.call().await;
match result {
Ok(response) => {
println!("Simulation succeeded, transaction would succeed with output: {:?}", response);
},
Err(e) => {
println!("Simulation failed, transaction would fail with error: {:?}", e);
}
} ethers rust has a deprecation warning that indicates to use alloy or foundry: gakonst/ethers-rs#2667 Part Two
and there is a transaction failure the ethers-rs error handling library ends up losing track of the error message when it calls error.into() in this line: if i make the following diff on the line that loses the error message I correctly get the error message we are expecting:
outputs the following:
|
From @raulk
I would approach it this way:
First, I would focus on printing the JSON-RPC error as it comes through.
Right now we're swalling the JSON-RPC error string, and just printing "Contract call reverted with data". Instead, if we dump the error string the user would see the same thing that cast prints out [1].
Whatever you do here must be deep enough that it automatically applies to all JSON-RPC calls we make.
This would be a first PR.
Next, I would attempt to extract the revert reason from the error string and match it against all ABIs we have.
Unfortunately, the errors are split across a number of contract bindings.
For example, errors for the GatewayManagerFacet are in this generated file: ipc/contracts/binding/src/gateway_manager_facet.rs:754, under enum GatewayManagerFacetErrors.
You can use the decode() method to decode from bytes into a higher type.
It's extremely impractical to check against all error structs of all contracts, so I think this will require some codegen logic in ipc/contracts/binding/build.rs + some macros.
I think this is too complex (especially because you're only getting started with the Rust side of things) and it'll probably be a timesink at the moment.
Let's punt it to later.
[1]:
The text was updated successfully, but these errors were encountered: