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

Inconsistent Handling of Revert Data in Error Objects #4954

Open
web3skeptic opened this issue Feb 28, 2025 · 1 comment
Open

Inconsistent Handling of Revert Data in Error Objects #4954

web3skeptic opened this issue Feb 28, 2025 · 1 comment
Assignees
Labels
investigate Under investigation and may be a bug. next-patch Issues scheduled for the next arch release. on-deck This Enhancement or Bug is currently being worked on. v6 Issues regarding v6

Comments

@web3skeptic
Copy link

web3skeptic commented Feb 28, 2025

Ethers Version

6.13.2

Search Terms

No response

Describe the Problem

Inconsistent Handling of Revert Data in Error Objects

Description

With help of provider.on("debug") hooks, I've tracked inconsistent error object structures when transactions revert. The same transaction can sometimes return proper execution revert data and other times return "missing revert data" error without the "execution reverted" message, making it difficult to reliably extract revert reasons.

Observed Behavior

For the exact same transaction input, I sometimes receive:

  1. Case 1 (Missing "execution reverted" message):
{
    "action": "receiveEip1193Error",
    "error": {
        "code": -32603,
        "data": {
            "code": -32015,
            "message": "0xe237d92200000000000000000000000040c8e83414dca470b8bad8a46c91837b80f960a4000000000000000000000000b604ccd343cdf254e100f206d903d6975ea2950b",
            "cause": null
        },
        "payload": {
            "method": "eth_estimateGas",
            "params": [
                {
                    "value": "0x0",
                    "from": "0x40c8e83414dca470b8bad8a46c91837b80f960a4",
                    "to": "0xc12c1e50abb450d6205ea2c3fa861b3b834d13e8",
                    "data": "0x0d22d9b50000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002e00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000700000000000000000000000040c8e83414dca470b8bad8a46c91837b80f960a400000000000000000000000057928fb15ffb7303b65edc326dc4dc38150008e1000000000000000000000000742b7dbb0f1d330a83497df79075ebc778e6e698000000000000000000000000b604ccd343cdf254e100f206d903d6975ea2950b000000000000000000000000c7d3df890952a327af94d5ba6fdc1bf145188a1b000000000000000000000000dca9d42a96ecf8ede1e6920bec08870bba69600e000000000000000000000000e8fc7a2d0573e5164597b05f14fa9a7fca7b215c000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030728cbce638c900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000030728cbce638c900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000db04426ea7dc73700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000db04426ea7dc737000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e0000000000040001000400030002000300050001000400060002000600050000"
                }
            ]
        }
    }
}
  1. Case 2 (Proper error structure):
{
    "action": "receiveEip1193Error",
    "error": {
        "code": -32603,
        "data": {
            "code": 3,
            "message": "execution reverted",
            "data": "0xe237d92200000000000000000000000040c8e83414dca470b8bad8a46c91837b80f960a4000000000000000000000000b604ccd343cdf254e100f206d903d6975ea2950b",
            "cause": null
        },
        "payload": {
            "method": "eth_estimateGas",
            "params": [
                {
                    "value": "0x0",
                    "from": "0x40c8e83414dca470b8bad8a46c91837b80f960a4",
                    "to": "0xc12c1e50abb450d6205ea2c3fa861b3b834d13e8",
                    "data": "0x0d22d9b50000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002e00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000700000000000000000000000040c8e83414dca470b8bad8a46c91837b80f960a400000000000000000000000057928fb15ffb7303b65edc326dc4dc38150008e1000000000000000000000000742b7dbb0f1d330a83497df79075ebc778e6e698000000000000000000000000b604ccd343cdf254e100f206d903d6975ea2950b000000000000000000000000c7d3df890952a327af94d5ba6fdc1bf145188a1b000000000000000000000000dca9d42a96ecf8ede1e6920bec08870bba69600e000000000000000000000000e8fc7a2d0573e5164597b05f14fa9a7fca7b215c000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030728cbce638c900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000030728cbce638c900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000db04426ea7dc73700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000db04426ea7dc737000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e0000000000040001000400030002000300050001000400060002000600050000"
                }
            ]
        }
    }
}

Key Differences

Property Case 1 (Problematic) Case 2 (Expected)
error.data.code -32015 3
error.data.message Contains raw revert data "execution reverted"
error.data.data Missing Contains raw revert data

Impact

This inconsistency makes it difficult to build reliable error handling logic, because the getBuiltinCallException function logic

let message = "missing revert data";
does not passes the message to the application level.

Environment

  • ethers.js version: 6.13.2
  • Network: GnosisChain
  • Provider type: Brwoser Metamask extension

Steps to Reproduce

  1. Set up a debug hook:
provider.on("debug", (info) => {
    console.log("DEBUG:", info);
});
  1. Attempt to create a transaction which should fail and cause the revert
const txResponse = await signer.sendTransaction(tx);
  1. The exact steps to reproduce the issue was not identified, run the same code multiple times to observe the inconsistent error structures.

Environment

Browser (Chrome, Safari, etc)

Environment (Other)

No response

@web3skeptic web3skeptic added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Feb 28, 2025
@web3skeptic web3skeptic changed the title Add Bug Title Here Inconsistent Handling of Revert Data in Error Objects Feb 28, 2025
@ricmoo
Copy link
Member

ricmoo commented Feb 28, 2025

Thanks! Yes, that makes sense to coalesce. I can add the logic to “just do it”, but would also love to test it out. If you figure out what the difference is, it would help otherwise I’ll just hammer it and hope it’s a client issue like timeout for a db read or such.

This is the entire point of the error coalescence in ethers, so I definitely want it fixed. :)

@ricmoo ricmoo added the on-deck This Enhancement or Bug is currently being worked on. label Feb 28, 2025
@ricmoo ricmoo added the next-patch Issues scheduled for the next arch release. label Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. next-patch Issues scheduled for the next arch release. on-deck This Enhancement or Bug is currently being worked on. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants