diff --git a/crawlers/deploy/xai-sepolia-state.service b/crawlers/deploy/xai-sepolia-state.service index 27088dd1..19c14226 100644 --- a/crawlers/deploy/xai-sepolia-state.service +++ b/crawlers/deploy/xai-sepolia-state.service @@ -6,6 +6,6 @@ After=network.target Type=oneshot WorkingDirectory=/home/ubuntu/moonstream/crawlers/mooncrawl EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env -ExecStart=/home/ubuntu/moonstream-env/bin/python -m mooncrawl.state_crawler.cli crawl-jobs --moonstream-token "${MOONSTREAM_PUBLIC_QUERIES_DATA_ACCESS_TOKEN}" --blockchain xai_sepolia --infura +ExecStart=/home/ubuntu/moonstream-env/bin/python -m mooncrawl.state_crawler.cli crawl-jobs --moonstream-token "${MOONSTREAM_PUBLIC_QUERIES_DATA_ACCESS_TOKEN}" --blockchain xai_sepolia CPUWeight=60 SyslogIdentifier=sepolia-state \ No newline at end of file diff --git a/crawlers/deploy/xai-state.service b/crawlers/deploy/xai-state.service index e3c835de..08cbbcfa 100644 --- a/crawlers/deploy/xai-state.service +++ b/crawlers/deploy/xai-state.service @@ -6,6 +6,6 @@ After=network.target Type=oneshot WorkingDirectory=/home/ubuntu/moonstream/crawlers/mooncrawl EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env -ExecStart=/home/ubuntu/moonstream-env/bin/python -m mooncrawl.state_crawler.cli crawl-jobs --moonstream-token "${MOONSTREAM_PUBLIC_QUERIES_DATA_ACCESS_TOKEN}" --blockchain xai --infura +ExecStart=/home/ubuntu/moonstream-env/bin/python -m mooncrawl.state_crawler.cli crawl-jobs --moonstream-token "${MOONSTREAM_PUBLIC_QUERIES_DATA_ACCESS_TOKEN}" --blockchain xai CPUWeight=60 SyslogIdentifier=xai-state \ No newline at end of file diff --git a/crawlers/mooncrawl/mooncrawl/moonworm_crawler/cli.py b/crawlers/mooncrawl/mooncrawl/moonworm_crawler/cli.py index a16bbfc0..32af00d8 100644 --- a/crawlers/mooncrawl/mooncrawl/moonworm_crawler/cli.py +++ b/crawlers/mooncrawl/mooncrawl/moonworm_crawler/cli.py @@ -197,13 +197,21 @@ def handle_crawl_v3(args: argparse.Namespace) -> None: index_engine = MoonstreamDBIndexesEngine() - with index_engine.yield_db_session_ctx() as index_db_session: + logger.info(f"Blockchain type: {blockchain_type.value}") + customer_connection = get_db_connection(args.customer_uuid) + + customer_engine = MoonstreamCustomDBEngine(customer_connection) + + index_engine = MoonstreamDBIndexesEngine() + + with customer_engine.yield_db_session_ctx() as db_session, index_engine.yield_db_session_ctx() as index_db_session: initial_event_jobs = get_event_crawl_job_records( index_db_session, blockchain_type, [], {}, + args.customer_uuid, ) logger.info(f"Initial event crawl jobs count: {len(initial_event_jobs)}") @@ -213,14 +221,13 @@ def handle_crawl_v3(args: argparse.Namespace) -> None: blockchain_type, [], {}, + args.customer_uuid, ) logger.info( f"Initial function call crawl jobs count: {len(initial_function_call_jobs)}" ) - logger.info(f"Blockchain type: {blockchain_type.value}") - with yield_db_session_ctx() as db_session: web3: Optional[Web3] = None if args.web3 is None: logger.info( @@ -238,7 +245,9 @@ def handle_crawl_v3(args: argparse.Namespace) -> None: logger.info("Using PoA middleware") web3.middleware_onion.inject(geth_poa_middleware, layer=0) - last_labeled_block = get_last_labeled_block_number(db_session, blockchain_type) + last_labeled_block = get_last_labeled_block_number( + db_session, blockchain_type, db_version=3 + ) logger.info(f"Last labeled block: {last_labeled_block}") start_block = args.start @@ -292,6 +301,8 @@ def handle_crawl_v3(args: argparse.Namespace) -> None: args.heartbeat_interval, args.new_jobs_refetch_interval, web3_uri=args.web3_uri, + version=3, + index_db_session=index_db_session, ) @@ -871,6 +882,13 @@ def main() -> None: help="Force start from the start block", ) + crawl_parser_v3.add_argument( + "--customer-uuid", + type=UUID, + required=True, + help="Customer UUID", + ) + crawl_parser_v3.set_defaults(func=handle_crawl_v3) historical_crawl_parser = subparsers.add_parser( diff --git a/crawlers/mooncrawl/mooncrawl/moonworm_crawler/continuous_crawler.py b/crawlers/mooncrawl/mooncrawl/moonworm_crawler/continuous_crawler.py index c379c95a..dd504b33 100644 --- a/crawlers/mooncrawl/mooncrawl/moonworm_crawler/continuous_crawler.py +++ b/crawlers/mooncrawl/mooncrawl/moonworm_crawler/continuous_crawler.py @@ -3,7 +3,6 @@ import time import traceback from datetime import datetime, timedelta from typing import Dict, List, Optional, Tuple -from uuid import UUID from moonstreamtypes.blockchain import AvailableBlockchainType @@ -16,10 +15,6 @@ from moonworm.crawler.ethereum_state_provider import Web3StateProvider from sqlalchemy.orm.session import Session from web3 import Web3 -from ..settings import ( - HISTORICAL_CRAWLER_STATUS_TAG_PREFIXES, - HISTORICAL_CRAWLER_STATUSES, -) from .crawler import ( EventCrawlJob, FunctionCallCrawlJob, @@ -31,10 +26,13 @@ from .crawler import ( merge_event_crawl_jobs, merge_function_call_crawl_jobs, moonworm_crawler_update_job_as_pickedup, + get_event_crawl_job_records, + get_function_call_crawl_job_records, ) from .db import add_events_to_session, add_function_calls_to_session, commit_session from .event_crawler import _crawl_events from .function_call_crawler import _crawl_functions +from ..settings import CRAWLER_LABEL, SEER_CRAWLER_LABEL logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) @@ -108,8 +106,16 @@ def continuous_crawler( web3_uri: Optional[str] = None, max_insert_batch: int = 10000, version: int = 2, + index_db_session: Optional[Session] = None, + customer_id: Optional[str] = None, ): crawler_type = "continuous" + if version == 3: + crawler_type = "continuous_v3" + + label_name = CRAWLER_LABEL + if version == 3: + label_name = SEER_CRAWLER_LABEL assert ( min_blocks_batch < max_blocks_batch ), "min_blocks_batch must be less than max_blocks_batch" @@ -191,6 +197,7 @@ def continuous_crawler( to_block=end_block, blocks_cache=blocks_cache, db_block_query_batch=min_blocks_batch * 2, + version=version, ) logger.info( f"Crawled {len(all_events)} events from {start_block} to {end_block}." @@ -203,9 +210,13 @@ def continuous_crawler( db_session, all_events[i : i + max_insert_batch], blockchain_type, + version, + label_name, ) else: - add_events_to_session(db_session, all_events, blockchain_type) + add_events_to_session( + db_session, all_events, blockchain_type, version, label_name + ) logger.info( f"Crawling function calls from {start_block} to {end_block}" @@ -228,10 +239,16 @@ def continuous_crawler( db_session, all_function_calls[i : i + max_insert_batch], blockchain_type, + db_version=version, + label_name=label_name, ) else: add_function_calls_to_session( - db_session, all_function_calls, blockchain_type + db_session, + all_function_calls, + blockchain_type, + db_version=version, + label_name=label_name, ) current_time = datetime.utcnow() @@ -239,20 +256,56 @@ def continuous_crawler( if current_time - jobs_refetchet_time > timedelta( seconds=new_jobs_refetch_interval ): - logger.info( - f"Refetching new jobs from bugout journal since {jobs_refetchet_time}" - ) - event_crawl_jobs, function_call_crawl_jobs = _refetch_new_jobs( - event_crawl_jobs, function_call_crawl_jobs, blockchain_type - ) + if version == 2: + ## Refetch new jobs from bugout journal + logger.info( + f"Refetching new jobs from bugout journal since {jobs_refetchet_time}" + ) + event_crawl_jobs, function_call_crawl_jobs = _refetch_new_jobs( + event_crawl_jobs, function_call_crawl_jobs, blockchain_type + ) - ( - event_crawl_jobs, - function_call_crawl_jobs, - ) = moonworm_crawler_update_job_as_pickedup( - event_crawl_jobs=event_crawl_jobs, - function_call_crawl_jobs=function_call_crawl_jobs, - ) + ( + event_crawl_jobs, + function_call_crawl_jobs, + ) = moonworm_crawler_update_job_as_pickedup( + event_crawl_jobs=event_crawl_jobs, + function_call_crawl_jobs=function_call_crawl_jobs, + ) + elif version == 3 and index_db_session is not None: + ## Refetch new jobs from index db + + updated_event_crawl_jobs = get_event_crawl_job_records( + index_db_session, + blockchain_type, + [], + {event.event_abi_hash: event for event in event_crawl_jobs}, + customer_id=customer_id, + ) + + event_crawl_jobs = [ + event for event in updated_event_crawl_jobs.values() + ] + + updated_function_call_crawl_jobs = ( + get_function_call_crawl_job_records( + index_db_session, + blockchain_type, + [], + { + function_call.contract_address: function_call + for function_call in function_call_crawl_jobs + }, + customer_id=customer_id, + ) + ) + + function_call_crawl_jobs = [ + function_call + for function_call in updated_function_call_crawl_jobs.values() + ] + else: + raise ValueError("Invalid version") jobs_refetchet_time = current_time diff --git a/crawlers/mooncrawl/mooncrawl/moonworm_crawler/crawler.py b/crawlers/mooncrawl/mooncrawl/moonworm_crawler/crawler.py index 79a4d58e..6c266843 100644 --- a/crawlers/mooncrawl/mooncrawl/moonworm_crawler/crawler.py +++ b/crawlers/mooncrawl/mooncrawl/moonworm_crawler/crawler.py @@ -704,6 +704,7 @@ def get_event_crawl_job_records( blockchain_type: AvailableBlockchainType, addresses: List[str], existing_crawl_job_records: Dict[str, EventCrawlJob], + customer_id: Optional[str] = None, ): """ Retrieve and update the event crawl job records from the database. @@ -712,9 +713,12 @@ def get_event_crawl_job_records( query = ( db_session.query(AbiJobs) .filter(AbiJobs.chain == blockchain_type.value) - .filter(func.length(AbiJobs.abi_selector) > 10) + .filter(func.cast(AbiJobs.abi, JSON).op("->>")("type") == "event") ) + if customer_id is not None: + query = query.filter(AbiJobs.customer_id == customer_id) + if len(addresses) != 0: query = query.filter( AbiJobs.address.in_([binascii.unhexlify(address) for address in addresses]) @@ -770,6 +774,7 @@ def get_function_call_crawl_job_records( blockchain_type: AvailableBlockchainType, addresses: List[str], existing_crawl_job_records: Dict[str, FunctionCallCrawlJob], + customer_id: Optional[str] = None, ): """ Retrieve and update the function call crawl job records from the database. @@ -786,6 +791,9 @@ def get_function_call_crawl_job_records( ) ) + if customer_id is not None: + query = query.filter(AbiJobs.customer_id == customer_id) + if len(addresses) != 0: query = query.filter( AbiJobs.address.in_([binascii.unhexlify(address) for address in addresses]) diff --git a/crawlers/mooncrawl/mooncrawl/moonworm_crawler/event_crawler.py b/crawlers/mooncrawl/mooncrawl/moonworm_crawler/event_crawler.py index af5bcd1f..f20e66ba 100644 --- a/crawlers/mooncrawl/mooncrawl/moonworm_crawler/event_crawler.py +++ b/crawlers/mooncrawl/mooncrawl/moonworm_crawler/event_crawler.py @@ -129,6 +129,7 @@ def _crawl_events( ) -> List[Event]: all_events = [] for job in jobs: + raw_events = _fetch_events_chunk( web3, job.event_abi, diff --git a/crawlers/mooncrawl/mooncrawl/settings.py b/crawlers/mooncrawl/mooncrawl/settings.py index 0c796424..4bcdaaed 100644 --- a/crawlers/mooncrawl/mooncrawl/settings.py +++ b/crawlers/mooncrawl/mooncrawl/settings.py @@ -340,12 +340,25 @@ except: f"Could not parse WEB3_CLIENT_REQUEST_TIMEOUT_SECONDS as int: {WEB3_CLIENT_REQUEST_TIMEOUT_SECONDS_RAW}" ) - multicall_contracts: Dict[AvailableBlockchainType, str] = { AvailableBlockchainType.POLYGON: "0xc8E51042792d7405184DfCa245F2d27B94D013b6", + AvailableBlockchainType.AMOY: "0xcA11bde05977b3631167028862bE2a173976CA11", AvailableBlockchainType.MUMBAI: "0xe9939e7Ea7D7fb619Ac57f648Da7B1D425832631", AvailableBlockchainType.ETHEREUM: "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696", + AvailableBlockchainType.SEPOLIA: "0xcA11bde05977b3631167028862bE2a173976CA11", AvailableBlockchainType.ZKSYNC_ERA: "0xF9cda624FBC7e059355ce98a31693d299FACd963", + AvailableBlockchainType.ZKSYNC_ERA_TESTNET: "0xF9cda624FBC7e059355ce98a31693d299FACd963", + AvailableBlockchainType.XDAI: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.XAI: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.BASE: "0xca11bde05977b3631167028862be2a173976ca11", + AvailableBlockchainType.ARBITRUM_ONE: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.ARBITRUM_NOVA: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.ARBITRUM_SEPOLIA: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.AVALANCHE: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.AVALANCHE_FUJI: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.BLAST: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.MANTLE: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.MANTLE_SEPOLIA: "0xcA11bde05977b3631167028862bE2a173976CA11", } diff --git a/crawlers/mooncrawl/mooncrawl/version.py b/crawlers/mooncrawl/mooncrawl/version.py index dba8faaa..2ea34e26 100644 --- a/crawlers/mooncrawl/mooncrawl/version.py +++ b/crawlers/mooncrawl/mooncrawl/version.py @@ -2,4 +2,4 @@ Moonstream crawlers version. """ -MOONCRAWL_VERSION = "0.4.8" +MOONCRAWL_VERSION = "0.4.9" diff --git a/crawlers/mooncrawl/setup.py b/crawlers/mooncrawl/setup.py index 641e7426..a59dacd3 100644 --- a/crawlers/mooncrawl/setup.py +++ b/crawlers/mooncrawl/setup.py @@ -37,8 +37,8 @@ setup( "bugout>=0.2.13", "chardet", "fastapi", - "moonstreamdb>=0.4.5", - "moonstreamdb-v3>=0.0.10", + "moonstreamdb>=0.4.4", + "moonstreamdb-v3>=0.0.11", "moonstream-types>=0.0.4", "moonstream>=0.1.1", "moonworm[moonstream]>=0.9.2", diff --git a/engineapi/engineapi/settings.py b/engineapi/engineapi/settings.py index 3d2450b6..a344c4d3 100644 --- a/engineapi/engineapi/settings.py +++ b/engineapi/engineapi/settings.py @@ -109,6 +109,8 @@ blockchain_names = [ "blast", "blast_sepolia", "proofofplay_apex", + "mantle", + "mantle_sepolia", ] for b in blockchain_names: diff --git a/engineapi/sample.env b/engineapi/sample.env index f24279e6..229da5f6 100644 --- a/engineapi/sample.env +++ b/engineapi/sample.env @@ -29,6 +29,8 @@ export MOONSTREAM_AVALANCHE_WEB3_PROVIDER_URI="https://" export MOONSTREAM_BLAST_WEB3_PROVIDER_URI="https://" export MOONSTREAM_BLAST_SEPOLIA_WEB3_PROVIDER_URI="https://" +export MOONSTREAM_MANTLE_WEB3_PROVIDER_URI="https://" +export MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI="https://" export MOONSTREAM_QUERIES_JOURNAL_ID="" export MOONSTREAM_USAGE_REPORTS_JOURNAL_ID="" diff --git a/moonstreamapi/moonstreamapi/admin/subscription_types.py b/moonstreamapi/moonstreamapi/admin/subscription_types.py index fb303beb..f79efaad 100644 --- a/moonstreamapi/moonstreamapi/admin/subscription_types.py +++ b/moonstreamapi/moonstreamapi/admin/subscription_types.py @@ -260,6 +260,28 @@ CANONICAL_SUBSCRIPTION_TYPES = { stripe_price_id=None, active=False, ), + "mantle_smartcontract": SubscriptionTypeResourceData( + id="mantle_smartcontract", + name="Mantle smartcontract", + blockchain="mantle", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Mantle blockchain.", + icon_url="https://static.simiotics.com/moonstream/assets/mantle-logo.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), + "mantle_sepolia_smartcontract": SubscriptionTypeResourceData( + id="mantle_sepolia_smartcontract", + name="Mantle Sepolia smartcontract", + blockchain="mantle_sepolia", + choices=["input:address", "tag:erc721"], + description="Contracts events and tx_calls of contract of Mantle Sepolia blockchain.", + icon_url="https://static.simiotics.com/moonstream/assets/mantle-sepolia-logo.png", + stripe_product_id=None, + stripe_price_id=None, + active=True, + ), "mumbai_blockchain": SubscriptionTypeResourceData( id="mumbai_blockchain", name="Mumbai transactions", @@ -470,6 +492,28 @@ CANONICAL_SUBSCRIPTION_TYPES = { stripe_price_id=None, active=True, ), + "mantle_blockchain": SubscriptionTypeResourceData( + id="mantle_blockchain", + name="Mantle smartcontract", + blockchain="mantle", + choices=["input:address", "tag:erc721"], + description="Mantle chain transactions subscription.", + icon_url="https://static.simiotics.com/moonstream/assets/mantle-logo.png", + stripe_product_id=None, + stripe_price_id=None, + active=False, + ), + "mantle_sepolia_blockchain": SubscriptionTypeResourceData( + id="mantle_sepolia_blockchain", + name="Mantle Sepolia transactions", + blockchain="mantle_sepolia", + choices=["input:address", "tag:erc721"], + description="Mantle Sepolia chain transactions subscription.", + icon_url="https://static.simiotics.com/moonstream/assets/mantle-logo.png", + stripe_product_id=None, + stripe_price_id=None, + active=False, + ), } diff --git a/moonstreamapi/moonstreamapi/providers/__init__.py b/moonstreamapi/moonstreamapi/providers/__init__.py index eab6a2dd..454d79c3 100644 --- a/moonstreamapi/moonstreamapi/providers/__init__.py +++ b/moonstreamapi/moonstreamapi/providers/__init__.py @@ -65,6 +65,8 @@ event_providers: Dict[str, Any] = { moonworm_provider.AvalancheFujiMoonwormProvider.event_type: moonworm_provider.AvalancheFujiMoonwormProvider, moonworm_provider.BlastMoonwormProvider.event_type: moonworm_provider.BlastMoonwormProvider, moonworm_provider.BlastSepoliaMoonwormProvider.event_type: moonworm_provider.BlastSepoliaMoonwormProvider, + moonworm_provider.MantleMoonwormProvider.event_type: moonworm_provider.MantleMoonwormProvider, + moonworm_provider.MantleSepoliaMoonwormProvider.event_type: moonworm_provider.MantleSepoliaMoonwormProvider, transactions.EthereumTransactions.event_type: transactions.EthereumTransactions, transactions.PolygonTransactions.event_type: transactions.PolygonTransactions, transactions.ProofOfPlayApexTransactions.event_type: transactions.ProofOfPlayApexTransactions, @@ -83,6 +85,8 @@ event_providers: Dict[str, Any] = { transactions.AvalancheFujiTransactions.event_type: transactions.AvalancheFujiTransactions, transactions.BlastTransactions.event_type: transactions.BlastTransactions, transactions.BlastSepoliaTransactions.event_type: transactions.BlastSepoliaTransactions, + transactions.MantleTransactions.event_type: transactions.MantleTransactions, + transactions.MantleSepoliaTransactions.event_type: transactions.MantleSepoliaTransactions, bugout.polygon_whalewatch_provider.event_type: bugout.polygon_whalewatch_provider, bugout.ethereum_txpool_provider.event_type: bugout.ethereum_txpool_provider, bugout.ethereum_whalewatch_provider.event_type: bugout.ethereum_whalewatch_provider, diff --git a/moonstreamapi/moonstreamapi/providers/moonworm_provider.py b/moonstreamapi/moonstreamapi/providers/moonworm_provider.py index 3d14b17c..16986e64 100644 --- a/moonstreamapi/moonstreamapi/providers/moonworm_provider.py +++ b/moonstreamapi/moonstreamapi/providers/moonworm_provider.py @@ -35,6 +35,8 @@ avalanche_event_type = "avalanche_blockchain" avalanche_fuji_sepolia_event_type = "avalanche_fuji_sepolia_blockchain" blast_event_type = "blast_blockchain" blast_sepolia_event_type = "blast_sepolia_blockchain" +mantle_event_type = "mantle_blockchain" +mantle_sepolia_event_type = "mantle_sepolia_blockchain" allowed_tags = ["tag:erc721"] @@ -526,3 +528,17 @@ ProofOfPlayApexMoonwormProvider = MoonwormProvider( description="Provider for reviving transactions from Proof of Play Apex tables.", streamboaundary_range_limit=2 * 60 * 60, ) + +MantleMoonwormProvider = MoonwormProvider( + event_type="mantle_smartcontract", + blockchain=AvailableBlockchainType("mantle"), + description="Provider for reviving transactions from Mantle tables.", + streamboaundary_range_limit=2 * 60 * 60, +) + +MantleSepoliaMoonwormProvider = MoonwormProvider( + event_type="mantle_sepolia_smartcontract", + blockchain=AvailableBlockchainType("mantle_sepolia"), + description="Provider for reviving transactions from Mantle Sepolia tables.", + streamboaundary_range_limit=2 * 60 * 60, +) diff --git a/moonstreamapi/moonstreamapi/providers/transactions.py b/moonstreamapi/moonstreamapi/providers/transactions.py index 1179a243..c7674b09 100644 --- a/moonstreamapi/moonstreamapi/providers/transactions.py +++ b/moonstreamapi/moonstreamapi/providers/transactions.py @@ -573,3 +573,17 @@ ProofOfPlayApexTransactions = TransactionsProvider( description="Provider for resiving transactions from Proof of Play Apex tables.", streamboaundary_range_limit=2 * 60 * 60, ) + +MantleTransactions = TransactionsProvider( + event_type="mantle_blockchain", + blockchain=AvailableBlockchainType("mantle"), + description="Provider for resiving transactions from Mantle tables.", + streamboaundary_range_limit=2 * 60 * 60, +) + +MantleSepoliaTransactions = TransactionsProvider( + event_type="mantle_sepolia_blockchain", + blockchain=AvailableBlockchainType("mantle_sepolia"), + description="Provider for resiving transactions from Mantle Sepolia tables.", + streamboaundary_range_limit=2 * 60 * 60, +) diff --git a/moonstreamapi/moonstreamapi/settings.py b/moonstreamapi/moonstreamapi/settings.py index a8ba7b0d..70e0109a 100644 --- a/moonstreamapi/moonstreamapi/settings.py +++ b/moonstreamapi/moonstreamapi/settings.py @@ -228,6 +228,19 @@ if MOONSTREAM_PROOFOFPLAY_APEX_WEB3_PROVIDER_URI == "": raise Exception( "MOONSTREAM_PROOFOFPLAY_APEX_WEB3_PROVIDER_URI env variable is not set" ) +MOONSTREAM_MANTLE_WEB3_PROVIDER_URI = os.environ.get( + "MOONSTREAM_MANTLE_WEB3_PROVIDER_URI", "" +) +if MOONSTREAM_MANTLE_WEB3_PROVIDER_URI == "": + raise Exception("MOONSTREAM_MANTLE_WEB3_PROVIDER_URI env variable is not set") + +MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI = os.environ.get( + "MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI", "" +) +if MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI == "": + raise Exception( + "MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI env variable is not set" + ) ## QueryAPI @@ -288,6 +301,11 @@ multicall_contracts: Dict[AvailableBlockchainType, str] = { AvailableBlockchainType.XDAI: "0xcA11bde05977b3631167028862bE2a173976CA11", AvailableBlockchainType.ZKSYNC_ERA: "0xF9cda624FBC7e059355ce98a31693d299FACd963", AvailableBlockchainType.ZKSYNC_ERA_TESTNET: "0xF9cda624FBC7e059355ce98a31693d299FACd963", + AvailableBlockchainType.AVALANCHE: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.AVALANCHE_FUJI: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.BLAST: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.MANTLE: "0xcA11bde05977b3631167028862bE2a173976CA11", + AvailableBlockchainType.MANTLE_SEPOLIA: "0xcA11bde05977b3631167028862bE2a173976CA11", } diff --git a/moonstreamapi/moonstreamapi/web3_provider.py b/moonstreamapi/moonstreamapi/web3_provider.py index ca74e014..7ebc15aa 100644 --- a/moonstreamapi/moonstreamapi/web3_provider.py +++ b/moonstreamapi/moonstreamapi/web3_provider.py @@ -13,14 +13,16 @@ from web3.providers.rpc import HTTPProvider from .settings import ( MOONSTREAM_AMOY_WEB3_PROVIDER_URI, - MOONSTREAM_ARBITRUM_ONE_WEB3_PROVIDER_URI, MOONSTREAM_ARBITRUM_NOVA_WEB3_PROVIDER_URI, + MOONSTREAM_ARBITRUM_ONE_WEB3_PROVIDER_URI, MOONSTREAM_ARBITRUM_SEPOLIA_WEB3_PROVIDER_URI, MOONSTREAM_AVALANCHE_FUJI_WEB3_PROVIDER_URI, MOONSTREAM_AVALANCHE_WEB3_PROVIDER_URI, MOONSTREAM_BLAST_SEPOLIA_WEB3_PROVIDER_URI, MOONSTREAM_BLAST_WEB3_PROVIDER_URI, MOONSTREAM_ETHEREUM_WEB3_PROVIDER_URI, + MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI, + MOONSTREAM_MANTLE_WEB3_PROVIDER_URI, MOONSTREAM_MUMBAI_WEB3_PROVIDER_URI, MOONSTREAM_POLYGON_WEB3_PROVIDER_URI, MOONSTREAM_PROOFOFPLAY_APEX_WEB3_PROVIDER_URI, @@ -109,6 +111,10 @@ def connect( web3_uri = MOONSTREAM_BLAST_SEPOLIA_WEB3_PROVIDER_URI elif blockchain_type == AvailableBlockchainType.PROOFOFPLAY_APEX: web3_uri = MOONSTREAM_PROOFOFPLAY_APEX_WEB3_PROVIDER_URI + elif blockchain_type == AvailableBlockchainType.MANTLE: + web3_uri = MOONSTREAM_MANTLE_WEB3_PROVIDER_URI + elif blockchain_type == AvailableBlockchainType.MANTLE_SEPOLIA: + web3_uri = MOONSTREAM_MANTLE_SEPOLIA_WEB3_PROVIDER_URI else: raise Exception("Wrong blockchain type provided for web3 URI") diff --git a/moonstreamapi/requirements.txt b/moonstreamapi/requirements.txt index 57840006..623bb0e1 100644 --- a/moonstreamapi/requirements.txt +++ b/moonstreamapi/requirements.txt @@ -37,7 +37,7 @@ lru-dict==1.1.8 Mako==1.2.3 MarkupSafe==2.1.1 moonstream==0.1.1 -moonstreamdb==0.4.4 +moonstreamdb==0.4.5 moonstreamdb-v3==0.0.9 multiaddr==0.0.9 multidict==6.0.2 diff --git a/moonstreamapi/setup.py b/moonstreamapi/setup.py index 2e3567be..b6b5b47f 100644 --- a/moonstreamapi/setup.py +++ b/moonstreamapi/setup.py @@ -16,7 +16,7 @@ setup( "bugout>=0.2.15", "fastapi", "moonstream", - "moonstreamdb>=0.4.4", + "moonstreamdb>=0.4.5", "moonstreamdb-v3>=0.0.9", "humbug", "pydantic==1.10.2", diff --git a/moonstreamdb-v3/moonstreamdbv3/db.py b/moonstreamdb-v3/moonstreamdbv3/db.py index 92563115..14a1e02b 100644 --- a/moonstreamdb-v3/moonstreamdbv3/db.py +++ b/moonstreamdb-v3/moonstreamdbv3/db.py @@ -13,15 +13,15 @@ from sqlalchemy.orm import Session, sessionmaker logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) +MOONSTREAM_DB_V3_URI = os.environ.get("MOONSTREAM_DB_V3_URI") +if MOONSTREAM_DB_V3_URI is None: + logger.warning("MOONSTREAM_DB_V3_URI environment variable must be set") + +MOONSTREAM_DB_V3_URI_READ_ONLY = os.environ.get("MOONSTREAM_DB_V3_URI_READ_ONLY") +if MOONSTREAM_DB_V3_URI_READ_ONLY is None: + logger.warning("MOONSTREAM_DB_V3_URI_READ_ONLY environment variable must be set") + try: - MOONSTREAM_DB_V3_URI = os.environ.get("MOONSTREAM_DB_V3_URI") - if MOONSTREAM_DB_V3_URI is None: - raise Warning("MOONSTREAM_DB_V3_URI environment variable must be set") - - MOONSTREAM_DB_V3_URI_READ_ONLY = os.environ.get("MOONSTREAM_DB_V3_URI_READ_ONLY") - if MOONSTREAM_DB_V3_URI_READ_ONLY is None: - raise Warning("MOONSTREAM_DB_V3_URI_READ_ONLY environment variable must be set") - MOONSTREAM_DB_V3_INDEXES_URI = os.environ.get("MOONSTREAM_DB_V3_INDEXES_URI") if MOONSTREAM_DB_V3_INDEXES_URI is None: raise Warning("MOONSTREAM_DB_V3_INDEXES_URI environment variable must be set") @@ -36,7 +36,7 @@ try: except ValueError as e: raise ValueError(e) except Warning: - logger.warning("Database variables not set") + logger.warning("Indexes database variables not set") MOONSTREAM_POOL_SIZE_RAW = os.environ.get("MOONSTREAM_POOL_SIZE") MOONSTREAM_POOL_SIZE = 1 diff --git a/moonstreamdb-v3/moonstreamdbv3/version.txt b/moonstreamdb-v3/moonstreamdbv3/version.txt index 7c1886bb..2cfabea2 100644 --- a/moonstreamdb-v3/moonstreamdbv3/version.txt +++ b/moonstreamdb-v3/moonstreamdbv3/version.txt @@ -1 +1 @@ -0.0.10 +0.0.11