Skip to content

Commit

Permalink
fix missing transferto_address in some tron traces
Browse files Browse the repository at this point in the history
  • Loading branch information
soad003 committed Jul 16, 2024
1 parent 758185a commit 0f260e2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [24.07.7/2.3.7] 2024-07-16
### fixed
- tron delta-dump: fix missing transferto_address in some tron traces

## [24.07.6/2.3.6] 2024-07-15
### fixed
- tron delta-dump freezes on grpc asyncio requests
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SHELL := /bin/bash
PROJECT := graphsense-lib
VENV := venv
RELEASE := 'v24.07.6'
RELEASESEM := 'v2.3.6'
RELEASE := 'v24.07.7'
RELEASESEM := 'v2.3.7'


all: format lint test build
Expand Down
12 changes: 12 additions & 0 deletions src/graphsenselib/ingest/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ def transform(self, block_range_content: BlockRangeContent) -> BlockRangeContent
traces = drop_columns_from_list(traces, ["block_id_group"])
logs = drop_columns_from_list(logs, ["block_id_group"])

def fix_transferToAddress(item):
if len(item["transferto_address"]) == 0:
# for some very rare txs
# e.g. f0b31777dcc58cbca074380ff6f25f8495898edba2da0c43b099b3f276ae3d74
# transferTo_address is empty which does not mach our schema.
# as a quick fix we set a dummy address for now.
dummy_address = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00ikna" # noqa
item["transferto_address"] = dummy_address
return item

traces = [fix_transferToAddress(trace) for trace in traces]

txs = to_bytes(txs, BINARY_COL_CONVERSION_MAP_ACCOUNT_TRX["transaction"])
blocks = to_bytes(blocks, BINARY_COL_CONVERSION_MAP_ACCOUNT_TRX["block"])
traces = to_bytes(traces, BINARY_COL_CONVERSION_MAP_ACCOUNT_TRX["trace"])
Expand Down
13 changes: 0 additions & 13 deletions src/graphsenselib/schema/resources/parquet/account_trx.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,6 @@ def set_field_type(schema, field_name, new_type):
block_schema = set_field_type(block_schema, "gas_used", pa.int64())
ACCOUNT_TRX_SCHEMA_RAW["block"] = block_schema

# trace_schema = ACCOUNT_TRX_SCHEMA_RAW["trace"]
# # internal_index', 'transferto_address', 'call_info_index',
# # 'caller_address', 'call_value', 'rejected', 'call_token_id', 'note
# trace_schema = set_field_type(trace_schema, "internal_index", pa.int16())
# trace_schema = set_field_type(trace_schema, "transferto_address", pa.binary(20))
# trace_schema = set_field_type(trace_schema, "call_info_index", pa.int16())
# trace_schema = set_field_type(trace_schema, "caller_address", pa.binary(20))
# trace_schema = set_field_type(trace_schema, "call_value", pa.binary())
# trace_schema = set_field_type(trace_schema, "rejected", pa.bool_())
# trace_schema = set_field_type(trace_schema, "call_token_id", pa.int32())
# trace_schema = set_field_type(trace_schema, "note", pa.string())
# ACCOUNT_TRX_SCHEMA_RAW["trace"] = trace_schema

transaction_schema = ACCOUNT_TRX_SCHEMA_RAW["transaction"]
transaction_schema = set_field_type(transaction_schema, "gas", pa.int64())
ACCOUNT_TRX_SCHEMA_RAW["transaction"] = transaction_schema
Expand Down

0 comments on commit 0f260e2

Please sign in to comment.