mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
core: align overflow checks in IntrinsicGas
This commit is contained in:
parent
1321a42525
commit
c40cb1be5f
1 changed files with 16 additions and 3 deletions
|
|
@ -110,11 +110,24 @@ func IntrinsicGas(data []byte, accessList types.AccessList, authList []types.Aut
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if accessList != nil {
|
if accessList != nil {
|
||||||
gas += uint64(len(accessList)) * params.TxAccessListAddressGas
|
numItems := uint64(len(accessList))
|
||||||
gas += uint64(accessList.StorageKeys()) * params.TxAccessListStorageKeyGas
|
if (math.MaxUint64-gas)/params.TxAccessListAddressGas < numItems {
|
||||||
|
return 0, ErrGasUintOverflow
|
||||||
|
}
|
||||||
|
gas += numItems * params.TxAccessListAddressGas
|
||||||
|
|
||||||
|
numStorageKeys := uint64(accessList.StorageKeys())
|
||||||
|
if (math.MaxUint64-gas)/params.TxAccessListStorageKeyGas < numStorageKeys {
|
||||||
|
return 0, ErrGasUintOverflow
|
||||||
|
}
|
||||||
|
gas += numStorageKeys * params.TxAccessListStorageKeyGas
|
||||||
}
|
}
|
||||||
if authList != nil {
|
if authList != nil {
|
||||||
gas += uint64(len(authList)) * params.CallNewAccountGas
|
numItems := uint64(len(authList))
|
||||||
|
if (math.MaxUint64-gas)/params.CallNewAccountGas < numItems {
|
||||||
|
return 0, ErrGasUintOverflow
|
||||||
|
}
|
||||||
|
gas += numItems * params.CallNewAccountGas
|
||||||
}
|
}
|
||||||
return gas, nil
|
return gas, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue