Skip to content

Commit 659b796

Browse files
lightclientcp-wjhan
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 499eecf commit 659b796

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
@@ -1561,9 +1561,11 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
15611561
if db == nil || err != nil {
15621562
return nil, 0, nil, err
15631563
}
1564-
// If the gas amount is not set, extract this as it will depend on access
1565-
// lists and we'll need to reestimate every time
1566-
nogas := args.Gas == nil
1564+
// If the gas amount is not set, default to RPC gas cap.
1565+
if args.Gas == nil {
1566+
tmp := hexutil.Uint64(b.RPCGasCap())
1567+
args.Gas = &tmp
1568+
}
15671569

15681570
// Ensure any missing fields are filled, extract the recipient and input data
15691571
if err := args.setDefaults(ctx, b); err != nil {
@@ -1589,15 +1591,6 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
15891591
accessList := prevTracer.AccessList()
15901592
log.Trace("Creating access list", "input", accessList)
15911593

1592-
// If no gas amount was specified, each unique access list needs it's own
1593-
// gas calculation. This is quite expensive, but we need to be accurate
1594-
// and it's convered by the sender only anyway.
1595-
if nogas {
1596-
args.Gas = nil
1597-
if err := args.setDefaults(ctx, b); err != nil {
1598-
return nil, 0, nil, err // shouldn't happen, just in case
1599-
}
1600-
}
16011594
// Copy the original db so we don't modify it
16021595
statedb := db.Copy()
16031596
// Set the accesslist to the last al

0 commit comments

Comments
 (0)