Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent tx_traces to be NULL within trace block rpc #364

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ethereumetl/jobs/export_geth_traces_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from blockchainetl.jobs.base_job import BaseJob
from ethereumetl.mappers.geth_trace_mapper import EthGethTraceMapper
from ethereumetl.utils import validate_range, rpc_response_to_result
from ethereumetl.misc.retriable_value_error import RetriableValueError


# Exports geth traces
Expand Down Expand Up @@ -68,6 +69,10 @@ def _export_batch(self, block_number_batch):
block_number = response_item.get('id')
result = rpc_response_to_result(response_item)

# We add this check because the response of trace block rpc is a list of tx_trace,
# so we need to make sure there is no error in each tx_trace
self._check_result(result, block_number)

geth_trace = self.geth_trace_mapper.json_dict_to_geth_trace({
'block_number': block_number,
'transaction_traces': [tx_trace.get('result') for tx_trace in result],
Expand All @@ -78,3 +83,11 @@ def _export_batch(self, block_number_batch):
def _end(self):
self.batch_work_executor.shutdown()
self.item_exporter.close()

def _check_result(self, result, block_number):
for tx_trace in result:
if tx_trace.get('result') is None:
raise RetriableValueError(
'Error for trace in block {block}. Need to retry. Error: {err}, trace: {trace}'
.format(block=block_number, trace=json.dumps(tx_trace), err=tx_trace.get('error'))
)