diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index e032228bc..e6a656e77 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1670,6 +1670,10 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH accessList := prevTracer.AccessList() log.Trace("Creating access list", "input", accessList) + // Set the accesslist to the current iteration's access list BEFORE gas estimation + // This ensures that DoEstimateGas accounts for the intrinsic gas cost of the access list + args.AccessList = &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. @@ -1681,8 +1685,6 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH } // Copy the original db so we don't modify it statedb := db.Copy() - // Set the accesslist to the last al - args.AccessList = &accessList msg, err := args.ToMessage(b.RPCGasCap(), header.BaseFee) if err != nil { return nil, 0, nil, err