Merge pull request #339 from bugout-dev/tx-eip-1559-migration

Migration with fields for EIP 1559
pull/352/head
Neeraj Kashyap 2021-10-28 09:07:04 -07:00 zatwierdzone przez GitHub
commit 2695fffeea
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 44 dodań i 2 usunięć

Wyświetl plik

@ -61,6 +61,7 @@ def add_block(db_session, block: Any) -> None:
extra_data=block.extraData.hex(),
gas_limit=block.gasLimit,
gas_used=block.gasUsed,
base_fee_per_gas=block.get("baseFeePerGas", None),
hash=block.hash.hex(),
logs_bloom=block.logsBloom.hex(),
miner=block.miner,
@ -91,9 +92,12 @@ def add_block_transactions(db_session, block: Any) -> None:
to_address=tx.to,
gas=tx.gas,
gas_price=tx.gasPrice,
max_fee_per_gas=tx.get("maxFeePerGas", None),
max_priority_fee_per_gas=tx.get("maxPriorityFeePerGas", None),
input=tx.input,
nonce=tx.nonce,
transaction_index=tx.transactionIndex,
transaction_type=int(tx["type"], 0) if tx["type"] is not None else None,
value=tx.value,
)
db_session.add(tx_obj)

Wyświetl plik

@ -12,7 +12,7 @@ chardet==4.0.0
charset-normalizer==2.0.4
click==8.0.1
cytoolz==0.11.0
-e git+https://git@github.com/bugout-dev/moonstream.git@6b5b6049b58b1edf0e5de261614c616e8e034b6e#egg=moonstreamdb&subdirectory=db
-e git+https://git@github.com/bugout-dev/moonstream.git@0a771ddfbca1254be331149ccf2d162aa09b7bc0#egg=moonstreamdb&subdirectory=db
eth-abi==2.1.1
eth-account==0.5.5
eth-hash==0.3.2

Wyświetl plik

@ -34,7 +34,7 @@ setup(
install_requires=[
"boto3",
"bugout >= 0.1.17",
"moonstreamdb @ git+https://git@github.com/bugout-dev/moonstream.git@6b5b6049b58b1edf0e5de261614c616e8e034b6e#egg=moonstreamdb&subdirectory=db",
"moonstreamdb @ git+https://git@github.com/bugout-dev/moonstream.git@0a771ddfbca1254be331149ccf2d162aa09b7bc0#egg=moonstreamdb&subdirectory=db",
"humbug",
"python-dateutil",
"requests",

Wyświetl plik

@ -0,0 +1,34 @@
"""fields-for-eip-1559
Revision ID: 0b46c8e17bf2
Revises: 240476c67b9f
Create Date: 2021-10-26 09:52:17.367528
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '0b46c8e17bf2'
down_revision = '240476c67b9f'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('ethereum_blocks', sa.Column('base_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True))
op.add_column('ethereum_transactions', sa.Column('max_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True))
op.add_column('ethereum_transactions', sa.Column('max_priority_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True))
op.add_column('ethereum_transactions', sa.Column('transaction_type', sa.Integer(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('ethereum_transactions', 'transaction_type')
op.drop_column('ethereum_transactions', 'max_priority_fee_per_gas')
op.drop_column('ethereum_transactions', 'max_fee_per_gas')
op.drop_column('ethereum_blocks', 'base_fee_per_gas')
# ### end Alembic commands ###

Wyświetl plik

@ -59,6 +59,7 @@ class EthereumBlock(Base): # type: ignore
extra_data = Column(VARCHAR(128))
gas_limit = Column(BigInteger)
gas_used = Column(BigInteger)
base_fee_per_gas = Column(Numeric(precision=78, scale=0), nullable=True)
hash = Column(VARCHAR(256), index=True)
logs_bloom = Column(VARCHAR(1024))
miner = Column(VARCHAR(256))
@ -92,9 +93,12 @@ class EthereumTransaction(Base): # type: ignore
to_address = Column(VARCHAR(256), index=True)
gas = Column(Numeric(precision=78, scale=0), index=True)
gas_price = Column(Numeric(precision=78, scale=0), index=True)
max_fee_per_gas = Column(Numeric(precision=78, scale=0), nullable=True)
max_priority_fee_per_gas = Column(Numeric(precision=78, scale=0), nullable=True)
input = Column(Text)
nonce = Column(VARCHAR(256))
transaction_index = Column(BigInteger)
transaction_type = Column(Integer, nullable=True)
value = Column(Numeric(precision=78, scale=0), index=True)
indexed_at = Column(