Start block for data sources
Until now, subgraphs were always indexing from the genesis block. This involved scanning the entire chain for relevant blocks, logs and traces, even if the subgraph contracts were only deployed recently.
This was fine initially. However, with more expensive features—such as block and call handlers—being added and more advanced subgraphs being developed, it has often become desirable to skip irrelevant old blocks entirely to speed up indexing.
This is now possible. As of this release, data sources can specify an optional startBlock
number in the manifest:
dataSources:
- name: Gravity
source:
address: '0x2E645469f354BB4F5c8a05B3b30A929361cf77eC'
abi: Gravity
startBlock: 6000000
The subgraph will then start indexing from this block. If there are multiple data sources with or without start blocks, the earliest of these blocks is used as the starting point. The absence of a startBlock
is equivalent to 0
(aka the genesis block).
Other changes
- Fix exit codes used in
graph deploy
command. - Validate data source
network
fields. Data sources (and templates) must either have no network set or they must all use the samenetwork
value. - Dependency updates (glob, tern, jayson, graphql, yaml, eslint).