The Graph 백서

The Graph

원문

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

y keyword or contract and check 30-day usage Retrieve real-time data from The Graph and onchain token sources Agent Skills for Subgraphs Subgraph Skills is a collection of AI agent skills that provide expert knowledge for developing, testing, and deploying Subgraphs. Skills are available as Claude Code plugins or OpenClaw skills. Available Subgraph Skills Skill What It Covers Subgraph Development Schema design, manifest configuration, AssemblyScript handlers, contract bindings, Subgraph Composition, and common patterns (ERC20, DEX, NFT, Lending, etc.) Subgraph Optimization Pruning, @derivedFrom , immutable entities, avoiding eth_calls , timeseries, aggregations, and grafting Subgraph Testing Matchstick unit testing, the Subgraph Linter, mock events, entity assertions, and CI/CD integration Agent Skills for Substreams Substreams Skills enhance AI coding assistants with specialized Substreams expertise. Install once and your assistant automatically applies Substreams best practices when working on relevant projects. Beyond authoring modules, the skills can discover existing packages on the substreams.dev ⁠ registry, inspect their module graphs and protobuf schemas, and generate ready-to-run sink commands. Available Skills Skill What It Covers substreams-dev Manifest configuration, Rust module types (map, store, index), protobuf schema design, performance optimization, and debugging substreams-sql CDC database sinks, relational mappings, PostgreSQL and ClickHouse patterns, and blockchain data modeling substreams-testing Unit, integration, and performance testing; FireCore tooling; and CI/CD pipelines ## /docs/en/subgraphs/overview Subgraphs What is a Subgraph? A Subgraph is a custom, open API that extracts data from a blockchain, processes it, and stores it so it can be easily queried via GraphQL. Subgraph Capabilities Access Data: Subgraphs enable the querying and indexing of blockchain data for web3. Build: Developers can build, deploy, and publish Subgraphs to The Graph Network. To get started, check out the Subgraph developer Quick Start . Index & Query: Once a Subgraph is indexed, anyone can query it. Explore and query all Subgraphs published to the network in Graph Explorer . Inside a Subgraph The Subgraph manifest, subgraph.yaml , defines the smart contracts & network your Subgraph will index, the events from these contracts to pay attention to, and how to map event data to entities that Graph Node stores and allows to query. The Subgraph definition consists of the following files: subgraph.yaml : Contains the Subgraph manifest schema.graphql : A GraphQL schema defining the data stored for your Subgraph and how to query it via GraphQL mapping.ts : AssemblyScript Mappings ⁠ code that translates event data into entities defined in your schema To learn more about each Subgraph component, check out creating a Subgraph . Subgraph Lifecycle Here is a general overview of a Subgraph’s lifecycle: Subgraph Lifecycle Subgraph Development Create a Subgraph Deploy a Subgraph Test a Subgraph Publish a Subgraph Signal on a Subgraph Build locally Great Subgraphs start with a local development environment and unit tests. Developers use Graph CLI ⁠ , a command-line interface tool for building and deploying Subgraphs on The Graph. They can also use Graph TypeScript and Matchstick to create robust Subgraphs. Deploy to Subgraph Studio Once defined, a Subgraph can be deployed to Subgraph Studio . In Subgraph Studio, you can do the following: Use its staging environment to index the deployed Subgraph and make it available for review. Verify that your Subgraph doesn’t have any indexing errors and works as expected. Publish to the Network When you’re happy with your Subgraph, you can publish it to The Graph Network. This is an onchain action, which registers the Subgraph and makes it discoverable by Indexers. Published Subgraphs have a corresponding NFT, which defines the ownership of the Subgraph. You can transfer the Subgraph’s ownership by sending the NFT. Published Subgraphs have associated metadata, which provides other network participants with useful context and information. Add Curation Signal for Indexing Published Subgraphs are unlikely to be picked up by Indexers without curation signal. To encourage indexing you should add signal to your Subgraph. Learn more about signaling and curating on The Graph. What is signal? Signal is locked GRT associated with a given Subgraph. It indicates to Indexers that a given Subgraph will receive query volume and it contributes to the indexing rewards available for processing it. Third-party Curators may also signal on a given Subgraph, if they deem the Subgraph likely to drive query volume. Querying & Application Development Subgraphs on The Graph Network receive 100,000 free queries per month, after which point developers can either pay for queries with GRT or a credit card . Learn more about querying Subgraphs . Updating Subgraphs To update your Subgraph with bug fixes or new functionalities, initiate a transaction to point it to the new version. You can deploy new versions of your Subgraphs to Subgraph Studio for development and testing. If you selected “auto-migrate” when you applied the signal, updating the Subgraph will migrate any signal to the new version and incur a migration tax. This signal migration should prompt Indexers to start indexing the new version of the Subgraph, so it should soon become available for querying. Deleting & Transferring Subgraphs If you no longer need a published Subgraph, you can delete or transfer it. Deleting a Subgraph returns any signaled GRT to Curators . ## /docs/en/substreams/overview Substreams Substreams Logo To start coding right away, check out the Substreams Quick Start . Overview Substreams is a powerful parallel blockchain indexing technology designed to enhance performance and scalability within The Graph Network. Substreams Benefits Accelerated Indexing : Boost Subgraph indexing time with a parallelized engine for quicker data retrieval and processing. Multi-Chain Support : Expand indexing capabilities beyond EVM-based chains, supporting ecosystems like Solana, Injective, Starknet, and Vara. Enhanced Data Model : Access comprehensive data, including the trace level data on EVM or account changes on Solana, while efficiently managing forks/disconnections. Multi-Sink Support: For Subgraph, Postgres database, Clickhouse, and Mongo database. How Substreams Works in 4 Steps You write a Rust program, which defines the transformations that you want to apply to the blockchain data. For example, the following Rust function extracts relevant information from an Ethereum block (number, hash, and parent hash). 1 fn get_my_block(blk: Block) -> Result<MyBlock, substreams::errors::Error> { 2 let header = blk.header.as_ref().unwrap(); 3 4 Ok(MyBlock { 5 number: blk.number, 6 hash: Hex::encode(&blk.hash), 7 parent_hash: Hex::encode(&header.parent_hash), 8 }) 9 } You wrap up your Rust program into a WASM module just by running a single CLI command. The WASM container is sent to a Substreams endpoint for execution. The Substreams provider feeds the WASM container with the blockchain data and the transformations are applied. You select a sink ⁠ , a place where you want to send the transformed data (such as a SQL database or a Subgraph). Additional Resources All Substreams developer documentation is maintained by the StreamingFast core development team on the Substreams registry ⁠ . ## /docs/en/indexing/overview Indexer Software Graph Horizon is live. The protocol upgrade changes how allocations, rewards, and delegation work. See the dedicated Graph Horizon section for a full overview of what changed, and the migration guide for indexer setup instructions. Indexers are node operators in The Graph Network that stake Graph Tokens (GRT) in order to provide indexing and query processing services. Indexers earn query fees and indexing rewards for their services. They also earn query fees that are rebated according to an exponential rebate function. GRT that is staked in the protocol is subject to a thawing period and can be slashed if Indexers are malicious and serve incorrect data to applications or if they index incorrectly. Indexers also earn rewards for delegated stake from Delegators, to contribute to the network. Indexers select Subgraphs to index based on the Subgraph’s curation signal, where Curators stake GRT in order to indicate which Subgraphs are high-quality and should be prioritized. Consumers (eg. applications) can also set parameters for which Indexers process queries for their Subgraphs and set preferences for query fee pricing. FAQ What is the minimum stake required to be an Indexer on the network? The minimum stake for an Indexer is currently set to 100K GRT. What are the revenue streams for an Indexer? Query fee rebates - Payments for serving queries on the network. These payments are mediated via GraphTally between an Indexer and a gateway. Each query request from a gateway contains a signed receipt and the corresponding response a proof of query result validity. Indexing rewards - Generated via a 3% annual protocol wide inflation, the indexing rewards are distributed to Indexers who are indexing Subgraph deployments for the network. How are indexing rewards distributed? Indexing rewards are collected by Indexers through periodic Proof of Indexing (POI) submissions while allocations remain open. Under Graph Horizon, allocations can remain open indefinitely — there is no requirement to close an allocation to collect rewards. Indexers must submit a valid POI before it becomes stale. The maxPOIStaleness parameter is currently set to 28 days — if no POI is submitted within this window, any network participant can force-close the allocation. There is no retroactive recovery of rewards. Rewards are distributed proportionally based on curation signal and the amount of GRT allocated to each subgraph deployment. Note: During the current transition period, the indexer-agent continues to recycle allocations approximately every 28 days for compatibility. A future agent version will leverage long-lived allocations natively. Check the Graph Horizon migration guide for current agent requirements. Numerous tools have been created by the community for calculating rewards; you’ll find a collection of them organized in the Community Guides collection ⁠ . You can also find an up to date list of tools in the #Delegators and #Indexers channels on the Discord server ⁠ . Here we link a recommended allocation optimiser ⁠ integrated with the indexer software stack. What is a proof of indexing (POI)? A Proof of Indexing (POI) is a cryptographic proof that an Indexer has correctly indexed a subgraph deployment up to a given block. A POI for a block is a digest of all entity store transactions for a specific Subgraph deployment up to and including that block. Under Graph Horizon, POIs are submitted periodically to collect accrued indexing rewards. Indexers do not need to close an allocation to submit a POI. However, if a POI becomes stale (exceeds maxPOIStaleness , currently 28 days ), the allocation can be force-closed by any network participant, resulting in loss of uncollected rewards with no ability to reclaim them retroactively. POIs are generated by the indexer-agent and verified on-chain by the SubgraphService contract. When are indexing rewards distributed? Under Graph Horizon, there is no maximum allocation lifetime. Allocations remain open until explicitly closed by the indexer, or force-closed due to POI staleness. Rewards accrue continuously and are collectible via periodic POI submission. The previous mechanism allowing Delegators to force-close allocations after 28 epochs was removed by Horizon. However, any network participant can now force-close an allocation if its POI becomes stale (no submission within 28 days). Can pending indexing rewards be monitored? The RewardsManager contract has a read-only getRewards ⁠ function that can be used to check the pending rewards for a specific allocation. Many of the community-made dashboards include pending rewards values and they can be easily checked manually by following these steps: Query the mainnet Subgraph to get the IDs for all active allocations: 1 query indexerAllocations { 2 indexer(id: "<INDEXER_ADDRESS>") { 3 allocations { 4 activeForIndexer { 5 allocations { 6 id 7 } 8 } 9 } 10 } 11 } Use Etherscan to call getRewards() : Navigate to Etherscan interface to Rewards contract ⁠ To call getRewards() : Expand the 9. getRewards dropdown. Enter the allocationID in the input. Click the Query button. What are disputes and where can I view them? Indexer’s queries and allocations can both be disputed on The Graph during the dispute period. The dispute period varies, depending on the type of dispute. Queries/attestations have 7 epochs dispute window, whereas allocations have 56 epochs. After these periods pass, disputes cannot be opened against either of allocations or queries. When a dispute is opened, a deposit of a minimum of 10,000 GRT is required by the Fishermen, which will be locked until the dispute is finalized and a resolution has been given. Fisherman are any network participants that open disputes. Disputes have three possible outcomes, so does the deposit of the Fishermen. If the dispute is rejected, the GRT deposited by the Fishermen will be burned, and the disputed Indexer will not be slashed. If the dispute is settled as a draw, the Fishermen’s deposit will be returned, and the disputed Indexer will not be slashed. If the dispute is accepted, the GRT deposited by the Fishermen will be returned, the disputed Indexer will be slashed and the Fishermen will earn 50% of the slashed GRT. Graph Horizon update: Slashing parameters are now flexible, with a maximum cap of 10% (the recommended default is 2.5%). Fishermen who raise valid disputes can reclaim their bond if the dispute is not resolved within the required timeframe. Disputes can be viewed in the UI in an Indexer’s profile page under the Disputes tab. What are query fee rebates and when are they distributed? Query fees are collected by the gateway and distributed to indexers according to the exponential rebate function (see GIP here ⁠ ). The exponential rebate function is proposed as a way to ensure indexers achieve the best outcome by faithfully serving queries. It works by incentivizing Indexers to allocate a large amount of stake (which can be slashed for erring when serving a query) relative to the amount of query fees they may collect. Once an allocation has been closed the rebates are available to be claimed by the Indexer. Upon claiming, the query fee rebates are distributed to the Indexer and their Delegators based on the query fee cut and the exponential rebate function. What is query fee cut and indexing reward cut? The queryFeeCut and indexingRewardCut values are delegation parameters that the Indexer may set along with cooldownBlocks to control the distribution of GRT between the Indexer and their Delegators. See the last steps in Staking in the Protocol for instructions on setting the delegation parameters. queryFeeCut - the % of query fee rebates that will be distributed to the Indexer. If this is set to 95%, the Indexer will receive 95% of the query fees earned when an allocation is closed with the other 5% going to the Delegators. indexingRewardCut - the % of indexing rewards that will be distributed to the Indexer. If this is set to 95%, the Indexer will receive 95% of the indexing rewards when an allocation is closed and the Delegators will split the other 5%. Graph Horizon update: Under Horizon, indexingRewardCut and queryFeeCut parameters are set by the indexer per data service (e.g., SubgraphService), rather than globally in the staking contract. The concept is the same — indexers share a portion of rewards with delegators — but the configuration is now per-service. See What changes with Graph Horizon? for details. How do Indexers know which Subgraphs to index? Indexers may differentiate themselves by applying advanced techniques for making Subgraph indexing decisions but to give a general idea we’ll discuss several key metrics used to evaluate Subgraphs in the network: Curation signal - The proportion of network curation signal applied to a particular Subgraph is a good indicator of the interest in that Subgraph, especially during the bootstrap phase when query volume is ramping up. Query fees collected - The historical data for volume of query fees collected for a specific Subgraph is a good indicator of future demand. Amount staked - Monitoring the behavior of other Indexers or looking at proportions of total stake allocated towards specific Subgraphs can allow an Indexer to monitor the supply side for Subgraph queries to identify Subgraphs that the network is showing confidence in or Subgraphs that may show a need for more supply. Subgraphs with no indexing rewards - Some Subgraphs do not generate indexing rewards mainly because they are using unsupported features like IPFS or because they are querying another network outside of mainnet. You will see a message on a Subgraph if it is not generating indexing rewards. What are the hardware requirements? Small - Enough to get started indexing several Subgraphs, will likely need to be expanded. Standard - Default setup, this is what is used in the example k8s/terraform deployment manifests. Medium - Production Indexer supporting 100 Subgraphs and 200-500 requests per second. Large - Prepared to index all currently used Subgraphs and serve requests for the related traffic. Setup Postgres (CPUs) Postgres (memory in GBs) Postgres (disk in TBs) VMs (CPUs) VMs (memory in GBs) Small 4 8 1 4 16 Standard 8 30 1 12 48 Medium 16 64 2 32 64 Large 72 468 3.5 48 184 What are some basic security precautions an Indexer should take? Operator wallet - Setting up an operator wallet is an important precaution because it allows an Indexer to maintain separation between their keys that control stake and those that are in control of day-to-day operations. See Stake in Protocol for instructions. Firewall - Only the Indexer service needs to be exposed publicly and particular attention should be paid to locking down admin ports and database access: the Graph Node JSON-RPC endpoint (default port: 8030), the Indexer management API endpoint (default port: 18000), and the Postgres database endpoint (default port: 5432) should not be exposed. Infrastructure At the center of an Indexer’s infrastructure is the Graph Node which monitors the indexed networks, extracts and loads data per a Subgraph definition and serves it as a GraphQL API . The Graph Node needs to be connected to an endpoint exposing data from each indexed network; an IPFS node for sourcing data; a PostgreSQL database for its store; and Indexer components which facilitate its interactions with the network. PostgreSQL database - The main store for the Graph Node, this is where Subgraph data is stored. The Indexer service, TAP agent, and Indexer agent also use the database to store receipt data, cost models, indexing rules, and allocation actions. Data endpoint - For EVM-compatible networks, Graph Node needs to be connected to an endpoint that exposes an EVM-compatible JSON-RPC API. This may take the form of a single client or it could be a more complex setup that load balances across multiple. It’s important to be aware that certain Subgraphs will require particular client capabilities such as archive mode and/or the parity tracing API. IPFS node (version less than 5) - Subgraph deployment metadata is stored on the IPFS network. The Graph Node primarily accesses the IPFS node
프로젝트로 돌아가기