Ejemplo n.º 1
0
from quarkchain.evm import opcodes
from quarkchain.evm import vm
from quarkchain.evm.specials import specials as default_specials
from quarkchain.evm.exceptions import (
    InvalidNonce,
    InsufficientStartGas,
    UnsignedTransaction,
    BlockGasLimitReached,
    InsufficientBalance,
    InvalidTransaction,
)
from quarkchain.evm.slogging import get_logger

null_address = b"\xff" * 20

log = get_logger("eth.block")
log_tx = get_logger("eth.pb.tx")
log_msg = get_logger("eth.pb.msg")
log_state = get_logger("eth.pb.msg.state")

# contract creating transactions send to an empty address
CREATE_CONTRACT_ADDRESS = b""

# DEV OPTIONS
SKIP_MEDSTATES = False


def rp(tx, what, actual, target):
    return "%r: %r actual:%r target:%r" % (tx, what, actual, target)

Ejemplo n.º 2
0
import argparse
import sys
from fractions import Fraction

from quarkchain.env import DEFAULT_ENV
from quarkchain.evm.tests import new_statetest_utils, testutils

from quarkchain.evm.slogging import get_logger, configure_logging

logger = get_logger()
# customize VM log output to your needs
# hint: use 'py.test' with the '-s' option to dump logs to the console
if "--trace" in sys.argv:  # not default
    configure_logging(":trace")
    sys.argv.remove("--trace")

checker = new_statetest_utils.verify_state_test
place_to_check = "GeneralStateTests"


def test_state(filename, testname, testdata):
    logger.debug("running test:%r in %r" % (testname, filename))
    try:
        checker(testdata)
    except new_statetest_utils.EnvNotFoundException:
        pass


def exclude_func(filename, _, __):
    return (
        "stQuadraticComplexityTest" in filename
Ejemplo n.º 3
0
import logging

from quarkchain.evm.slogging import get_logger, configure_logging
"""
slogging module used by ethereum is configured via a comman-separated string,
and each named logger will receive custom level (defaults to INFO)
examples:
':info'
':info,p2p.discovery:debug'

because of the way that configure_logging() is written, we cannot call configure_logging() after cluster_config is loaded;
so the best way to configure slogging is to change SLOGGING_CONFIGURATION here
"""
SLOGGING_CONFIGURATION = ":info"
configure_logging(SLOGGING_CONFIGURATION)

if __name__ == "__main__":
    logging.basicConfig()
    log = get_logger("test")
    log.warn("miner.new_block", block_hash="abcdef123", nonce=2234231)
Ejemplo n.º 4
0
from math import ceil

from quarkchain.rlp.utils import encode_hex, ascii_chr
from quarkchain.evm import utils
from quarkchain.evm import opcodes
from quarkchain.evm.slogging import get_logger
from quarkchain.evm.utils import to_string, bytearray_to_bytestr, safe_ord

# ###### dev hack flags ###############

verify_stack_after_op = False

#  ######################################

sys.setrecursionlimit(10000)
log_log = get_logger("eth.vm.log")
log_msg = get_logger("eth.pb.msg")
log_vm_exit = get_logger("eth.vm.exit")
log_vm_op = get_logger("eth.vm.op")
log_vm_op_stack = get_logger("eth.vm.op.stack")
log_vm_op_memory = get_logger("eth.vm.op.memory")
log_vm_op_storage = get_logger("eth.vm.op.storage")

TT256 = 2 ** 256
TT256M1 = 2 ** 256 - 1
TT255 = 2 ** 255

MAX_DEPTH = 1024
PROC_CURRENT_MNT_ID = (
    b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x51\x4b\x43\x00\x01"
)
Ejemplo n.º 5
0
from rlp.sedes.binary import Binary
from rlp.utils import decode_hex, encode_hex
from quarkchain.evm import utils  # FIXME: use eth_utils
from quarkchain.evm import bloom  # FIXME: use eth_bloom
from quarkchain.evm import transactions
from quarkchain.evm import opcodes
from quarkchain.evm import vm
from quarkchain.evm.specials import specials as default_specials
from quarkchain.evm.exceptions import InvalidNonce, InsufficientStartGas, UnsignedTransaction, \
    BlockGasLimitReached, InsufficientBalance, InvalidTransaction
from quarkchain.evm.slogging import get_logger


null_address = b'\xff' * 20

log = get_logger('eth.block')
log_tx = get_logger('eth.pb.tx')
log_msg = get_logger('eth.pb.msg')
log_state = get_logger('eth.pb.msg.state')

# contract creating transactions send to an empty address
CREATE_CONTRACT_ADDRESS = b''

# DEV OPTIONS
SKIP_MEDSTATES = False


def rp(tx, what, actual, target):
    return '%r: %r actual:%r target:%r' % (tx, what, actual, target)

Ejemplo n.º 6
0
    COLOR_END,
    host_port_pubkey_to_uri,
    update_config_with_defaults,
)
from devp2p import app_helper
import rlp
from quarkchain.rlp.utils import encode_hex, decode_hex, is_integer
import gevent

