Skip to content

Commit

Permalink
zkSync in crawlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey committed Aug 29, 2023
1 parent 5fcffd7 commit f49b7c4
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 11 deletions.
3 changes: 1 addition & 2 deletions crawlers/mooncrawl/mooncrawl/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from .middleware import MoonstreamHTTPException
from .settings import (
BUGOUT_RESOURCE_TYPE_ENTITY_SUBSCRIPTION,
BUGOUT_RESOURCE_TYPE_SUBSCRIPTION,
DOCS_TARGET_PATH,
LINKS_EXPIRATION_TIME,
MOONSTREAM_ADMIN_ACCESS_TOKEN,
Expand Down Expand Up @@ -173,7 +172,7 @@ async def status_handler(
dashboard_subscription_filters["subscription_id"]
]

for reqired_field in subscription.required_fields:
for reqired_field in subscription.required_fields: # type: ignore
if "subscription_type_id" in reqired_field:
subscriprions_type = reqired_field["subscription_type_id"]

Expand Down
3 changes: 3 additions & 0 deletions crawlers/mooncrawl/mooncrawl/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
MOONSTREAM_WYRM_WEB3_PROVIDER_URI,
MOONSTREAM_XDAI_WEB3_PROVIDER_URI,
MOONSTREAM_ZKSYNC_ERA_TESTNET_WEB3_PROVIDER_URI,
MOONSTREAM_ZKSYNC_ERA_WEB3_PROVIDER_URI,
NB_ACCESS_ID_HEADER,
NB_DATA_SOURCE_HEADER,
WEB3_CLIENT_REQUEST_TIMEOUT_SECONDS,
Expand Down Expand Up @@ -73,6 +74,8 @@ def connect(
web3_uri = MOONSTREAM_WYRM_WEB3_PROVIDER_URI
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA_TESTNET:
web3_uri = MOONSTREAM_ZKSYNC_ERA_TESTNET_WEB3_PROVIDER_URI
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA:
web3_uri = MOONSTREAM_ZKSYNC_ERA_WEB3_PROVIDER_URI
else:
raise Exception("Wrong blockchain type provided for web3 URI")

Expand Down
2 changes: 0 additions & 2 deletions crawlers/mooncrawl/mooncrawl/leaderboards_generator/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import argparse
import json
import logging
import os
from typing import cast, List
import uuid

Expand All @@ -12,7 +11,6 @@
from ..settings import (
MOONSTREAM_ADMIN_ACCESS_TOKEN,
MOONSTREAM_LEADERBOARD_GENERATOR_JOURNAL_ID,
BUGOUT_REQUEST_TIMEOUT_SECONDS,
MOONSTREAM_API_URL,
MOONSTREAM_ENGINE_URL,
)
Expand Down
3 changes: 0 additions & 3 deletions crawlers/mooncrawl/mooncrawl/metadata_crawler/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
import logging
import random
import urllib.request
from contextlib import contextmanager
from concurrent.futures import ThreadPoolExecutor
from typing import Any, Dict, List, Optional
from urllib.error import HTTPError

from moonstreamdb.blockchain import AvailableBlockchainType
from sqlalchemy.orm import sessionmaker

from ..db import (
yield_db_preping_session_ctx,
yield_db_read_only_preping_session_ctx,
)
from ..settings import MOONSTREAM_CRAWLERS_DB_STATEMENT_TIMEOUT_MILLIS
from .db import (
clean_labels_from_db,
get_current_metadata_for_address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def continuous_crawler(
network = Network.wyrm
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA_TESTNET:
network = Network.zksync_era_testnet
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA:
network = Network.zksync_era
else:
raise ValueError(f"Unknown blockchain type: {blockchain_type}")

Expand Down
3 changes: 3 additions & 0 deletions crawlers/mooncrawl/mooncrawl/moonworm_crawler/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class SubscriptionTypes(Enum):
XDAI_BLOCKCHAIN = "xdai_smartcontract"
WYRM_BLOCKCHAIN = "wyrm_smartcontract"
ZKSYNC_ERA_TESTNET_BLOCKCHAIN = "zksync_era_testnet_smartcontract"
ZKSYNC_ERA_BLOCKCHAIN = "zksync_era_smartcontract"


def abi_input_signature(input_abi: Dict[str, Any]) -> str:
Expand Down Expand Up @@ -142,6 +143,8 @@ def blockchain_type_to_subscription_type(
return SubscriptionTypes.WYRM_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA_TESTNET:
return SubscriptionTypes.ZKSYNC_ERA_TESTNET_BLOCKCHAIN
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA:
return SubscriptionTypes.ZKSYNC_ERA_BLOCKCHAIN
else:
raise ValueError(f"Unknown blockchain type: {blockchain_type}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def function_call_crawler(
network = Network.wyrm
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA_TESTNET:
network = Network.zksync_era_testnet
elif blockchain_type == AvailableBlockchainType.ZKSYNC_ERA:
network = Network.zksync_era
else:
raise ValueError(f"Unknown blockchain type: {blockchain_type}")

Expand Down
6 changes: 6 additions & 0 deletions crawlers/mooncrawl/mooncrawl/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@
"MOONSTREAM_ZKSYNC_ERA_TESTNET_WEB3_PROVIDER_URI env variable is not set"
)

MOONSTREAM_ZKSYNC_ERA_WEB3_PROVIDER_URI = os.environ.get(
"MOONSTREAM_ZKSYNC_ERA_WEB3_PROVIDER_URI", ""
)
if MOONSTREAM_ZKSYNC_ERA_WEB3_PROVIDER_URI == "":
raise Exception("MOONSTREAM_ZKSYNC_ERA_WEB3_PROVIDER_URI env variable is not set")

MOONSTREAM_CRAWL_WORKERS = 4
MOONSTREAM_CRAWL_WORKERS_RAW = os.environ.get("MOONSTREAM_CRAWL_WORKERS")
try:
Expand Down
2 changes: 0 additions & 2 deletions crawlers/mooncrawl/mooncrawl/state_crawler/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from moonstreamdb.blockchain import AvailableBlockchainType
from moonstream.client import Moonstream # type: ignore
from web3._utils.request import cache_session
from web3.middleware import geth_poa_middleware

from mooncrawl.moonworm_crawler.crawler import _retry_connect_web3
Expand All @@ -21,7 +20,6 @@
from ..db import PrePing_SessionLocal
from ..settings import (
INFURA_PROJECT_ID,
MOONSTREAM_ADMIN_ACCESS_TOKEN,
NB_CONTROLLER_ACCESS_ID,
infura_networks,
multicall_contracts,
Expand Down
2 changes: 2 additions & 0 deletions crawlers/mooncrawl/mooncrawl/stats_worker/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"xdai": "xdai_smartcontract",
"wyrm": "wyrm_smartcontract",
"zksync_era_testnet": "zksync_era_testnet_smartcontract",
"zksync_era": "zksync_era_smartcontract",
}

blockchain_by_subscription_id = {
Expand All @@ -68,6 +69,7 @@
"xdai_smartcontract": "xdai",
"wyrm_smartcontract": "wyrm",
"zksync_era_testnet_smartcontract": "zksync_era_testnet",
"zksync_era_smartcontract": "zksync_era",
}


Expand Down
2 changes: 1 addition & 1 deletion crawlers/mooncrawl/mooncrawl/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Moonstream crawlers version.
"""

MOONCRAWL_VERSION = "0.3.4"
MOONCRAWL_VERSION = "0.3.5"
2 changes: 1 addition & 1 deletion moonstreamapi/moonstreamapi/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Moonstream library and API version.
"""

MOONSTREAMAPI_VERSION = "0.2.9"
MOONSTREAMAPI_VERSION = "0.3.0"

0 comments on commit f49b7c4

Please sign in to comment.