-
Notifications
You must be signed in to change notification settings - Fork 590
Description
What are you trying to do?
Gas golfing. ⛳
Use estimateGas: true to get gas estimates for a transaction that exceeds the AVM maximum processable gas (6M L2 gas). The simulation should return the estimated gas used so I can see how much gas the tx needs and decide what to change, but it throws instead.
Code Reference
const result = await contract.methods .heavyFunction(...) .simulate({ from: sender.address, fee: { estimateGas: true, estimatedGasPadding: 0.1 }, }); // Throws "Transaction consumes more gas than the AVM maximum processable gas" // instead of returning estimatedGas with the actual values
Root cause in yarn-project/aztec.js/src/contract/get_gas_limits.ts:
if (gasLimits.l2Gas > AVM_MAX_PROCESSABLE_L2_GAS) { throw new Error('Transaction consumes more gas than the AVM maximum processable gas'); }
simulationResult.gasUsed is available here but is not included in the error or returned.
Aztec Version
v4.0.0
OS
No response
Browser (if relevant)
No response
Node Version
No response
Additional Context
Simulation uses GAS_ESTIMATION_L2_GAS_LIMIT (12M), so it can finish even when gas use is above the AVM cap. The limit is enforced only in getGasLimits() after simulation.
Expected options: (1) Return the estimated gas with a flag like exceedsAvmMax: true, or (2) At least include the actual gas values in the error, e.g.: "Transaction consumes 7,200,000 L2 gas, which exceeds the AVM maximum processable gas of 6,000,000."
That would make it clearer how much the tx exceeds the limit and how to simplify it.