Skip to content

Commit

Permalink
Merge pull request #488 from blockchain-etl/add_dencun_fields_to_post…
Browse files Browse the repository at this point in the history
…gres_tables

Add Dencun fields to postgres_tables.py
  • Loading branch information
medvedev1088 authored Apr 11, 2024
2 parents a4d6f8f + 1c6508f commit 836f30e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:


class SimpleItemConverter:

def __init__(self, field_converters=None):
self.field_converters = field_converters

def convert_item(self, item):
return {
key: self.convert_field(key, value) for key, value in item.items()
}

def convert_field(self, key, value):
return value
if self.field_converters is not None and key in self.field_converters:
return self.field_converters[key](value)
else:
return value
12 changes: 10 additions & 2 deletions ethereumetl/streaming/item_exporter_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ def create_item_exporter(output):
from blockchainetl.jobs.exporters.converters.unix_timestamp_item_converter import UnixTimestampItemConverter
from blockchainetl.jobs.exporters.converters.int_to_decimal_item_converter import IntToDecimalItemConverter
from blockchainetl.jobs.exporters.converters.list_field_item_converter import ListFieldItemConverter
from blockchainetl.jobs.exporters.converters.simple_item_converter import SimpleItemConverter
from ethereumetl.streaming.postgres_tables import BLOCKS, TRANSACTIONS, LOGS, TOKEN_TRANSFERS, TRACES, TOKENS, CONTRACTS

def array_to_str(val):
return ','.join(val) if val is not None else None

item_exporter = PostgresItemExporter(
output, item_type_to_insert_stmt_mapping={
'block': create_insert_statement_for_table(BLOCKS),
Expand All @@ -74,8 +78,12 @@ def create_item_exporter(output):
'token': create_insert_statement_for_table(TOKENS),
'contract': create_insert_statement_for_table(CONTRACTS),
},
converters=[UnixTimestampItemConverter(), IntToDecimalItemConverter(),
ListFieldItemConverter('topics', 'topic', fill=4)])
converters=[
UnixTimestampItemConverter(),
IntToDecimalItemConverter(),
ListFieldItemConverter('topics', 'topic', fill=4),
SimpleItemConverter(field_converters={'blob_versioned_hashes': array_to_str})
])
elif item_exporter_type == ItemExporterType.GCS:
from blockchainetl.jobs.exporters.gcs_item_exporter import GcsItemExporter
bucket, path = get_bucket_and_path_from_gcs_output(output)
Expand Down
7 changes: 7 additions & 0 deletions ethereumetl/streaming/postgres_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
Column('gas_used', BigInteger),
Column('transaction_count', BigInteger),
Column('base_fee_per_gas', BigInteger),
Column('withdrawals_root', String),
Column('blob_gas_used', BigInteger),
Column('excess_blob_gas', BigInteger),
)

TRANSACTIONS = Table(
Expand Down Expand Up @@ -78,6 +81,10 @@
Column('receipt_l1_gas_used', BigInteger),
Column('receipt_l1_gas_price', BigInteger),
Column('receipt_l1_fee_scalar', Float),
Column('max_fee_per_blob_gas', BigInteger),
Column('blob_versioned_hashes', String),
Column('receipt_blob_gas_price', BigInteger),
Column('receipt_blob_gas_used', BigInteger),
)

LOGS = Table(
Expand Down

0 comments on commit 836f30e

Please sign in to comment.