internal/ethapi: add a simple DoS protection to authorizations processing in eth_createAccessList

This commit is contained in:
sashabeton 2025-03-17 20:11:22 +01:00
parent 4bcf1449d3
commit 6e18588f80

View file

@ -1171,14 +1171,18 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
addressesToExclude[addr] = struct{}{} addressesToExclude[addr] = struct{}{}
} }
for _, auth := range args.AuthorizationList { // Prevent redundant operations if args contain more authorizations than EVM may handle
// Duplicating stateTransition.validateAuthorization() logic maxAuthorizations := uint64(*args.Gas) / params.TxAuthTupleGas
if (!auth.ChainID.IsZero() && auth.ChainID.CmpBig(b.ChainConfig().ChainID) != 0) || auth.Nonce+1 < auth.Nonce { if uint64(len(args.AuthorizationList)) <= maxAuthorizations {
continue for _, auth := range args.AuthorizationList {
} // Duplicating stateTransition.validateAuthorization() logic
if (!auth.ChainID.IsZero() && auth.ChainID.CmpBig(b.ChainConfig().ChainID) != 0) || auth.Nonce+1 < auth.Nonce {
continue
}
if authority, err := auth.Authority(); err == nil { if authority, err := auth.Authority(); err == nil {
addressesToExclude[authority] = struct{}{} addressesToExclude[authority] = struct{}{}
}
} }
} }