zksync-era: Unexpected `Panic` Error and Increased Gas Consumption in zkSync Era Transactions

πŸ› Bug Report:

πŸ“ Description

I’m encountering two main issues with transactions on the zkSync Era mainnet.

First, some transactions exit with a Panic error such as this transaction, even though they have been allocated sufficient gas for execution. This error occurs under conditions that do not traditionally indicate an out-of-gas situation, as the gas used is significantly below the gas limit specified. Regarding this issue more detail is provided under Additional Context. NOTE: the aforementioned transaction and the 2 transactions mentioned below perform essentially the same operations(with slightly different state that shouldn’t significantly change the gas requirement).

Secondly, there’s a noticeable increase in gas consumption for transactions that execute essentially the same logic(which can be verified by observing similar call traces), observed over a span of 4 weeks, without any apparent changes to the transaction logic or smart contract code or state changes to warrant such a drastic increase in gas cost.

πŸ”„ Reproduction Steps

  1. Execute a transaction similar to the provided example.
  2. Use the debug_traceTransaction method to analyze the transaction.
  3. Observe the Panic error in the debug trace and compare gas consumption with similar transactions over time.

πŸ€” Expected Behavior

Transactions with sufficient gas limits should not exit prematurely with a Panic error. Similarly, transactions executing the same logic and interacting with the same contracts should have consistent gas consumption, allowing for minor fluctuations.

😯 Current Behavior

  • Transactions are exiting with a Panic error, despite having sufficient gas allocated.
  • A significant, unexplained increase in gas consumption for similar transactions has been observed over a relatively short period.

πŸ–₯️ Environment

  • zkSync Era Mainnet
  • Transactions observed over the last 4 weeks.

πŸ“‹ Additional Context

The issue was identified through the analysis of transaction outcomes and gas consumption patterns. The Panic error was specifically observed in a transaction debug trace, indicating an unexpected termination of the transaction execution.

πŸ“Ž Log Output

{
    "jsonrpc": "2.0",
    "result": {
        // ...
        "calls": [
            {
                "type": "Call",
                "from": "0xf670f7fa7e55ed9816fbe2685aeb1b4e963f923d",
                "to": "0x291d9f9764c72c9ba6ff47b451a9f7885ebf9977",
                "gas": "0x106815",
                "gasUsed": "0x106815",
                "value": "0x0",
                "output": "0x",
                "input": "...",
                "error": "Panic",
                "revertReason": null,
                "calls": [
                    // ...
                 ],
                 // ...
            }
        ]
    }
}

I executed the following command to retrieve the debug trace for the transaction exhibiting the Panic error:

curl https://mainnet.era.zksync.io \
-X POST \
-H "Content-Type: application/json" \
--data '{"method":"debug_traceTransaction","params":["0xf58a6a2c2d24ec84d8db481524b7ba0b4c833812f1dc2a2f99c8d00d8efc7a3a", {"tracer": "callTracer"}], "id":1,"jsonrpc":"2.0"}'

This issue raises concerns about potential underlying problems with gas estimation or execution logic on the zkSync Era mainnet.

About this issue

  • Original URL
  • State: open
  • Created 4 months ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

Hi @mshakeg

First, some transactions exit with a Panic error such as this transaction, even though they have been allocated sufficient gas for execution.

Why do you think that there was enough gas for execution? gas_used < gas_limit is not a strong evidence as some gas is refunded.

A significant, unexplained increase in gas consumption for similar transactions has been observed over a relatively short period.

Gas per pubdata may fluctuate a lot, so this can’t hold. Please refer to https://docs.zksync.io/zk-stack/concepts/fee-mechanism.html for more details