@@ -1166,10 +1166,33 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
1166
1166
// Retrieve the precompiles since they don't need to be added to the access list
1167
1167
precompiles := vm .ActivePrecompiles (b .ChainConfig ().Rules (header .Number , isPostMerge , header .Time ))
1168
1168
1169
+ // addressesToExclude contains sender, receiver, precompiles and valid authorizations
1170
+ addressesToExclude := map [common.Address ]struct {}{args .from (): {}, to : {}}
1171
+ for _ , addr := range precompiles {
1172
+ addressesToExclude [addr ] = struct {}{}
1173
+ }
1174
+
1175
+ // Prevent redundant operations if args contain more authorizations than EVM may handle
1176
+ maxAuthorizations := uint64 (* args .Gas ) / params .CallNewAccountGas
1177
+ if uint64 (len (args .AuthorizationList )) > maxAuthorizations {
1178
+ return nil , 0 , nil , errors .New ("insufficient gas to process all authorizations" )
1179
+ }
1180
+
1181
+ for _ , auth := range args .AuthorizationList {
1182
+ // Duplicating stateTransition.validateAuthorization() logic
1183
+ if (! auth .ChainID .IsZero () && auth .ChainID .CmpBig (b .ChainConfig ().ChainID ) != 0 ) || auth .Nonce + 1 < auth .Nonce {
1184
+ continue
1185
+ }
1186
+
1187
+ if authority , err := auth .Authority (); err == nil {
1188
+ addressesToExclude [authority ] = struct {}{}
1189
+ }
1190
+ }
1191
+
1169
1192
// Create an initial tracer
1170
- prevTracer := logger .NewAccessListTracer (nil , args . from (), to , precompiles )
1193
+ prevTracer := logger .NewAccessListTracer (nil , addressesToExclude )
1171
1194
if args .AccessList != nil {
1172
- prevTracer = logger .NewAccessListTracer (* args .AccessList , args . from (), to , precompiles )
1195
+ prevTracer = logger .NewAccessListTracer (* args .AccessList , addressesToExclude )
1173
1196
}
1174
1197
for {
1175
1198
if err := ctx .Err (); err != nil {
@@ -1186,7 +1209,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
1186
1209
msg := args .ToMessage (header .BaseFee , true , true )
1187
1210
1188
1211
// Apply the transaction with the access list tracer
1189
- tracer := logger .NewAccessListTracer (accessList , args . from (), to , precompiles )
1212
+ tracer := logger .NewAccessListTracer (accessList , addressesToExclude )
1190
1213
config := vm.Config {Tracer : tracer .Hooks (), NoBaseFee : true }
1191
1214
evm := b .GetEVM (ctx , statedb , header , & config , nil )
1192
1215
0 commit comments