Add Dencun fields to postgres_tables.py

This commit is contained in:
evgeny
2024-04-11 19:38:27 +07:00
parent a4d6f8fcb1
commit 1c6508f15d
3 changed files with 24 additions and 4 deletions

View File

@@ -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

View File

@@ -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),
@@ -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)

View File

@@ -49,6 +49,9 @@ BLOCKS = Table(
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(
@@ -78,6 +81,10 @@ TRANSACTIONS = Table(
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(