Skip to content

Commit

Permalink
core: check for underflow
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVanDerWijden committed Feb 28, 2024
1 parent 77e89c0 commit 6bd424f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,14 @@ func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation b
if (math.MaxUint64-gas)/params.InitCodeWordGas < lenWords {
return 0, ErrGasUintOverflow
}
gasForData += lenWords * params.InitCodeWordGas
gas += lenWords * params.InitCodeWordGas
}

if isEIP7623 {
tokens := z + nz*params.TokenPerNonZeroByte7623
if (math.MaxUint64-gas-gasForData)/params.CostFloorPerToken7623 < tokens {
return 0, ErrGasUintOverflow
}
if floor := params.CostFloorPerToken7623 * tokens; gasForData < floor {
gasForData = floor
}
Expand Down

0 comments on commit 6bd424f

Please sign in to comment.