From 948e08d55bf185e4b80ca7a10d689cbfd3f7fcdd Mon Sep 17 00:00:00 2001 From: lightclient <14004106+lightclient@users.noreply.github.com> Date: Wed, 3 Aug 2022 10:18:45 -0600 Subject: [PATCH] internal/ethapi: don't estimate gas if no limit provided in eth_createAccessList (#25467) Because the goal of eth_createAccessList is providing the caller with the largest-possible access list, it's generally not important that the gas limit used by the tracer will match the usage of the call exactly. Avoiding the gas estimation step is a performance improvement. As long as the call does not branch based on gas limit, the returned access list will be accurate. --- internal/ethapi/api.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 90322033b9..939dd69396 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1392,9 +1392,11 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH if db == nil || err != nil { return nil, 0, nil, err } - // If the gas amount is not set, extract this as it will depend on access - // lists and we'll need to reestimate every time - nogas := args.Gas == nil + // If the gas amount is not set, default to RPC gas cap. + if args.Gas == nil { + tmp := hexutil.Uint64(b.RPCGasCap()) + args.Gas = &tmp + } // Ensure any missing fields are filled, extract the recipient and input data if err := args.setDefaults(ctx, b); err != nil { @@ -1420,15 +1422,6 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH accessList := prevTracer.AccessList() log.Trace("Creating access list", "input", accessList) - // If no gas amount was specified, each unique access list needs it's own - // gas calculation. This is quite expensive, but we need to be accurate - // and it's convered by the sender only anyway. - if nogas { - args.Gas = nil - if err := args.setDefaults(ctx, b); err != nil { - return nil, 0, nil, err // shouldn't happen, just in case - } - } // Copy the original db so we don't modify it statedb := db.Copy() // Set the accesslist to the last al