def export_traces(start_block, end_block, batch_size, output, max_workers, provider_uri, genesis_traces, daofork_traces, timeout=60, chain='ethereum'): """Exports traces from parity node.""" if chain == 'classic' and daofork_traces == True: raise ValueError( 'Classic chain does not include daofork traces. Disable daofork traces with --no-daofork-traces option.' ) job = ExportTracesJob( start_block=start_block, end_block=end_block, batch_size=batch_size, web3=ThreadLocalProxy(lambda: Web3( get_provider_from_uri(provider_uri, timeout=timeout))), item_exporter=traces_item_exporter(output), max_workers=max_workers, include_genesis_traces=genesis_traces, include_daofork_traces=daofork_traces) job.run()
def extract_geth_traces(input, batch_size, output, max_workers): """Extracts geth traces from JSON lines file.""" with smart_open(input, 'r') as geth_traces_file: if input.endswith('.json'): traces_iterable = (json.loads(line) for line in geth_traces_file) else: traces_iterable = (trace for trace in csv.DictReader(geth_traces_file)) job = ExtractGethTracesJob(traces_iterable=traces_iterable, batch_size=batch_size, max_workers=max_workers, item_exporter=traces_item_exporter(output)) job.run()
def test_extract_traces_job(tmpdir, resource_group): output_file = str(tmpdir.join('actual_traces.csv')) geth_traces_content = read_resource(resource_group, 'geth_traces.json') traces_iterable = (json.loads(line) for line in geth_traces_content.splitlines()) job = ExtractGethTracesJob(traces_iterable=traces_iterable, batch_size=2, item_exporter=traces_item_exporter(output_file), max_workers=5) job.run() compare_lines_ignore_order( read_resource(resource_group, 'expected_traces.csv'), read_file(output_file))
def export_traces(start_block, end_block, batch_size, output, max_workers, provider_uri, genesis_traces, daofork_traces): """Exports traces from parity node.""" job = ExportTracesJob( start_block=start_block, end_block=end_block, batch_size=batch_size, web3=ThreadLocalProxy( lambda: Web3(get_provider_from_uri(provider_uri))), item_exporter=traces_item_exporter(output), max_workers=max_workers, include_genesis_traces=genesis_traces, include_daofork_traces=daofork_traces) job.run()
def test_export_traces_job(tmpdir, start_block, end_block, resource_group, web3_provider_type): traces_output_file = tmpdir.join('actual_traces.csv') job = ExportTracesJob( start_block=start_block, end_block=end_block, batch_size=1, web3=ThreadLocalProxy(lambda: Web3( get_web3_provider(web3_provider_type, lambda file: read_resource( resource_group, file)))), max_workers=5, item_exporter=traces_item_exporter(traces_output_file), ) job.run() compare_lines_ignore_order( read_resource(resource_group, 'expected_traces.csv'), read_file(traces_output_file))
'--output', default='-', type=str, help='The output file. If not specified stdout is used.') parser.add_argument('-w', '--max-workers', default=5, type=int, help='The maximum number of workers.') parser.add_argument( '-p', '--provider-uri', required=True, type=str, help='The URI of the web3 provider e.g. ' 'file://$HOME/.local/share/io.parity.ethereum/jsonrpc.ipc or http://localhost:8545/' ) args = parser.parse_args() job = ExportTracesJob( start_block=args.start_block, end_block=args.end_block, batch_size=args.batch_size, web3=ThreadLocalProxy( lambda: Web3(get_provider_from_uri(args.provider_uri))), item_exporter=traces_item_exporter(args.output), max_workers=args.max_workers) job.run()