Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit 9ea951b

Browse files
Merge pull request #28 from spicehq/phillip/option-to-skip-geth-traces
Add option to skip using geth traces for contract creations
2 parents 9adaa5f + 3f453a9 commit 9ea951b

3 files changed

Lines changed: 26 additions & 23 deletions

File tree

ethereumetl/cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747

4848
@click.group()
49-
@click.version_option(version='1.11.0-spicehq/release/v1.0.18')
49+
@click.version_option(version='1.11.0-spicehq/release/v1.0.19')
5050
@click.pass_context
5151
def cli(ctx):
5252
pass

ethereumetl/cli/export_all.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@ def get_partitions(start, end, partition_batch_size, provider_uri):
119119
@click.option('-P', '--postgres-connection-string', default='', show_default=False, type=str, help='Postgres connection string.')
120120
@click.option('-w', '--max-workers', default=5, show_default=True, type=int, help='The maximum number of workers.')
121121
@click.option('-B', '--export-batch-size', default=100, show_default=True, type=int, help='The number of requests in JSON RPC batches.')
122+
@click.option('--skip-geth-traces', default=False, show_default=True, type=bool, help='Whether to skip using geth traces to get contracts')
122123
@click.option('-c', '--chain', default='ethereum', show_default=True, type=str, help='The chain network to connect to.')
123124
def export_all(start, end, partition_batch_size, provider_uri, output_dir, postgres_connection_string, max_workers, export_batch_size,
124-
chain='ethereum'):
125+
chain='ethereum', skip_geth_traces=False):
125126
"""Exports all data for a range of blocks."""
126127
provider_uri = check_classic_provider_uri(chain, provider_uri)
127128
export_all_common(get_partitions(start, end, partition_batch_size, provider_uri),
128-
output_dir, postgres_connection_string, provider_uri, max_workers, export_batch_size)
129+
output_dir, postgres_connection_string, provider_uri, max_workers, export_batch_size, skip_geth_traces)

ethereumetl/jobs/export_all_common.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_multi_item_exporter(item_exporters: list):
8989
return MultiItemExporter(valid_item_exporters)
9090

9191

92-
def export_all_common(partitions, output_dir, postgres_connection_string, provider_uri, max_workers, batch_size):
92+
def export_all_common(partitions, output_dir, postgres_connection_string, provider_uri, max_workers, batch_size, skip_geth_traces):
9393

9494
for batch_start_block, batch_end_block, partition_dir in partitions:
9595
# # # start # # #
@@ -291,26 +291,28 @@ def export_all_common(partitions, output_dir, postgres_connection_string, provid
291291

292292
# # # geth traces # # #
293293

294-
logger.info('Exporting geth traces from blocks {block_range}'.format(
295-
block_range=block_range
296-
))
294+
geth_traces_available = False
295+
if not skip_geth_traces:
296+
logger.info('Exporting geth traces from blocks {block_range}'.format(
297+
block_range=block_range
298+
))
297299

298-
geth_traces_available = True
299-
job = ExportGethTracesJob(
300-
start_block=batch_start_block,
301-
end_block=batch_end_block,
302-
batch_size=batch_size,
303-
batch_web3_provider=ThreadLocalProxy(
304-
lambda: get_provider_from_uri(provider_uri, batch=True)),
305-
max_workers=max_workers,
306-
item_exporter=inmemory_exporter
307-
)
308-
try:
309-
job.run()
310-
except HistoricalStateUnavailableError:
311-
geth_traces_available = False
312-
except HTTPError:
313-
geth_traces_available = False
300+
geth_traces_available = True
301+
job = ExportGethTracesJob(
302+
start_block=batch_start_block,
303+
end_block=batch_end_block,
304+
batch_size=batch_size,
305+
batch_web3_provider=ThreadLocalProxy(
306+
lambda: get_provider_from_uri(provider_uri, batch=True)),
307+
max_workers=max_workers,
308+
item_exporter=inmemory_exporter
309+
)
310+
try:
311+
job.run()
312+
except HistoricalStateUnavailableError:
313+
geth_traces_available = False
314+
except HTTPError:
315+
geth_traces_available = False
314316

315317
contracts_output_dir = '{output_dir}/contracts{partition_dir}'.format(
316318
output_dir=output_dir,

0 commit comments

Comments
 (0)