consensus-shipyard / ipc

🌳 Spawn multi-level trees of customized, scalable, EVM-compatible networks with IPC. L2++ powered by FVM, Wasm, libp2p, IPFS/IPLD, and CometBFT.
https://ipc.space
Apache License 2.0
44 stars 39 forks source link

Improve Error Handling in IPC CLI #1155

Open karlem opened 1 month ago

karlem commented 1 month ago

Some contract calls revert with specific errors. For instance, trying to join a subnet as a collateral validator in federated mode fails with revert MethodNotAllowed(ERR_PERMISSIONED_AND_BOOTSTRAPPED). The CLI should parse these errors and report the reason back to the user.

cryptoAtwill commented 1 month ago

We've had this discussion before. The issue is the ethers-rs somehow does not expose the revert error to ipc-cli, from the tests we did before.

karlem commented 1 month ago

@cryptoAtwill I can have a look.

karlem commented 1 month ago

The issue is that the Calibration net does not return the revert data in the JSON RPC response. Not in the ethers-rs library. Though the error is inside the message field in the response and can be parsed. Suggested solution:

  1. Look at what ethers-rs does internally to turn the value in "data" to a human readable error, and see if the same "interpretation" API is available publicly. Then we could handle this case by extracting the error data from the message string, and calling that API.
  2. See if you can attach a middleware to intercept the response and massage it into what ethers expects.