Skip to content

[feat] Improve eth_estimateGas performance further using optimistic gas based on the gasUsed + gasRefunded in the first run #2426

@Unique-Divine

Description

@Unique-Divine

Inspiration: Optimistic Gas Limit Pre-Check

Geth implementation (lines 143-159 in gasestimator.go):

// There's a fairly high chance for the transaction to execute successfully
// with gasLimit set to the first execution's usedGas + gasRefund. Explicitly
// check that gas amount and use as a limit for the binary search.
optimisticGasLimit := (result.UsedGas + result.RefundedGas + params.CallStipend) * 64 / 63
if optimisticGasLimit < hi {
    failed, _, err = execute(ctx, call, opts, optimisticGasLimit)
    if err != nil {
        log.Error("Execution error in estimate gas", "err", err)
        return 0, nil, err
    }
    if failed {
        lo = optimisticGasLimit
    } else {
        hi = optimisticGasLimit
    }
}

The Ask

Implement analogous behavior for Nibiru's EstimateGas keeper method, which
powers the RPC method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    x: evmRelates to Nibiru EVM or the EVM Module

    Type

    No type

    Projects

    Status

    ✅ Completed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions