The Graph 백서

The Graph

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 18쪽 중 12쪽

ched, as are the results of eth_calls (the latter being cached as of a specific block). This caching can dramatically increase indexing speed during “resyncing” of a slightly altered Subgraph. However, in some instances, if an Ethereum node has provided incorrect data for some period, that can make its way into the cache, leading to incorrect data or failed Subgraphs. In this case indexers can use graphman to clear the poisoned cache, and then rewind the affected Subgraphs, which will then fetch fresh data from the (hopefully) healthy provider. If a block cache inconsistency is suspected, such as a tx receipt missing event: graphman chain list to find the chain name. graphman chain check-blocks <CHAIN> by-number <NUMBER> will check if the cached block matches the provider, and deletes the block from the cache if it doesn’t. If there is a difference, it may be safer to truncate the whole cache with graphman chain truncate <CHAIN> . If the block matches the provider, then the issue can be debugged directly against the provider. Querying issues and errors Once a Subgraph has been indexed, indexers can expect to serve queries via the Subgraph’s dedicated query endpoint. If the indexer is hoping to serve significant query volume, a dedicated query node is recommended, and in case of very high query volumes, indexers may want to configure replica shards so that queries don’t impact the indexing process. However, even with a dedicated query node and replicas, certain queries can take a long time to execute, and in some cases increase memory usage and negatively impact the query time for other users. There is not one “silver bullet”, but a range of tools for preventing, diagnosing and dealing with slow queries. Query caching Graph Node caches GraphQL queries by default, which can significantly reduce database load. This can be further configured with the GRAPH_QUERY_CACHE_BLOCKS and GRAPH_QUERY_CACHE_MAX_MEM settings - read more here ⁠ . Analysing queries Problematic queries most often surface in one of two ways. In some cases, users themselves report that a given query is slow. In that case the challenge is to diagnose the reason for the slowness - whether it is a general issue, or specific to that Subgraph or query. And then of course to resolve it, if possible. In other cases, the trigger might be high memory usage on a query node, in which case the challenge is first to identify the query causing the issue. Indexers can use qlog ⁠ to process and summarize Graph Node’s query logs. GRAPH_LOG_QUERY_TIMING can also be enabled to help identify and debug slow queries. Given a slow query, indexers have a few options. Of course they can alter their cost model, to significantly increase the cost of sending the problematic query. This may result in a reduction in the frequency of that query. However this often doesn’t resolve the root cause of the issue. Account-like optimisation Database tables that store entities seem to generally come in two varieties: ‘transaction-like’, where entities, once created, are never updated, i.e., they store something akin to a list of financial transactions, and ‘account-like’ where entities are updated very often, i.e., they store something like financial accounts that get modified every time a transaction is recorded. Account-like tables are characterized by the fact that they contain a large number of entity versions, but relatively few distinct entities. Often, in such tables the number of distinct entities is 1% of the total number of rows (entity versions) For account-like tables, graph-node can generate queries that take advantage of details of how Postgres ends up storing data with such a high rate of change, namely that all of the versions for recent blocks are in a small subsection of the overall storage for such a table. The command graphman stats show <sgdNNNN> shows, for each entity type/table in a deployment, how many distinct entities, and how many entity versions each table contains. That data is based on Postgres-internal estimates, and is therefore necessarily imprecise, and can be off by an order of magnitude. A -1 in the entities column means that Postgres believes that all rows contain a distinct entity. In general, tables where the number of distinct entities are less than 1% of the total number of rows/entity versions are good candidates for the account-like optimization. When the output of graphman stats show indicates that a table might benefit from this optimization, running graphman stats show <sgdNNN> <table> will perform a full count of the table - that can be slow, but gives a precise measure of the ratio of distinct entities to overall entity versions. Once a table has been determined to be account-like, running graphman stats account-like <sgdNNN>.<table> will turn on the account-like optimization for queries against that table. The optimization can be turned off again with graphman stats account-like --clear <sgdNNN>.<table> It takes up to 5 minutes for query nodes to notice that the optimization has been turned on or off. After turning the optimization on, it is necessary to verify that the change does not in fact make queries slower for that table. If you have configured Grafana to monitor Postgres, slow queries would show up in pg_stat_activity in large numbers, taking several seconds. In that case, the optimization needs to be turned off again. For Uniswap-like Subgraphs, the pair and token tables are prime candidates for this optimization, and can have a dramatic effect on database load. Removing Subgraphs At some point an indexer might want to remove a given Subgraph. This can be easily done via graphman drop , which deletes a deployment and all it’s indexed data. The deployment can be specified as either a Subgraph name, an IPFS hash Qm.. , or the database namespace sgdNNN . Further documentation is available here ⁠ . ## /docs/en/indexing/tooling/firehose Indexer Software > Indexer Tooling Firehose Logo Firehose is a new technology developed by StreamingFast working with The Graph Foundation. The product provides previously unseen capabilities and speeds for indexing blockchain data using a files-based and streaming-first approach. The Graph merges into Go Ethereum/geth with the adoption of Live Tracer with v1.14.0 release ⁠ . Firehose extracts, transforms and saves blockchain data in a highly performant file-based strategy. Blockchain developers can then access data extracted by Firehose through binary data streams. Firehose is intended to stand as a replacement for The Graph’s original blockchain data extraction layer. Firehose Documentation The Firehose documentation is currently maintained by the StreamingFast team on the StreamingFast website ⁠ . Getting Started Read this Firehose introduction ⁠ to get an overview of what it is and why it was built. Learn about the Prerequisites ⁠ to install and deploy Firehose. Expand Your Knowledge Learn about the different Firehose components ⁠ available. ## /docs/info@thegraph.foundation Oops! This page was lost in space... Check if you’re using the right address or explore our website by clicking on the link below. ⁠ Go Home ## /docs/en/supported-networks/anubis Anubis Mainnet Subgraphs Subgraph Studio (API Keys) ⁠ • Community Indexing Type mainnet Protocol ethereum Identifier anubis Chain ID eip155:6714 Native Currency gasDAI Chain Docs https://anubis-network.gitbook.io/anubis-network ⁠ Getting Started on Anubis Anubis Chain is a privacy-focused, EVM-compatible Layer 1 that pairs base-layer privacy (PLONK ZK proofs and selective disclosure) with publicly verifiable onchain data, live on mainnet since April 2026 and already running 1M+ transactions a day across a growing DeFi ecosystem (RocketSwap, AWAKE). A subgraph could index that onchain activity — DEX swaps, pools, and liquidity; lending and RWA positions; token transfers and holder balances; and contract events — and serve it via GraphQL. That powers DeFi frontends, analytics dashboards, block explorers, portfolio trackers, and onchain agents without teams having to run their own indexing infrastructure. Importantly, Anubis is a selective-privacy chain. A Subgraph can only index data that is public on-chain. Transparent transactions, and the events they emit, are fully indexable. Data inside shielded (PLONK ZK) transactions is not visible on-chain, so it cannot be indexed. Design your contract’s public events with this in mind if you want that data to be queryable. Indexing Anubis with Subgraphs Getting smart contract data is hard. You write your own indexer, run your own database, and handle chain reorganizations yourself. The Graph removes that work, giving you an open API, called a Subgraph , that you query with GraphQL. Anubis is EVM-compatible, so the Subgraph workflow is the same as on most EVM chains. You point a Subgraph at your Anubis contract, define the entities you want, and Indexers on The Graph Network keep those entities current and queryable. Quick Start: Build Your Own Subgraph Building a Subgraph for Anubis takes three steps: Initialize a Subgraph project from your Anubis contract. Publish it to The Graph Network for decentralized indexing. Query it over GraphQL with an API key. See the Subgraph pricing page for current query rates and free-tier limits. Anubis is supported on The Graph Network, but does not currently have Subgraph Studio testing/staging support. Skip the standard graph deploy and Studio playground path. Instead, you can validate your Subgraph locally (see below) or publish directly to The Graph Network, where a decentralized Indexer that supports Anubis indexes it. Step 1: Initialize your Subgraph project Install the Graph CLI with the package manager you prefer: 1 # npm 2 npm install -g @graphprotocol/graph-cli@latest 3 4 # or yarn 5 yarn global add @graphprotocol/graph-cli Verify the install: 1 graph --version Initialize from your Anubis contract: 1 graph init The CLI walks you through a set of prompts . Anubis is a custom EVM network, so provide the network details manually when asked : Protocol : choose ethereum . Anubis is EVM-compatible. Subgraph slug : an identifier for your Subgraph, for example my-anubis-subgraph . Directory : where the project is scaffolded. Ethereum network : enter anubis as the network identifier. Contract address : the address of the contract you want to index. Find it on browser.anubispace.org . ABI : if the CLI cannot fetch the ABI, export it from your build artifacts or the Blockscout contract page. Supply it as a JSON file. Start block : the block your contract was deployed at. Set this so indexing does not scan from genesis. The explorer shows the deployment block. Contract name : the name of your contract. Index contract events as entities : set this to true . The CLI then scaffolds entities and mappings for every emitted event. The network value you enter ( anubis ) must match the network identifier that The Graph has registered for Anubis . If graph init does not recognize the network, scaffold with any EVM network and set the network field manually in subgraph.yaml (next step). Step 2: Write and build your Subgraph You work with three files: Manifest: subgraph.yaml defines which data sources your Subgraph indexes. Schema: schema.graphql defines the entities you want to query. Mappings: src/mapping.ts uses AssemblyScript that translates on-chain events into your entities. Point the manifest at Anubis : 1 dataSources: 2 - kind: ethereum 3 name: MyContract 4 network: anubis 5 source: 6 address: '0xYourAnubisContractAddress' 7 abi: MyContract 8 startBlock: 123456 # your contract's deployment block For a full walkthrough of schema and mapping authoring, see Creating a Subgraph . Generate types and build: 1 graph codegen && graph build Optional: verify locally before publishing. The Studio playground cannot index Anubis, so test indexing with a local Graph Node ⁠ pointed at an RPC endpoint for Anubis . In your docker-compose.yml , set the Ethereum environment to your Anubis network : 1 environment: 2 ethereum: 'anubis:https://rpc.anubispace.org' Create and deploy to your local node: 1 graph create --node http://localhost:8020/ my-anubis-subgraph 2 graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 my-anubis-subgraph Query the local endpoint until your entities look right, then publish. Step 3: Publish & Curate on The Graph Network This is the recommended path for Anubis. Publishing is an on-chain action that: makes your Subgraph available for decentralized Indexers that support Anubis to index, makes it publicly searchable and queryable in Graph Explorer , and makes it available for Curators to add signal. Build, then publish from the Graph CLI: 1 graph codegen && graph build 2 graph publish A browser window opens. Connect your wallet, add metadata (name, description, image), and publish your Subgraph. The --protocol-network flag refers to where The Graph’s protocol contracts live (Arbitrum One), not to Anubis . During the publish transaction, you can add 500 GRT in curation signal to save on gas fees. Signal tells Indexers that your Subgraph is worth indexing. Any Subgraph with 500 GRT or more signal will automatically be indexed; without signal, no Indexer is incentivized to pick up your Subgraph. Step 4: Query your Subgraph After you publish, open your Subgraph in Graph Explorer and copy its query URL from the Query button. Create an API key from the API Keys dashboard at thegraph.com/studio . This dashboard handles keys and billing for The Graph Network on Arbitrum, independent of which chains Studio can index . Send GraphQL queries to the query URL with your API key. See the Subgraph pricing page for query rates, and Querying The Graph for the full query API. Guides 10 min Subgraph quick start Kickstart your journey into subgraph development. 12 min Graph Explorer Find and query existing blockchain data. 5 min Billing Optimize costs and manage billing efficiently. 5 min Timeseries & Aggregations Learn to track metrics like daily volumes or user growth. 7 min Advanced subgraph features Leverage features like custom data sources, event handlers, and topic filters. ## /docs/en/supported-networks/arc Arc Mainnet Subgraphs Subgraph Studio ⁠ Substreams (Extended EVM) The Graph Market ⁠ • Pinax Network ⁠ Type mainnet Protocol ethereum Identifier arc Chain ID eip155:5042 Native Currency USDC Chain Docs https://docs.arc.network ⁠ Indexing Data on Arc Arc is an EVM-compatible Layer 1 built by Circle for stablecoin finance, using USDC as its native gas token and designed for payments, FX, and institutional settlement. The Graph can index that onchain activity, including DEX swaps, pools, and liquidity; lending and borrowing positions; token transfers and holder balances; and contract events. That powers DeFi frontends, analytics dashboards, block explorers, portfolio trackers, and onchain agents without teams having to run their own indexing infrastructure. Arc is supported by The Graph in two ways: You can develop and publish Subgraphs in Subgraph Studio — publishing is enabled, though guaranteed indexing via The Graph Network is not yet available. You can also consume Substreams — a real-time streaming engine for high-throughput use cases via Pinax Network ⁠ . Indexing Arc with Subgraphs Getting smart contract data is hard. You write your own indexer, run your own database, and handle chain reorganizations yourself. The Graph removes that work, giving you an open API, called a Subgraph , that you query with GraphQL. Arc is EVM-compatible, so the Subgraph workflow is the same as on most EVM chains. You develop and test your Subgraph in Subgraph Studio , then query it through the development endpoint. Subgraph publishing is enabled for Arc , but no guaranteed indexing is available via The Graph Network at this time. You can develop, test, and publish your Subgraph in Subgraph Studio , but Indexers on the decentralized network are not guaranteed to index and serve it yet. Quick Start: Build Your Own Subgraph Building a Subgraph for Arc takes four steps: Create your Subgraph in Subgraph Studio. Initialize a Subgraph project from your Arc contract. Deploy it to Subgraph Studio and test it in the playground. Query it over GraphQL with the development endpoint. See the Subgraph pricing page for current query rates and free-tier limits. Step 1: Create your Subgraph in Subgraph Studio Open Subgraph Studio and connect your wallet (MetaMask, Coinbase Wallet, WalletConnect, or Safe). Create a Subgraph, then copy its slug and your deploy key from the Subgraph details page — you use both from the CLI. For a full walkthrough, see Using Subgraph Studio . Step 2: Initialize your Subgraph project Install the Graph CLI with the package manager you prefer: 1 # npm 2 npm install -g @graphprotocol/graph-cli@latest 3 4 # or yarn 5 yarn global add @graphprotocol/graph-cli Initialize from your Arc contract: 1 graph init The CLI walks you through a set of prompts: Protocol : choose ethereum . Arc is EVM-compatible. Subgraph slug : use the slug of the Subgraph you created in Subgraph Studio, for example my-arc-subgraph . Directory : where the project is scaffolded. Ethereum network : select arc from the list of supported networks. Contract address : the address of the contract you want to index. Find it on arcscan.app . ABI : if the CLI cannot fetch the ABI, export it from your build artifacts or the Arcscan contract page. Supply it as a JSON file. Start block : the block your contract was deployed at. Set this so indexing does not scan from genesis. The explorer shows the deployment block. Contract name : the name of your contract. Index contract events as entities : set this to true . The CLI then scaffolds entities and mappings for every emitted event. Point the manifest at Arc : 1 dataSources: 2 - kind: ethereum 3 name: MyContract 4 network: arc 5 source: 6 address: '0xYourArcContractAddress' 7 abi: MyContract 8 startBlock: 123456 # your contract's deployment block For a full walkthrough of schema and mapping authoring, see Creating a Subgraph . Then generate types and build: 1 graph codegen && graph build Step 3: Deploy to Subgraph Studio Authenticate the CLI with the deploy key from your Subgraph details page: 1 graph auth <DEPLOY_KEY> Then deploy your Subgraph to Subgraph Studio (the CLI asks for a version label such as 0.0.1 ): 1 graph deploy <SUBGRAPH_SLUG> Deploying pushes your Subgraph to Subgraph Studio, where you can test it in the playground and check indexing logs. It does not publish it to the decentralized network — see Using Subgraph Studio for details. Step 4: Query your Subgraph Once your Subgraph is syncing in Studio, test your queries against the development query URL shown on the Subgraph details page. Create an API key from the API Keys dashboard at thegraph.com/studio . Send GraphQL queries to the development query URL with your API key. The development endpoint is rate-limited (currently 3,000 queries per day). You can publish your Subgraph to The Graph Network at any time, but Indexers are not guaranteed to serve Arc Subgraphs yet, so the Subgraph Studio development endpoint is the reliable way to query today. See Querying The Graph for the full query API. Indexing Arc with Substreams Substreams is a parallelized, real-time streaming engine for extracting and transforming blockchain data. Where a Subgraph indexes into a hosted GraphQL API, Substreams lets you consume high-throughput data directly or via 10+ supported sinks . Arc is served with the extended EVM block model, so Substreams modules have access to full transaction,
프로젝트로 돌아가기