Skip to content

Commit

Permalink
Merge pull request #452 from daejunpark/master
Browse files Browse the repository at this point in the history
fix issue #448: buggy translation of LLL operator `sha3_32`
  • Loading branch information
DavidKnott authored Nov 16, 2017
2 parents 0cbbf7a + 48301a3 commit 5bbfd13
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions tests/compiler/test_sha3_32.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest
from viper.parser.parser_utils import LLLnode
from viper import compile_lll, optimizer

def test_sha3_32():
lll = ['sha3_32', 0]
evm = ['PUSH1', 0, 'PUSH1', 192, 'MSTORE', 'PUSH1', 32, 'PUSH1', 192, 'SHA3']
assert compile_lll.compile_to_assembly(LLLnode.from_list(lll)) == evm
assert compile_lll.compile_to_assembly(optimizer.optimize(LLLnode.from_list(lll))) == evm
2 changes: 1 addition & 1 deletion viper/compile_lll.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def compile_to_assembly(code, withargs=None, break_dest=None, height=0):
# SHA3 a single value
elif code.value == 'sha3_32':
o = compile_to_assembly(code.args[0], withargs, break_dest, height)
o.extend(['PUSH1', MemoryPositions.FREE_VAR_SPACE, 'MSTORE', 'PUSH1', MemoryPositions.FREE_VAR_SPACE, 'PUSH1', 32, 'SHA3'])
o.extend(['PUSH1', MemoryPositions.FREE_VAR_SPACE, 'MSTORE', 'PUSH1', 32, 'PUSH1', MemoryPositions.FREE_VAR_SPACE, 'SHA3'])
return o
# <= operator
elif code.value == 'le':
Expand Down

0 comments on commit 5bbfd13

Please # to comment.