Exemplo n.º 1
0
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
Exemplo n.º 2
0
 def lll_compiler(lll):
     lll = optimizer.optimize(LLLnode.from_list(lll))
     byte_code = compile_lll.assembly_to_evm(compile_lll.compile_to_assembly(lll))
     t.s.tx(to=b'', data=byte_code)
Exemplo n.º 3
0
                            'mstore',
                            add(sub(data, ['mload', position_offset]),
                                ['mload', i]),
                            add(['mload',
                                 add(positions, ['mload', i])],
                                ['mload', position_offset])
                        ],
                        # ~mstore(data - positionOffset + i, ~mload(positions + i) + positionOffset)
                        ['mstore', i, sub(['mload', i], 32)],
                    ]
                ],
                [
                    'mstore',
                    sub(data, 32),
                    add(['mload', position_offset], ['mload', data_pos])
                ],
                [
                    'return',
                    sub(data, ['mload', position_offset]),
                    add(['mload', position_offset], ['mload', data_pos])
                ]
            ],
            [0]
        ]
    ]
])

rlp_decoder_lll = optimizer.optimize(rlp_decoder_lll)
rlp_decoder_bytes = compile_lll.assembly_to_evm(
    compile_lll.compile_to_assembly(rlp_decoder_lll))
    simple_factory_contract_bytecode,
)
from tests.core.contract_fixtures.PAYGAS_contract import (
    simple_forwarder_contract_lll_code,
    PAYGAS_contract_normal_lll_code,
    PAYGAS_contract_triggered_twice_lll_code,
)
from tests.core.contract_fixtures.nonce_tracking_contract import (
    nonce_tracking_lll_code,
    no_nonce_tracking_lll_code,
)

DIR = os.path.dirname(__file__)

simple_transfer_contract_bytecode = assembly_to_evm(
    compile_to_assembly(LLLnode.from_list(simple_transfer_contract_lll_code)))

CREATE2_contract_bytecode = assembly_to_evm(
    compile_to_assembly(LLLnode.from_list(CREATE2_contract_lll_code)))

CREATE2_json = {
    "simple_transfer_contract": {
        "bytecode":
        encode_hex(simple_transfer_contract_bytecode),
        "address":
        encode_hex(
            generate_CREATE2_contract_address(
                b'', simple_transfer_contract_bytecode)),
    },
    "CREATE2_contract": {
        "bytecode":