示例#1
0
def proc_deploy_system_contract(ext, msg):
    from quarkchain.evm.messages import create_contract

    gascost = 3
    if msg.gas < gascost:
        return 0, 0, []

    data = msg.data.extract32(0)
    contract_index = data if data else 1

    try:
        target_addr, bytecode, enable_ts = _system_contracts[SystemContract(
            contract_index)]
    except (ValueError, KeyError):
        # Not a valid `SystemContract` or the dict doesn't contain its info
        return 0, 0, []

    if ext.block_timestamp < enable_ts:
        return 0, 0, []

    new_msg = vm.Message(
        msg.to,  # current special address
        b"",
        0,
        msg.gas - gascost,
        bytecode,
        msg.depth + 1,
        to_full_shard_key=msg.to_full_shard_key,
        transfer_token_id=msg.transfer_token_id,
        gas_token_id=msg.gas_token_id,
    )
    # Use predetermined contract address
    return create_contract(ext, new_msg, target_addr)
示例#2
0
def proc_deploy_system_contract(ext, msg):
    from quarkchain.evm.messages import create_contract

    gascost = 3
    if msg.gas < gascost:
        return 0, 0, []

    data = msg.data.extract32(0)
    contract_index = data if data else 1
    if contract_index not in [e.value for e in SystemContract]:
        return 0, 0, []

    target_addr, bytecode, enable_ts = _system_contracts[SystemContract(
        contract_index)]
    if ext.block_timestamp < enable_ts:
        return 0, 0, []

    new_msg = vm.Message(
        msg.to,  # current special address
        b"",
        0,
        msg.gas - gascost,
        bytecode,
        msg.depth + 1,
        to_full_shard_key=msg.to_full_shard_key,
        transfer_token_id=msg.transfer_token_id,
        gas_token_id=msg.gas_token_id,
    )
    # Use predetermined contract address
    return create_contract(ext, new_msg, target_addr)
示例#3
0
def proc_deploy_root_chain_staking_contract(ext, msg):
    from quarkchain.evm.messages import create_contract

    gascost = 3
    if msg.gas < gascost:
        return 0, 0, []

    target_addr, bytecode = _system_contracts[SystemContract.ROOT_CHAIN_POSW]
    new_msg = vm.Message(
        msg.to,  # current special address
        b"",
        0,
        msg.gas - gascost,
        bytecode,
        msg.depth + 1,
        to_full_shard_key=msg.to_full_shard_key,
        transfer_token_id=msg.transfer_token_id,
        gas_token_id=msg.gas_token_id,
    )
    # Use predetermined contract address
    return create_contract(ext, new_msg, target_addr)