Esempio n. 1
0
def return_op(computation: ComputationAPI) -> None:
    start_position, size = computation.stack_pop_ints(2)

    computation.extend_memory(start_position, size)

    computation.output = computation.memory_read_bytes(start_position, size)
    raise Halt('RETURN')
Esempio n. 2
0
def return_op(computation: BaseComputation) -> None:
    start_position, size = computation.stack_pop(num_items=2,
                                                 type_hint=constants.UINT256)

    computation.extend_memory(start_position, size)

    computation.output = computation.memory_read_bytes(start_position, size)
    raise Halt('RETURN')
Esempio n. 3
0
def _selfdestruct(computation: ComputationAPI, beneficiary: Address) -> None:
    local_balance = computation.state.get_balance(computation.msg.storage_address)
    beneficiary_balance = computation.state.get_balance(beneficiary)

    # 1st: Transfer to beneficiary
    computation.state.set_balance(beneficiary, local_balance + beneficiary_balance)
    # 2nd: Zero the balance of the address being deleted (must come after
    # sending to beneficiary in case the contract named itself as the
    # beneficiary.
    computation.state.set_balance(computation.msg.storage_address, 0)

    computation.logger.debug2(
        "SELFDESTRUCT: %s (%s) -> %s",
        encode_hex(computation.msg.storage_address),
        local_balance,
        encode_hex(beneficiary),
    )

    # 3rd: Register the account to be deleted
    computation.register_account_for_deletion(beneficiary)
    raise Halt('SELFDESTRUCT')
Esempio n. 4
0
def stop(computation: BaseComputation) -> None:
    raise Halt('STOP')
Esempio n. 5
0
def selfdestruct(computation: BaseComputation) -> None:
    beneficiary = force_bytes_to_address(
        computation.stack_pop(type_hint=constants.BYTES))
    _selfdestruct(computation, beneficiary)
    raise Halt('SELFDESTRUCT')
Esempio n. 6
0
def stop(computation):
    raise Halt('STOP')