Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FEATURE] return estimated gas when estimateGas: true throws "over limit" #20621

Open
Labels
T-bugType: Bug. Something is broken. from-communityThis originated from the community :)
@wei3erHase

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-bugType: Bug. Something is broken. from-communityThis originated from the community :)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /