mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
internal/ethapi: add a simple DoS protection to authorizations processing in eth_createAccessList
This commit is contained in:
parent
4bcf1449d3
commit
6e18588f80
1 changed files with 11 additions and 7 deletions
|
|
@ -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{}{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue