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

Tracer doesn't detect out-of-gas errors #3394

Closed
JackHamer09 opened this issue Dec 17, 2024 · 1 comment · Fixed by #3469
Closed

Tracer doesn't detect out-of-gas errors #3394

JackHamer09 opened this issue Dec 17, 2024 · 1 comment · Fixed by #3469
Assignees
Labels
bug Something isn't working

Comments

@JackHamer09
Copy link
Member

🐛 Bug Report

📝 Description

When making debug_traceBlockByNumber RPC request for transactions that failed with out-of-gas error response would not include anything in the error field.

🔄 Reproduction Steps

curl 'https://mainnet.era.zksync.io' \
  --header 'Content-Type: application/json' \
  --request POST \
  --data-raw '{
    "id": 0,
    "method": "debug_traceTransaction",
    "params": [
      "0x1d55f591f2dec2db4ede9dfdf1e921c38f315daeddfc5f4f690ab13c1fa0cc72",
      {
        "tracer": "flatCallTracer",
        "timeout": "160s"
      }
    ],
    "jsonrpc": "2.0"
  }'

Example transactions:
Block 2558830 -> Tx: 0x1d55f591f2dec2db4ede9dfdf1e921c38f315daeddfc5f4f690ab13c1fa0cc72 (example listed above)
Block 2637427 -> Tx: 0xacb4bb951661950a9cb0df04f3e5ce8dce37c98a684924a07e1bab5f118202c8
Block 2610752 -> Tx: 0x38822e3ef0298e9131790333356986d5051784861e43e602da5a9b97b8c66118
Block 2579103 -> Tx: 0x45634aa7756181707f1b8e6ef6404069c4f2c4506f20466ed637850a113237ab
Block 2642447 -> Tx: 0x94fc982c4c2fb8146912f15a362bb5292e8094a77ec68c6be243e5861cec2321

🤔 Expected Behavior

error field includes error message

😯 Current Behavior

In the response error field would be null.

🖥️ Environment

Mainnet

📋 Additional Context

Github Discussion report - zkSync-Community-Hub/zksync-developers#836

📎 Log Output

{
    "jsonrpc": "2.0",
    "id": 0,
    "result": [{
        "action": {
            "callType": "call",
            "from": "0x0000000000000000000000000000000000000000",
            "gas": "0x1063d5",
            "input": "0xdb6b5246",
            "to": "0x0000000000000000000000000000000000008001",
            "value": "0x470de4df8200000"
        },
        "blockHash": "0x4b8268fa115a5835c6cb7f9e57316feff422ca478d6d7f89fcc34b4e0068bd3f",
        "blockNumber": 2558830,
        "error": null,
        "result": {
            "gasUsed": "0x1063c9",
            "output": "0x"
        },
        "subtraces": 17,
        "traceAddress": [1],
        "transactionHash": "0x1d55f591f2dec2db4ede9dfdf1e921c38f315daeddfc5f4f690ab13c1fa0cc72",
        "transactionPosition": 1,
        "type": "call"
    }]
}
@JackHamer09 JackHamer09 added the bug Something isn't working label Dec 17, 2024
@dutterbutter dutterbutter self-assigned this Jan 7, 2025
@dutterbutter
Copy link
Contributor

hmmmm...

Investigating this it seems that the issue is only for out of gas errors from very early protocol versions. Testing locally against main and submitting out of gas transactions successfully pick up the error in the debug tracer as expected (e.g. "error":"Error function_selector = 0x, data = 0x")

Will continue to investigate a potential resolution here but the issue does not seem to be present on current API. Example of an out of gas error that is picked up by debug tracer from a recent tx:

curl --request POST \
  --url https://mainnet.era.zksync.io/ \
  --header 'Content-Type: application/json' \
  --data '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "debug_traceTransaction",
      "params": ["0x4bd364235671022969672f64a6f655f1b05b339cbdd37383d996397b2846b0a2",
      {
        "tracer": "flatCallTracer",
        "timeout": "160s"
      }]
    }'

Response:

{"jsonrpc":"2.0","result":[{"action":{"callType":"call","from":"0x0000000000000000000000000000000000000000","gas":"0x76b38","input":"0x7aaa90e1000000000000000000000000000000000000000000000000000000000000009e0000000000000000000000000000000000000000000000d8226d9f2679b27bdb","to":"0x0000000000000000000000000000000000008001","value":"0x0"},"blockHash":"0xb97f01f2b5a047aac228f2c0140b8357a05a838f8c171374c60b7777d521f4fe","blockNumber":53589848,"error":"Error function_selector = 0x, data = 0x","result":null,"subtraces":1,"traceAddress":[0],"transactionHash":"0x4bd364235671022969672f64a6f655f1b05b339cbdd37383d996397b2846b0a2",
...
}

github-merge-queue bot pushed a commit that referenced this issue Jan 14, 2025
(hopefully) fixes #3394
See the issue for the context.

Looks like some old transactions do not have error stored for out-of-gas
errors. However, we know that they're failed, and we know that based on
[the error field from the transactions
table](https://github.com/matter-labs/zksync-era/blob/main/core/lib/dal/src/models/storage_transaction.rs#L361).

This PR adds a "fallback" error -- if no other error is detected in the
call trace, we use the error from the sequencer.

Granted, I do not have access to the mainnet DB, so not sure what error
messages are inside, but if I am to guess, it will be more or less
adequate. 😅

⚠️ To make things spicier, I have no way to test this functionality (per
@dutterbutter report in the issue, it does not reproduce with the
current protocol version), so it's kind of "hope it helps" fix. Please
be careful during the review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants