Esempio n. 1
0
def enable_greenlet_debugger(request):
    if request.config.option.usepdb:
        from pyethapp.utils import enable_greenlet_debugger
        enable_greenlet_debugger()
Esempio n. 2
0
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--transfers', default=100, type=int)
    parser.add_argument('--nodes', default=10, type=int)
    parser.add_argument('--tokens', default=1, type=int)
    parser.add_argument('--channels-per-node', default=2, type=int)
    parser.add_argument('-p', '--profile', default=False, action='store_true')
    parser.add_argument('--pdb', default=False, action='store_true')
    parser.add_argument('--throughput',
                        dest='throughput',
                        action='store_true',
                        default=True)
    parser.add_argument('--latency', dest='throughput', action='store_false')
    parser.add_argument('--log', action='store_true', default=False)
    args = parser.parse_args()

    if args.log:
        slogging.configure(':DEBUG')

    if args.profile:
        import GreenletProfiler
        GreenletProfiler.set_clock_type('cpu')
        GreenletProfiler.start()

    tokens = [
        sha3('token:{}'.format(number))[:20] for number in range(args.tokens)
    ]

    amount = 10
    apps = setup_apps(
        amount,
        tokens,
        args.transfers,
        args.nodes,
        args.channels_per_node,
    )

    if args.pdb:
        from pyethapp.utils import enable_greenlet_debugger
        enable_greenlet_debugger()

        try:
            if args.throughput:
                test_throughput(apps, tokens, args.transfers, amount)
            else:
                test_latency(apps, tokens, args.transfers, amount)
        except:
            import pdb
            pdb.xpm()
    else:
        if args.throughput:
            test_throughput(apps, tokens, args.transfers, amount)
        else:
            test_latency(apps, tokens, args.transfers, amount)

    if args.profile:
        GreenletProfiler.stop()
        stats = GreenletProfiler.get_func_stats()
        pstats = GreenletProfiler.convert2pstats(stats)

        print_serialization(pstats)
        print_slow_path(pstats)
        print_slow_function(pstats)

        pstats.sort_stats('time').print_stats()
Esempio n. 3
0
def run(ctx, dev, nodial, fake, console):
    """Start the client ( --dev to stop on error)"""
    config = ctx.obj['config']
    if nodial:
        # config['deactivated_services'].append(PeerManager.name)
        # config['deactivated_services'].append(NodeDiscovery.name)
        config['discovery']['bootstrap_nodes'] = []
        config['discovery']['listen_port'] = 29873
        config['p2p']['listen_port'] = 29873
        config['p2p']['min_peers'] = 0

    if fake:
        from ethereum import blocks
        blocks.GENESIS_DIFFICULTY = 1024
        blocks.BLOCK_DIFF_FACTOR = 16
        blocks.MIN_GAS_LIMIT = blocks.default_config['GENESIS_GAS_LIMIT'] / 2
        config['eth']['block']['GENESIS_DIFFICULTY'] = 1024
        config['eth']['block']['BLOCK_DIFF_FACTOR'] = 16

    # create app
    app = EthApp(config)

    # development mode
    if dev:
        enable_greenlet_debugger()
        try:
            config['client_version'] += '/' + os.getlogin()
        except:
            log.warn("can't get and add login name to client_version")
            pass

    # dump config
    dump_config(config)

    # init and unlock accounts first to check coinbase
    if AccountsService in services:
        AccountsService.register_with_app(app)
        unlock_accounts(ctx.obj['unlock'],
                        app.services.accounts,
                        password=ctx.obj['password'])
        try:
            app.services.accounts.coinbase
        except ValueError as e:
            log.fatal('invalid coinbase',
                      coinbase=config.get('pow', {}).get('coinbase_hex'),
                      error=e.message)
            sys.exit()

    app.start_console = console

    # register services
    contrib_services = load_contrib_services(config)

    for service in services + contrib_services:
        assert issubclass(service, BaseService)
        if service.name not in app.config['deactivated_services'] + [
                AccountsService.name
        ]:
            assert service.name not in app.services
            service.register_with_app(app)
            assert hasattr(app.services, service.name)

    # start app
    log.info('starting')
    app.start()

    if ctx.obj['log_file']:
        log.info("Logging to file %s", ctx.obj['log_file'])
        # User requested file logging - remove stderr handler
        root_logger = slogging.getLogger()
        for hndlr in root_logger.handlers:
            if isinstance(hndlr, StreamHandler) and hndlr.stream == sys.stderr:
                root_logger.removeHandler(hndlr)
                break

    if config['post_app_start_callback'] is not None:
        config['post_app_start_callback'](app)

    # wait for interrupt
    evt = Event()
    gevent.signal(signal.SIGQUIT, evt.set)
    gevent.signal(signal.SIGTERM, evt.set)
    evt.wait()

    # finally stop
    app.stop()
Esempio n. 4
0
import gevent.monkey

from ethereum import slogging

from raiden.tests.utils.transfer import direct_transfer, mediated_transfer

# Monkey patch subprocess.Popen used by solidity wrapper
gevent.monkey.patch_socket()
slogging.configure(
    ':ERROR'
    ',eth.chain.tx:DEBUG'
    ',jsonrpc:DEBUG'
    ',eth.vm:TRACE,eth.pb.tx:TRACE,eth.pb.msg:TRACE,eth.pb.msg.state:TRACE')

from pyethapp.utils import enable_greenlet_debugger
enable_greenlet_debugger()


@pytest.mark.parametrize('privatekey_seed', ['fullnetwork:{}'])
@pytest.mark.parametrize('number_of_nodes', [3])
@pytest.mark.parametrize('channels_per_node', [2])
@pytest.mark.parametrize('deposit', [2**20])
def test_fullnetwork(deployed_network):
    app0, app1, app2 = deployed_network  # pylint: disable=unbalanced-tuple-unpacking

    asset_address = app0.raiden.chain.default_registry.asset_addresses()[0]

    amount = 80
    direct_transfer(app0, app1, asset_address, amount)

    amount = 50
Esempio n. 5
0
def enable_greenlet_debugger(request):
    if request.config.option.usepdb:
        from pyethapp.utils import enable_greenlet_debugger
        enable_greenlet_debugger()
Esempio n. 6
0
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--transfers', default=100, type=int)
    parser.add_argument('--nodes', default=10, type=int)
    parser.add_argument('--assets', default=1, type=int)
    parser.add_argument('--channels-per-node', default=2, type=int)
    parser.add_argument('-p', '--profile', default=False, action='store_true')
    parser.add_argument('--pdb', default=False, action='store_true')
    parser.add_argument('--throughput', dest='throughput', action='store_true', default=True)
    parser.add_argument('--latency', dest='throughput', action='store_false')
    parser.add_argument('--log', action='store_true', default=False)
    args = parser.parse_args()

    if args.log:
        slogging.configure(':DEBUG')

    if args.profile:
        import GreenletProfiler
        GreenletProfiler.set_clock_type('cpu')
        GreenletProfiler.start()

    assets = [
        sha3('asset:{}'.format(number))[:20]
        for number in range(args.assets)
    ]

    amount = 10
    apps = setup_apps(
        amount,
        assets,
        args.transfers,
        args.nodes,
        args.channels_per_node,
    )

    if args.pdb:
        from pyethapp.utils import enable_greenlet_debugger
        enable_greenlet_debugger()

        try:
            if args.throughput:
                test_throughput(apps, assets, args.transfers, amount)
            else:
                test_latency(apps, assets, args.transfers, amount)
        except:
            import pdb
            pdb.xpm()
    else:
        if args.throughput:
            test_throughput(apps, assets, args.transfers, amount)
        else:
            test_latency(apps, assets, args.transfers, amount)

    if args.profile:
        GreenletProfiler.stop()
        stats = GreenletProfiler.get_func_stats()
        pstats = GreenletProfiler.convert2pstats(stats)

        print_serialization(pstats)
        print_slow_path(pstats)
        print_slow_function(pstats)

        pstats.sort_stats('time').print_stats()
Esempio n. 7
0
from ethereum import slogging

from raiden.tests.utils.transfer import direct_transfer, mediated_transfer

# Monkey patch subprocess.Popen used by solidity wrapper
gevent.monkey.patch_socket()
slogging.configure(
    ':ERROR'
    ',eth.chain.tx:DEBUG'
    ',jsonrpc:DEBUG'
    ',eth.vm:TRACE,eth.pb.tx:TRACE,eth.pb.msg:TRACE,eth.pb.msg.state:TRACE'
)

from pyethapp.utils import enable_greenlet_debugger
enable_greenlet_debugger()


@pytest.mark.parametrize('privatekey_seed', ['fullnetwork:{}'])
@pytest.mark.parametrize('number_of_nodes', [3])
@pytest.mark.parametrize('channels_per_node', [2])
@pytest.mark.parametrize('deposit', [2 ** 20])
def test_fullnetwork(deployed_network):
    app0, app1, app2 = deployed_network  # pylint: disable=unbalanced-tuple-unpacking

    asset_address = app0.raiden.chain.default_registry.asset_addresses()[0]

    amount = 80
    direct_transfer(app0, app1, asset_address, amount)

    amount = 50