From a2070ed69397ec1d442f5b21dfa25f79918876bf Mon Sep 17 00:00:00 2001 From: incrypto32 Date: Tue, 16 Jan 2024 17:56:09 +0530 Subject: [PATCH 1/3] add docs for indexer hints --- .../pages/en/developing/creating-a-subgraph.mdx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/website/pages/en/developing/creating-a-subgraph.mdx b/website/pages/en/developing/creating-a-subgraph.mdx index 88dee414bac8..d819b740c43a 100644 --- a/website/pages/en/developing/creating-a-subgraph.mdx +++ b/website/pages/en/developing/creating-a-subgraph.mdx @@ -101,6 +101,8 @@ description: Gravatar for Ethereum repository: https://github.com/graphprotocol/graph-tooling schema: file: ./schema.graphql +indexerHints: + historyBlocks: min dataSources: - kind: ethereum/contract name: Gravity @@ -150,6 +152,19 @@ The important entries to update for the manifest are: - `features`: a list of all used [feature](#experimental-features) names. +- `indexerHints.prune`: Defines the retention of historical block data for a subgraph. Options include: + + 1. `"never"`: No pruning of historical data; retains the entire history. + 2. `"auto"`: Retains the minimum necessary history as set by the indexer, optimizing query performance. + 3. A specific number: Sets a custom limit on the number of historical blocks to retain. + + ``` + indexerHints: + prune: auto + ``` + + Using `"auto"` is generally recommended as it maximizes query performance and is sufficient for most users who do not require access to extensive historical data. + - `dataSources.source`: the address of the smart contract the subgraph sources, and the ABI of the smart contract to use. The address is optional; omitting it allows to index matching events from all contracts. - `dataSources.source.startBlock`: the optional number of the block that the data source starts indexing from. In most cases, we suggest using the block in which the contract was created. From 6c8abf23282309d65472c9fba4f3b825bdbd65b0 Mon Sep 17 00:00:00 2001 From: incrypto32 Date: Fri, 2 Feb 2024 22:50:35 +0530 Subject: [PATCH 2/3] Add clarification for term history in indexerHInts docs --- .../en/developing/creating-a-subgraph.mdx | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/website/pages/en/developing/creating-a-subgraph.mdx b/website/pages/en/developing/creating-a-subgraph.mdx index d819b740c43a..f26cf091d7a0 100644 --- a/website/pages/en/developing/creating-a-subgraph.mdx +++ b/website/pages/en/developing/creating-a-subgraph.mdx @@ -102,7 +102,7 @@ repository: https://github.com/graphprotocol/graph-tooling schema: file: ./schema.graphql indexerHints: - historyBlocks: min + prune: auto dataSources: - kind: ethereum/contract name: Gravity @@ -163,8 +163,26 @@ The important entries to update for the manifest are: prune: auto ``` + > The term "history" in this context of subgraphs is about storing data that reflects the old states of mutable entities. This capability is essential for [time travel queries](/querying/graphql-api/#time-travel-queries), This feature enables querying the past states of these entities at specific blocks throughout the blockchain's history. + Using `"auto"` is generally recommended as it maximizes query performance and is sufficient for most users who do not require access to extensive historical data. + For subgraphs leveraging [time travel queries](/querying/graphql-api/#time-travel-queries), it's advisable to either set a specific number of blocks for historical data retention or use `prune: never` to keep all historical entity states. Below are examples of how to configure both options in your subgraph's settings: + + To retain a specific amount of historical data: + + ``` + indexerHints: + prune: 1000 # Replace 10000 with the desired number of blocks to retain + ``` + + To preserve the complete history of entity states: + + ``` + indexerHints: + prune: never + ``` + - `dataSources.source`: the address of the smart contract the subgraph sources, and the ABI of the smart contract to use. The address is optional; omitting it allows to index matching events from all contracts. - `dataSources.source.startBlock`: the optional number of the block that the data source starts indexing from. In most cases, we suggest using the block in which the contract was created. From a016ae9965008da5225ceec8d307eee84a76dd9b Mon Sep 17 00:00:00 2001 From: Krishnanand V P <44740264+incrypto32@users.noreply.github.com> Date: Mon, 5 Feb 2024 09:36:38 +0530 Subject: [PATCH 3/3] Update indexerHints comment Co-authored-by: Leonardo Yvens --- website/pages/en/developing/creating-a-subgraph.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/pages/en/developing/creating-a-subgraph.mdx b/website/pages/en/developing/creating-a-subgraph.mdx index f26cf091d7a0..d46f0030f8b2 100644 --- a/website/pages/en/developing/creating-a-subgraph.mdx +++ b/website/pages/en/developing/creating-a-subgraph.mdx @@ -173,7 +173,7 @@ The important entries to update for the manifest are: ``` indexerHints: - prune: 1000 # Replace 10000 with the desired number of blocks to retain + prune: 1000 # Replace 1000 with the desired number of blocks to retain ``` To preserve the complete history of entity states: