Skip to content

Commit f1bc98a

Browse files
authored
Add a separate section for indexer hints (#603)
1 parent b427415 commit f1bc98a

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

website/pages/en/developing/creating-a-subgraph.mdx

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -152,36 +152,7 @@ The important entries to update for the manifest are:
152152

153153
- `features`: a list of all used [feature](#experimental-features) names.
154154

155-
- `indexerHints.prune`: Defines the retention of historical block data for a subgraph. Options include:
156-
157-
1. `"never"`: No pruning of historical data; retains the entire history.
158-
2. `"auto"`: Retains the minimum necessary history as set by the indexer, optimizing query performance.
159-
3. A specific number: Sets a custom limit on the number of historical blocks to retain.
160-
161-
```
162-
indexerHints:
163-
prune: auto
164-
```
165-
166-
> 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.
167-
168-
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.
169-
170-
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:
171-
172-
To retain a specific amount of historical data:
173-
174-
```
175-
indexerHints:
176-
prune: 1000 # Replace 1000 with the desired number of blocks to retain
177-
```
178-
179-
To preserve the complete history of entity states:
180-
181-
```
182-
indexerHints:
183-
prune: never
184-
```
155+
- `indexerHints.prune`: Defines the retention of historical block data for a subgraph. See [prune](#prune) in [indexerHints](#indexer-hints) section.
185156

186157
- `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.
187158

@@ -762,6 +733,43 @@ dataSources:
762733
> 2. Click on the creation transaction hash in the `Contract Creator` section.
763734
> 3. Load the transaction details page where you'll find the start block for that contract.
764735

736+
## Indexer Hints
737+
738+
The `indexerHints` setting in a subgraph's manifest provides directives for indexers on processing and managing a subgraph. It influences operational decisions across data handling, indexing strategies, and optimizations. Presently, it features the `prune` option for managing historical data retention or pruning.
739+
740+
### Prune
741+
742+
`indexerHints.prune`: Defines the retention of historical block data for a subgraph. Options include:
743+
744+
1. `"never"`: No pruning of historical data; retains the entire history.
745+
2. `"auto"`: Retains the minimum necessary history as set by the indexer, optimizing query performance.
746+
3. A specific number: Sets a custom limit on the number of historical blocks to retain.
747+
748+
```
749+
indexerHints:
750+
prune: auto
751+
```
752+
753+
> 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.
754+
755+
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.
756+
757+
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:
758+
759+
To retain a specific amount of historical data:
760+
761+
```
762+
indexerHints:
763+
prune: 1000 # Replace 1000 with the desired number of blocks to retain
764+
```
765+
766+
To preserve the complete history of entity states:
767+
768+
```
769+
indexerHints:
770+
prune: never
771+
```
772+
765773
## Call Handlers
766774

767775
While events provide an effective way to collect relevant changes to the state of a contract, many contracts avoid generating logs to optimize gas costs. In these cases, a subgraph can subscribe to calls made to the data source contract. This is achieved by defining call handlers referencing the function signature and the mapping handler that will process calls to this function. To process these calls, the mapping handler will receive an `ethereum.Call` as an argument with the typed inputs to and outputs from the call. Calls made at any depth in a transaction's call chain will trigger the mapping, allowing activity with the data source contract through proxy contracts to be captured.

0 commit comments

Comments
 (0)