Skip to content

Commit fc0540d

Browse files
lightclientjagdeep sidhu
authored andcommitted
internal/ethapi: don't estimate gas if no limit provided in eth_createAccessList (ethereum#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.
1 parent 4503c83 commit fc0540d

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

internal/ethapi/api.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,9 +1392,11 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
13921392
if db == nil || err != nil {
13931393
return nil, 0, nil, err
13941394
}
1395-
// If the gas amount is not set, extract this as it will depend on access
1396-
// lists and we'll need to reestimate every time
1397-
nogas := args.Gas == nil
1395+
// If the gas amount is not set, default to RPC gas cap.
1396+
if args.Gas == nil {
1397+
tmp := hexutil.Uint64(b.RPCGasCap())
1398+
args.Gas = &tmp
1399+
}
13981400

13991401
// Ensure any missing fields are filled, extract the recipient and input data
14001402
if err := args.setDefaults(ctx, b); err != nil {
@@ -1420,15 +1422,6 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
14201422
accessList := prevTracer.AccessList()
14211423
log.Trace("Creating access list", "input", accessList)
14221424

1423-
// If no gas amount was specified, each unique access list needs it's own
1424-
// gas calculation. This is quite expensive, but we need to be accurate
1425-
// and it's convered by the sender only anyway.
1426-
if nogas {
1427-
args.Gas = nil
1428-
if err := args.setDefaults(ctx, b); err != nil {
1429-
return nil, 0, nil, err // shouldn't happen, just in case
1430-
}
1431-
}
14321425
// Copy the original db so we don't modify it
14331426
statedb := db.Copy()
14341427
// Set the accesslist to the last al

0 commit comments

Comments
 (0)