Skip to content

Commit 07ffc25

Browse files
committed
core/vm: optimize osakaMultComplexity
1 parent 3954259 commit 07ffc25

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

core/vm/contracts.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,10 @@ func osakaMultComplexity(x uint64) uint64 {
456456
}
457457
// For x > 32, return 2 * berlinMultComplexity(x)
458458
result := berlinMultComplexity(x)
459-
carry, result := bits.Mul64(result, 2)
460-
if carry != 0 {
459+
if result >= (1 << 63) { // overflow check
461460
return math.MaxUint64
462461
}
463-
return result
462+
return result << 1
464463
}
465464

466465
// modexpIterationCount calculates the number of iterations for the modexp precompile.

0 commit comments

Comments
 (0)