Arbitrum nova blockchain tables

pull/1009/head
kompotkot 2024-01-30 13:57:13 +00:00
rodzic 974128528e
commit b9966558c2
5 zmienionych plików z 135 dodań i 79 usunięć

Wyświetl plik

@ -46,6 +46,9 @@ from moonstreamdb.models import (
ZkSyncEraTestnetBlock,
ZkSyncEraTestnetLabel,
ZkSyncEraTestnetTransaction,
ArbitrumNovaBlock,
ArbitrumNovaTransaction,
ArbitrumNovaLabel,
)
@ -72,6 +75,9 @@ def include_symbol(tablename, schema):
ZkSyncEraTestnetBlock.__tablename__,
ZkSyncEraTestnetLabel.__tablename__,
ZkSyncEraTestnetTransaction.__tablename__,
ArbitrumNovaBlock.__tablename__,
ArbitrumNovaTransaction.__tablename__,
ArbitrumNovaLabel.__tablename__,
}

Wyświetl plik

@ -23,6 +23,9 @@ from .models import (
ZkSyncEraBlock,
ZkSyncEraLabel,
ZkSyncEraTransaction,
ArbitrumNovaBlock,
ArbitrumNovaTransaction,
ArbitrumNovaLabel,
)
@ -34,6 +37,7 @@ class AvailableBlockchainType(Enum):
WYRM = "wyrm"
ZKSYNC_ERA_TESTNET = "zksync_era_testnet"
ZKSYNC_ERA = "zksync_era"
ARBITRUM_NOVA = "arbitrum_nova"
def get_block_model(
@ -47,10 +51,11 @@ def get_block_model(
WyrmBlock,
ZkSyncEraTestnetBlock,
ZkSyncEraBlock,
ArbitrumNovaBlock,
]
]:
"""
Depends on provided blockchain type: Ethereum, Polygon, Mumbai, XDai, Wyrm, ZkSyncEra, ZkSyncEraTestnet
Depends on provided blockchain type: Ethereum, Polygon, Mumbai, XDai, Wyrm, ZkSyncEra, ZkSyncEraTestnet, ArbitrumNovaBlock
set proper blocks model.
"""
block_model: Type[
@ -62,6 +67,7 @@ def get_block_model(
WyrmBlock,
ZkSyncEraTestnetBlock,
ZkSyncEraBlock,
ArbitrumNovaBlock,
]
]
if blockchain_type == AvailableBlockchainType.ETHEREUM:
@ -78,6 +84,8 @@ def get_block_model(
block_model = ZkSyncEraTestnetBlock
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA:
block_model = ZkSyncEraBlock
elif blockchain_type == AvailableBlockchainType.ARBITRUM_NOVA:
block_model = ArbitrumNovaBlock
else:
raise Exception("Unsupported blockchain type provided")
@ -95,10 +103,11 @@ def get_label_model(
WyrmLabel,
ZkSyncEraTestnetLabel,
ZkSyncEraLabel,
ArbitrumNovaLabel,
]
]:
"""
Depends on provided blockchain type: Ethereum, Polygon, Mumbai, XDai, Wyrm, ZkSyncEra, ZkSyncEraTestnet
Depends on provided blockchain type: Ethereum, Polygon, Mumbai, XDai, Wyrm, ZkSyncEra, ZkSyncEraTestnet, ArbitrumNovaLabel
set proper block label model.
"""
label_model: Type[
@ -110,6 +119,7 @@ def get_label_model(
WyrmLabel,
ZkSyncEraTestnetLabel,
ZkSyncEraLabel,
ArbitrumNovaLabel,
]
]
if blockchain_type == AvailableBlockchainType.ETHEREUM:
@ -126,6 +136,8 @@ def get_label_model(
label_model = ZkSyncEraTestnetLabel
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA:
label_model = ZkSyncEraLabel
elif blockchain_type == AvailableBlockchainType.ARBITRUM_NOVA:
label_model = ArbitrumNovaLabel
else:
raise Exception("Unsupported blockchain type provided")
@ -143,10 +155,11 @@ def get_transaction_model(
WyrmTransaction,
ZkSyncEraTestnetTransaction,
ZkSyncEraTransaction,
ArbitrumNovaTransaction,
]
]:
"""
Depends on provided blockchain type: Ethereum, Polygon, Mumbai, XDai, Wyrm, ZkSyncEra, ZkSyncEraTestnet
Depends on provided blockchain type: Ethereum, Polygon, Mumbai, XDai, Wyrm, ZkSyncEra, ZkSyncEraTestnet, ArbitrumNovaTransaction
set proper block transactions model.
"""
transaction_model: Type[
@ -158,6 +171,7 @@ def get_transaction_model(
WyrmTransaction,
ZkSyncEraTestnetTransaction,
ZkSyncEraTransaction,
ArbitrumNovaTransaction,
]
]
if blockchain_type == AvailableBlockchainType.ETHEREUM:
@ -174,6 +188,8 @@ def get_transaction_model(
transaction_model = ZkSyncEraTestnetTransaction
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA:
transaction_model = ZkSyncEraTransaction
elif blockchain_type == AvailableBlockchainType.ARBITRUM_NOVA:
transaction_model = ArbitrumNovaTransaction
else:
raise Exception("Unsupported blockchain type provided")

Wyświetl plik

@ -214,21 +214,6 @@ class PolygonTransaction(Base): # type: ignore
class PolygonLabel(Base): # type: ignore
"""
Example of label_data:
{
"label": "ERC20",
"label_data": {
"name": "Uniswap",
"symbol": "UNI"
}
},
{
"label": "Exchange"
"label_data": {...}
}
"""
__tablename__ = "polygon_labels"
__table_args__ = (
@ -445,21 +430,6 @@ class XDaiTransaction(Base): # type: ignore
class XDaiLabel(Base): # type: ignore
"""
Example of label_data:
{
"label": "ERC20",
"label_data": {
"name": "Uniswap",
"symbol": "UNI"
}
},
{
"label": "Exchange"
"label_data": {...}
}
"""
__tablename__ = "xdai_labels"
id = Column(
@ -551,21 +521,6 @@ class WyrmTransaction(Base): # type: ignore
class WyrmLabel(Base): # type: ignore
"""
Example of label_data:
{
"label": "ERC20",
"label_data": {
"name": "Uniswap",
"symbol": "UNI"
}
},
{
"label": "Exchange"
"label_data": {...}
}
"""
__tablename__ = "wyrm_labels"
__table_args__ = (
@ -682,21 +637,6 @@ class ZkSyncEraTransaction(Base): # type: ignore
class ZkSyncEraLabel(Base): # type: ignore
"""
Example of label_data:
{
"label": "ERC20",
"label_data": {
"name": "Uniswap",
"symbol": "UNI"
}
},
{
"label": "Exchange"
"label_data": {...}
}
"""
__tablename__ = "zksync_era_labels"
__table_args__ = (
@ -813,21 +753,6 @@ class ZkSyncEraTestnetTransaction(Base): # type: ignore
class ZkSyncEraTestnetLabel(Base): # type: ignore
"""
Example of label_data:
{
"label": "ERC20",
"label_data": {
"name": "Uniswap",
"symbol": "UNI"
}
},
{
"label": "Exchange"
"label_data": {...}
}
"""
__tablename__ = "zksync_era_testnet_labels"
__table_args__ = (
@ -876,6 +801,105 @@ class ZkSyncEraTestnetLabel(Base): # type: ignore
)
class ArbitrumNovaBlock(Base): # type: ignore
__tablename__ = "arbitrum_nova_blocks"
block_number = Column(
BigInteger, primary_key=True, unique=True, nullable=False, index=True
)
difficulty = Column(BigInteger)
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))
nonce = Column(VARCHAR(256))
parent_hash = Column(VARCHAR(256))
uncles = Column(VARCHAR(256))
size = Column(Integer)
state_root = Column(VARCHAR(256))
timestamp = Column(BigInteger, index=True)
total_difficulty = Column(VARCHAR(256))
transactions_root = Column(VARCHAR(256))
indexed_at = Column(
DateTime(timezone=True), server_default=utcnow(), nullable=False
)
sha3_uncles = Column(VARCHAR(256), nullable=True)
l1_block_number = Column(BigInteger, nullable=True)
send_count = Column(BigInteger, nullable=True)
send_root = Column(VARCHAR(256), nullable=True)
mix_hash = Column(VARCHAR(256), nullable=True)
class ArbitrumNovaTransaction(Base): # type: ignore
__tablename__ = "arbitrum_nova_transactions"
hash = Column(
VARCHAR(256), primary_key=True, unique=True, nullable=False, index=True
)
block_number = Column(
BigInteger,
ForeignKey("arbitrum_nova_blocks.block_number", ondelete="CASCADE"),
nullable=False,
index=True,
)
from_address = Column(VARCHAR(256), index=True)
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(
DateTime(timezone=True), server_default=utcnow(), nullable=False
)
y_parity = Column(BigInteger, nullable=True)
class ArbitrumNovaLabel(Base): # type: ignore
__tablename__ = "arbitrum_nova_labels"
id = Column(
UUID(as_uuid=True),
primary_key=True,
default=uuid.uuid4,
unique=True,
nullable=False,
)
label = Column(VARCHAR(256), nullable=False, index=True)
block_number = Column(
BigInteger,
nullable=True,
index=True,
)
address = Column(
VARCHAR(256),
nullable=True,
index=True,
)
transaction_hash = Column(
VARCHAR(256),
nullable=True,
index=True,
)
label_data = Column(JSONB, nullable=True)
block_timestamp = Column(BigInteger, index=True)
log_index = Column(Integer, nullable=True)
created_at = Column(
DateTime(timezone=True), server_default=utcnow(), nullable=False
)
class ESDFunctionSignature(Base): # type: ignore
"""
Function signature from blockchain (Ethereum/Polygon) Signature Database.

Wyświetl plik

@ -24,6 +24,9 @@ from .models import (
ZkSyncEraBlock,
ZkSyncEraLabel,
ZkSyncEraTransaction,
ArbitrumNovaBlock,
ArbitrumNovaTransaction,
ArbitrumNovaLabel,
)
@ -35,6 +38,7 @@ class Network(Enum):
wyrm = "wyrm"
zksync_era_testnet = "zksync_era_testnet"
zksync_era = "zksync_era"
arbitrum_nova = "arbitrum_nova"
tx_raw_types = Union[
@ -45,6 +49,7 @@ tx_raw_types = Union[
XDaiTransaction,
ZkSyncEraTestnetTransaction,
ZkSyncEraTransaction,
ArbitrumNovaTransaction,
]
MODELS: Dict[Network, Dict[str, Base]] = {
@ -83,4 +88,9 @@ MODELS: Dict[Network, Dict[str, Base]] = {
"labels": ZkSyncEraLabel,
"transactions": ZkSyncEraTransaction,
},
Network.arbitrum_nova: {
"blocks": ArbitrumNovaBlock,
"labels": ArbitrumNovaLabel,
"transactions": ArbitrumNovaTransaction,
},
}

Wyświetl plik

@ -2,4 +2,4 @@
Moonstream database version.
"""
MOONSTREAMDB_VERSION = "0.3.5"
MOONSTREAMDB_VERSION = "0.3.6"