try:
    import quarkchain.evm.slogging as slogging

    slogging.configure(config_string=":info,p2p.protocol:info,p2p.peer:info")
except:
    import devp2p.slogging as slogging
log = slogging.get_logger("poc_app")
"""
Spawns 1 app connecting to bootstrap node.
use poc_network.py for multiple apps in different processes.
"""


class ExampleProtocol(BaseProtocol):
    protocol_id = 1
    network_id = 0
    max_cmd_id = 1  # Actually max id is 0, but 0 is the special value.
    name = b"example"
    version = 1

    def __init__(self, peer, service):
        # required by P2PProtocol
Ejemplo n.º 7
0
import copy
from rlp.utils import encode_hex, ascii_chr
from quarkchain.evm import utils
from quarkchain.evm import opcodes
from quarkchain.evm.slogging import get_logger
from quarkchain.evm.utils import to_string, bytearray_to_bytestr, safe_ord
from functools import lru_cache

# ###### dev hack flags ###############

verify_stack_after_op = False

#  ######################################

sys.setrecursionlimit(10000)
log_log = get_logger('eth.vm.log')
log_msg = get_logger('eth.pb.msg')
log_vm_exit = get_logger('eth.vm.exit')
log_vm_op = get_logger('eth.vm.op')
log_vm_op_stack = get_logger('eth.vm.op.stack')
log_vm_op_memory = get_logger('eth.vm.op.memory')
log_vm_op_storage = get_logger('eth.vm.op.storage')

TT256 = 2**256
TT256M1 = 2**256 - 1
TT255 = 2**255

MAX_DEPTH = 1024


# Wrapper to store call data. This is needed because it is possible to
Ejemplo n.º 8
0
from devp2p.service import WiredService
from devp2p.crypto import privtopub as privtopub_raw, sha3
from devp2p.utils import colors, COLOR_END
from devp2p import app_helper
import rlp
from rlp.utils import encode_hex, decode_hex, is_integer
import gevent

try:
    import quarkchain.evm.slogging as slogging

    slogging.configure(config_string=":info,p2p.protocol:info,p2p.peer:info")
except:
    import devp2p.slogging as slogging

log = slogging.get_logger("my_app")
"""
based on devp2p/examples/full_app.py
Spawns 10 apps (gevent) with discovery service on different ports,
and print out their peers periodically.
"""


class ExampleProtocol(BaseProtocol):
    protocol_id = 1
    network_id = 0
    max_cmd_id = 1  # Actually max id is 0, but 0 is the special value.
    name = b"example"
    version = 1

    def __init__(self, peer, service):
Ejemplo n.º 9
0
import logging

from quarkchain.evm.slogging import get_logger, configure, configure_logging, getLogger

configure_logging(':info')

if __name__ == '__main__':
    logging.basicConfig()
    log = get_logger('test')
    log.warn('miner.new_block', block_hash='abcdef123', nonce=2234231)
Ejemplo n.º 10
0
from functools import total_ordering
import json
import os
import pbkdf2
from random import SystemRandom
import shutil
from uuid import UUID, uuid4
from Crypto.Cipher import (
    AES, )  # Crypto imports necessary for AES encryption of the private key
from Crypto.Hash import SHA256
from Crypto.Util import Counter
from quarkchain.core import Address, Identity
from quarkchain.evm.slogging import get_logger
from quarkchain.evm.utils import decode_hex, encode_hex, is_string, sha3, to_string

log = get_logger("accounts")

DEFAULT_COINBASE = decode_hex("de0b295669a9fd93d5f28d9ec85e40f4cb697bae")

random = SystemRandom()


@total_ordering
class MinType(object):
    """ Return Min value for sorting comparison

    This class is used for comparing unorderded types. e.g., NoneType
    """
    def __le__(self, other):
        return True
Ejemplo n.º 11
0
import json
import os
import pbkdf2
from random import SystemRandom
import shutil
from uuid import UUID, uuid4
from Crypto.Cipher import AES  # Crypto imports necessary for AES encryption of the private key
from Crypto.Hash import SHA256
from Crypto.Util import Counter
from devp2p.service import BaseService
from quarkchain.core import Address, Identity
from quarkchain.evm.slogging import get_logger
from quarkchain.evm.utils import privtopub  # this is different  than the one used in devp2p.crypto
from quarkchain.evm.utils import decode_hex, encode_hex, encode_int32, is_string, remove_0x_head, sha3, to_string

log = get_logger('accounts')

DEFAULT_COINBASE = decode_hex('de0b295669a9fd93d5f28d9ec85e40f4cb697bae')

random = SystemRandom()


@total_ordering
class MinType(object):
    """ Return Min value for sorting comparison

    This class is used for comparing unorderded types. e.g., NoneType
    """
    def __le__(self, other):
        return True