From 3932b1ca35543bed65d01e9755df30d67afc65ee Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 5 Sep 2025 14:33:53 +0200 Subject: [PATCH] core/vm: improve comments --- core/vm/contracts.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 70aea91ac8..c491b9fdf4 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -396,24 +396,24 @@ func byzantiumMultComplexity(x uint64) uint64 { case x <= 1024: // x^2 / 4 + 96*x - 3072 return x*x/4 + 96*x - 3072 + default: // For large x, use uint256 arithmetic to avoid overflow // x^2 / 16 + 480*x - 199680 - // xSqr = x^2 + + // xSqr = x^2 / 16 carry, xSqr := bits.Mul64(x, x) if carry != 0 { return math.MaxUint64 } - - // Calculate x^2 / 16 xSqr = xSqr >> 4 // Calculate 480 * x (can't overflow if x^2 didn't overflow) x480 := x * 480 - // Calculate 480 * x - 199680 (will not underflow, since x > 1024) x480 = x480 - 199680 + // xSqr + x480 sum, carry := bits.Add64(xSqr, x480, 0) if carry != 0 { return math.MaxUint64