Skip to content

Commit

Permalink
eth/vm/logic/arithmetic: handle exp(X,0) == 1.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
veox committed Aug 28, 2018
1 parent fcf73d0 commit 08674f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion eth/vm/logic/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ def exp(computation, gas_per_byte):
bit_size = exponent.bit_length()
byte_size = ceil8(bit_size) // 8

if base == 0:
if exponent == 0:
result = 1
elif base == 0:
result = 0
else:
result = pow(base, exponent, constants.UINT_256_CEILING)
Expand Down

0 comments on commit 08674f6

Please sign in to comment.