mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
This changes the internals of the EVM-JIT by dropping support for blocks (and therefor also transactions) that can exceed a 64^2-1 gas-limit. This means that the EVM-JIT can drop support for abritrary precision (*big.Int) and move to 64bit based gas calculations. For obvious reasons integer overflows have added to make sure that gas calculations such as gas for memory doesn't overflow 64bit. If the overflow check fails it throws an out-of-gas error and will halt the execution of the code.
22 lines
566 B
Go
22 lines
566 B
Go
package math
|
|
|
|
import gmath "math"
|
|
|
|
/*
|
|
* NOTE: The following methods need to be optimised using either bit checking or asm
|
|
*/
|
|
|
|
// IsMinSafe returns whether the subtraction is safe and does not overflow.
|
|
func IsSubSafe(x, y uint64) bool {
|
|
return x >= y
|
|
}
|
|
|
|
// IsAddSafe returns whether the addition is safe and does not overflow.
|
|
func IsAddSafe(x, y uint64) bool {
|
|
return y <= gmath.MaxUint64-x
|
|
}
|
|
|
|
// IsAddSafe returns whether the multiplication is safe and does not overflow.
|
|
func IsMulSafe(x, y uint64) bool {
|
|
return x == 0 || y == 0 || y <= gmath.MaxUint64/x
|
|
}
|