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.
- Comparative Analysis of Gas Consumption:
- Transaction from 4 weeks ago: 0xe55eb635aef7e4b2ba4241fdb9ddea7ed341dd2f959d708f1c65e35a3dd4a169
- More Recent Transaction: 0x2e6d0b8ff88c1e528644f90ef2bd63c13e7a02921264991bcecd87c4fddb18c0
- Observation: The gas consumption for the recent transaction increased significantly to almost 7M gas from just over 4M gas for an earlier transaction performing similar logic. This change occurred without apparent alterations in the transaction logic or smart contract code that could justify such an increase.
π Reproduction Steps
- Execute a transaction similar to the provided example.
- Use the
debug_traceTransaction
method to analyze the transaction. - 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)
Hi @mshakeg
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.
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