From c2434a90d790d86e5793485aa0db3445d27b8143 Mon Sep 17 00:00:00 2001 From: kompotkot Date: Mon, 14 Oct 2024 16:00:51 +0000 Subject: [PATCH 1/3] Game7 mainnet labels table --- moonstreamdb-v3/moonstreamdbv3/alembic/env.py | 2 + .../d816689b786a_add_game7_mainnet_labels.py | 75 +++++++++++++++++++ moonstreamdb-v3/moonstreamdbv3/models.py | 45 +++++++++++ 3 files changed, 122 insertions(+) create mode 100644 moonstreamdb-v3/moonstreamdbv3/alembic/versions/d816689b786a_add_game7_mainnet_labels.py diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic/env.py b/moonstreamdb-v3/moonstreamdbv3/alembic/env.py index d4e6837a..9dd671c1 100644 --- a/moonstreamdb-v3/moonstreamdbv3/alembic/env.py +++ b/moonstreamdb-v3/moonstreamdbv3/alembic/env.py @@ -37,6 +37,7 @@ BlastLabel, BlastSepoliaLabel, EthereumLabel, + Game7Label, Game7OrbitArbitrumSepoliaLabel, Game7TestnetLabel, ImxZkevmLabel, @@ -71,6 +72,7 @@ def include_symbol(tablename, schema): ArbitrumNovaLabel.__tablename__, ArbitrumOneLabel.__tablename__, ArbitrumSepoliaLabel.__tablename__, + Game7Label.__tablename__, Game7OrbitArbitrumSepoliaLabel.__tablename__, Game7TestnetLabel.__tablename__, XaiLabel.__tablename__, diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic/versions/d816689b786a_add_game7_mainnet_labels.py b/moonstreamdb-v3/moonstreamdbv3/alembic/versions/d816689b786a_add_game7_mainnet_labels.py new file mode 100644 index 00000000..28f88e59 --- /dev/null +++ b/moonstreamdb-v3/moonstreamdbv3/alembic/versions/d816689b786a_add_game7_mainnet_labels.py @@ -0,0 +1,75 @@ +"""Add Game7 mainnet labels + +Revision ID: d816689b786a +Revises: 1d53afc1eff4 +Create Date: 2024-10-14 15:58:21.374247 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision: str = 'd816689b786a' +down_revision: Union[str, None] = '1d53afc1eff4' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('game7_labels', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('label', sa.VARCHAR(length=256), nullable=False), + sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False), + sa.Column('log_index', sa.Integer(), nullable=True), + sa.Column('block_number', sa.BigInteger(), nullable=False), + sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('block_timestamp', sa.BigInteger(), nullable=False), + sa.Column('caller_address', sa.LargeBinary(), nullable=True), + sa.Column('origin_address', sa.LargeBinary(), nullable=True), + sa.Column('address', sa.LargeBinary(), nullable=False), + sa.Column('label_name', sa.Text(), nullable=True), + sa.Column('label_type', sa.VARCHAR(length=64), nullable=True), + sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), + sa.PrimaryKeyConstraint('id', name=op.f('pk_game7_labels')), + sa.UniqueConstraint('id', name=op.f('uq_game7_labels_id')) + ) + op.create_index('ix_game7_labels_addr_block_num', 'game7_labels', ['address', 'block_number'], unique=False) + op.create_index('ix_game7_labels_addr_block_ts', 'game7_labels', ['address', 'block_timestamp'], unique=False) + op.create_index(op.f('ix_game7_labels_address'), 'game7_labels', ['address'], unique=False) + op.create_index(op.f('ix_game7_labels_block_number'), 'game7_labels', ['block_number'], unique=False) + op.create_index(op.f('ix_game7_labels_caller_address'), 'game7_labels', ['caller_address'], unique=False) + op.create_index(op.f('ix_game7_labels_label'), 'game7_labels', ['label'], unique=False) + op.create_index(op.f('ix_game7_labels_label_name'), 'game7_labels', ['label_name'], unique=False) + op.create_index(op.f('ix_game7_labels_label_type'), 'game7_labels', ['label_type'], unique=False) + op.create_index(op.f('ix_game7_labels_origin_address'), 'game7_labels', ['origin_address'], unique=False) + op.create_index(op.f('ix_game7_labels_transaction_hash'), 'game7_labels', ['transaction_hash'], unique=False) + op.create_index('uk_game7_labels_tx_hash_log_idx_evt', 'game7_labels', ['transaction_hash', 'log_index'], unique=True, postgresql_where=sa.text("label='seer' and label_type='event'")) + op.create_index('uk_game7_labels_tx_hash_log_idx_evt_raw', 'game7_labels', ['transaction_hash', 'log_index'], unique=True, postgresql_where=sa.text("label='seer-raw' and label_type='event'")) + op.create_index('uk_game7_labels_tx_hash_tx_call', 'game7_labels', ['transaction_hash'], unique=True, postgresql_where=sa.text("label='seer' and label_type='tx_call'")) + op.create_index('uk_game7_labels_tx_hash_tx_call_raw', 'game7_labels', ['transaction_hash'], unique=True, postgresql_where=sa.text("label='seer-raw' and label_type='tx_call'")) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index('uk_game7_labels_tx_hash_tx_call_raw', table_name='game7_labels', postgresql_where=sa.text("label='seer-raw' and label_type='tx_call'")) + op.drop_index('uk_game7_labels_tx_hash_tx_call', table_name='game7_labels', postgresql_where=sa.text("label='seer' and label_type='tx_call'")) + op.drop_index('uk_game7_labels_tx_hash_log_idx_evt_raw', table_name='game7_labels', postgresql_where=sa.text("label='seer-raw' and label_type='event'")) + op.drop_index('uk_game7_labels_tx_hash_log_idx_evt', table_name='game7_labels', postgresql_where=sa.text("label='seer' and label_type='event'")) + op.drop_index(op.f('ix_game7_labels_transaction_hash'), table_name='game7_labels') + op.drop_index(op.f('ix_game7_labels_origin_address'), table_name='game7_labels') + op.drop_index(op.f('ix_game7_labels_label_type'), table_name='game7_labels') + op.drop_index(op.f('ix_game7_labels_label_name'), table_name='game7_labels') + op.drop_index(op.f('ix_game7_labels_label'), table_name='game7_labels') + op.drop_index(op.f('ix_game7_labels_caller_address'), table_name='game7_labels') + op.drop_index(op.f('ix_game7_labels_block_number'), table_name='game7_labels') + op.drop_index(op.f('ix_game7_labels_address'), table_name='game7_labels') + op.drop_index('ix_game7_labels_addr_block_ts', table_name='game7_labels') + op.drop_index('ix_game7_labels_addr_block_num', table_name='game7_labels') + op.drop_table('game7_labels') + # ### end Alembic commands ### diff --git a/moonstreamdb-v3/moonstreamdbv3/models.py b/moonstreamdb-v3/moonstreamdbv3/models.py index 9164c62d..2a58501b 100644 --- a/moonstreamdb-v3/moonstreamdbv3/models.py +++ b/moonstreamdb-v3/moonstreamdbv3/models.py @@ -1289,6 +1289,51 @@ class ImxZkevmSepoliaLabel(EvmBasedLabel): # type: ignore ) +class Game7Label(EvmBasedLabel): # type: ignore + __tablename__ = "game7_labels" + + __table_args__ = ( + Index( + "ix_game7_labels_addr_block_num", + "address", + "block_number", + unique=False, + ), + Index( + "ix_game7_labels_addr_block_ts", + "address", + "block_timestamp", + unique=False, + ), + Index( + "uk_game7_labels_tx_hash_tx_call", + "transaction_hash", + unique=True, + postgresql_where=text("label='seer' and label_type='tx_call'"), + ), + Index( + "uk_game7_labels_tx_hash_log_idx_evt", + "transaction_hash", + "log_index", + unique=True, + postgresql_where=text("label='seer' and label_type='event'"), + ), + Index( + "uk_game7_labels_tx_hash_tx_call_raw", + "transaction_hash", + unique=True, + postgresql_where=text("label='seer-raw' and label_type='tx_call'"), + ), + Index( + "uk_game7_labels_tx_hash_log_idx_evt_raw", + "transaction_hash", + "log_index", + unique=True, + postgresql_where=text("label='seer-raw' and label_type='event'"), + ), + ) + + class Game7TestnetLabel(EvmBasedLabel): # type: ignore __tablename__ = "game7_testnet_labels" From c61671f4f399d724d44358c9fefdaaf8c744ea3c Mon Sep 17 00:00:00 2001 From: kompotkot Date: Mon, 14 Oct 2024 16:11:21 +0000 Subject: [PATCH 2/3] Game7 mainnet indexes table --- .../moonstreamdbv3/alembic_indexes/env.py | 4 ++ .../c1bc596631f9_add_game7_mainnet_indexes.py | 57 +++++++++++++++++++ .../moonstreamdbv3/models_indexes.py | 19 +++++++ 3 files changed, 80 insertions(+) create mode 100644 moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/c1bc596631f9_add_game7_mainnet_indexes.py diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/env.py b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/env.py index 7cfcc9f0..2e249461 100644 --- a/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/env.py +++ b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/env.py @@ -44,10 +44,12 @@ EthereumLogIndex, EthereumReorgs, EthereumTransactionIndex, + Game7BlockIndex, Game7OrbitArbitrumSepoliaBlockIndex, Game7OrbitArbitrumSepoliaLogIndex, Game7OrbitArbitrumSepoliaReorgs, Game7OrbitArbitrumSepoliaTransactionIndex, + Game7Reorgs, Game7TestnetBlockIndex, Game7TestnetLogIndex, Game7TestnetReorgs, @@ -113,6 +115,8 @@ def include_symbol(tablename, schema): Game7OrbitArbitrumSepoliaTransactionIndex.__tablename__, Game7OrbitArbitrumSepoliaLogIndex.__tablename__, Game7OrbitArbitrumSepoliaReorgs.__tablename__, + Game7BlockIndex.__tablename__, + Game7Reorgs.__tablename__, Game7TestnetBlockIndex.__tablename__, Game7TestnetTransactionIndex.__tablename__, Game7TestnetLogIndex.__tablename__, diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/c1bc596631f9_add_game7_mainnet_indexes.py b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/c1bc596631f9_add_game7_mainnet_indexes.py new file mode 100644 index 00000000..348d0af0 --- /dev/null +++ b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/c1bc596631f9_add_game7_mainnet_indexes.py @@ -0,0 +1,57 @@ +"""Add Game7 mainnet indexes + +Revision ID: c1bc596631f9 +Revises: 6807bdf6f417 +Create Date: 2024-10-14 16:10:27.757094 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = 'c1bc596631f9' +down_revision: Union[str, None] = '6807bdf6f417' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('game7_blocks', + sa.Column('l1_block_number', sa.BigInteger(), nullable=False), + sa.Column('block_number', sa.BigInteger(), nullable=False), + sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('block_timestamp', sa.BigInteger(), nullable=False), + sa.Column('parent_hash', sa.VARCHAR(length=256), nullable=False), + sa.Column('row_id', sa.BigInteger(), nullable=False), + sa.Column('path', sa.Text(), nullable=False), + sa.Column('transactions_indexed_at', sa.DateTime(timezone=True), nullable=True), + sa.Column('logs_indexed_at', sa.DateTime(timezone=True), nullable=True), + sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), + sa.PrimaryKeyConstraint('block_number', name=op.f('pk_game7_blocks')) + ) + op.create_index(op.f('ix_game7_blocks_block_number'), 'game7_blocks', ['block_number'], unique=False) + op.create_index(op.f('ix_game7_blocks_block_timestamp'), 'game7_blocks', ['block_timestamp'], unique=False) + op.create_table('game7_reorgs', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('block_number', sa.BigInteger(), nullable=False), + sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False), + sa.PrimaryKeyConstraint('id', name=op.f('pk_game7_reorgs')) + ) + op.create_index(op.f('ix_game7_reorgs_block_hash'), 'game7_reorgs', ['block_hash'], unique=False) + op.create_index(op.f('ix_game7_reorgs_block_number'), 'game7_reorgs', ['block_number'], unique=False) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f('ix_game7_reorgs_block_number'), table_name='game7_reorgs') + op.drop_index(op.f('ix_game7_reorgs_block_hash'), table_name='game7_reorgs') + op.drop_table('game7_reorgs') + op.drop_index(op.f('ix_game7_blocks_block_timestamp'), table_name='game7_blocks') + op.drop_index(op.f('ix_game7_blocks_block_number'), table_name='game7_blocks') + op.drop_table('game7_blocks') + # ### end Alembic commands ### diff --git a/moonstreamdb-v3/moonstreamdbv3/models_indexes.py b/moonstreamdb-v3/moonstreamdbv3/models_indexes.py index 89d015df..760cbef3 100644 --- a/moonstreamdb-v3/moonstreamdbv3/models_indexes.py +++ b/moonstreamdb-v3/moonstreamdbv3/models_indexes.py @@ -727,6 +727,22 @@ class ImxZkevmSepoliaReorgs(EvmBasedReorgs): __tablename__ = "imx_zkevm_sepolia_reorgs" +# Game7 + + +class Game7BlockIndex(EvmBasedBlocks): + __tablename__ = "game7_blocks" + + l1_block_number = Column(BigInteger, nullable=False) + + +class Game7Reorgs(EvmBasedReorgs): + __tablename__ = "game7_reorgs" + + +# Game7 Testnet + + class Game7TestnetBlockIndex(EvmBasedBlocks): __tablename__ = "game7_testnet_blocks" @@ -775,6 +791,9 @@ class Game7TestnetReorgs(EvmBasedReorgs): __tablename__ = "game7_testnet_reorgs" +# B3 + + class B3BlockIndex(EvmBasedBlocks): __tablename__ = "b3_blocks" From 1fc774bf7dfc76595b194bef607151bceb291abf Mon Sep 17 00:00:00 2001 From: kompotkot Date: Mon, 14 Oct 2024 16:11:46 +0000 Subject: [PATCH 3/3] Updated version --- moonstreamdb-v3/moonstreamdbv3/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moonstreamdb-v3/moonstreamdbv3/version.txt b/moonstreamdb-v3/moonstreamdbv3/version.txt index 44517d51..fe04e7f6 100644 --- a/moonstreamdb-v3/moonstreamdbv3/version.txt +++ b/moonstreamdb-v3/moonstreamdbv3/version.txt @@ -1 +1 @@ -0.0.19 +0.0.20