Skip to content

Commit 08674f6

Browse files
committed
eth/vm/logic/arithmetic: handle exp(X,0) == 1.
Caught by `exp8.json` test (not yet tracked in tests fixture). Ref: https://github.com/ethereum/tests/blob/10ab37c095bb87d2e781bcf112b6104912fccb44/VMTests/vmArithmeticTest/exp8.json Accidentally caught in PR ethereum#1181.
1 parent fcf73d0 commit 08674f6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

eth/vm/logic/arithmetic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ def exp(computation, gas_per_byte):
147147
bit_size = exponent.bit_length()
148148
byte_size = ceil8(bit_size) // 8
149149

150-
if base == 0:
150+
if exponent == 0:
151+
result = 1
152+
elif base == 0:
151153
result = 0
152154
else:
153155
result = pow(base, exponent, constants.UINT_256_CEILING)

0 commit comments

Comments
 (0)